function saveNewsArticle($data, Form $form)
 {
     try {
         $form->clearMessage();
         $form->resetValidation();
         if ($data['newsID']) {
             $this->manager->updateNews($data);
         } else {
             $this->manager->postNews($data);
         }
         Session::clear("FormInfo.Form_NewsRequestForm.data");
         return Controller::curr()->redirect('/news-add/?saved=1');
     } catch (EntityValidationException $ex1) {
         $messages = $ex1->getMessages();
         $msg = $messages[0];
         $form->addErrorMessage('Headline', $msg['message'], 'bad');
         SS_Log::log($msg['message'], SS_Log::ERR);
         // Load errors into session and post back
         Session::set("FormInfo.Form_NewsRequestForm.data", $data);
         return $this->redirectBack();
     } catch (Exception $ex) {
         $form->addErrorMessage('Headline', 'Server Error', 'bad');
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         // Load errors into session and post back
         Session::set("FormInfo.Form_NewsRequestForm.data", $data);
         return $this->redirectBack();
     }
 }
 function run()
 {
     set_time_limit(0);
     try {
         $manager = new NewsRequestManager(new SapphireNewsRepository(), new SapphireSubmitterRepository(), new NewsFactory(), new NewsValidationFactory(), new SapphireFileUploadService(), SapphireTransactionManager::getInstance());
         $manager->activateNews();
         $manager->removeExpired();
         $manager->archiveOld();
         return 'OK';
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         echo $ex->getMessage();
     }
 }
 public function archiveArticle()
 {
     $article_id = intval($this->request->postVar('id'));
     $type = $this->request->postVar('type');
     $old_rank = intval($this->request->postVar('old_rank'));
     $this->news_manager->archiveNewsArticle($article_id);
     $this->news_manager->sortNewsArticles($article_id, 0, $old_rank, false, true, $type);
 }
 public function restoreArticle()
 {
     $article_id = intval($this->request->postVar('id'));
     $this->news_manager->restoreNewsArticle($article_id);
 }