protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, Projects::getTable());
     parent::_addForeignKeyColumn(self::ROLE_ID, ListTypes::getTable());
     parent::_addForeignKeyColumn(self::TEAM_ID, Teams::getTable());
 }
示例#2
0
 public function do_execute()
 {
     /* Prepare variables */
     try {
         $project_id = $this->getProvidedArgument('projectid');
         $project_row = \thebuggenie\core\entities\tables\Projects::getTable()->getById($project_id, false);
         \thebuggenie\core\framework\Context::setScope(new \thebuggenie\core\entities\Scope($project_row[\thebuggenie\core\entities\tables\Projects::SCOPE]));
         $project = new \thebuggenie\core\entities\Project($project_id, $project_row);
     } catch (\Exception $e) {
         $this->cliEcho("The project with the ID " . $this->getProvidedArgument('projectid') . " does not exist\n", 'red', 'bold');
         exit;
     }
     $author = $this->getProvidedArgument('author');
     $new_rev = $this->getProvidedArgument('revno');
     $commit_msg = $this->getProvidedArgument('log');
     $changed = $this->getProvidedArgument('changed');
     $old_rev = $this->getProvidedArgument('oldrev', null);
     $date = $this->getProvidedArgument('date', null);
     $branch = $this->getProvidedArgument('branch', null);
     if (\thebuggenie\core\framework\Settings::get('access_method_' . $project->getKey()) == Vcs_integration::ACCESS_HTTP) {
         $this->cliEcho("This project uses the HTTP access method, and so access via the CLI has been disabled\n", 'red', 'bold');
         exit;
     }
     if ($old_rev === null && !ctype_digit($new_rev)) {
         $this->cliEcho("Error: if only the new revision is specified, it must be a number so that old revision can be calculated from it (by substracting 1 from new revision number).");
     } else {
         if ($old_rev === null) {
             $old_rev = $new_rev - 1;
         }
     }
     $output = Vcs_integration::processCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author, $branch);
     $this->cliEcho($output);
 }
示例#3
0
 public function selectAll()
 {
     $crit = $this->getCriteria();
     $crit->addJoin(Projects::getTable(), Projects::ID, self::PROJECT);
     $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID());
     $crit->addOrderBy(Projects::NAME, Criteria::SORT_ASC);
     $crit->addOrderBy(self::NAME, Criteria::SORT_ASC);
     return $this->select($crit);
 }
示例#4
0
 /**
  * Pre-execute function
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function preExecute(framework\Request $request, $action)
 {
     $this->article = null;
     $this->article_name = $request->getRawParameter('article_name');
     $this->article_id = (int) $request['article_id'];
     $this->special = false;
     if (!is_null($this->article_name) && mb_strpos($this->article_name, ':') !== false) {
         $this->article_name = $this->_getArticleNameDetails($this->article_name);
     } else {
         try {
             if ($project_key = $request['project_key']) {
                 $this->selected_project = \thebuggenie\core\entities\Project::getByKey($project_key);
             } elseif ($project_id = (int) $request['project_id']) {
                 $this->selected_project = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($project_id);
             }
         } catch (\Exception $e) {
         }
     }
     if (!$this->special) {
         if ($this->article_id) {
             $this->article = Articles::getTable()->selectById($this->article_id);
         } elseif ($this->article_name) {
             $this->article = Articles::getTable()->getArticleByName($this->article_name);
         }
         if (!$this->article instanceof Article) {
             $this->article = new Article();
             if ($this->article_name) {
                 $this->article->setName($this->article_name);
             } elseif ($request->hasParameter('parent_article_name')) {
                 $parent_article_name = $request->getRawParameter('parent_article_name');
                 $this->article->setParentArticle(Articles::getTable()->getArticleByName($parent_article_name));
                 $this->_getArticleNameDetails($parent_article_name);
                 if ($this->article->getParentArticle() instanceof Article) {
                     if ($this->article->getParentArticle()->getArticleType() == Article::TYPE_WIKI) {
                         $this->article->setName($this->article->getParentArticle()->getName() . ':');
                     }
                     $this->article->setArticleType($this->article->getParentArticle()->getArticleType());
                 }
             }
             $this->article->setContentSyntax($this->getUser()->getPreferredWikiSyntax(true));
         }
     }
     if ($this->selected_project instanceof \thebuggenie\core\entities\Project) {
         if (!$this->selected_project->hasAccess()) {
             $this->forward403();
         } else {
             framework\Context::setCurrentProject($this->selected_project);
         }
     }
 }
示例#5
0
 /**
  * Performs quicksearch
  *
  * @param framework\Request $request The request object
  */
 public function runQuickSearch(framework\Request $request)
 {
     if ($this->getUser()->canAccessConfigurationPage(framework\Settings::CONFIGURATION_SECTION_USERS)) {
         $this->found_users = tables\Users::getTable()->findInConfig($this->searchterm, 10, false);
         $this->found_teams = tables\Teams::getTable()->quickfind($this->searchterm);
         $this->found_clients = tables\Clients::getTable()->quickfind($this->searchterm);
         $this->num_users = count($this->found_users);
         $this->num_teams = count($this->found_teams);
         $this->num_clients = count($this->found_clients);
     }
     $found_projects = tables\Projects::getTable()->quickfind($this->searchterm);
     $projects = array();
     foreach ($found_projects as $project) {
         if ($project->hasAccess()) {
             $projects[$project->getID()] = $project;
         }
     }
     $this->found_projects = $projects;
     $this->num_projects = count($projects);
 }
示例#6
0
 protected function _getAllInNamespace($namespace, \thebuggenie\core\entities\Project $project = null)
 {
     $crit = $this->getCriteria();
     if ($project instanceof \thebuggenie\core\entities\Project) {
         $crit->addWhere(self::NAME, "{$namespace}:" . ucfirst($project->getKey()) . ":%", Criteria::DB_LIKE);
     } else {
         $crit->addWhere(self::NAME, "{$namespace}:%", Criteria::DB_LIKE);
         foreach (\thebuggenie\core\entities\tables\Projects::getTable()->getAllIncludingDeleted() as $project) {
             if (trim($project->getKey()) == '') {
                 continue;
             }
             $crit->addWhere(self::NAME, "{$namespace}:" . ucfirst($project->getKey()) . "%", Criteria::DB_NOT_LIKE);
             $crit->addWhere(self::NAME, ucfirst($project->getKey()) . ":%", Criteria::DB_NOT_LIKE);
         }
     }
     $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID());
     return $this->select($crit);
 }
示例#7
0
 /**
  * Get all the projects a user is associated with
  *
  * @return array|Project
  */
 public function getAssociatedProjects()
 {
     if ($this->_associated_projects === null) {
         $this->_associated_projects = array();
         $projects = tables\ProjectAssignedUsers::getTable()->getProjectsByUserID($this->getID());
         $lo_projects = tables\Projects::getTable()->getByUserID($this->getID());
         $project_ids = array_merge(array_keys($projects), array_keys($lo_projects));
         foreach ($this->getTeams() as $team) {
             $project_ids = array_merge($project_ids, array_keys($team->getAssociatedProjects()));
         }
         $project_ids = array_unique($project_ids);
         foreach ($project_ids as $project_id) {
             try {
                 $this->_associated_projects[$project_id] = tables\Projects::getTable()->selectById($project_id);
             } catch (\Exception $e) {
             }
         }
     }
     return $this->_associated_projects;
 }
示例#8
0
 protected function _upgradeFrom4dot1dot6(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_416\Project::getB2DBTable());
     $this->upgrade_complete = true;
     $this->current_version = '4.1.7';
 }
示例#9
0
 public function getByPrefixAndIssueNo($prefix, $issue_no)
 {
     $crit = $this->getCriteria();
     $crit->addWhere(self::DELETED, false);
     $crit->addJoin(Projects::getTable(), Projects::ID, self::PROJECT_ID);
     $crit->addWhere(Projects::PREFIX, mb_strtolower($prefix), Criteria::DB_EQUALS, '', '', Criteria::DB_LOWER);
     $crit->addWhere(Projects::DELETED, false);
     $crit->addWhere(self::ISSUE_NO, $issue_no);
     return $this->selectOne($crit, false);
 }
示例#10
0
 protected function moveProject($project_id, $to_scope_id)
 {
     $this->cliEcho("--------------\n");
     $this->cliEcho("Moving project\n");
     $this->cliEcho("--------------\n");
     $this->moveIssues($project_id, $to_scope_id);
     $this->cliEcho("Moving components, editions and releases...");
     $tables = ['\\thebuggenie\\core\\entities\\tables\\Components' => 'components', '\\thebuggenie\\core\\entities\\tables\\Editions' => 'editions', '\\thebuggenie\\core\\entities\\tables\\Builds' => 'builds'];
     foreach ($tables as $class_name => $table_name) {
         $crit = $class_name::getTable()->getCriteria();
         $crit->addUpdate($table_name . '.scope', $to_scope_id);
         $crit->addWhere($table_name . '.project', $project_id);
         $class_name::getTable()->doUpdate($crit);
     }
     $edition_criteria = Editions::getTable()->getCriteria();
     $edition_criteria->addWhere('editions.project', $project_id);
     $edition_criteria->addSelectionColumn('editions.id', 'id');
     if ($res = Editions::getTable()->doSelect($edition_criteria)) {
         while ($row = $res->getNextRow()) {
             $edition_id = $row['id'];
             $edition_criteria = EditionComponents::getTable()->getCriteria();
             $edition_criteria->addWhere('editioncomponents.edition', $edition_id);
             $edition_criteria->addUpdate('editioncomponents.scope', $to_scope_id);
             EditionComponents::getTable()->doUpdate($edition_criteria);
         }
     }
     $this->cliEcho(" done\n");
     $this->cliEcho("Moving project dashboard...");
     $dashboard_criteria = Dashboards::getTable()->getCriteria();
     $dashboard_criteria->addWhere('dashboards.project_id', $project_id);
     $dashboard_criteria->addSelectionColumn('dashboards.id', 'id');
     $dashboard_ids = [];
     if ($res = Dashboards::getTable()->doSelect($dashboard_criteria)) {
         while ($row = $res->getNextRow()) {
             $dashboard_ids[] = $row['id'];
         }
         $dashboardviews_criteria = DashboardViews::getTable()->getCriteria();
         $dashboardviews_criteria->addWhere('dashboard_views.dashboard_id', $dashboard_ids, Criteria::DB_IN);
         $dashboardviews_criteria->addUpdate('dashboards.scope', $to_scope_id);
         DashboardViews::getTable()->doUpdate($dashboardviews_criteria);
         $dashboard_criteria = Dashboards::getTable()->getCriteria();
         $dashboard_criteria->addWhere('dashboards.project_id', $project_id);
         $dashboard_criteria->addUpdate('dashboards.scope', $to_scope_id);
         Dashboards::getTable()->doUpdate($dashboard_criteria);
     }
     $this->cliEcho(" done\n");
     $this->moveDatatypes($project_id, $to_scope_id);
     $crit = Projects::getTable()->getCriteria();
     $crit->addUpdate('projects.scope', $to_scope_id);
     Projects::getTable()->doUpdateById($crit, $project_id);
     $this->cliEcho("-------------------\n");
     $this->cliEcho("Done moving project\n");
     $this->cliEcho("-------------------\n");
 }
示例#11
0
 public function isInUse()
 {
     if ($this->_number_of_projects === null) {
         $this->_number_of_projects = tables\Projects::getTable()->countByIssuetypeSchemeID($this->getID());
     }
     return (bool) $this->_number_of_projects;
 }
示例#12
0
 /**
  * Partial backdrop loader
  *
  * @Route(name="get_partial_for_backdrop", url="/get/partials/:key/*")
  * @AnonymousRoute
  *
  * @param framework\Request $request
  *
  * @return bool
  */
 public function runGetBackdropPartial(framework\Request $request)
 {
     if (!$request->isAjaxCall()) {
         return $this->return404($this->getI18n()->__('You need to enable javascript for The Bug Genie to work properly'));
     }
     try {
         $template_name = null;
         if ($request->hasParameter('issue_id')) {
             $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
             $options = array('issue' => $issue);
         } else {
             $options = array();
         }
         switch ($request['key']) {
             case 'usercard':
                 $template_name = 'main/usercard';
                 if ($user_id = $request['user_id']) {
                     $user = entities\User::getB2DBTable()->selectById($user_id);
                     $options['user'] = $user;
                 }
                 break;
             case 'login':
                 $template_name = 'main/loginpopup';
                 $options = $request->getParameters();
                 $options['content'] = $this->getComponentHTML('login', array('section' => $request->getParameter('section', 'login')));
                 $options['mandatory'] = false;
                 break;
             case 'uploader':
                 $template_name = 'main/uploader';
                 $options = $request->getParameters();
                 $options['uploader'] = $request['uploader'] == 'dynamic' ? 'dynamic' : 'standard';
                 break;
             case 'attachlink':
                 $template_name = 'main/attachlink';
                 break;
             case 'openid':
                 $template_name = 'main/openid';
                 break;
             case 'notifications':
                 $template_name = 'main/notifications';
                 $options['first_notification_id'] = $request['first_notification_id'];
                 $options['last_notification_id'] = $request['last_notification_id'];
                 break;
             case 'workflow_transition':
                 $transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']);
                 $template_name = $transition->getTemplate();
                 $options['transition'] = $transition;
                 if ($request->hasParameter('issue_ids')) {
                     $options['issues'] = array();
                     foreach ($request['issue_ids'] as $issue_id) {
                         $options['issues'][$issue_id] = new entities\Issue($issue_id);
                     }
                 } else {
                     $options['issue'] = new entities\Issue($request['issue_id']);
                 }
                 $options['show'] = true;
                 $options['interactive'] = true;
                 $options['project'] = $this->selected_project;
                 break;
             case 'reportissue':
                 $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
                 if ($this->selected_project instanceof entities\Project && !$this->selected_project->isLocked() && $this->getUser()->canReportIssues($this->selected_project)) {
                     $template_name = 'main/reportissuecontainer';
                     $options['selected_project'] = $this->selected_project;
                     $options['selected_issuetype'] = $this->selected_issuetype;
                     $options['locked_issuetype'] = $this->locked_issuetype;
                     $options['selected_milestone'] = $this->_getMilestoneFromRequest($request);
                     $options['parent_issue'] = $this->_getParentIssueFromRequest($request);
                     $options['board'] = $this->_getBoardFromRequest($request);
                     $options['selected_build'] = $this->_getBuildFromRequest($request);
                     $options['issuetypes'] = $this->issuetypes;
                     $options['errors'] = array();
                 } else {
                     throw new \Exception($this->getI18n()->__('You are not allowed to do this'));
                 }
                 break;
             case 'move_issue':
                 $template_name = 'main/moveissue';
                 $options['multi'] = (bool) $request->getParameter('multi', false);
                 break;
             case 'issue_permissions':
                 $template_name = 'main/issuepermissions';
                 break;
             case 'issue_subscribers':
                 $template_name = 'main/issuesubscribers';
                 break;
             case 'issue_spenttimes':
                 $template_name = 'main/issuespenttimes';
                 $options['initial_view'] = $request->getParameter('initial_view', 'list');
                 break;
             case 'issue_spenttime':
                 $template_name = 'main/issuespenttime';
                 $options['entry_id'] = $request->getParameter('entry_id');
                 break;
             case 'relate_issue':
                 $template_name = 'main/relateissue';
                 break;
             case 'project_build':
                 $template_name = 'project/build';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 if ($request->hasParameter('build_id')) {
                     $options['build'] = entities\Build::getB2DBTable()->selectById($request['build_id']);
                 }
                 break;
             case 'project_icons':
                 $template_name = 'project/projecticons';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'project_workflow':
                 $template_name = 'project/projectworkflow';
                 $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 break;
             case 'permissions':
                 $options['key'] = $request['permission_key'];
                 $target_module = $request['target_module'] !== 'core' ? $request['target_module'] : null;
                 if ($details = framework\Context::getPermissionDetails($options['key'], null, $target_module)) {
                     $template_name = 'configuration/permissionspopup';
                     $options['mode'] = $request['mode'];
                     $options['module'] = $request['target_module'];
                     $options['target_id'] = $request['target_id'];
                     $options['item_name'] = $details['description'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'issuefield_permissions':
                 $options['item_key'] = $request['item_key'];
                 if ($details = framework\Context::getPermissionDetails($options['item_key'])) {
                     $template_name = 'configuration/issuefieldpermissions';
                     $options['item_name'] = $details['description'];
                     $options['item_id'] = $request['item_id'];
                     $options['access_level'] = $request['access_level'];
                 }
                 break;
             case 'site_icons':
                 $template_name = 'configuration/siteicons';
                 break;
             case 'project_config':
                 $template_name = 'project/projectconfig_container';
                 $project = entities\Project::getB2DBTable()->selectById($request['project_id']);
                 $options['project'] = $project;
                 $options['section'] = $request->getParameter('section', 'info');
                 if ($request->hasParameter('edition_id')) {
                     $edition = entities\Edition::getB2DBTable()->selectById($request['edition_id']);
                     $options['edition'] = $edition;
                     $options['selected_section'] = $request->getParameter('section', 'general');
                 }
                 break;
             case 'issue_add_item':
                 $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
                 $template_name = 'main/issueadditem';
                 break;
             case 'client_users':
                 $options['client'] = entities\Client::getB2DBTable()->selectById($request['client_id']);
                 $template_name = 'main/clientusers';
                 break;
             case 'dashboard_config':
                 $template_name = 'main/dashboardconfig';
                 $options['tid'] = $request['tid'];
                 $options['target_type'] = $request['target_type'];
                 $options['previous_route'] = $request['previous_route'];
                 $options['mandatory'] = true;
                 break;
             case 'archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['mandatory'] = true;
                 break;
             case 'team_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'team';
                 $options['id'] = $request['tid'];
                 $options['mandatory'] = true;
                 break;
             case 'client_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'client';
                 $options['id'] = $request['cid'];
                 $options['mandatory'] = true;
                 break;
             case 'project_archived_projects':
                 $template_name = 'main/archivedprojects';
                 $options['target'] = 'project';
                 $options['id'] = $request['pid'];
                 $options['mandatory'] = true;
                 break;
             case 'bulk_workflow':
                 $template_name = 'search/bulkworkflow';
                 $options['issue_ids'] = $request['issue_ids'];
                 break;
             case 'confirm_username':
                 $template_name = 'main/confirmusername';
                 $options['username'] = $request['username'];
                 break;
             case 'add_dashboard_view':
                 $template_name = 'main/adddashboardview';
                 break;
             case 'userscopes':
                 if (!framework\Context::getScope()->isDefault()) {
                     throw new \Exception($this->getI18n()->__('This is not allowed outside the default scope'));
                 }
                 $template_name = 'configuration/userscopes';
                 $options['user'] = new entities\User((int) $request['user_id']);
                 break;
             case 'milestone':
                 $template_name = 'project/milestone';
                 $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
                 if ($request->hasParameter('milestone_id')) {
                     $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
                 }
                 break;
             default:
                 $event = new \thebuggenie\core\framework\Event('core', 'get_backdrop_partial', $request['key']);
                 $event->triggerUntilProcessed();
                 $options = $event->getReturnList();
                 $template_name = $event->getReturnValue();
         }
         if ($template_name !== null) {
             return $this->renderJSON(array('content' => $this->getComponentHTML($template_name, $options)));
         }
     } catch (\Exception $e) {
         $this->getResponse()->cleanBuffer();
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => framework\Context::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage()))));
     }
     $this->getResponse()->cleanBuffer();
     $this->getResponse()->setHttpStatus(400);
     $error = framework\Context::isDebugMode() ? framework\Context::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup');
     return $this->renderJSON(array('error' => $error));
 }
示例#13
0
 /**
  * @Listener(module='core', identifier='get_backdrop_partial')
  * @param \thebuggenie\core\framework\Event $event
  */
 public function listen_get_backdrop_partial(framework\Event $event)
 {
     $request = framework\Context::getRequest();
     $options = array();
     switch ($event->getSubject()) {
         case 'agileboard':
             $template_name = 'agile/editagileboard';
             $board = $request['board_id'] ? entities\tables\AgileBoards::getTable()->selectById($request['board_id']) : new entities\AgileBoard();
             if (!$board->getID()) {
                 $board->setAutogeneratedSearch(\thebuggenie\core\entities\SavedSearch::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES);
                 $board->setTaskIssuetype(framework\Settings::get('issuetype_task'));
                 $board->setEpicIssuetype(framework\Settings::get('issuetype_epic'));
                 $board->setIsPrivate($request->getParameter('is_private', true));
                 $board->setProject($request['project_id']);
             }
             $options['board'] = $board;
             break;
         case 'milestone_finish':
             $template_name = 'agile/milestonefinish';
             $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
             $options['board'] = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
             $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
             if (!$options['milestone']->hasReachedDate()) {
                 $options['milestone']->setReachedDate(time());
             }
             break;
         case 'agilemilestone':
             $template_name = 'agile/milestone';
             $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']);
             $options['board'] = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
             if ($request->hasParameter('milestone_id')) {
                 $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']);
             }
             break;
         default:
             return;
     }
     foreach ($options as $key => $value) {
         $event->addToReturnList($value, $key);
     }
     $event->setReturnValue($template_name);
     $event->setProcessed();
 }
示例#14
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::MILESTONE_ID, Milestones::getTable(), Milestones::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, Projects::getTable(), Projects::ID);
 }
示例#15
0
 public function getUnattachedFiles()
 {
     $crit = $this->getCriteria();
     $crit->addSelectionColumn(self::ID, 'id');
     $res = $this->doSelect($crit);
     $file_ids = [];
     if ($res) {
         while ($row = $res->getNextRow()) {
             $file_ids[$row['id']] = $row['id'];
         }
     }
     $file_ids = array_diff($file_ids, IssueFiles::getTable()->getLinkedFileIds($file_ids));
     $event = framework\Event::createNew('core', 'thebuggenie\\core\\entities\\tables\\Files::getUnattachedFiles', $this, ['file_ids' => $file_ids], []);
     $event->trigger();
     if ($event->isProcessed()) {
         foreach ($event->getReturnList() as $linked_file_ids) {
             $file_ids = array_diff($file_ids, $linked_file_ids);
         }
     }
     $system_file_ids = Settings::getTable()->getFileIds();
     $file_ids = array_diff($file_ids, $system_file_ids);
     $project_file_ids = Projects::getTable()->getFileIds();
     $file_ids = array_diff($file_ids, $project_file_ids);
     return $file_ids;
 }
示例#16
0
 protected function _upgradeFrom3dot2(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable());
     \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable());
     \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable());
     \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable());
     \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable());
     \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable());
     \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable());
     \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable());
     \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable());
     \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable());
     \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable());
     \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable());
     \thebuggenie\core\entities\Dashboard::getB2DBTable()->create();
     \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable());
     \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create();
     \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create();
     $transaction = \b2db\Core::startTransaction();
     // Upgrade user passwords
     switch ($request['upgrade_passwords']) {
         case 'manual':
             $password = $request['manual_password'];
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 $user->setPassword($password);
                 $user->save();
             }
             break;
         case 'auto':
             $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email';
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 if ($field == 'username' && trim($user->getUsername())) {
                     $user->setPassword(trim($user->getUsername()));
                     $user->save();
                 } elseif ($field == 'email' && trim($user->getEmail())) {
                     $user->setPassword(trim($user->getEmail()));
                     $user->save();
                 }
             }
             break;
     }
     $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1);
     $adminuser->setPassword($request['admin_password']);
     $adminuser->save();
     // Add new settings
     framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1);
     foreach ($request->getParameter('status') as $scope_id => $status_id) {
         $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id);
         if ($scope instanceof \thebuggenie\core\entities\Scope) {
             $epic = new \thebuggenie\core\entities\Issuetype();
             $epic->setName('Epic');
             $epic->setIcon('epic');
             $epic->setDescription('Issue type suited for entering epics');
             $epic->setScope($scope_id);
             $epic->save();
             framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id);
             foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) {
                 $transition = new \thebuggenie\core\entities\WorkflowTransition();
                 $steps = $workflow->getSteps();
                 $step = array_shift($steps);
                 $step->setLinkedStatusID((int) $status_id);
                 $step->save();
                 $transition->setOutgoingStep($step);
                 $transition->setName('Issue created');
                 $transition->setWorkflow($workflow);
                 $transition->setScope($scope);
                 $transition->setDescription('This is the initial transition for issues using this workflow');
                 $transition->save();
                 $workflow->setInitialTransition($transition);
                 $workflow->save();
             }
             \thebuggenie\core\entities\ActivityType::loadFixtures($scope);
         }
     }
     $transaction->commitAndEnd();
     framework\Context::finishUpgrading();
     foreach (framework\Context::getModules() as $module) {
         $module->upgrade();
     }
     $this->upgrade_complete = true;
 }
示例#17
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addForeignKeyColumn(self::ISSUETYPE_ID, IssueTypes::getTable(), IssueTypes::ID);
     parent::_addForeignKeyColumn(self::PROJECT_ID, Projects::getTable(), Projects::ID);
 }