Beispiel #1
0
 public function GETlogin($status = "default")
 {
     \bloc\Application::instance()->getExchange('response')->addHeader("HTTP/1.0 401 Unauthorized");
     $messages = ['default' => 'Request Token', 'invalid' => 'ID malformed', 'duplicate' => 'A password link was alread sent (you can still use it).', 'instructor' => 'Check Credentials'];
     $view = new \bloc\View(self::layout);
     $view->content = "views/layouts/forms/authenticate.html";
     if ($status == 'instructor') {
         $view->user = \bloc\dom\Document::ELEM('<input type="text" value="" name="uid" placeholder="instructor"/>');
     }
     $this->status = $messages[$status];
     return $view->render($this());
 }
Beispiel #2
0
 public function CLIenroll($semester, $course, $section, $id = null, $name = null, $email = null, $year = null, $major = null)
 {
     $doc = new Document("data/{$semester}");
     $section = (new \DomXpath($doc))->query("//courses/section[@id='{$section}' and @course='{$course}']");
     if ($section->length < 1) {
         throw new \RuntimeException("No section {$section} for {$course} in {$semester}", 1);
     }
     $student = $section->item(0)->appendChild($doc->createElement('student'));
     if ($name === null) {
         echo "\nName: ";
         $name = trim(fgets(STDIN));
     }
     if ($id === null) {
         echo "\nOasis ID: ";
         $id = trim(fgets(STDIN));
     }
     if ($email === null) {
         echo "\nEmail: ";
         $email = trim(fgets(STDIN));
     }
     if ($year === null) {
         echo "\nYear: ";
         $year = trim(fgets(STDIN));
     }
     if ($major === null) {
         echo "\nMajor: ";
         $major = trim(fgets(STDIN));
     }
     $student->setAttribute('name', $name);
     $student->setAttribute('email', $email);
     $key = substr($email, 0, strpos($email, '@'));
     $student->setAttribute('url', "http://iam.colum.edu/students/{$key}/{$course}");
     $student->setAttribute('id', \models\Student::BLEAR($id));
     $student->setAttribute('year', $year);
     $student->setAttribute('major', $major);
     echo $student->write() . "\nCreate Account (Y/n): ";
     if (strtoupper(trim(fgets(STDIN))) === 'Y') {
         return $this->save($doc);
     }
 }