diff --git a/module/group/config.php b/module/group/config.php index d5c482678e..6098560e93 100644 --- a/module/group/config.php +++ b/module/group/config.php @@ -44,33 +44,41 @@ $config->group->priv->search['params']['dependPrivs'] = array('operator' => ' $config->group->priv->search['params']['desc'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->group->actionList = array(); -$config->group->actionList['manageView']['icon'] = 'eye'; -$config->group->actionList['manageView']['text'] = $lang->group->manageView; -$config->group->actionList['manageView']['hint'] = $lang->group->manageView; -$config->group->actionList['manageView']['url'] = helper::createLink('group', 'manageView', "groupID={id}"); -$config->group->actionList['manageView']['data-toggle'] = 'modal'; +$config->group->actionList['manageView']['icon'] = 'eye'; +$config->group->actionList['manageView']['text'] = $lang->group->manageView; +$config->group->actionList['manageView']['hint'] = $lang->group->manageView; +$config->group->actionList['manageView']['url'] = helper::createLink('group', 'manageView', "groupID={id}"); $config->group->actionList['managePriv']['icon'] = 'lock'; $config->group->actionList['managePriv']['text'] = $lang->group->managePriv; $config->group->actionList['managePriv']['hint'] = $lang->group->managePriv; $config->group->actionList['managePriv']['url'] = helper::createLink('group', 'managepriv', "type=bypackage&groupID={id}"); -$config->group->actionList['manageMember']['icon'] = 'persons'; -$config->group->actionList['manageMember']['text'] = $lang->group->manageMember; -$config->group->actionList['manageMember']['hint'] = $lang->group->manageMember; -$config->group->actionList['manageMember']['url'] = helper::createLink('group', 'manageMember', "groupID={id}"); +$config->group->actionList['manageProjectAdmin']['icon'] = 'persons'; +$config->group->actionList['manageProjectAdmin']['text'] = $lang->group->manageProjectAdmin; +$config->group->actionList['manageProjectAdmin']['hint'] = $lang->group->manageProjectAdmin; +$config->group->actionList['manageProjectAdmin']['url'] = helper::createLink('group', 'manageProjectAdmin', "groupID={id}"); +$config->group->actionList['manageProjectAdmin']['data-toggle'] = 'modal'; -$config->group->actionList['edit']['icon'] = 'edit'; -$config->group->actionList['edit']['text'] = $lang->group->edit; -$config->group->actionList['edit']['hint'] = $lang->group->edit; -$config->group->actionList['edit']['url'] = helper::createLink('group', 'edit', "groupID={id}"); +$config->group->actionList['manageMember']['icon'] = 'persons'; +$config->group->actionList['manageMember']['text'] = $lang->group->manageMember; +$config->group->actionList['manageMember']['hint'] = $lang->group->manageMember; +$config->group->actionList['manageMember']['url'] = helper::createLink('group', 'manageMember', "groupID = {id}"); +$config->group->actionList['manageMember']['data-toggle'] = 'modal'; -$config->group->actionList['copy']['icon'] = 'copy'; -$config->group->actionList['copy']['text'] = $lang->group->copy; -$config->group->actionList['copy']['hint'] = $lang->group->copy; -$config->group->actionList['copy']['url'] = helper::createLink('group', 'copy', "groupID={id}"); +$config->group->actionList['edit']['icon'] = 'edit'; +$config->group->actionList['edit']['text'] = $lang->group->edit; +$config->group->actionList['edit']['hint'] = $lang->group->edit; +$config->group->actionList['edit']['url'] = helper::createLink('group', 'edit', "groupID={id}"); +$config->group->actionList['edit']['data-toggle'] = 'modal'; + +$config->group->actionList['copy']['icon'] = 'copy'; +$config->group->actionList['copy']['text'] = $lang->group->copy; +$config->group->actionList['copy']['hint'] = $lang->group->copy; +$config->group->actionList['copy']['url'] = helper::createLink('group', 'copy', "groupID={id}"); +$config->group->actionList['copy']['data-toggle'] = 'modal'; $config->group->actionList['delete']['icon'] = 'trash'; $config->group->actionList['delete']['text'] = $lang->group->delete; $config->group->actionList['delete']['hint'] = $lang->group->delete; -$config->group->actionList['delete']['url'] = helper::createLink('group', 'delete', "groupID={id}"); +$config->group->actionList['delete']['url'] = 'javascript:confirmDelete("{id}")'; diff --git a/module/group/config/dtable.php b/module/group/config/dtable.php new file mode 100644 index 0000000000..dd2f0a72b0 --- /dev/null +++ b/module/group/config/dtable.php @@ -0,0 +1,28 @@ +group->dtable = new stdclass(); + +$config->group->dtable->fieldList['id']['title'] = $lang->idAB; +$config->group->dtable->fieldList['id']['name'] = 'id'; +$config->group->dtable->fieldList['id']['type'] = 'id'; + +$config->group->dtable->fieldList['name']['title'] = $lang->group->name; +$config->group->dtable->fieldList['name']['name'] = 'name'; +$config->group->dtable->fieldList['name']['type'] = 'title'; +$config->group->dtable->fieldList['name']['sortType'] = false; + +$config->group->dtable->fieldList['desc']['title'] = $lang->group->desc; +$config->group->dtable->fieldList['desc']['name'] = 'desc'; +$config->group->dtable->fieldList['desc']['type'] = 'desc'; +$config->group->dtable->fieldList['desc']['hint'] = true; + +$config->group->dtable->fieldList['users']['title'] = $lang->group->users; +$config->group->dtable->fieldList['users']['name'] = 'users'; +$config->group->dtable->fieldList['users']['type'] = 'desc'; +$config->group->dtable->fieldList['users']['hint'] = true; + +$config->group->dtable->fieldList['actions']['title'] = $lang->actions; +$config->group->dtable->fieldList['actions']['name'] = 'actions'; +$config->group->dtable->fieldList['actions']['type'] = 'actions'; +$config->group->dtable->fieldList['actions']['list'] = $config->group->actionList; +$config->group->dtable->fieldList['actions']['menu'] = array('manageView', 'managePriv', 'manageProjectAdmin|manageMember', 'edit', 'copy', 'delete'); diff --git a/module/group/control.php b/module/group/control.php index 7871250a75..e3ad9cae6e 100644 --- a/module/group/control.php +++ b/module/group/control.php @@ -32,27 +32,25 @@ class group extends control */ public function browse() { - $title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->browse; - $position[] = $this->lang->group->browse; $groups = $this->group->getList(); - $groupUsers = array(); foreach($groups as $group) { + $group->actions = array(); if($group->role == 'projectAdmin') { - $groupUsers[$group->id] = $this->dao->select('t1.account, t2.realname')->from(TABLE_PROJECTADMIN)->alias('t1')->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account')->fetchPairs(); + $groupUsers = $this->dao->select('t1.account, t2.realname')->from(TABLE_PROJECTADMIN)->alias('t1')->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account')->fetchPairs(); + $group->users = implode(',', $groupUsers); } else { - $groupUsers[$group->id] = $this->group->getUserPairs($group->id); + $groupUsers = $this->group->getUserPairs($group->id); + $group->users = implode(',', $groupUsers); } } - $this->view->title = $title; - $this->view->position = $position; - $this->view->groups = $groups; - $this->view->groupUsers = $groupUsers; + $this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->browse; + $this->view->groups = $groups; $this->display(); } @@ -458,37 +456,26 @@ class group extends control * Delete a group. * * @param int $groupID - * @param string $confirm yes|no * @access public * @return void */ - public function delete($groupID, $confirm = 'no') + public function delete($groupID) { - if($confirm == 'no') + $this->group->delete($groupID); + + /* if ajax request, send result. */ + if(dao::isError()) { - return print(js::confirm($this->lang->group->confirmDelete, $this->createLink('group', 'delete', "groupID=$groupID&confirm=yes"))); + $response['result'] = 'fail'; + $response['message'] = dao::getError(); } else { - $this->group->delete($groupID); - - /* if ajax request, send result. */ - if($this->server->ajax) - { - if(dao::isError()) - { - $response['result'] = 'fail'; - $response['message'] = dao::getError(); - } - else - { - $response['result'] = 'success'; - $response['message'] = ''; - } - return $this->send($response); - } - return print(js::locate($this->createLink('group', 'browse'), 'parent')); + $response['result'] = 'success'; + $response['message'] = ''; + $response['load'] = inLink('browse'); } + return $this->send($response); } /** diff --git a/module/group/js/browse.ui.js b/module/group/js/browse.ui.js new file mode 100644 index 0000000000..bb17828d7b --- /dev/null +++ b/module/group/js/browse.ui.js @@ -0,0 +1,15 @@ +/** + * 提示并删除分组。 + * Delete group with tips. + * + * @param int groupID + * @access public + * @return void + */ +window.confirmDelete = function(groupID) +{ + if(window.confirm(confirmDelete)) + { + $.ajaxSubmit({url: $.createLink('group', 'delete', 'groupID=' + groupID)}); + } +} diff --git a/module/group/lang/de.php b/module/group/lang/de.php index 2e6daf44f6..329baeda3f 100644 --- a/module/group/lang/de.php +++ b/module/group/lang/de.php @@ -128,6 +128,8 @@ $lang->privlang->parent = 'Module/Package'; $lang->group->copyOptions['copyPriv'] = 'Rechte kopieren'; $lang->group->copyOptions['copyUser'] = 'Benutzer kopieren'; +$lang->group->featureBar['browse']['all'] = 'Privilege Group'; + $lang->group->versions[''] = 'Verlauf'; $lang->group->versions['18_4_alpha1'] = 'ZenTao18.4.alpha1'; $lang->group->versions['18_3'] = 'ZenTao18.3'; diff --git a/module/group/lang/en.php b/module/group/lang/en.php index 539c385e63..e93540f7ba 100644 --- a/module/group/lang/en.php +++ b/module/group/lang/en.php @@ -128,6 +128,8 @@ $lang->privlang->parent = 'Module/Package'; $lang->group->copyOptions['copyPriv'] = 'Copy Privileges'; $lang->group->copyOptions['copyUser'] = 'Copy Users'; +$lang->group->featureBar['browse']['all'] = 'Privilege Group'; + $lang->group->versions[''] = 'History'; $lang->group->versions['18_4_alpha1'] = 'ZenTao18.4.alpha1'; $lang->group->versions['18_3'] = 'ZenTao18.3'; diff --git a/module/group/lang/fr.php b/module/group/lang/fr.php index daf64729be..3c96bad1a5 100644 --- a/module/group/lang/fr.php +++ b/module/group/lang/fr.php @@ -128,6 +128,8 @@ $lang->privlang->parent = 'Module/Package'; $lang->group->copyOptions['copyPriv'] = 'Copier Privilèges'; $lang->group->copyOptions['copyUser'] = 'Copier Utilisateurs'; +$lang->group->featureBar['browse']['all'] = 'Privilege Group'; + $lang->group->versions[''] = 'History'; $lang->group->versions['18_4_alpha1'] = 'ZenTao18.4.alpha1'; $lang->group->versions['18_3'] = 'ZenTao18.3'; diff --git a/module/group/lang/zh-cn.php b/module/group/lang/zh-cn.php index 3186962177..80f85e85a7 100644 --- a/module/group/lang/zh-cn.php +++ b/module/group/lang/zh-cn.php @@ -128,6 +128,8 @@ $lang->privlang->parent = '所属模块/权限包'; $lang->group->copyOptions['copyPriv'] = '复制权限'; $lang->group->copyOptions['copyUser'] = '复制用户'; +$lang->group->featureBar['browse']['all'] = '浏览分组'; + $lang->group->versions[''] = '修改历史'; $lang->group->versions['18_4_alpha1'] = '禅道18.4.alpha1'; $lang->group->versions['18_3'] = '禅道18.3'; diff --git a/module/group/model.php b/module/group/model.php index 820c82e77f..c730fdfbef 100644 --- a/module/group/model.php +++ b/module/group/model.php @@ -839,8 +839,10 @@ class groupModel extends model { $action = strtolower($action); - if($action == 'manageview' and $group->role == 'limited') return false; - if($action == 'copy' and $group->role == 'limited') return false; + if($action == 'manageview' && $group->role == 'limited') return false; + if($action == 'copy' && $group->role == 'limited') return false; + if($group->role == 'projectAdmin' && in_array($action, array('manageview', 'managepriv', 'managemember', 'edit', 'copy'))) return false; + if($group->role != 'projectAdmin' && $actions == 'manageprojectadmin') return false; return true; } diff --git a/module/group/ui/browse.html.php b/module/group/ui/browse.html.php new file mode 100644 index 0000000000..6fc23c3588 --- /dev/null +++ b/module/group/ui/browse.html.php @@ -0,0 +1,28 @@ + + * @package group + * @link https://www.zentao.net + */ +namespace zin; + +/* zin: Define the set::module('group') feature bar on main menu. */ +featureBar +( + set::current('all'), +); + +jsVar('confirmDelete', $lang->group->confirmDelete); +$tableData = initTableData($groups, $config->group->dtable->fieldList, $this->group); +dtable +( + set::cols(array_values($config->group->dtable->fieldList)), + set::data($tableData), +); + +/* ====== Render page ====== */ +render();