Esempio n. 1
0
 public function importUsers()
 {
     try {
         $raw = fRequest::get('content');
         $this->db = fORMDatabase::retrieve();
         $this->db->query('BEGIN');
         foreach (explode("\n", $raw) as $i) {
             $j = preg_split('/\\s+/', $i);
             if (count($j) < 2) {
                 continue;
             }
             $x = $j[0];
             $y = $j[1];
             $user = new Name();
             $user->setRealname($x);
             $user->setStudentNumber($y);
             $user->store();
         }
         $this->db->query('COMMIT');
         $this->ajaxReturn(array('result' => 'success'));
     } catch (fException $e) {
         if (isset($this->db)) {
             $this->db->query('ROLLBACK');
         }
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }
Esempio n. 2
0
 public function update($id)
 {
     try {
         $users = new Name($id);
         if (!UserHelper::isEditor()) {
             throw new fValidationException('not allowed');
         }
         $users->setStudentNumber(fRequest::get('stuid'));
         $users->setRealname(fRequest::get('realname'));
         $users->store();
         $this->ajaxReturn(array('result' => 'success', 'user_id' => $users->getId()));
     } catch (fException $e) {
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }