* Compute program priv.
This commit is contained in:
+38
-4
@@ -1569,14 +1569,20 @@ EOD;
|
||||
public static function hasPriv($module, $method, $object = null)
|
||||
{
|
||||
global $app, $lang;
|
||||
$module = strtolower($module);
|
||||
$method = strtolower($method);
|
||||
|
||||
/* Check is the super admin or not. */
|
||||
if(!empty($app->user->admin) || strpos($app->company->admins, ",{$app->user->account},") !== false) return true;
|
||||
|
||||
/* If is the program admin, have all program related privs. */
|
||||
$inProgram = isset($lang->navGroup->$module) && $lang->navGroup->$module == 'program';
|
||||
if(strpos(",{$app->user->rights['programs']},", ",{$app->session->program},") !== false && $inProgram) return true;
|
||||
if($inProgram) self::resetProgramPriv($module, $method);
|
||||
|
||||
/* If not super admin, check the rights. */
|
||||
$rights = $app->user->rights['rights'];
|
||||
$acls = $app->user->rights['acls'];
|
||||
$module = strtolower($module);
|
||||
$method = strtolower($method);
|
||||
$rights = $app->user->rights['rights'];
|
||||
$acls = $app->user->rights['acls'];
|
||||
|
||||
if((($app->user->account != 'guest') or ($app->company->guest and $app->user->account == 'guest')) and $module == 'report' and $method == 'annualdata') return true;
|
||||
|
||||
@@ -1600,6 +1606,34 @@ EOD;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset program priv.
|
||||
*
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @static
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function resetProgramPriv($module, $method)
|
||||
{
|
||||
global $app, $lang, $dbh;
|
||||
/* Get user program priv. */
|
||||
if(!$app->session->program) return;
|
||||
$program = $dbh->query("SELECT * FROM " . TABLE_PROJECT . " WHERE `id` = '{$app->session->program}'")->fetch();
|
||||
$programRights = $dbh->query("SELECT t3.module, t3.method FROM " . TABLE_GROUP . " AS t1 LEFT JOIN " . TABLE_USERGROUP . " AS t2 ON t1.id = t2.group LEFT JOIN " . TABLE_GROUPPRIV . " AS t3 ON t2.group=t3.group WHERE t1.program = " . "'{$app->session->program}'" . ' AND t2.account = ' . "'{$app->user->account}'")->fetchAll();
|
||||
|
||||
/* Group priv by module. */
|
||||
$programRightGroup = array();
|
||||
foreach($programRights as $programRight) $programRightGroup[$programRight->module][$programRight->method] = 1;
|
||||
|
||||
/* Reset priv by program privway. */
|
||||
$rights = $app->user->rights['rights'];
|
||||
$acls = $app->user->rights['acls'];
|
||||
if($program->privway == 'extend') $app->user->rights['rights'] = array_merge_recursive($programRightGroup, $rights);
|
||||
if($program->privway == 'reset') $app->user->rights['rights'] = $programRightGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check db priv.
|
||||
*
|
||||
|
||||
@@ -48,6 +48,7 @@ $lang->group->priv = 'Privilege Group';
|
||||
$lang->group->option = 'Option';
|
||||
$lang->group->inside = 'Group Users';
|
||||
$lang->group->outside = 'Other Users';
|
||||
$lang->group->limited = 'Limited Users';
|
||||
$lang->group->other = 'Others';
|
||||
$lang->group->all = 'All Privileges';
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ $lang->group->priv = '权限';
|
||||
$lang->group->option = '选项';
|
||||
$lang->group->inside = '组内用户';
|
||||
$lang->group->outside = '组外用户';
|
||||
$lang->group->limited = '受限用户组';
|
||||
$lang->group->other = '其他模块';
|
||||
$lang->group->all = '所有权限';
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ class groupModel extends model
|
||||
public function create()
|
||||
{
|
||||
$group = fixer::input('post')->get();
|
||||
if(isset($group->limited))
|
||||
{
|
||||
unset($group->limited);
|
||||
$group->role = 'limited';
|
||||
}
|
||||
return $this->dao->insert(TABLE_GROUP)->data($group)->batchCheck($this->config->group->create->requiredFields, 'notempty')->exec();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,15 +51,11 @@
|
||||
<?php common::printIcon('group', 'edit', "groupID=$group->id", $group, 'list', '', '', 'iframe', 'yes', "data-width='550'");?>
|
||||
<?php common::printIcon('group', 'copy', "groupID=$group->id", $group, 'list', '', '', 'iframe', 'yes', "data-width='550'");?>
|
||||
<?php
|
||||
if(common::hasPriv('group', 'delete') and $group->role != 'limited')
|
||||
if(common::hasPriv('group', 'delete'))
|
||||
{
|
||||
$deleteURL = $this->createLink('group', 'delete', "groupID=$group->id&confirm=yes");
|
||||
echo html::a("javascript:ajaxDelete(\"$deleteURL\", \"groupList\", confirmDelete)", '<i class="icon icon-trash"></i>', '', "title='{$lang->group->delete}' class='btn'");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<button class='btn disabled'><i class='icon icon-trash disabled' title='{$lang->group->delete}'></i></button>";
|
||||
}
|
||||
?>
|
||||
<?php else:?>
|
||||
<?php common::printIcon('group', 'manageView', "groupID=$group->id", $group, 'list', 'eye', '', 'disabled');?>
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
<th><?php echo $lang->group->desc;?></th>
|
||||
<td><?php echo html::textarea('desc', '', "rows=5 class=form-control");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->group->limited;?></th>
|
||||
<td><?php echo html::checkbox('limited', '');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='text-center'><?php echo html::submitButton();?></td>
|
||||
</tr>
|
||||
|
||||
@@ -13,5 +13,5 @@ $config->program->list = new stdclass();
|
||||
$config->program->list->exportFields = 'id,name,code,type,category,status,begin,end,budget,PM,end,desc';
|
||||
|
||||
$config->program->priv = new stdclass();
|
||||
$config->program->priv->scrum = array('program', 'product', 'story', 'productplan', 'release', 'project', 'task', 'build', 'qa', 'bug', 'testcase', 'testsuite', 'testreport', 'caselib', 'doc', 'report', 'repo', 'svn', 'git', 'search', 'tree', 'file', 'jenkins', 'job', 'ci', 'branch');
|
||||
$config->program->priv->scrum = array('product', 'story', 'productplan', 'release', 'project', 'task', 'build', 'qa', 'bug', 'testcase', 'testsuite', 'testreport', 'caselib', 'doc', 'report', 'repo', 'svn', 'git', 'search', 'tree', 'file', 'jenkins', 'job', 'ci', 'branch');
|
||||
$config->program->priv->cmmi = $config->program->priv->scrum + array('workestimation', 'durationestimation', 'budget', 'programplan', 'review', 'reviewissue', 'weekly', 'milestone', 'design', 'issue', 'risk', 'auditplan', 'nc', 'cm', 'pssp');
|
||||
|
||||
@@ -246,7 +246,7 @@ class program extends control
|
||||
$group = $this->group->getById($groupID);
|
||||
if($group->acl) $group->acl = json_decode($group->acl, true);
|
||||
|
||||
$this->view->title = $this->lang->company->common . $this->lang->colon . $group->name . $this->lang->colon . $this->lang->group->manageView;
|
||||
$this->view->title = $group->name . $this->lang->colon . $this->lang->group->manageView;
|
||||
$this->view->position[] = $group->name;
|
||||
$this->view->position[] = $this->lang->group->manageView;
|
||||
|
||||
@@ -254,10 +254,6 @@ class program extends control
|
||||
$this->view->products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->andWhere('program')->eq($group->program)->orderBy('order_desc')->fetchPairs('id', 'name');
|
||||
$this->view->projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq('0')->andWhere('program')->eq($group->program)->orderBy('order_desc')->fetchPairs('id', 'name');
|
||||
|
||||
$menugroup = array();
|
||||
foreach($this->lang->menugroup as $moduleName => $groupName) $menugroup[$groupName][$moduleName] = $moduleName;
|
||||
$this->view->menugroup = $menugroup;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,13 @@
|
||||
<td title='<?php echo $users;?>'><?php echo $users;?></td>
|
||||
<td class='c-actions'>
|
||||
<?php $lang->group->managepriv = $lang->group->managePrivByGroup;?>
|
||||
<?php common::printIcon('program', 'manageView', "groupID=$group->id", $group, 'list', 'eye');?>
|
||||
<?php $disabled = $group->role == 'limited' ? 'disabled' : '';?>
|
||||
<?php common::printIcon('program', 'manageView', "groupID=$group->id", $group, 'list', 'eye', '', $disabled);?>
|
||||
<?php common::printIcon('program', 'managePriv', "type=byGroup¶m=$group->id", $group, 'list', 'lock');?>
|
||||
<?php $lang->group->managemember = $lang->group->manageMember;?>
|
||||
<?php common::printIcon('program', 'manageGroupMember', "groupID=$group->id", $group, 'list', 'persons', '', 'iframe', 'yes', "data-width='90%'");?>
|
||||
<?php common::printIcon('program', 'editGroup', "groupID=$group->id", $group, 'list', 'edit', '', 'iframe', 'yes', "data-width='550'");?>
|
||||
<?php common::printIcon('program', 'copyGroup', "groupID=$group->id", $group, 'list', 'copy', '', 'iframe', 'yes', "data-width='550'");?>
|
||||
<?php common::printIcon('program', 'copyGroup', "groupID=$group->id", $group, 'list', 'copy', '', "iframe $disabled", 'yes', "data-width='550'");?>
|
||||
<?php
|
||||
if(common::hasPriv('group', 'delete') and $group->role != 'limited')
|
||||
{
|
||||
|
||||
+16
-4
@@ -760,10 +760,12 @@ class userModel extends model
|
||||
$groups = $this->dao->select('t1.acl')->from(TABLE_GROUP)->alias('t1')
|
||||
->leftJoin(TABLE_USERGROUP)->alias('t2')->on('t1.id=t2.group')
|
||||
->where('t2.account')->eq($account)
|
||||
->andWhere('t1.program')->eq(0)
|
||||
->andWhere('role')->ne('limited')
|
||||
->fetchAll();
|
||||
$acls = array();
|
||||
$viewAllow = false;
|
||||
$programAllow = false;
|
||||
$productAllow = false;
|
||||
$projectAllow = false;
|
||||
$actionAllow = false;
|
||||
@@ -772,6 +774,7 @@ class userModel extends model
|
||||
$acl = json_decode($group->acl, true);
|
||||
if(empty($group->acl))
|
||||
{
|
||||
$programAllow = true;
|
||||
$productAllow = true;
|
||||
$projectAllow = true;
|
||||
$viewAllow = true;
|
||||
@@ -779,6 +782,7 @@ class userModel extends model
|
||||
break;
|
||||
}
|
||||
|
||||
if(empty($acl['programs'])) $programAllow = true;
|
||||
if(empty($acl['products'])) $productAllow = true;
|
||||
if(empty($acl['projects'])) $projectAllow = true;
|
||||
if(empty($acl['views'])) $viewAllow = true;
|
||||
@@ -790,19 +794,23 @@ class userModel extends model
|
||||
}
|
||||
|
||||
if(!empty($acl['views'])) $acls['views'] = array_merge($acls['views'], $acl['views']);
|
||||
if(!empty($acl['programs'])) $acls['programs'] = !empty($acls['programs']) ? array_merge($acls['programs'], $acl['programs']) : $acl['programs'];
|
||||
if(!empty($acl['products'])) $acls['products'] = !empty($acls['products']) ? array_merge($acls['products'], $acl['products']) : $acl['products'];
|
||||
if(!empty($acl['projects'])) $acls['projects'] = !empty($acls['projects']) ? array_merge($acls['projects'], $acl['projects']) : $acl['projects'];
|
||||
if(!empty($acl['actions'])) $acls['actions'] = !empty($acls['actions']) ? ($acl['actions'] + $acls['actions']) : $acl['actions'];
|
||||
}
|
||||
|
||||
if($programAllow) $acls['programs'] = array();
|
||||
if($productAllow) $acls['products'] = array();
|
||||
if($projectAllow) $acls['projects'] = array();
|
||||
if($viewAllow) $acls['views'] = array();
|
||||
if($actionAllow) unset($acls['actions']);
|
||||
|
||||
$sql = $this->dao->select('module, method')->from(TABLE_USERGROUP)->alias('t1')->leftJoin(TABLE_GROUPPRIV)->alias('t2')
|
||||
->on('t1.group = t2.group')
|
||||
->where('t1.account')->eq($account);
|
||||
$sql = $this->dao->select('module, method')->from(TABLE_GROUP)->alias('t1')
|
||||
->leftJoin(TABLE_USERGROUP)->alias('t2')->on('t1.id = t2.group')
|
||||
->leftJoin(TABLE_GROUPPRIV)->alias('t3')->on('t2.group = t3.group')
|
||||
->where('t2.account')->eq($account)
|
||||
->andWhere('t1.program')->eq(0);
|
||||
}
|
||||
|
||||
$stmt = $sql->query();
|
||||
@@ -811,7 +819,11 @@ class userModel extends model
|
||||
{
|
||||
$rights[strtolower($row['module'])][strtolower($row['method'])] = true;
|
||||
}
|
||||
return array('rights' => $rights, 'acls' => $acls);
|
||||
|
||||
/* Get can manage programs by user. */
|
||||
$pgmAdminGroupID = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->eq('pgmadmin')->fetch('id');
|
||||
$canManagePrograms = $this->dao->select('program')->from(TABLE_USERGROUP)->where('`group`')->eq($pgmAdminGroupID)->andWhere('account')->eq($account)->fetch('program');
|
||||
return array('rights' => $rights, 'acls' => $acls, 'programs' => $canManagePrograms);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user