Example #1
0
 public function show()
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit terms.');
     }
     $printable = Term::getPrintableSelectedTerm();
     $tpl = array();
     $tpl['TITLE'] = dgettext('hms', 'Term settings for ') . $printable;
     $newTermCmd = CommandFactory::getCommand('ShowCreateTerm');
     $tpl['NEW_TERM_URI'] = $newTermCmd->getURI();
     // Is this the Current Term?
     if (Term::isCurrentTermSelected()) {
         $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is the <strong>active term</strong>.  To make another term active, please select it from the list at the top-left.');
     } else {
         $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is <strong>not</strong> the active term.');
         if (Current_User::allow('hms', 'activate_term')) {
             $cmd = CommandFactory::getCommand('SetCurrentTerm');
             $cmd->setTerm(Term::getSelectedTerm());
             $tpl['SET_TERM_URI'] = $cmd->getURI();
             $tpl['SET_TERM_TEXT'] = "Make <strong>{$printable}</strong> the Current Term";
         }
     }
     // What's with the Banner Queue?
     $term = new Term(Term::getSelectedTerm());
     if ($term->getBannerQueue()) {
         $tpl['QUEUE_ENABLED'] = '';
         $count = $term->getQueueCount();
         $tpl['BANNER_QUEUE_COUNT'] = $count;
         if ($count > 0) {
             $cmd = CommandFactory::getCommand('ProcessBannerQueue');
             $cmd->setTerm(Term::getSelectedTerm());
             $tpl['BANNER_QUEUE_PROCESS_URI'] = $cmd->getURI();
         } else {
             $cmd = CommandFactory::getCommand('DisableBannerQueue');
             $cmd->setTerm(Term::getSelectedTerm());
             $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Disable');
         }
     } else {
         $tpl['QUEUE_DISABLED'] = '';
         $cmd = CommandFactory::getCommand('EnableBannerQueue');
         $cmd->setTerm(Term::getSelectedTerm());
         $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Enable');
     }
     // Terms and Conditions
     PHPWS_Core::initModClass('hms', 'TermsConditionsAdminView.php');
     $tcav = new TermsConditionsAdminView($this->term);
     $tpl['TERMS_CONDITIONS_CONTENT'] = $tcav->show();
     // Features and Deadlines
     PHPWS_Core::initModClass('hms', 'ApplicationFeatureListView.php');
     $aflv = new ApplicationFeatureListView(Term::getSelectedTerm());
     $tpl['FEATURES_DEADLINES_CONTENT'] = $aflv->show();
     Layout::addPageTitle("Term Settings");
     return PHPWS_Template::process($tpl, 'hms', 'admin/TermEditView.tpl');
 }
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to enable/disable the Banner queue.');
     }
     if (is_null($this->term)) {
         $this->term = $context->get('term');
     }
     $term = $this->term;
     if (is_null($term)) {
         throw new InvalidArgumentException('No term was specified to DisableBannerQueue');
     }
     $term = new Term($term);
     if (!$term->getBannerQueue()) {
         NQ::Simple('hms', hms\NotificationView::ERROR, 'The Banner Queue is not enabled for ' . Term::toString($term->term) . '.');
     } else {
         if ($term->getQueueCount() < 1) {
             NQ::Simple('hms', hms\NotificationView::WARNING, 'The Banner Queue was already empty for ' . Term::toString($term->term) . '.');
             $term->setBannerQueue(FALSE);
             $term->save();
             NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
         } else {
             PHPWS_Core::initModClass('hms', 'BannerQueue.php');
             $result = BannerQueue::processAll($term->term);
             if ($result === TRUE) {
                 NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been processed for ' . Term::toString($term->term) . '.');
                 $term->setBannerQueue(FALSE);
                 $term->save();
                 NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
             } else {
                 // TODO: This is just awful.
                 $text = 'The following failures occurred reporting to Banner:<br /><br /><ul>';
                 foreach ($result as $error) {
                     $text .= "<li>{$error['username']}: ({$error['code']}) - {$error['message']}</li>";
                 }
                 $text .= '</ul>The queue was not disabled.';
                 NQ::Simple('hms', hms\NotificationView::ERROR, $text);
             }
         }
     }
     $cmd = CommandFactory::getCommand('ShowEditTerm');
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to enable/disable the Banner queue.');
     }
     if (is_null($this->term)) {
         $this->term = $context->get('term');
     }
     $term = $this->term;
     if (is_null($term)) {
         throw new InvalidArgumentException('No term was specified to DisableBannerQueue');
     }
     $term = new Term($term);
     if ($term->getQueueCount() > 0) {
         NQ::Simple('hms', hms\NotificationView::ERROR, 'You must process the Banner Queue before it can be disabled.');
     } else {
         $term->setBannerQueue(FALSE);
         $term->save();
         NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
     }
     CommandContext::goBack();
 }