コード例 #1
0
ファイル: SpecialEnroll.php プロジェクト: schwarer2006/wikia
 /**
  * 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()));
         }
     }
 }