* Finish task #8107,8108,8109.

This commit is contained in:
Yagami
2020-10-12 14:52:59 +08:00
parent 36a1d27c32
commit 5813c42a71
11 changed files with 14 additions and 604 deletions
+2 -233
View File
@@ -156,6 +156,7 @@ class program extends control
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst');
$this->view->poUsers = $this->user->getPairs('noclosed|nodeleted|pofirst');
$this->view->parentProgram = $parentProgramID ? $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($parentProgramID)->fetch() : '';
$this->view->parents = $this->program->getParentPairs();
@@ -197,6 +198,7 @@ class program extends control
$this->view->position[] = $this->lang->program->PGMEdit;
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $program->PM);
$this->view->poUsers = $this->user->getPairs('noclosed|nodeleted|pofirst');
$this->view->program = $program;
$this->view->parents = $parents;
$this->view->groups = $this->loadModel('group')->getPairs();
@@ -324,239 +326,6 @@ class program extends control
die(js::reload('parent'));
}
/**
* Browse groups.
*
* @param int $companyID
* @access public
* @return void
*/
public function PGMGroup($programID = 0)
{
$this->lang->navGroup->program = 'program';
$this->lang->program->switcherMenu = $this->program->getPGMCommonAction();
$this->session->set('program', $programID);
$title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->browse;
$position[] = $this->lang->group->browse;
$groups = $this->group->getList($programID);
$groupUsers = array();
foreach($groups as $group) $groupUsers[$group->id] = $this->group->getUserPairs($group->id);
$this->view->title = $title;
$this->view->position = $position;
$this->view->groups = $groups;
$this->view->programID = $programID;
$this->view->groupUsers = $groupUsers;
$this->display();
}
/**
* Create a group.
*
* @access public
* @return void
*/
public function PGMCreateGroup($programID = 0)
{
if(!empty($_POST))
{
$_POST['PRJ'] = $programID;
$this->group->create();
if(dao::isError()) die(js::error(dao::getError()));
die(js::closeModal('parent.parent', 'this'));
}
$this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->create;
$this->view->position[] = $this->lang->group->create;
$this->display('group', 'create');
}
/**
* Edit a group.
*
* @param int $groupID
* @access public
* @return void
*/
public function PGMEditGroup($groupID)
{
if(!empty($_POST))
{
$this->group->update($groupID);
die(js::closeModal('parent.parent', 'this'));
}
$this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->edit;
$this->view->position[] = $this->lang->group->edit;
$this->view->group = $this->group->getById($groupID);
$this->display('group', 'edit');
}
/**
* Copy a group.
*
* @param int $groupID
* @access public
* @return void
*/
public function PGMCopyGroup($groupID)
{
if(!empty($_POST))
{
$group = $this->group->getByID($groupID);
$_POST['PRJ'] = $group->PRJ;
$this->group->copy($groupID);
if(dao::isError()) die(js::error(dao::getError()));
die(js::closeModal('parent.parent', 'this'));
}
$this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->copy;
$this->view->position[] = $this->lang->group->copy;
$this->view->group = $this->group->getById($groupID);
$this->display('group', 'copy');
}
/**
* Manage views.
*
* @param int $groupID
* @access public
* @return void
*/
public function PGMManageView($groupID)
{
$this->lang->navGroup->program = 'program';
$this->lang->program->switcherMenu = $this->program->getPGMCommonAction();
if($_POST)
{
$this->group->updateView($groupID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
}
$group = $this->group->getById($groupID);
if($group->acl) $group->acl = json_decode($group->acl, true);
$this->view->title = $group->name . $this->lang->colon . $this->lang->group->manageView;
$this->view->position[] = $group->name;
$this->view->position[] = $this->lang->group->manageView;
$this->view->group = $group;
$this->view->products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->andWhere('program')->eq($group->PRJ)->orderBy('order_desc')->fetchPairs('id', 'name');
$this->view->projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq('0')->andWhere('parent')->eq($group->PRJ)->andWhere('type')->in('sprint,stage')->orderBy('order_desc')->fetchPairs('id', 'name');
$this->display();
}
/**
* Manage privleges of a group.
*
* @param int $groupID
* @access public
* @return void
*/
public function PGMManagePriv($type = 'byGroup', $param = 0, $menu = '', $version = '')
{
$this->lang->navGroup->program = 'program';
$this->lang->program->switcherMenu = $this->program->getPGMCommonAction();
if($type == 'byGroup')
{
$groupID = $param;
$group = $this->group->getById($groupID);
}
$this->view->type = $type;
foreach($this->lang->resource as $moduleName => $action)
{
if($this->group->checkMenuModule($menu, $moduleName) or $type != 'byGroup') $this->app->loadLang($moduleName);
}
if(!empty($_POST))
{
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID, $menu, $version);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('pgmgroup', "programID=$group->PRJ")));
}
if($type == 'byGroup')
{
$this->group->sortResource();
$groupPrivs = $this->group->getPrivs($groupID);
$this->view->title = $group->name . $this->lang->colon . $this->lang->group->managePriv;
$this->view->position[] = $group->name;
$this->view->position[] = $this->lang->group->managePriv;
/* Join changelog when be equal or greater than this version.*/
$realVersion = str_replace('_', '.', $version);
$changelog = array();
foreach($this->lang->changelog as $currentVersion => $currentChangeLog)
{
if(version_compare($currentVersion, $realVersion, '>=')) $changelog[] = join($currentChangeLog, ',');
}
$this->view->group = $group;
$this->view->changelogs = ',' . join($changelog, ',') . ',';
$this->view->groupPrivs = $groupPrivs;
$this->view->groupID = $groupID;
$this->view->menu = $menu;
$this->view->version = $version;
$program = $this->program->getPGMByID($group->PRJ);
/* Unset not program privs. */
foreach($this->lang->resource as $method => $label)
{
if(!in_array($method, $this->config->programPriv->{$program->model})) unset($this->lang->resource->$method);
}
}
$this->display();
}
/**
* Manage members of a group.
*
* @param int $groupID
* @param int $deptID
* @access public
* @return void
*/
public function PGMManageGroupMember($groupID, $deptID = 0)
{
if(!empty($_POST))
{
$this->group->updateUser($groupID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('group', 'browse'), 'parent'));
}
$group = $this->group->getById($groupID);
$groupUsers = $this->group->getUserPairs($groupID);
$allUsers = $this->loadModel('dept')->getDeptUserPairs($deptID);
$otherUsers = array_diff_assoc($allUsers, $groupUsers);
$title = $group->name . $this->lang->colon . $this->lang->group->manageMember;
$position[] = $group->name;
$position[] = $this->lang->group->manageMember;
$this->view->title = $title;
$this->view->position = $position;
$this->view->group = $group;
$this->view->deptTree = $this->loadModel('dept')->getTreeMenu($rooteDeptID = 0, array('deptModel', 'createGroupManageMemberLink'), $groupID);
$this->view->groupUsers = $groupUsers;
$this->view->otherUsers = $otherUsers;
$this->display('group', 'manageMember');
}
/**
* Manage program members.
*