/** * Gets called after the form is saved. * * @since 0.1 */ public function onSuccess() { $this->getOutput()->redirect(SpecialPage::getTitleFor('MyCourses')->getLocalURL(array('enrolled' => $this->course->getId()))); }
/** * Returns role a controls for the course if the * current user has the right permissions. * * @since 0.1 * * @param EPCourse $course * @param string $roleName * * @return string */ protected function getRoleControls(EPCourse $course, $roleName) { $user = $this->getUser(); $links = array(); $field = $roleName === 'instructor' ? 'instructors' : $roleName . '_ambs'; if (($user->isAllowed('ep-' . $roleName) || $user->isAllowed('ep-be' . $roleName)) && !in_array($user->getId(), $course->getField($field))) { $links[] = Html::element('a', array('href' => '#', 'class' => 'ep-add-role', 'data-role' => $roleName, 'data-courseid' => $course->getId(), 'data-coursename' => $course->getField('name'), 'data-mode' => 'self'), wfMsg('ep-course-become-' . $roleName)); } if ($user->isAllowed('ep-' . $roleName)) { $links[] = Html::element('a', array('href' => '#', 'class' => 'ep-add-role', 'data-role' => $roleName, 'data-courseid' => $course->getId(), 'data-coursename' => $course->getField('name')), wfMsg('ep-course-add-' . $roleName)); } if (count($links) > 0) { $this->getOutput()->addModules('ep.enlist'); return '<br />' . $this->getLanguage()->pipeList($links); } else { return ''; } }
protected function getInstructorControls(EPCourse $course) { $user = $this->getUser(); $links = array(); if (($user->isAllowed('ep-instructor') || $user->isAllowed('ep-beinstructor')) && !in_array($user->getId(), $course->getField('instructors'))) { $links[] = Html::element('a', array('href' => '#', 'class' => 'ep-add-instructor', 'data-courseid' => $course->getId(), 'data-coursename' => $course->getField('name'), 'data-mode' => 'self'), wfMsg('ep-course-become-instructor')); } if ($user->isAllowed('ep-instructor')) { $links[] = Html::element('a', array('href' => '#', 'class' => 'ep-add-instructor', 'data-courseid' => $course->getId(), 'data-coursename' => $course->getField('name')), wfMsg('ep-course-add-instructor')); } if (count($links) > 0) { $this->getOutput()->addModules('ep.instructor'); return '<br />' . $this->getLanguage()->pipeList($links); } else { return ''; } }