Exemple #1
0
 /**
  * @return User|false
  */
 public function getUser()
 {
     if (isset($_SESSION['userId'], $_SESSION['username'], $_SESSION['loginString'])) {
         $userId = $_SESSION['userId'];
         /** @var User $user */
         $user = DB::getObjectByID('User', $userId);
         if ($user) {
             $loginCheck = hash('sha512', $user->Password . $this->userBrowser);
             $this->user = $loginCheck == $this->loginString ? $user : false;
         }
     }
     return $this->user ?: false;
 }
Exemple #2
0
 public function __get($name)
 {
     if (array_key_exists($name, $this->fields)) {
         return $this->fields[$name];
     }
     if (isset(static::$has_many[$name])) {
         $field = strtolower(get_class($this) . '_id');
         $className = static::$has_many[$name];
         $this->fields[$name] = DB::getDataList($className, array($field => $this->getId()), null, $className::$sort);
         return $this->fields[$name];
     }
     if (isset(static::$belongs_to[$name])) {
         $className = static::$belongs_to[$name];
         $field = strtolower($className . '_id');
         $this->fields[$name] = DB::getObjectByID($className, $this->{$field});
         return $this->fields[$name];
     }
     if (isset(static::$has_one[$name])) {
         $className = static::$has_one[$name];
         $field = strtolower(get_class($this) . '_id');
         $this->fields[$name] = DB::getObjectBy($className, array($field => $this->getId()));
         return $this->fields[$name];
     }
     $trace = debug_backtrace();
     trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
     return null;
 }
 public function removeEduAction()
 {
     $id = $this->request->getRouteValue('id');
     if ($record = DB::getObjectByID('Education', $id)) {
         DB::remove($record);
         $this->redirectUrl($this->request->getBackUrl());
     } else {
         $this->handleNotFound('This record was not found');
     }
 }