/**
  * Main method.
  *
  * @since 0.1
  *
  * @param string $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     if ($this->getRequest()->getCheck('enrolled')) {
         EPStudent::setReadDb(DB_MASTER);
     }
     $student = EPStudent::newFromUser($this->getUser());
     if ($student === false) {
         $this->getOutput()->addWikiMsg('ep-mycourses-not-a-student');
     } else {
         if ($this->getUser()->isAllowed('ep-org')) {
             $this->displayNavigation();
         }
         if ($this->subPage === '') {
             $this->displayCourses($student);
         } else {
             $this->displayCourse($student, $this->subPage);
         }
     }
 }
Exemplo n.º 2
0
 protected function displayEnrollment()
 {
     if ($this->getRequest()->getCheck('enrolled')) {
         EPStudent::setReadDb(DB_MASTER);
     }
     $student = EPStudent::newFromUser($this->getUser());
     $courses = $student->getCourses('id');
     $courseIds = array_map(function (EPCourse $course) {
         return $course->getId();
     }, $courses);
     if ($this->getRequest()->getCheck('enrolled') && in_array($this->getRequest()->getInt('enrolled'), $courseIds)) {
         $course = EPCourse::selectRow(array('name', 'org_id'), array('id' => $this->getRequest()->getInt('enrolled')));
         $this->showSuccess(wfMessage('ep-mycourses-enrolled', $course->getField('name'), $course->getOrg()->getField('name')));
     }
     if (count($courseIds) === 1) {
         $course = $courses[0];
         $course->loadFields();
         $this->displayCourse($course);
     } elseif (count($courseIds) > 1) {
         $this->getOutput()->addElement('h2', array(), wfMsg('ep-mycourses-enrollment'));
         EPCourse::displayPager($this->getContext(), array('id' => $courseIds), true, 'enrollment');
     }
 }