protected function _postSave($is_new) { if ($is_new) { framework\Context::setPermission("canseecomponent", $this->getID(), "core", 0, framework\Context::getUser()->getGroup()->getID(), 0, true); \thebuggenie\core\framework\Event::createNew('core', 'Component::createNew', $this)->trigger(); } }
public static function loadFixtures(\thebuggenie\core\entities\Scope $scope) { Category::loadFixtures($scope); Priority::loadFixtures($scope); Reproducability::loadFixtures($scope); Resolution::loadFixtures($scope); Severity::loadFixtures($scope); Status::loadFixtures($scope); Role::loadFixtures($scope); ActivityType::loadFixtures($scope); foreach (self::getTypes() as $type => $class) { framework\Context::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID()); } }
/** * Adds an assignee with a given role * * @param \thebuggenie\core\entities\common\Identifiable $assignee The user or team to add * @param Role $role The role to add * * @return null */ public function addAssignee($assignee, $role = null) { $user_id = 0; $team_id = 0; if ($assignee instanceof \thebuggenie\core\entities\User) { $user_id = $assignee->getID(); if (tables\ProjectAssignedUsers::getTable()->addUserToProject($this->getID(), $user_id, $role->getID()) && is_array($this->_assigned_users)) { $this->_assigned_users = array_merge($this->_assigned_users, tables\ProjectAssignedUsers::getTable()->getUserByProjectIDUserIDRoleID($this->getID(), $user_id, $role->getID())); } } elseif ($assignee instanceof \thebuggenie\core\entities\Team) { $team_id = $assignee->getID(); if (tables\ProjectAssignedTeams::getTable()->addTeamToProject($this->getID(), $team_id, $role->getID()) && is_array($this->_assigned_users)) { $this->_assigned_teams = array_merge($this->_assigned_teams, tables\ProjectAssignedTeams::getTable()->getTeamByProjectIDTeamIDRoleID($this->getID(), $team_id, $role->getID())); } } if ($role instanceof \thebuggenie\core\entities\Role) { $role_id = $role->getID(); foreach ($role->getPermissions() as $role_permission) { $target_id = strtolower($role_permission->getExpandedTargetID($role)); tables\Permissions::getTable()->removeSavedPermission($user_id, 0, $team_id, $role_permission->getModule(), $role_permission->getPermission(), $target_id, framework\Context::getScope()->getID(), $role_id); framework\Context::setPermission($role_permission->getPermission(), $target_id, $role_permission->getModule(), $user_id, 0, $team_id, true, null, $role_id); } } }
protected function _loadFixtures($scope) { $this->loadFixturesArticles($scope); Links::getTable()->addLink('wiki', 0, 'MainPage', 'Wiki Frontpage', 1, $scope); Links::getTable()->addLink('wiki', 0, 'WikiFormatting', 'Formatting help', 2, $scope); Links::getTable()->addLink('wiki', 0, 'Category:Help', 'Help topics', 3, $scope); framework\Context::setPermission(self::PERMISSION_READ_ARTICLE, 0, 'publish', 0, 1, 0, true, $scope); framework\Context::setPermission(self::PERMISSION_EDIT_ARTICLE, 0, 'publish', 0, 1, 0, true, $scope); framework\Context::setPermission(self::PERMISSION_DELETE_ARTICLE, 0, 'publish', 0, 1, 0, true, $scope); }
public function runSetPermission(framework\Request $request) { $i18n = framework\Context::getI18n(); if ($this->access_level == framework\Settings::ACCESS_FULL) { $uid = 0; $gid = 0; $tid = 0; switch ($request['target_type']) { case 'user': $uid = $request['item_id']; break; case 'group': $gid = $request['item_id']; break; case 'team': $tid = $request['item_id']; break; } $target_id = $request->getRawParameter('target_id'); switch ($request['mode']) { case 'allowed': framework\Context::setPermission($request['key'], $target_id, $request['target_module'], $uid, $gid, $tid, true); break; case 'denied': framework\Context::setPermission($request['key'], $target_id, $request['target_module'], $uid, $gid, $tid, false); break; case 'unset': framework\Context::removePermission($request['key'], $target_id, $request['target_module'], $uid, $gid, $tid, true, null, 0); break; } return $this->renderJSON(array('content' => $this->getComponentHTML('configuration/permissionsinfoitem', array('key' => $request['key'], 'target_id' => $target_id, 'type' => $request['target_type'], 'mode' => $request['template_mode'], 'item_id' => $request['item_id'], 'module' => $request['target_module'], 'access_level' => $this->access_level)))); } $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array("error" => $i18n->__("You don't have access to modify permissions"))); }
/** * @param framework\Request $request * @param $issue */ protected function _unlockIssueAfter(framework\Request $request, $issue) { tables\Permissions::getTable()->deleteByPermissionTargetIDAndModule('canviewissue', $issue->getID()); $al_users = $request->getParameter('access_list_users', array()); $al_teams = $request->getParameter('access_list_teams', array()); $i_al = $issue->getAccessList(); foreach ($i_al as $k => $item) { if ($item['target'] instanceof entities\Team) { $tid = $item['target']->getID(); if (array_key_exists($tid, $al_teams)) { unset($i_al[$k]); } } elseif ($item['target'] instanceof entities\User) { $uid = $item['target']->getID(); if (array_key_exists($uid, $al_users)) { unset($i_al[$k]); } } } foreach ($al_users as $uid) { framework\Context::setPermission('canviewissue', $issue->getID(), 'core', $uid, 0, 0, true); } foreach ($al_teams as $tid) { framework\Context::setPermission('canviewissue', $issue->getID(), 'core', 0, 0, $tid, true); } }
/** * Unlock the issue * * @param \thebuggenie\core\framework\Request $request */ public function runLockIssue(framework\Request $request) { if ($issue_id = $request['issue_id']) { try { $issue = entities\Issue::getB2DBTable()->selectById($issue_id); if (!$issue->canEditIssueDetails()) { $this->forward403($this->getI18n()->__("You don't have access to update the issue access policy")); return; } $issue->setLocked(); $issue->save(); framework\Context::setPermission('canviewissue', $issue->getID(), 'core', 0, 0, 0, false); framework\Context::setPermission('canviewissue', $issue->getID(), 'core', $this->getUser()->getID(), 0, 0, true); $al_users = $request->getParameter('access_list_users', array()); $al_teams = $request->getParameter('access_list_teams', array()); $i_al = $issue->getAccessList(); foreach ($i_al as $k => $item) { if ($item['target'] instanceof entities\Team) { $tid = $item['target']->getID(); if (array_key_exists($tid, $al_teams)) { unset($i_al[$k]); } else { framework\Context::removePermission('canviewissue', $issue->getID(), 'core', 0, 0, $tid); } } elseif ($item['target'] instanceof entities\User) { $uid = $item['target']->getID(); if (array_key_exists($uid, $al_users)) { unset($i_al[$k]); } elseif ($uid != $this->getUser()->getID()) { framework\Context::removePermission('canviewissue', $issue->getID(), 'core', $uid, 0, 0); } } } foreach ($al_users as $uid) { framework\Context::setPermission('canviewissue', $issue->getID(), 'core', $uid, 0, 0, true); } foreach ($al_teams as $tid) { framework\Context::setPermission('canviewissue', $issue->getID(), 'core', 0, 0, $tid, true); } } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('message' => framework\Context::getI18n()->__('This issue does not exist'))); } } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('message' => framework\Context::getI18n()->__('This issue does not exist'))); } return $this->renderJSON(array('message' => $this->getI18n()->__('Issue access policy updated'))); }
/** * Adds an assignee with a given role * * @param \thebuggenie\core\entities\common\Identifiable $assignee The user or team to add * @param Role $role The role to add * * @return null */ public function addAssignee($assignee, $role = null) { $user_id = 0; $team_id = 0; if ($assignee instanceof \thebuggenie\core\entities\User) { $user_id = $assignee->getID(); tables\ProjectAssignedUsers::getTable()->addUserToProject($this->getID(), $user_id, $role->getID()); } elseif ($assignee instanceof \thebuggenie\core\entities\Team) { $team_id = $assignee->getID(); tables\ProjectAssignedTeams::getTable()->addTeamToProject($this->getID(), $team_id, $role->getID()); } if ($role instanceof \thebuggenie\core\entities\Role) { foreach ($role->getPermissions() as $role_permission) { $target_id = $role_permission->hasTargetID() ? $role_permission->getReplacedTargetID($this) : $this->getID(); framework\Context::setPermission($role_permission->getPermission(), $target_id, $role_permission->getModule(), $user_id, 0, $team_id, true, null, $role->getID()); } } }