This commit is contained in:
wangyidong
2021-06-07 11:31:32 +08:00
5 changed files with 91 additions and 13 deletions
+2
View File
@@ -39,6 +39,7 @@ class spliter
{
$i ++;
/* Stitching content in the case of words or Spaces. */
if($this->isLetter($letter))
{
$word = $letter;
@@ -80,6 +81,7 @@ class spliter
}
else
{
/* When the current word has a corresponding number in the dictionary table, concatenate a space before it. */
if(is_numeric(substr($words, strlen($words) - 1, 1)))
{
$words .= ' ' . $letter;
+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.
*