예제 #1
0
 public static function loadFixtures(TBGScope $scope)
 {
     $roles = array();
     $roles['Developer'] = array(array('permission' => 'page_project_allpages_access'), array('permission' => 'canseeproject'), array('permission' => 'canseeprojecthierarchy'), array('permission' => 'candoscrumplanning'), array('permission' => 'canvoteforissues'), array('permission' => 'canlockandeditlockedissues'), array('permission' => 'cancreateandeditissues'), array('permission' => 'caneditissue'), array('permission' => 'caneditissuecustomfields'), array('permission' => 'canaddextrainformationtoissues'), array('permission' => 'canpostseeandeditallcomments'), array('permission' => 'readarticle', 'module' => 'publish', 'target_id' => '%project_key%'), array('permission' => 'editarticle', 'module' => 'publish', 'target_id' => '%project_key%'), array('permission' => 'deletearticle', 'module' => 'publish', 'target_id' => '%project_key%'));
     $roles['Project manager'] = array(array('permission' => 'page_project_allpages_access'), array('permission' => 'canseeproject'), array('permission' => 'canseeprojecthierarchy'), array('permission' => 'candoscrumplanning'), array('permission' => 'canvoteforissues'), array('permission' => 'canlockandeditlockedissues'), array('permission' => 'cancreateandeditissues'), array('permission' => 'caneditissue'), array('permission' => 'caneditissuecustomfields'), array('permission' => 'canaddextrainformationtoissues'), array('permission' => 'canpostseeandeditallcomments'), array('permission' => 'readarticle', 'module' => 'publish', 'target_id' => '%project_key%'), array('permission' => 'editarticle', 'module' => 'publish', 'target_id' => '%project_key%'), array('permission' => 'deletearticle', 'module' => 'publish', 'target_id' => '%project_key%'));
     $roles['Tester'] = array(array('permission' => 'page_project_allpages_access'), array('permission' => 'canseeproject'), array('permission' => 'canseeprojecthierarchy'), array('permission' => 'canvoteforissues'), array('permission' => 'cancreateandeditissues'), array('permission' => 'caneditissuecustomfields'), array('permission' => 'canaddextrainformationtoissues'), array('permission' => 'canpostandeditcomments'), array('permission' => 'readarticle', 'module' => 'publish', 'target_id' => '%project_key%'), array('permission' => 'editarticle', 'module' => 'publish', 'target_id' => '%project_key%'));
     $roles['Documentation editor'] = array(array('permission' => 'page_project_allpages_access'), array('permission' => 'canseeproject'), array('permission' => 'canseeprojecthierarchy'), array('permission' => 'canvoteforissues'), array('permission' => 'cancreateandeditissues'), array('permission' => 'canaddextrainformationtoissues'), array('permission' => 'canpostandeditcomments'), array('permission' => 'readarticle', 'module' => 'publish', 'target_id' => '%project_key%'), array('permission' => 'editarticle', 'module' => 'publish', 'target_id' => '%project_key%'));
     foreach ($roles as $name => $permissions) {
         $role = new TBGRole();
         $role->setName($name);
         $role->setScope($scope);
         $role->save();
         foreach ($permissions as $k => $permission) {
             $p = new TBGRolePermission();
             $p->setPermission($permission['permission']);
             if (array_key_exists('target_id', $permission)) {
                 $p->setTargetID($permission['target_id']);
             }
             if (array_key_exists('module', $permission)) {
                 $p->setModule($permission['module']);
             }
             $role->addPermission($p);
         }
     }
 }
예제 #2
0
 public static function loadFixtures(TBGScope $scope)
 {
     TBGCategory::loadFixtures($scope);
     TBGPriority::loadFixtures($scope);
     TBGReproducability::loadFixtures($scope);
     TBGResolution::loadFixtures($scope);
     TBGSeverity::loadFixtures($scope);
     TBGStatus::loadFixtures($scope);
     TBGRole::loadFixtures($scope);
     TBGActivityType::loadFixtures($scope);
     foreach (self::getTypes() as $type => $class) {
         TBGContext::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID());
     }
 }
예제 #3
0
 public function runAddRole(TBGRequest $request)
 {
     if ($this->getUser()->canManageProject($this->selected_project)) {
         if ($request['role_name']) {
             $role = new TBGRole();
             $role->setName($request['role_name']);
             $role->setProject($this->selected_project);
             $role->save();
             return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/role', array('role' => $role))));
         }
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('message' => $this->getI18n()->__('You must provide a role name')));
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array('message' => $this->getI18n()->__('You do not have access to create new project roles')));
 }
예제 #4
0
 public function runConfigureRoles(TBGRequest $request)
 {
     if ($request->isPost()) {
         if (trim($request['role_name']) == '') {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('error' => $this->getI18n()->__('You have to specify a name for this role')));
         }
         $role = new TBGRole();
         $role->setName($request['role_name']);
         $role->save();
         return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/role', array('role' => $role))));
     }
     $this->roles = TBGRole::getAll();
 }
예제 #5
0
 public function componentProjectPermissions()
 {
     $this->roles = TBGRole::getAll();
     $this->project_roles = TBGRole::getByProjectID($this->project->getID());
 }
예제 #6
0
 protected function _upgradeFrom3dot1()
 {
     // Add classpath for existing old tables used for upgrade
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.1');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'classes' . DS . 'B2DB');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'mailing' . DS . 'classes');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes' . DS . 'B2DB');
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes');
     // Create new tables
     TBGDashboardViewsTable::getTable()->create();
     TBGOpenIdAccountsTable::getTable()->create();
     TBGProjectAssignedUsersTable::getTable()->create();
     TBGProjectAssignedTeamsTable::getTable()->create();
     TBGEditionAssignedUsersTable::getTable()->create();
     TBGEditionAssignedTeamsTable::getTable()->create();
     TBGComponentAssignedUsersTable::getTable()->create();
     TBGComponentAssignedTeamsTable::getTable()->create();
     TBGRolePermissionsTable::getTable()->create();
     TBGUserScopesTable::getTable()->create();
     // Upgrade existing tables
     TBGProjectsTable::getTable()->upgrade(TBGProjectsTable3dot1::getTable());
     TBGUsersTable::getTable()->upgrade(TBGUsersTable3dot1::getTable());
     TBGIssuesTable::getTable()->upgrade(TBGIssuesTable3dot1::getTable());
     TBGIssueTypesTable::getTable()->upgrade(TBGIssueTypesTable3dot1::getTable());
     TBGListTypesTable::getTable()->upgrade(TBGListTypesTable3dot1::getTable());
     TBGEditionsTable::getTable()->upgrade(TBGEditionsTable3dot1::getTable());
     TBGBuildsTable::getTable()->upgrade(TBGBuildsTable3dot1::getTable());
     TBGCommentsTable::getTable()->upgrade(TBGCommentsTable3dot1::getTable());
     TBGComponentsTable::getTable()->upgrade(TBGComponentsTable3dot1::getTable());
     TBGCustomFieldsTable::getTable()->upgrade(TBGCustomFieldsTable3dot1::getTable());
     TBGCustomFieldOptionsTable::getTable()->upgrade(TBGCustomFieldOptionsTable3dot1::getTable());
     TBGIssueCustomFieldsTable::getTable()->upgrade(TBGIssueCustomFieldsTable3dot1::getTable());
     // Create new module tables
     TBGIncomingEmailAccountTable::getTable()->create();
     // Add new indexes
     TBGArticlesTable::getTable()->createIndexes();
     TBGCommentsTable::getTable()->createIndexes();
     TBGIssueAffectsBuildTable::getTable()->createIndexes();
     TBGIssueAffectsComponentTable::getTable()->createIndexes();
     TBGIssueAffectsEditionTable::getTable()->createIndexes();
     TBGIssueFieldsTable::getTable()->createIndexes();
     TBGIssueFilesTable::getTable()->createIndexes();
     TBGIssuesTable::getTable()->createIndexes();
     TBGIssuetypeSchemesTable::getTable()->createIndexes();
     TBGPermissionsTable::getTable()->createIndexes();
     TBGProjectsTable::getTable()->createIndexes();
     TBGSettingsTable::getTable()->createIndexes();
     TBGTeamMembersTable::getTable()->createIndexes();
     TBGUserIssuesTable::getTable()->createIndexes();
     TBGUsersTable::getTable()->createIndexes();
     TBGUserScopesTable::getTable()->createIndexes();
     if (TBGContext::getRequest()->getParameter('fix_my_timestamps', false)) {
         $this->_fixTimestamps();
     }
     foreach (TBGScope::getAll() as $scope) {
         TBGRole::loadFixtures($scope);
         foreach (TBGDatatype::getTypes() as $type => $class) {
             TBGContext::setPermission('set_datatype_' . $type, 0, 'core', 0, 0, 0, true, $scope->getID());
         }
         TBGContext::setPermission('page_confirm_scope_access', 0, 'core', 0, 0, 0, true, $scope->getID());
         if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_WORKFLOW, 'core', $scope->getID())) {
             $workflow_id = TBGWorkflowsTable::getTable()->getFirstIdByScope($scope->getID());
             if ($workflow_id) {
                 TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOW, $workflow_id, 'core', $scope->getID());
             } else {
                 TBGWorkflow::loadFixtures($scope);
             }
         }
         if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_WORKFLOWSCHEME, 'core', $scope->getID())) {
             $workflow_scheme_id = TBGWorkflowSchemesTable::getTable()->getFirstIdByScope($scope->getID());
             if ($workflow_scheme_id) {
                 TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_WORKFLOWSCHEME, $workflow_scheme_id, 'core', $scope->getID());
             } else {
                 TBGWorkflowScheme::loadFixtures($scope);
             }
         }
         if (!TBGSettings::get(TBGSettings::SETTING_DEFAULT_ISSUETYPESCHEME, 'core', $scope->getID())) {
             $issuetype_scheme_id = TBGIssuetypeSchemesTable::getTable()->getFirstIdByScope($scope->getID());
             if ($issuetype_scheme_id) {
                 TBGSettings::saveSetting(TBGSettings::SETTING_DEFAULT_ISSUETYPESCHEME, $issuetype_scheme_id, 'core', $scope->getID());
             } else {
                 TBGIssuetypeScheme::loadFixtures($scope);
             }
         }
         TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_ID, 0, 'core', $scope->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_FAVICON_TYPE, 0, 'core', $scope->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_ID, 0, 'core', $scope->getID());
         TBGSettings::saveSetting(TBGSettings::SETTING_HEADER_ICON_TYPE, 0, 'core', $scope->getID());
     }
     $linkstable = TBGLinksTable::getTable();
     $crit = $linkstable->getCriteria();
     $crit->addUpdate(TBGLinksTable::URL, 'http://issues.thebuggenie.com');
     $crit->addWhere(TBGLinksTable::URL, 'http://thebuggenie.com/thebuggenie');
     $crit->addOr(TBGLinksTable::URL, 'http://www.thebuggenie.com/thebuggenie');
     $linkstable->doUpdate($crit);
     $listtypestable = TBGListTypesTable::getTable();
     $crit = $listtypestable->getCriteria();
     $crit->addUpdate(TBGListTypesTable::ITEMTYPE, 'role');
     $crit->addWhere(TBGListTypesTable::ITEMTYPE, 'projectrole');
     $listtypestable->doUpdate($crit);
     $crit = $listtypestable->getCriteria();
     $crit->addUpdate(TBGListTypesTable::ITEMTYPE, 'priority');
     $crit->addWhere(TBGListTypesTable::ITEMTYPE, 'b2_prioritytypes');
     $listtypestable->doUpdate($crit);
     TBGWorkflowTransitionsTable::getTable()->upgradeFrom3dot1();
     TBGSettings::saveSetting(TBGSettings::SETTING_ICONSET, TBGSettings::get(TBGSettings::SETTING_THEME_NAME));
     TBGContext::setPermission('readarticle', 0, 'publish', 0, 0, 0, true);
     foreach (TBGProject::getAll() as $project) {
         TBGDashboardViewsTable::getTable()->setDefaultViews($project->getID(), TBGDashboardViewsTable::TYPE_PROJECT);
         if (!$project->getKey()) {
             $project->setName($project->getName());
         }
     }
     $this->upgrade_complete = true;
 }