/**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $args = explode('/', $this->subPage, 2);
     if (!ctype_digit($args[0])) {
         $this->showWarning(wfMessage($args[0] === '' ? 'ep-enroll-no-id' : 'ep-enroll-invalid-id'));
     } else {
         $term = EPTerm::selectRow(null, array('id' => $args[0]));
         if ($term === false) {
             $this->showWarning(wfMessage('ep-enroll-invalid-id'));
         } elseif ($term->getStatus() === 'current') {
             $token = '';
             $tokenIsValid = $term->getField('token') === '';
             if (!$tokenIsValid) {
                 $tokenIsValid = $term->getField('token') === $token;
                 if (count($args) === 2) {
                     $token = $args[1];
                 } elseif ($this->getRequest()->wasPosted() && $this->getRequest()->getCheck('wptoken')) {
                     $token = $this->getRequest()->getText('wptoken');
                 }
             }
             if ($tokenIsValid) {
                 $this->showEnrollmentView($term);
             } else {
                 if ($token !== '') {
                     $this->showWarning(wfMessage('ep-enroll-invalid-token'));
                 }
                 $this->showTokenInput();
             }
         } else {
             $this->showWarning(wfMessage('ep-enroll-term-' . $term->getStatus()));
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Institutions')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-institution-title', 'parsemag', $this->subPage));
         $org = EPOrg::selectRow(null, array('name' => $this->subPage));
         if ($org === false) {
             $this->displayNavigation();
             if ($this->getUser()->isAllowed('ep-org')) {
                 $out->addWikiMsg('ep-institution-create', $this->subPage);
                 EPOrg::displayAddNewControl($this->getContext(), array('name' => $this->subPage));
             } else {
                 $out->addWikiMsg('ep-institution-none', $this->subPage);
             }
         } else {
             $links = array();
             if ($this->getUser()->isAllowed('ep-org')) {
                 $links[wfMsg('ep-institution-nav-edit')] = SpecialPage::getTitleFor('EditInstitution', $this->subPage);
             }
             $this->displayNavigation($links);
             $this->displaySummary($org);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-courses')));
             EPCourse::displayPager($this->getContext(), array('org_id' => $org->getId()));
             if ($this->getUser()->isAllowed('ep-course')) {
                 $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-add-course')));
                 EPCourse::displayAddNewControl($this->getContext(), array('org' => $org->getId()));
             }
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Courses')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-course-title', 'parsemag', $this->subPage));
         $course = EPCourse::selectRow(null, array('name' => $this->subPage));
         if ($course === false) {
             $this->displayNavigation();
             if ($this->getUser()->isAllowed('ep-course')) {
                 $out->addWikiMsg('ep-course-create', $this->subPage);
                 EPCourse::displayAddNewRegion($this->getContext(), array('name' => $this->subPage));
             } else {
                 $out->addWikiMsg('ep-course-none', $this->subPage);
             }
         } else {
             $links = array();
             if ($this->getUser()->isAllowed('ep-course')) {
                 $links[wfMsg('ep-course-nav-edit')] = SpecialPage::getTitleFor('EditCourse', $this->subPage);
             }
             $this->displayNavigation($links);
             $this->displaySummary($course);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-course-description')));
             $out->addHTML($this->getOutput()->parse($course->getField('description')));
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-course-terms')));
             EPTerm::displayPager($this->getContext(), array('course_id' => $course->getId()));
             if ($this->getUser()->isAllowed('ep-course')) {
                 $out->addHTML(Html::element('h2', array(), wfMsg('ep-course-add-term')));
                 EPTerm::displayAddNewControl($this->getContext(), array('course' => $course->getId()));
             }
         }
     }
 }
Example #4
0
 /**
  * (non-PHPdoc)
  * @see SpecialEPPage::getDefaultNavigationItems()
  */
 protected function getDefaultNavigationItems()
 {
     $items = parent::getDefaultNavigationItems();
     if ($this->subPage === '') {
         unset($items[wfMsg('ep-nav-mycourses')]);
     }
     return $items;
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     if ($this->subPage === '') {
         $this->displayNavigation();
         EPStudent::displayPager($this->getContext());
     } else {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Student', $this->subPage)->getLocalURL());
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string|null $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     if ($this->subPage === '') {
         $this->displayNavigation();
         EPOrg::displayAddNewControl($this->getContext());
         EPOrg::displayPager($this->getContext());
     } else {
         $this->getOutput()->redirect(Title::newFromText($this->subPage, EP_NS_INSTITUTION)->getLocalURL());
     }
 }
Example #7
0
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string|null $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     if ($this->subPage === '') {
         $this->displayNavigation();
         EPCourse::displayAddNewRegion($this->getContext());
         EPCourse::displayPager($this->getContext());
     } else {
         $this->getOutput()->redirect(Title::newFromText($this->subPage, EP_NS_COURSE)->getLocalURL());
     }
 }
Example #8
0
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('CampusAmbassadors')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-ca-title', 'parsemag', $this->subPage));
         $this->displayNavigation();
         $ca = false;
         // TODO
         if ($ca === false) {
             $this->showWarning(wfMessage('ep-ca-does-not-exist', $this->subPage));
         } else {
             $this->displaySummary($ca);
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Ambassadors')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-ambassador-title', 'parsemag', $this->subPage));
         $this->displayNavigation();
         $mentor = false;
         // EPMentor::selectRow( null, array( 'id' => $this->subPage ) );
         if ($mentor === false) {
             $this->showWarning(wfMessage('ep-ambassador-does-not-exist', $this->subPage));
         } else {
             $this->displaySummary($mentor);
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Students')->getLocalURL());
     } else {
         $this->displayNavigation();
         $student = EPStudent::selectRow(null, array('id' => $this->subPage));
         if ($student === false) {
             $out->addWikiMsg('ep-student-none', $this->subPage);
         } else {
             $out->setPageTitle(wfMsgExt('ep-student-title', 'parsemag', $student->getName()));
             $this->displaySummary($student);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-student-terms')));
             $termIds = array_map(function (EPTerm $term) {
                 return $term->getId();
             }, $student->getTerms('id'));
             EPTerm::displayPager($this->getContext(), array('id' => $termIds));
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     if (trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Terms')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-term-title', 'parsemag', $this->subPage));
         $term = EPTerm::selectRow(null, array('id' => $this->subPage));
         if ($term === false) {
             $this->displayNavigation();
             if ($this->getUser()->isAllowed('ep-term')) {
                 $out->addWikiMsg('ep-term-create', $this->subPage);
                 EPTerm::displayAddNewRegion($this->getContext(), array('id' => $this->subPage));
             } else {
                 $out->addWikiMsg('ep-term-none', $this->subPage);
             }
         } else {
             $links = array();
             if ($this->getUser()->isAllowed('ep-term')) {
                 $links[wfMsg('ep-term-nav-edit')] = SpecialPage::getTitleFor('EditTerm', $this->subPage);
             }
             $this->displayNavigation($links);
             $this->displaySummary($term);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-term-description')));
             $out->addHTML($this->getOutput()->parse($term->getField('description')));
             $studentIds = array_map(function (EPStudent $student) {
                 return $student->getId();
             }, $term->getStudents('id'));
             if (count($studentIds) > 0) {
                 $out->addHTML(Html::element('h2', array(), wfMsg('ep-term-students')));
                 EPStudent::displayPager($this->getContext(), array('id' => $studentIds));
             } else {
                 // TODO
             }
         }
     }
 }
Example #12
0
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $args = explode('/', $this->subPage, 2);
     if ($args[0] === '') {
         $this->showWarning(wfMessage('ep-enroll-no-id'));
     } else {
         $course = EPCourse::get($args[0]);
         if ($course === false) {
             $this->showWarning(wfMessage('ep-enroll-invalid-id'));
         } elseif ($course->getStatus() === 'current') {
             $this->setPageTitle($course);
             $token = '';
             $tokenIsValid = $course->getField('token') === '';
             if (!$tokenIsValid) {
                 if (count($args) === 2) {
                     $token = $args[1];
                 } elseif ($this->getRequest()->getCheck('wptoken')) {
                     $token = $this->getRequest()->getText('wptoken');
                 }
                 $tokenIsValid = $course->getField('token') === $token;
                 $this->token = $token;
             }
             if ($tokenIsValid) {
                 $this->showEnrollmentView($course);
             } else {
                 if ($token !== '') {
                     $this->showWarning(wfMessage('ep-enroll-invalid-token'));
                 }
                 $this->showTokenInput();
             }
         } else {
             $this->setPageTitle($course);
             $this->showWarning(wfMessage('ep-enroll-course-' . $course->getStatus()));
         }
     }
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $arg
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $out = $this->getOutput();
     // TODO
 }
 /**
  * (non-PHPdoc)
  * @see SpecialEPPage::getDefaultNavigationItems()
  */
 protected function getDefaultNavigationItems()
 {
     $items = parent::getDefaultNavigationItems();
     unset($items[wfMsg('ep-nav-mycourses')]);
     return $items;
 }
 /**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     if ($this->getRequest()->wasPosted() && $this->getUser()->matchEditToken($this->getRequest()->getVal('wpEditToken'))) {
         $this->showForm();
     } else {
         $this->showContent();
     }
 }