* Code for project admin.
This commit is contained in:
+83
-39
@@ -1072,11 +1072,20 @@ class userModel extends model
|
||||
}
|
||||
|
||||
/* Get can manage projects by user. */
|
||||
$canManageProjects = array();
|
||||
$canManageProjects = '';
|
||||
$canManagePrograms = '';
|
||||
$canManageProducts = '';
|
||||
$canManageExecutions = '';
|
||||
if(!defined('IN_UPGRADE'))
|
||||
{
|
||||
$projectAdminGroupID = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->eq('projectAdmin')->fetch('id');
|
||||
$canManageProjects = $this->dao->select('project')->from(TABLE_USERGROUP)->where('`group`')->eq($projectAdminGroupID)->andWhere('account')->eq($account)->fetch('project');
|
||||
$canManageObjects = $this->dao->select('programs,projects,products,executions')->from(TABLE_PROJECTADMIN)->where('account')->eq($account)->fetchAll();
|
||||
foreach($canManageObjects as $object)
|
||||
{
|
||||
$canManageProjects .= $object->projects . ',';
|
||||
$canManageProducts .= $object->products . ',';
|
||||
$canManagePrograms .= $object->programs . ',';
|
||||
$canManageExecutions .= $object->executions . ',';
|
||||
}
|
||||
}
|
||||
|
||||
/* Set basic priv when no any priv. */
|
||||
@@ -1085,7 +1094,7 @@ class userModel extends model
|
||||
$rights['index']['index'] = 1;
|
||||
$rights['my']['index'] = 1;
|
||||
}
|
||||
return array('rights' => $rights, 'acls' => $acls, 'projects' => $canManageProjects);
|
||||
return array('rights' => $rights, 'acls' => $acls, 'projects' => $canManageProjects, 'programs' => $canManagePrograms, 'products' => $canManageProducts, 'executions' => $canManageExecutions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1741,15 +1750,15 @@ class userModel extends model
|
||||
{
|
||||
foreach($projectAdmin as $key => $value)
|
||||
{
|
||||
$manageObjects['list'][$key] = isset($manageObjects['list'][$key]) ? $manageObjects['list'][$key] : '';
|
||||
$manageObjects[$key]['list'] = isset($manageObjects[$key]['list']) ? $manageObjects[$key]['list'] : '';
|
||||
|
||||
if($value == 'all')
|
||||
{
|
||||
$manageObjects['isAdmin'][$key] = 1;
|
||||
$manageObjects[$key]['isAdmin'] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$manageObjects['list'][$key] .= $value . ',';
|
||||
$manageObjects[$key]['list'] .= $value . ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1812,14 +1821,14 @@ class userModel extends model
|
||||
else
|
||||
{
|
||||
/* Process program userview. */
|
||||
if(!empty($manageObjects['isAdmin']['programs']))
|
||||
if(!empty($manageObjects['programs']['isAdmin']))
|
||||
{
|
||||
$userView->programs = join(',', array_keys($allPrograms));
|
||||
}
|
||||
else
|
||||
{
|
||||
$programs = array();
|
||||
$managePrograms = isset($manageObjects['list']['programs']) ? $manageObjects['list']['programs'] : '';
|
||||
$managePrograms = isset($manageObjects['programs']['list']) ? $manageObjects['programs']['list'] : '';
|
||||
foreach($allPrograms as $id => $program)
|
||||
{
|
||||
$programStakeholders = zget($stakeholders, $id, array());
|
||||
@@ -1831,14 +1840,14 @@ class userModel extends model
|
||||
}
|
||||
|
||||
/* Process product userview. */
|
||||
if(!empty($manageObjects['isAdmin']['products']))
|
||||
if(!empty($manageObjects['products']['isAdmin']))
|
||||
{
|
||||
$userView->products = join(',', array_keys($allProducts));
|
||||
}
|
||||
else
|
||||
{
|
||||
$products = array();
|
||||
$manageProducts = isset($manageObjects['list']['products']) ? $manageObjects['list']['products'] : '';
|
||||
$manageProducts = isset($manageObjects['products']['list']) ? $manageObjects['products']['list'] : '';
|
||||
foreach($allProducts as $id => $product)
|
||||
{
|
||||
if($this->checkProductPriv($product, $account, $groups, zget($productTeams, $product->id, array()), zget($productStakeholders, $product->id, array()), zget($productWhiteList, $product->id, array()))) $products[$id] = $id;
|
||||
@@ -1848,14 +1857,14 @@ class userModel extends model
|
||||
}
|
||||
|
||||
/* Process project userview. */
|
||||
if(!empty($manageObjects['isAdmin']['projects']))
|
||||
if(!empty($manageObjects['projects']['isAdmin']))
|
||||
{
|
||||
$userView->projects = join(',', array_keys($allProjects));
|
||||
}
|
||||
else
|
||||
{
|
||||
$projects = array();
|
||||
$manageProjects = isset($manageObjects['list']['projects']) ? $manageObjects['list']['projects'] : '';
|
||||
$manageProjects = isset($manageObjects['projects']['list']) ? $manageObjects['projects']['list'] : '';
|
||||
foreach($allProjects as $id => $project)
|
||||
{
|
||||
$projectTeams = zget($teams, $id, array());
|
||||
@@ -1868,14 +1877,14 @@ class userModel extends model
|
||||
}
|
||||
|
||||
/* Process sprint userview. */
|
||||
if(!empty($manageObjects['isAdmin']['executions']))
|
||||
if(!empty($manageObjects['executions']['isAdmin']))
|
||||
{
|
||||
$userView->sprints = join(',', array_keys($allSprints));
|
||||
}
|
||||
else
|
||||
{
|
||||
$sprints = array();
|
||||
$manageExecutions = isset($manageObjects['list']['executions']) ? $manageObjects['list']['executions'] : '';
|
||||
$manageExecutions = isset($manageObjects['executions']['list']) ? $manageObjects['executions']['list'] : '';
|
||||
foreach($allSprints as $id => $sprint)
|
||||
{
|
||||
$sprintTeams = zget($teams, $id, array());
|
||||
@@ -2104,6 +2113,9 @@ class userModel extends model
|
||||
/* Get all parent program and subprogram relation. */
|
||||
$parentPMGroup = $this->loadModel('program')->getParentPM($programIdList);
|
||||
|
||||
/* Get programs's admins. */
|
||||
$programAdmins = $this->loadModel('group')->getAdmins($programIdList, 'programs');
|
||||
|
||||
$whiteListGroup = array();
|
||||
$stmt = $this->dao->select('objectID,account')->from(TABLE_ACL)
|
||||
->where('objectType')->eq('program')
|
||||
@@ -2121,6 +2133,7 @@ class userModel extends model
|
||||
{
|
||||
$stakeholders = zget($stakeholderGroup, $program->id, array());
|
||||
$whiteList = zget($whiteListGroup, $program->id, array());
|
||||
$admins = zget($programAdmins, $program->id, array());
|
||||
if($program->acl == 'program')
|
||||
{
|
||||
$parentIds = explode(',', $program->path);
|
||||
@@ -2130,7 +2143,7 @@ class userModel extends model
|
||||
$stakeholders += zget($parentPMGroup, $parentId, array());
|
||||
}
|
||||
}
|
||||
$authedUsers += $this->getProgramAuthedUsers($program, $stakeholders, $whiteList);
|
||||
$authedUsers += $this->getProgramAuthedUsers($program, $stakeholders, $whiteList, $admins);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2149,13 +2162,14 @@ class userModel extends model
|
||||
{
|
||||
$stakeholders = zget($stakeholderGroup, $program->id, array());
|
||||
$whiteList = zget($whiteListGroup, $program->id, array());
|
||||
$admins = zget($programAdmins, $program->id, array());
|
||||
if($program->acl == 'program')
|
||||
{
|
||||
$stakeholders += zget($parentStakeholderGroup, $program->id, array());
|
||||
$stakeholders += zget($parentPMGroup, $program->id, array());
|
||||
}
|
||||
|
||||
$hasPriv = $this->checkProgramPriv($program, $account, $stakeholders, $whiteList);
|
||||
$hasPriv = $this->checkProgramPriv($program, $account, $stakeholders, $whiteList, $admins);
|
||||
if($hasPriv and strpos(",{$view},", ",{$programID},") === false) $view .= ",{$programID}";
|
||||
if(!$hasPriv and strpos(",{$view},", ",{$programID},") !== false) $view = trim(str_replace(",{$programID},", ',', ",{$view},"), ',');
|
||||
}
|
||||
@@ -2201,6 +2215,9 @@ class userModel extends model
|
||||
/* Get self stakeholders. */
|
||||
$stakeholderGroup = $this->loadModel('stakeholder')->getStakeholderGroup($projectIdList);
|
||||
|
||||
/* Get projects's admins. */
|
||||
$projectAdmins = $this->loadModel('group')->getAdmins($projectIdList, 'projects');
|
||||
|
||||
/* Get all parent program and subprogram relation. */
|
||||
$parentStakeholderGroup = $this->stakeholder->getParentStakeholderGroup($projectIdList);
|
||||
|
||||
@@ -2214,9 +2231,10 @@ class userModel extends model
|
||||
$stakeholders = zget($stakeholderGroup, $project->id, array());
|
||||
$teams = zget($teamGroups, $project->id, array());
|
||||
$whiteList = zget($whiteListGroup, $project->id, array());
|
||||
$admins = zget($projectAdmins, $project->id, array());
|
||||
if($project->acl == 'program') $stakeholders += zget($parentStakeholderGroup, $project->id, array());
|
||||
|
||||
$authedUsers += $this->getProjectAuthedUsers($project, $stakeholders, $teams, $whiteList);
|
||||
$authedUsers += $this->getProjectAuthedUsers($project, $stakeholders, $teams, $whiteList, $admins);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2236,9 +2254,10 @@ class userModel extends model
|
||||
$stakeholders = zget($stakeholderGroup, $project->id, array());
|
||||
$teams = zget($teamGroups, $project->id, array());
|
||||
$whiteList = zget($whiteListGroup, $project->id, array());
|
||||
$admins = zget($projectAdmins, $project->id, array());
|
||||
if($project->acl == 'program') $stakeholders += zget($parentStakeholderGroup, $project->id, array());
|
||||
|
||||
$hasPriv = $this->checkProjectPriv($project, $account, $stakeholders, $teams, $whiteList);
|
||||
$hasPriv = $this->checkProjectPriv($project, $account, $stakeholders, $teams, $whiteList, $admins);
|
||||
if($hasPriv and strpos(",{$view},", ",{$projectID},") === false) $view .= ",{$projectID}";
|
||||
if(!$hasPriv and strpos(",{$view},", ",{$projectID},") !== false) $view = trim(str_replace(",{$projectID},", ',', ",{$view},"), ',');
|
||||
}
|
||||
@@ -2279,6 +2298,9 @@ class userModel extends model
|
||||
|
||||
while($whiteList = $stmt->fetch()) $whiteListGroup[$whiteList->objectID][$whiteList->account] = $whiteList->account;
|
||||
|
||||
/* Get products' admins. */
|
||||
$productAdmins = $this->loadModel('group')->getAdmins($productIdList, 'products');
|
||||
|
||||
/* Get product view list. */
|
||||
$viewList = array();
|
||||
if(empty($users))
|
||||
@@ -2288,7 +2310,8 @@ class userModel extends model
|
||||
$teams = zget($productTeams, $productID, array());
|
||||
$stakeholders = zget($productStakeholders, $productID, array());
|
||||
$whiteList = zget($whiteListGroup, $productID, array());
|
||||
$viewList += $this->getProductViewListUsers($product, $teams, $stakeholders, $whiteList);
|
||||
$admins = zget($productAdmins, $productID, array());
|
||||
$viewList += $this->getProductViewListUsers($product, $teams, $stakeholders, $whiteList, $admins);
|
||||
}
|
||||
|
||||
$users = $viewList;
|
||||
@@ -2306,8 +2329,9 @@ class userModel extends model
|
||||
$members = zget($productTeams, $productID, array());
|
||||
$stakeholders = zget($productStakeholders, $productID, array());
|
||||
$whiteList = zget($whiteListGroup, $productID, array());
|
||||
$admins = zget($productAdmins, $productID, array());
|
||||
|
||||
$hasPriv = $this->checkProductPriv($product, $account, zget($userGroups, $account, ''), $members, $stakeholders, $whiteList);
|
||||
$hasPriv = $this->checkProductPriv($product, $account, zget($userGroups, $account, ''), $members, $stakeholders, $whiteList, $admins);
|
||||
if($hasPriv and strpos(",{$view},", ",{$productID},") === false) $view .= ",{$productID}";
|
||||
if(!$hasPriv and strpos(",{$view},", ",{$productID},") !== false) $view = trim(str_replace(",{$productID},", ',', ",{$view},"), ',');
|
||||
}
|
||||
@@ -2359,6 +2383,9 @@ class userModel extends model
|
||||
/* Get parent project stakeholders. */
|
||||
$stakeholderGroup = $this->loadModel('stakeholder')->getStakeholderGroup($projectIdList);
|
||||
|
||||
/* Get executions' admins. */
|
||||
$executionAdmins = $this->loadModel('group')->getAdmins($sprintIdList, 'executions');
|
||||
|
||||
/* Get auth users. */
|
||||
$authedUsers = array();
|
||||
if(!empty($users)) $authedUsers = $users;
|
||||
@@ -2370,8 +2397,9 @@ class userModel extends model
|
||||
$teams = zget($teamGroups, $sprint->id, array());
|
||||
$parentTeams = zget($teamGroups, $sprint->project, array());
|
||||
$whiteList = zget($whiteListGroup, $sprint->project, array());
|
||||
$admins = zget($executionAdmins, $sprint->id, array());
|
||||
|
||||
$authedUsers += $this->getSprintAuthedUsers($sprint, $stakeholders, array_merge($teams, $parentTeams), $whiteList);
|
||||
$authedUsers += $this->getSprintAuthedUsers($sprint, $stakeholders, array_merge($teams, $parentTeams), $whiteList, $admins);
|
||||
|
||||
/* If you have parent stage view permissions, you have child stage permissions. */
|
||||
if($sprint->type == 'stage' && $sprint->grade == 2)
|
||||
@@ -2398,8 +2426,9 @@ class userModel extends model
|
||||
$stakeholders = zget($stakeholderGroup, $sprint->project, array());
|
||||
$teams = zget($teamGroups, $sprint->id, array());
|
||||
$whiteList = zget($whiteListGroup, $sprint->id, array());
|
||||
$admins = zget($executionAdmins, $sprint->id, array());
|
||||
|
||||
$hasPriv = $this->checkSprintPriv($sprint, $account, $stakeholders, $teams, $whiteList);
|
||||
$hasPriv = $this->checkSprintPriv($sprint, $account, $stakeholders, $teams, $whiteList, $admins);
|
||||
if($hasPriv and strpos(",{$view},", ",{$sprintID},") === false) $view .= ",{$sprintID}";
|
||||
if(!$hasPriv and strpos(",{$view},", ",{$sprintID},") !== false) $view = trim(str_replace(",{$sprintID},", ',', ",{$view},"), ',');
|
||||
}
|
||||
@@ -2414,10 +2443,11 @@ class userModel extends model
|
||||
* @param string $account
|
||||
* @param array $stakeholders
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkProgramPriv($program, $account, $stakeholders, $whiteList)
|
||||
public function checkProgramPriv($program, $account, $stakeholders, $whiteList, $admins)
|
||||
{
|
||||
if(strpos($this->app->company->admins, ',' . $account . ',') !== false) return true;
|
||||
|
||||
@@ -2434,7 +2464,8 @@ class userModel extends model
|
||||
if($program->acl == 'open') return true;
|
||||
|
||||
if(isset($stakeholders[$account])) return true;
|
||||
if(isset($whiteList[$account])) return true;
|
||||
if(isset($whiteList[$account])) return true;
|
||||
if(isset($admins[$account])) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2447,17 +2478,20 @@ class userModel extends model
|
||||
* @param string $groups
|
||||
* @param array $teams
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkProjectPriv($project, $account, $stakeholders, $teams, $whiteList)
|
||||
public function checkProjectPriv($project, $account, $stakeholders, $teams, $whiteList, $admins)
|
||||
{
|
||||
if(strpos($this->app->company->admins, ',' . $account . ',') !== false) return true;
|
||||
if($project->PO == $account OR $project->QD == $account OR $project->RD == $account OR $project->PM == $account) return true;
|
||||
if($project->acl == 'open') return true;
|
||||
if(isset($teams[$account])) return true;
|
||||
|
||||
if($project->acl == 'open') return true;
|
||||
if(isset($teams[$account])) return true;
|
||||
if(isset($stakeholders[$account])) return true;
|
||||
if(isset($whiteList[$account])) return true;
|
||||
if(isset($whiteList[$account])) return true;
|
||||
if(isset($admins[$account])) return true;
|
||||
|
||||
/* Parent program managers. */
|
||||
if($project->type == 'project' && $project->parent != 0 && $project->acl == 'program')
|
||||
@@ -2486,12 +2520,13 @@ class userModel extends model
|
||||
* @param string $groups
|
||||
* @param array $teams
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkSprintPriv($sprint, $account, $stakeholders, $teams, $whiteList)
|
||||
public function checkSprintPriv($sprint, $account, $stakeholders, $teams, $whiteList, $admins)
|
||||
{
|
||||
return $this->checkProjectPriv($sprint, $account, $stakeholders, $teams, $whiteList);
|
||||
return $this->checkProjectPriv($sprint, $account, $stakeholders, $teams, $whiteList, $admins);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2503,18 +2538,20 @@ class userModel extends model
|
||||
* @param array $linkedProjects
|
||||
* @param array $teams
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkProductPriv($product, $account, $groups, $teams, $stakeholders, $whiteList)
|
||||
public function checkProductPriv($product, $account, $groups, $teams, $stakeholders, $whiteList, $admins)
|
||||
{
|
||||
if(strpos($this->app->company->admins, ',' . $account . ',') !== false) return true;
|
||||
if($product->PO == $account OR $product->QD == $account OR $product->RD == $account OR $product->createdBy == $account OR (isset($product->feedback) && $product->feedback == $account)) return true;
|
||||
if($product->acl == 'open') return true;
|
||||
|
||||
if(isset($teams[$account])) return true;
|
||||
if(isset($teams[$account])) return true;
|
||||
if(isset($stakeholders[$account])) return true;
|
||||
if(isset($whiteList[$account])) return true;
|
||||
if(isset($whiteList[$account])) return true;
|
||||
if(isset($admins[$account])) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2526,10 +2563,11 @@ class userModel extends model
|
||||
* @param array $stakeholders
|
||||
* @param array $teams
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectAuthedUsers($project, $stakeholders, $teams, $whiteList)
|
||||
public function getProjectAuthedUsers($project, $stakeholders, $teams, $whiteList, $admins = array())
|
||||
{
|
||||
$users = array();
|
||||
|
||||
@@ -2544,6 +2582,7 @@ class userModel extends model
|
||||
$users += $stakeholders ? $stakeholders : array();
|
||||
$users += $teams ? $teams : array();
|
||||
$users += $whiteList ? $whiteList : array();
|
||||
$users += $admins ? $admins : array();
|
||||
|
||||
/* Parent program managers. */
|
||||
if($project->type == 'project' && $project->parent != 0 && $project->acl == 'program')
|
||||
@@ -2574,10 +2613,11 @@ class userModel extends model
|
||||
* @param object $program
|
||||
* @param array $stakeholders
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProgramAuthedUsers($program, $stakeholders, $whiteList)
|
||||
public function getProgramAuthedUsers($program, $stakeholders, $whiteList, $admins)
|
||||
{
|
||||
$users = array();
|
||||
|
||||
@@ -2588,6 +2628,7 @@ class userModel extends model
|
||||
|
||||
$users += $stakeholders ? $stakeholders : array();
|
||||
$users += $whiteList ? $whiteList : array();
|
||||
$users += $admins ? $admins : array();
|
||||
|
||||
return $users;
|
||||
}
|
||||
@@ -2599,12 +2640,13 @@ class userModel extends model
|
||||
* @param array $stakeholders
|
||||
* @param array $teams
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSprintAuthedUsers($sprint, $stakeholders, $teams, $whiteList)
|
||||
public function getSprintAuthedUsers($sprint, $stakeholders, $teams, $whiteList, $admins)
|
||||
{
|
||||
return $this->getProjectAuthedUsers($sprint, $stakeholders, $teams, $whiteList);
|
||||
return $this->getProjectAuthedUsers($sprint, $stakeholders, $teams, $whiteList, $admins);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2614,10 +2656,11 @@ class userModel extends model
|
||||
* @param array $linkedProjects
|
||||
* @param array $teams
|
||||
* @param array $whiteList
|
||||
* @param array $admins
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProductViewListUsers($product, $teams, $stakeholders, $whiteList)
|
||||
public function getProductViewListUsers($product, $teams, $stakeholders, $whiteList, $admins)
|
||||
{
|
||||
$users = array();
|
||||
|
||||
@@ -2647,6 +2690,7 @@ class userModel extends model
|
||||
$users += $teams ? $teams : array();
|
||||
$users += $stakeholders ? $stakeholders : array();
|
||||
$users += $whiteList ? $whiteList : array();
|
||||
$users += $admins ? $admins : array();
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user