535 lines
18 KiB
PHP
535 lines
18 KiB
PHP
<?php
|
|
/**
|
|
* The control file of dashboard module of ZenTaoPMS.
|
|
*
|
|
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
|
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
|
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
|
* @package dashboard
|
|
* @version $Id: control.php 5020 2013-07-05 02:03:26Z wyd621@gmail.com $
|
|
* @link http://www.zentao.net
|
|
*/
|
|
class my extends control
|
|
{
|
|
/**
|
|
* Construct function.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function __construct($module = '', $method = '')
|
|
{
|
|
parent::__construct($module, $method);
|
|
$this->loadModel('user');
|
|
$this->loadModel('dept');
|
|
$this->my->setMenu();
|
|
}
|
|
|
|
/**
|
|
* Index page, goto todo.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->view->title = $this->lang->my->common;
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My todos.
|
|
*
|
|
* @param string $type
|
|
* @param string $account
|
|
* @param string $status
|
|
* @param int $recTotal
|
|
* @param int $recPerPage
|
|
* @param int $pageID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function todo($type = 'today', $account = '', $status = 'all', $orderBy = "date_desc,status,begin", $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Save session. */
|
|
$uri = $this->app->getURI(true);
|
|
$this->session->set('todoList', $uri);
|
|
$this->session->set('bugList', $uri);
|
|
$this->session->set('taskList', $uri);
|
|
|
|
/* Load pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* The title and position. */
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->todo;
|
|
$this->view->position[] = $this->lang->my->todo;
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
|
|
/* Assign. */
|
|
$this->view->todos = $this->loadModel('todo')->getList($type, $account, $status, 0, $pager, $sort);
|
|
$this->view->date = (int)$type == 0 ? date(DT_DATE1) : date(DT_DATE1, strtotime($type));
|
|
$this->view->type = $type;
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->status = $status;
|
|
$this->view->account = $this->app->user->account;
|
|
$this->view->orderBy = $orderBy == 'date_desc,status,begin,id_desc' ? '' : $orderBy;
|
|
$this->view->pager = $pager;
|
|
$this->view->importFuture = ($type != 'today');
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My stories
|
|
|
|
* @param string $type
|
|
* @param int $recTotal
|
|
* @param int $recPerPage
|
|
* @param int $pageID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function story($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Save session. */
|
|
$this->session->set('storyList', $this->app->getURI(true));
|
|
|
|
/* Load pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
|
|
/* Assign. */
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->story;
|
|
$this->view->position[] = $this->lang->my->story;
|
|
$this->view->stories = $this->loadModel('story')->getUserStories($this->app->user->account, $type, $sort, $pager);
|
|
$this->view->users = $this->user->getPairs('noletter');
|
|
$this->view->type = $type;
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->orderBy = $orderBy;
|
|
$this->view->pager = $pager;
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My tasks
|
|
*
|
|
* @param string $type
|
|
* @param int $recTotal
|
|
* @param int $recPerPage
|
|
* @param int $pageID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function task($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Save session. */
|
|
$this->session->set('taskList', $this->app->getURI(true));
|
|
$this->session->set('storyList', $this->app->getURI(true));
|
|
|
|
/* Load pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
|
|
/* Assign. */
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->task;
|
|
$this->view->position[] = $this->lang->my->task;
|
|
$this->view->tabID = 'task';
|
|
$this->view->tasks = $this->loadModel('task')->getUserTasks($this->app->user->account, $type, 0, $pager, $sort);
|
|
$this->view->type = $type;
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->orderBy = $orderBy;
|
|
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
|
$this->view->pager = $pager;
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My bugs.
|
|
*
|
|
* @param string $type
|
|
* @param string $orderBy
|
|
* @param int $recTotal
|
|
* @param int $recPerPage
|
|
* @param int $pageID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function bug($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Save session. load Lang. */
|
|
$this->session->set('bugList', $this->app->getURI(true));
|
|
$this->app->loadLang('bug');
|
|
|
|
/* Load pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
$bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $type, $sort, 0, $pager);
|
|
|
|
/* Save bugIDs session for get the pre and next bug. */
|
|
$bugIDs = '';
|
|
foreach($bugs as $bug) $bugIDs .= ',' . $bug->id;
|
|
$this->session->set('bugIDs', $bugIDs . ',');
|
|
|
|
/* assign. */
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->bug;
|
|
$this->view->position[] = $this->lang->my->bug;
|
|
$this->view->bugs = $bugs;
|
|
$this->view->users = $this->user->getPairs('noletter');
|
|
$this->view->tabID = 'bug';
|
|
$this->view->type = $type;
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->orderBy = $orderBy;
|
|
$this->view->pager = $pager;
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My test task.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function testtask($type = 'wait', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Load pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* Save session. */
|
|
$this->session->set('testtaskList', $this->app->getURI(true));
|
|
|
|
$this->app->loadLang('testcase');
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->testTask;
|
|
$this->view->position[] = $this->lang->my->testTask;
|
|
$this->view->tasks = $this->loadModel('testtask')->getByUser($this->app->user->account, $pager, $sort, $type);
|
|
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->orderBy = $orderBy;
|
|
$this->view->type = $type;
|
|
$this->view->pager = $pager;
|
|
$this->display();
|
|
|
|
}
|
|
|
|
/**
|
|
* My test case.
|
|
*
|
|
* @param string $type
|
|
* @param string $orderBy
|
|
* @param int $recTotal
|
|
* @param int $recPerPage
|
|
* @param int $pageID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function testcase($type = 'assigntome', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Save session, load lang. */
|
|
$this->session->set('caseList', $this->app->getURI(true));
|
|
$this->app->loadLang('testcase');
|
|
$this->app->loadLang('testtask');
|
|
|
|
/* Load pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
|
|
$cases = array();
|
|
if($type == 'assigntome')
|
|
{
|
|
$cases = $this->loadModel('testcase')->getByAssignedTo($this->app->user->account, $sort, $pager);
|
|
}
|
|
elseif($type == 'openedbyme')
|
|
{
|
|
$cases = $this->loadModel('testcase')->getByOpenedBy($this->app->user->account, $sort, $pager);
|
|
}
|
|
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', $type == 'assigntome' ? false : true);
|
|
|
|
/* Assign. */
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->testCase;
|
|
$this->view->position[] = $this->lang->my->testCase;
|
|
$this->view->cases = $cases;
|
|
$this->view->users = $this->user->getPairs('noletter');
|
|
$this->view->tabID = 'test';
|
|
$this->view->type = $type;
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->orderBy = $orderBy;
|
|
$this->view->pager = $pager;
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My projects.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function project()
|
|
{
|
|
$this->app->loadLang('project');
|
|
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->myProject;
|
|
$this->view->position[] = $this->lang->my->myProject;
|
|
$this->view->tabID = 'project';
|
|
$this->view->projects = @array_reverse($this->user->getProjects($this->app->user->account));
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Edit profile
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function editProfile()
|
|
{
|
|
if($this->app->user->account == 'guest') die(js::alert('guest') . js::locate('back'));
|
|
if(!empty($_POST))
|
|
{
|
|
$this->user->update($this->app->user->id);
|
|
if(dao::isError()) die(js::error(dao::getError()));
|
|
die(js::locate($this->createLink('my', 'profile'), 'parent'));
|
|
}
|
|
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->editProfile;
|
|
$this->view->position[] = $this->lang->my->editProfile;
|
|
$this->view->user = $this->user->getById($this->app->user->account);
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Change password
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function changePassword()
|
|
{
|
|
if($this->app->user->account == 'guest') die(js::alert('guest') . js::locate('back'));
|
|
if(!empty($_POST))
|
|
{
|
|
$this->user->updatePassword($this->app->user->id);
|
|
if(dao::isError()) die(js::error(dao::getError()));
|
|
die(js::locate($this->createLink('my', 'profile'), 'parent'));
|
|
}
|
|
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->changePassword;
|
|
$this->view->position[] = $this->lang->my->changePassword;
|
|
$this->view->user = $this->user->getById($this->app->user->account);
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Manage contacts.
|
|
*
|
|
* @param int $listID
|
|
* @param string $mode
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function manageContacts($listID = 0, $mode = '')
|
|
{
|
|
if($_POST)
|
|
{
|
|
if($this->post->mode == 'new')
|
|
{
|
|
$listID = $this->user->createContactList($this->post->newList, $this->post->users);
|
|
if(isonlybody()) die(js::closeModal('parent.parent', '', 'function(){parent.parent.ajaxGetContacts(\'#mailtoGroup\')}'));
|
|
die(js::locate(inlink('manageContacts', "listID=$listID"), 'parent'));
|
|
}
|
|
elseif($this->post->mode == 'edit')
|
|
{
|
|
$this->user->updateContactList($this->post->listID, $this->post->listName, $this->post->users);
|
|
die(js::locate(inlink('manageContacts', "listID={$this->post->listID}"), 'parent'));
|
|
}
|
|
}
|
|
|
|
$mode = empty($mode) ? 'edit' : $mode;
|
|
$lists = $this->user->getContactLists($this->app->user->account);
|
|
$listID = $listID ? $listID : key($lists);
|
|
if(!$listID) $mode = 'new';
|
|
|
|
/* Create or manage list according to mode. */
|
|
if($mode == 'new')
|
|
{
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->user->contacts->createList;
|
|
$this->view->position[] = $this->lang->user->contacts->createList;
|
|
}
|
|
else
|
|
{
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->user->contacts->manage;
|
|
$this->view->position[] = $this->lang->user->contacts->manage;
|
|
$this->view->list = $this->user->getContactListByID($listID);
|
|
}
|
|
|
|
$this->view->mode = $mode;
|
|
$this->view->lists = $lists;
|
|
$this->view->listID = $listID;
|
|
$this->view->users = $this->user->getPairs('noletter|nodeleted|noempty|noclosed');
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Delete a contact list.
|
|
*
|
|
* @param int $listID
|
|
* @param string $confirm
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function deleteContacts($listID, $confirm = 'no')
|
|
{
|
|
if($confirm == 'no')
|
|
{
|
|
die(js::confirm($this->lang->user->contacts->confirmDelete, inlink('deleteContacts', "listID=$listID&confirm=yes")));
|
|
}
|
|
else
|
|
{
|
|
$this->user->deleteContactList($listID);
|
|
die(js::locate(inlink('manageContacts'), 'parent'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Build contact lists.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function buildContactLists()
|
|
{
|
|
$this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote');
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* View my profile.
|
|
*
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function profile()
|
|
{
|
|
if($this->app->user->account == 'guest') die(js::alert('guest') . js::locate('back'));
|
|
|
|
$user = $this->user->getById($this->app->user->account);
|
|
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->profile;
|
|
$this->view->position[] = $this->lang->my->profile;
|
|
$this->view->user = $user;
|
|
$this->view->groups = $this->loadModel('group')->getByAccount($this->app->user->account);
|
|
$this->view->deptPath = $this->dept->getParents($user->dept);
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* My dynamic.
|
|
*
|
|
* @param string $type
|
|
* @param string $orderBy
|
|
* @param int $recTotal
|
|
* @param int $recPerPage
|
|
* @param int $pageID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function dynamic($type = 'today', $orderBy = 'date_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
|
{
|
|
/* Save session. */
|
|
$uri = $this->app->getURI(true);
|
|
$this->session->set('productList', $uri);
|
|
$this->session->set('productPlanList', $uri);
|
|
$this->session->set('releaseList', $uri);
|
|
$this->session->set('storyList', $uri);
|
|
$this->session->set('projectList', $uri);
|
|
$this->session->set('taskList', $uri);
|
|
$this->session->set('buildList', $uri);
|
|
$this->session->set('bugList', $uri);
|
|
$this->session->set('caseList', $uri);
|
|
$this->session->set('testtaskList', $uri);
|
|
|
|
/* Set the pager. */
|
|
$this->app->loadClass('pager', $static = true);
|
|
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
|
|
|
/* Append id for secend sort. */
|
|
$sort = $this->loadModel('common')->appendOrder($orderBy);
|
|
|
|
/* The header and position. */
|
|
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->dynamic;
|
|
$this->view->position[] = $this->lang->my->dynamic;
|
|
|
|
/* Assign. */
|
|
$this->view->type = $type;
|
|
$this->view->recTotal = $recTotal;
|
|
$this->view->recPerPage = $recPerPage;
|
|
$this->view->pageID = $pageID;
|
|
$this->view->orderBy = $orderBy;
|
|
$this->view->pager = $pager;
|
|
$this->view->actions = $this->loadModel('action')->getDynamic($this->app->user->account, $type, $sort, $pager);
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Unbind ranzhi
|
|
*
|
|
* @param string $confirm
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function unbind($confirm = 'no')
|
|
{
|
|
$this->loadModel('user');
|
|
if($confirm == 'no')
|
|
{
|
|
die(js::confirm($this->lang->user->confirmUnbind, $this->createLink('my', 'unbind', "confirm=yes")));
|
|
}
|
|
else
|
|
{
|
|
$this->user->unbind($this->app->user->account);
|
|
die(js::locate($this->createLink('my', 'profile'), 'parent'));
|
|
}
|
|
}
|
|
|
|
}
|