예제 #1
0
 /**
  * Removes an article from the list of flagged articles
  *
  * @param integer $article_id ID of article to remove
  */
 public function removeStarredArticle($article_id)
 {
     TBGUserArticlesTable::getTable()->removeStarredArticle($this->getID(), $article_id);
     if (is_array($this->_starredarticles) && array_key_exists($article_id, $this->_starredarticles)) {
         unset($this->_starredarticles[$article_id]);
     }
     return true;
 }
예제 #2
0
 public function addSubscriber($user_id)
 {
     TBGUserArticlesTable::getTable()->addStarredArticle($user_id, $this->getID());
 }
예제 #3
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;
 }