예제 #1
0
 /**
  * Performs the "find issues" action
  *
  * @param TBGRequest $request
  */
 public function runFindIssues(TBGRequest $request)
 {
     $this->_getSearchDetailsFromRequest($request);
     if ($request->isMethod(TBGRequest::POST) && !$request->getParameter('quicksearch')) {
         if ($request->getParameter('delete_saved_search')) {
             try {
                 $search = TBGSavedSearchesTable::getTable()->getByID($request->getParameter('saved_search_id'));
                 if ($search->get(TBGSavedSearchesTable::UID) == TBGContext::getUser()->getID() || $search->get(TBGSavedSearchesTable::IS_PUBLIC) && TBGContext::getUser()->canCreatePublicSearches()) {
                     TBGSavedSearchesTable::getTable()->doDeleteById($request->getParameter('saved_search_id'));
                     return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('The saved search was deleted successfully')));
                 }
             } catch (Exception $e) {
                 return $this->renderJSON(array('failed' => true, 'message' => TBGContext::getI18n()->__('Cannot delete this saved search')));
             }
         } elseif ($request->getParameter('saved_search_name') != '') {
             $project_id = TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0;
             TBGSavedSearchesTable::getTable()->saveSearch($request->getParameter('saved_search_name'), $request->getParameter('saved_search_description'), $request->getParameter('saved_search_public'), $this->filters, $this->groupby, $this->grouporder, $this->ipp, $this->templatename, $this->template_parameter, $project_id, $request->getParameter('saved_search_id'));
             if ($request->getParameter('saved_search_id')) {
                 TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search was updated'));
             } else {
                 TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search has been created'));
             }
             $params = array();
         } else {
             TBGContext::setMessage('search_error', TBGContext::getI18n()->__('You have to specify a name for the saved search'));
             $params = array('filters' => $this->filters, 'groupby' => $this->groupby, 'grouporder' => $this->grouporder, 'templatename' => $this->templatename, 'saved_search' => $request->getParameter('saved_search_id'), 'issues_per_page' => $this->ipp);
         }
         if (TBGContext::isProjectContext()) {
             $route = 'project_issues';
             $params['project_key'] = TBGContext::getCurrentProject()->getKey();
         } else {
             $route = 'search';
         }
         $this->forward(TBGContext::getRouting()->generate($route, $params));
     } else {
         $this->doSearch($request);
         $this->issues = $this->foundissues;
         if ($request->getParameter('quicksearch') == true) {
             $this->redirect('quicksearch');
         }
     }
     $this->search_error = TBGContext::getMessageAndClear('search_error');
     $this->search_message = TBGContext::getMessageAndClear('search_message');
     $this->appliedfilters = $this->filters;
     $this->templates = $this->getTemplates();
     $this->savedsearches = B2DB::getTable('TBGSavedSearchesTable')->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID(), TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0);
 }
예제 #2
0
 public static function getAvailableViews($target_type)
 {
     switch ($target_type) {
         case TBGDashboardView::TYPE_USER:
             $searches = array();
             $searches[self::VIEW_PREDEFINED_SEARCH] = array(TBGContext::PREDEFINED_SEARCH_MY_REPORTED_ISSUES => TBGContext::getI18n()->__('Issues reported by me'), TBGContext::PREDEFINED_SEARCH_MY_ASSIGNED_OPEN_ISSUES => TBGContext::getI18n()->__('Open issues assigned to me'), TBGContext::PREDEFINED_SEARCH_MY_OWNED_OPEN_ISSUES => TBGContext::getI18n()->__('Open issues owned by me'), TBGContext::PREDEFINED_SEARCH_TEAM_ASSIGNED_OPEN_ISSUES => TBGContext::getI18n()->__('Open issues assigned to my teams'));
             $searches[self::VIEW_LOGGED_ACTIONS] = array(0 => TBGContext::getI18n()->__("What you've done recently"));
             if (TBGContext::getUser()->canViewComments()) {
                 $searches[self::VIEW_RECENT_COMMENTS] = array(0 => TBGContext::getI18n()->__('Recent comments'));
             }
             $searches[self::VIEW_SAVED_SEARCH] = array();
             $allsavedsearches = TBGSavedSearchesTable::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID());
             foreach ($allsavedsearches as $savedsearches) {
                 foreach ($savedsearches as $a_savedsearch) {
                     $searches[self::VIEW_SAVED_SEARCH][$a_savedsearch->getID()] = $a_savedsearch->getName();
                 }
             }
             break;
         case TBGDashboardView::TYPE_PROJECT:
             $issuetype_icons = array();
             foreach (TBGIssuetype::getAll() as $id => $issuetype) {
                 $issuetype_icons[$id] = TBGContext::getI18n()->__('Recent issues: %issuetype', array('%issuetype' => $issuetype->getName()));
             }
             $searches = array();
             $searches[self::VIEW_PROJECT_INFO] = array(0 => TBGContext::getI18n()->__('About this project'));
             $searches[self::VIEW_PROJECT_TEAM] = array(0 => TBGContext::getI18n()->__('Project team'));
             $searches[self::VIEW_PROJECT_CLIENT] = array(0 => TBGContext::getI18n()->__('Project client'));
             $searches[self::VIEW_PROJECT_SUBPROJECTS] = array(0 => TBGContext::getI18n()->__('Subprojects'));
             $searches[self::VIEW_PROJECT_STATISTICS_LAST15] = array(0 => TBGContext::getI18n()->__('Graph of closed vs open issues, past 15 days'));
             $searches[self::VIEW_PROJECT_STATISTICS_PRIORITY] = array(0 => TBGContext::getI18n()->__('Statistics by priority'));
             $searches[self::VIEW_PROJECT_STATISTICS_SEVERITY] = array(0 => TBGContext::getI18n()->__('Statistics by severity'));
             $searches[self::VIEW_PROJECT_STATISTICS_CATEGORY] = array(0 => TBGContext::getI18n()->__('Statistics by category'));
             $searches[self::VIEW_PROJECT_STATISTICS_STATUS] = array(0 => TBGContext::getI18n()->__('Statistics by status'));
             $searches[self::VIEW_PROJECT_STATISTICS_RESOLUTION] = array(0 => TBGContext::getI18n()->__('Statistics by resolution'));
             $searches[self::VIEW_PROJECT_STATISTICS_WORKFLOW_STEP] = array(0 => TBGContext::getI18n()->__('Statistics by workflow step'));
             $searches[self::VIEW_PROJECT_RECENT_ISSUES] = $issuetype_icons;
             $searches[self::VIEW_PROJECT_RECENT_ACTIVITIES] = array(0 => TBGContext::getI18n()->__('Recent activities'));
             $searches[self::VIEW_PROJECT_UPCOMING] = array(0 => TBGContext::getI18n()->__('Upcoming milestones and deadlines'));
             $searches[self::VIEW_PROJECT_DOWNLOADS] = array(0 => TBGContext::getI18n()->__('Latest downloads'));
             break;
     }
     return $searches;
 }
예제 #3
0
 /**
  * @param TBGRequest $request
  *
  * @return TBGSavedSearch
  */
 public static function getFromRequest(TBGRequest $request)
 {
     $search = null;
     $search_id = $request['saved_search_id'] ? $request['saved_search_id'] : $request['saved_search'];
     if ($search_id) {
         $search = TBGSavedSearchesTable::getTable()->selectById($search_id);
     } else {
         $search = new TBGSavedSearch();
         $search->setValuesFromRequest($request);
     }
     return $search;
 }
예제 #4
0
 protected function _upgradeFrom3dot2(TBGRequest $request)
 {
     set_time_limit(0);
     TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'installation' . DS . 'classes' . DS . 'upgrade_3.2');
     foreach (array('publish', 'mailing') as $module) {
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . $module . DS . 'classes');
         TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . $module . DS . 'classes' . DS . 'B2DB');
     }
     TBGMilestonesTable::getTable()->upgrade(TBGMilestonesTable3dot2::getTable());
     TBGArticlesTable::getTable()->upgrade(TBGArticlesTable3dot2::getTable());
     TBGProjectsTable::getTable()->upgrade(TBGProjectsTable3dot2::getTable());
     TBGLogTable::getTable()->upgrade(TBGLogTable3dot2::getTable());
     TBGUsersTable::getTable()->upgrade(TBGUsersTable3dot2::getTable());
     TBGIssuesTable::getTable()->upgrade(TBGIssuesTable3dot2::getTable());
     TBGWorkflowsTable::getTable()->upgrade(TBGWorkflowsTable3dot2::getTable());
     TBGIncomingEmailAccountTable::getTable()->upgrade(TBGIncomingEmailAccountTable3dot2::getTable());
     TBGIssueSpentTimesTable::getTable()->upgrade(TBGIssueSpentTimesTable3dot2::getTable());
     TBGCommentsTable::getTable()->upgrade(TBGCommentsTable3dot2::getTable());
     TBGSavedSearchesTable::getTable()->upgrade(TBGSavedSearchesTable3dot2::getTable());
     TBGSettingsTable::getTable()->upgrade(TBGSettingsTable3dot2::getTable());
     TBGNotificationsTable::getTable()->upgrade(TBGNotificationsTable3dot2::getTable());
     TBGPermissionsTable::getTable()->upgrade(TBGPermissionsTable3dot2::getTable());
     TBGUserArticlesTable::getTable()->create();
     TBGApplicationPasswordsTable::getTable()->create();
     TBGUserNotificationSettingsTable::getTable()->create();
     $transaction = \b2db\Core::startTransaction();
     // Upgrade user passwords
     switch ($request['upgrade_passwords']) {
         case 'manual':
             $password = $request['manul_password'];
             foreach (TBGUsersTable::getTable()->selectAll() as $user) {
                 $user->setPassword($password);
                 $user->save();
             }
             break;
         case 'auto':
             $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email';
             foreach (TBGUsersTable::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 = TBGUsersTable::getTable()->selectById(1);
     $adminuser->setPassword($request['admin_password']);
     $adminuser->save();
     // Add new settings
     TBGSettings::saveSetting(TBGSettings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1);
     foreach ($request->getParameter('status') as $scope_id => $status_id) {
         $scope = TBGScopesTable::getTable()->selectById((int) $scope_id);
         if ($scope instanceof TBGScope) {
             foreach (TBGWorkflowsTable::getTable()->getAll((int) $scope_id) as $workflow) {
                 $transition = new TBGWorkflowTransition();
                 $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();
             }
             TBGActivityType::loadFixtures($scope);
         }
     }
     $transaction->commitAndEnd();
     TBGContext::finishUpgrading();
     TBGContext::getModule('mailing')->upgradeFrom3dot2();
     $this->upgrade_complete = true;
 }
예제 #5
0
 public function componentSidebar()
 {
     $savedsearches = TBGSavedSearchesTable::getTable()->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID(), TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0);
     foreach ($savedsearches['user'] as $a_savedsearch) {
         $this->getResponse()->addFeed(make_url('search', array('saved_search' => $a_savedsearch->getID(), 'search' => true, 'format' => 'rss')), __($a_savedsearch->getName()));
     }
     foreach ($savedsearches['public'] as $a_savedsearch) {
         $this->getResponse()->addFeed(make_url('search', array('saved_search' => $a_savedsearch->getID(), 'search' => true, 'format' => 'rss')), __($a_savedsearch->getName()));
     }
     $this->savedsearches = $savedsearches;
 }