This commit is contained in:
holan20180123
2021-06-18 10:27:57 +08:00
8 changed files with 104 additions and 21 deletions
+7 -4
View File
@@ -818,11 +818,14 @@ class commonModel extends model
foreach($menu as $menuItem)
{
/* Fix work and contribute navigation permission check issues. */
if($menuItem->link['module'] == 'my' and ($menuItem->link['method'] == 'work' or $menuItem->link['method'] == 'contribute'))
if(isset($menuItem->link) and isset($menuItem->link['module']) and isset($menuItem->link['method']))
{
$mode = explode('&', $menuItem->link['vars']);
$mode = substr($mode[0], 5);
$menuItem->hidden = !common::hasPriv('my', $mode);
if($menuItem->link['module'] == 'my' and ($menuItem->link['method'] == 'work' or $menuItem->link['method'] == 'contribute'))
{
$mode = explode('&', $menuItem->link['vars']);
$mode = substr($mode[0], 5);
$menuItem->hidden = !common::hasPriv('my', $mode);
}
}
if(isset($menuItem->hidden) && $menuItem->hidden) continue;
+4 -1
View File
@@ -29,7 +29,10 @@
<p class='text-info'><?php echo $lang->upgrade->selectedModeTips['new'];?></p>
</td>
</tr>
<tr><td></td><td><?php echo html::submitButton($lang->upgrade->common);?></td></tr>
<tr>
<td></td>
<td><?php echo html::submitButton($lang->custom->switch);?></td>
</tr>
</table>
</form>
</div>
+5
View File
@@ -4,3 +4,8 @@ $config->group->create = new stdclass();
$config->group->edit = new stdclass();
$config->group->create->requiredFields = 'name';
$config->group->edit->requiredFields = 'name';
$config->group->acl = new stdclass();
$config->group->acl->objectTypes['programs'] = 'program';
$config->group->acl->objectTypes['projects'] = 'project';
$config->group->acl->objectTypes['products'] = 'product';
+2 -1
View File
@@ -132,7 +132,8 @@ class group extends control
$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' => 'parent'));
$link = isonlybody() ? 'parent' : $this->createLink('group', 'browse');
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link));
}
/* Get the group data by id. */
+16 -1
View File
@@ -345,7 +345,8 @@ class groupModel extends model
*/
public function updateView($groupID)
{
$actions = $this->post->actions;
$actions = $this->post->actions;
$oldGroup = $this->getByID($groupID);
if(isset($_POST['allchecker']))$actions['views'] = array();
if(!isset($actions['actions']))$actions['actions'] = array();
@@ -362,6 +363,20 @@ class groupModel extends model
}
$actions['actions'] = $dynamic;
/* Update whitelist. */
$users = $this->getUserPairs($groupID);
$users = array_keys($users);
foreach($this->config->group->acl->objectTypes as $key => $objectType)
{
$oldAcls = isset($oldGroup->acl[$key]) ? $oldGroup->acl[$key] : array();
$newAcls = isset($actions[$key]) ? $actions[$key] : array();
$needRemoveAcls = array_diff($oldAcls, $newAcls);
$needAddAcls = array_diff($newAcls, $oldAcls);
foreach($needAddAcls as $objectID) $this->loadModel('personnel')->updateWhitelist($users, $objectType, $objectID, 'whitelist', 'add', 'increase');
foreach($needRemoveAcls as $objectID) $this->loadModel('personnel')->deleteWhitelist($users, $objectType, $objectID);
}
$actions = empty($actions) ? '' : json_encode($actions);
$this->dao->update(TABLE_GROUP)->set('acl')->eq($actions)->where('id')->eq($groupID)->exec();
return dao::isError() ? false : true;
+66 -11
View File
@@ -497,25 +497,27 @@ class personnelModel extends model
* @param array $users
* @param string $objectType program|project|product|sprint
* @param int $objectID
* @param string $type whitelist|blacklist
* @param string $source upgrade|add|sync
* @param string $type whitelist|blacklist
* @param string $source upgrade|add|sync
* @param string $updateType increase|replace
* @access public
* @return void
*/
public function updateWhitelist($users = array(), $objectType = '', $objectID = 0, $type = 'whitelist', $source = 'add')
public function updateWhitelist($users = array(), $objectType = '', $objectID = 0, $type = 'whitelist', $source = 'add', $updateType = 'replace')
{
$oldWhitelist = $this->dao->select('account,objectType,objectID,type,source')->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->fetchAll('account');
$this->dao->delete()->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->exec();
if($updateType == 'replace') $this->dao->delete()->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->exec();
$users = array_filter($users);
$users = array_unique($users);
$accounts = array();
foreach($users as $account)
{
$accounts[$account] = $account;
if(isset($oldWhitelist[$account]))
{
$this->dao->insert(TABLE_ACL)->data($oldWhitelist[$account])->exec();
$accounts[$account] = $account;
if($updateType == 'replace') $this->dao->insert(TABLE_ACL)->data($oldWhitelist[$account])->exec();
continue;
}
@@ -527,11 +529,17 @@ class personnelModel extends model
$acl->source = $source;
$this->dao->insert(TABLE_ACL)->data($acl)->autoCheck()->exec();
if(!dao::isError()) $this->loadModel('user')->updateUserView($acl->objectID, $acl->objectType, $acl->account);
$accounts[$account] = $account;
}
$whitelist = ',' . implode(',', $accounts);
/* Update whitelist field. */
$objectTable = $objectType == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
if($updateType == 'increase')
{
$oldWhitelist = $this->dao->select('whitelist')->from($objectTable)->where('id')->eq($objectID)->fetch('whitelist');
$oldWhitelist = explode(',', $oldWhitelist);
$accounts = array_unique(array_merge($accounts, $oldWhitelist));
}
$whitelist = ',' . implode(',', $accounts);
$this->dao->update($objectTable)->set('whitelist')->eq($whitelist)->where('id')->eq($objectID)->exec();
$deletedAccounts = array();
@@ -549,10 +557,13 @@ class personnelModel extends model
$programWhitelist = $this->getWhitelistAccount($product->program, 'program');
$newWhitelist = array_merge($programWhitelist, $accounts);
$source = $source == 'upgrade' ? 'upgrade' : 'sync';
$this->updateWhitelist($newWhitelist, 'program', $product->program, 'whitelist', $source);
$this->updateWhitelist($newWhitelist, 'program', $product->program, 'whitelist', $source, $updateType);
/* Removal of persons from centralized program whitelisting. */
foreach($deletedAccounts as $account) $this->deleteProgramWhitelist($objectID, $account);
if($updateType == 'replace')
{
foreach($deletedAccounts as $account) $this->deleteProgramWhitelist($objectID, $account);
}
}
/* Synchronization of people from the sprint white list to the project. */
@@ -567,7 +578,10 @@ class personnelModel extends model
$this->updateWhitelist($newWhitelist, 'project', $sprint->project, 'whitelist', $source);
/* Removal of whitelisted persons from projects. */
foreach($deletedAccounts as $account) $this->deleteProjectWhitelist($objectID, $account);
if($updateType == 'replace')
{
foreach($deletedAccounts as $account) $this->deleteProjectWhitelist($objectID, $account);
}
}
}
@@ -585,6 +599,23 @@ class personnelModel extends model
$this->updateWhitelist($users, $objectType, $objectID);
}
/**
* Delete product whitelist.
*
* @param int $objectID
* @param string $account
* @access public
* @return void
*/
public function deleteProductWhitelist($objectID, $account = '')
{
$product = $this->dao->select('id,whitelist')->from(TABLE_PRODUCT)->where('id')->eq($objectID)->fetch('whitelist');
if(empty($product)) return false;
$newWhitelist = str_replace(',' . $acl->account, '', $product->whitelist);
$this->dao->update(TABLE_PRODUCT)->set('whitelist')->eq($newWhitelist)->where('id')->eq($objectID)->exec();
}
/**
* Determine whether the user exists in the white list of multiple products.
*
@@ -635,6 +666,30 @@ class personnelModel extends model
}
}
/**
* Delete users in whitelist.
*
* @param array $users
* @param string $objectType
* @param int $objectID
* @access public
* @return void
*/
public function deleteWhitelist($users = array(), $objectType = 'program', $objectID = 0)
{
$this->dao->delete()->from(TABLE_ACL)
->where('objectID')->eq($objectID)
->andWhere('account')->in($users)
->exec();
foreach($users as $account)
{
if($objectType == 'program') $this->deleteProgramWhitelist($objectID, $account);
if($objectType == 'project') $this->deleteProjectWhitelist($objectID, $account);
if($objectType == 'product') $this->deleteProductWhitelist($objectID, $account);
}
}
/**
* Create access links by department.
*
+2 -1
View File
@@ -32,7 +32,8 @@
$visibleFields = array();
foreach(explode(',', $showFields) as $field)
{
if($field and ($storyType == 'story' or $field != 'stage'))$visibleFields[$field] = '';
if($storyType == 'requeirment' and $field == 'stage') continue;
if($field) $visibleFields[$field] = '';
}
?>
<form method='post' target='hiddenwin' action="<?php echo inLink('batchEdit', "productID=$productID&executionID=$executionID")?>" id="batchEditForm">
@@ -209,7 +209,7 @@ var colorKey = 0;
for(var key in bugPriList)
{
$('.pri-' + key).css('background', colorList[colorKey]);
var priName = key == 0 ? zeroPri : bugPriList[key];
var priName = key == 0 ? zeroPri : bugPriList[key];
var pri = {
label: priName,
color: colorList[colorKey],
@@ -230,7 +230,7 @@ colorKey = 2;
for(var key in bugHandleGroups)
{
$('.' + key).css('background', colorList[colorKey]);
var stageName = bugStageList[key];
var stageName = bugStageList[key];
var stage = {
label: stageName,
color: colorList[colorKey],