public function register(array $userData) { //$this->userDao->getUserByUsername($userData['username']); //TODO: Ashot userData validation and insert/update payman karochi if (!$userData['userId']) { $userId = $this->userDao->createUser($userData); } else { return $this->userDao->updateUser($userData); } Notification::success(3, '_(Registered Successfully)'); return $userId; }
/** * @return AjaxResponse */ protected function initResponse() { $ajaxResponse = new AjaxResponse(); try { $app = App::getInstance(); $ajaxResponse->status = true; $ajaxResponse->result = $app->callFromRequest($this->arguments); } catch (\Exception $e) { $ajaxResponse->status = false; $ajaxResponse->result = null; App::exceptionHandler($e); } $ajaxResponse->notification = Notification::getAll(); return $ajaxResponse; }
public function updateUser(array $userData) { $user = new User($userData); $userId = $user->getUserId(); if (empty($userId)) { return Notification::error('UserId is empty'); } if (empty($user->getUserName())) { $user->setUserName('user' . App::getCounterNextIndex('user')); } $userTableUpdate = $this->db->update('users', $user->toArray(), 'userId = :userId', ['userId' => $userId]); if ($userTableUpdate) { switch ($user->getRole()) { case Defines::ROLE_DOCTOR: $doctor = new User($userData); return $this->db->update('doctors', $doctor->toArray(), 'doctorId = :userId', ['userId' => $userId]); case Defines::ROLE_CLIENT: $client = new User($userData); return $this->db->update('clients', $client->toArray(), 'clientId = :userId', ['userId' => $userId]); } } return false; }
public static function errorHandler($errno, $errstr, $errfile, $errline) { if (Config::getInstance()->environment != 'development') { return; } if ($errno == E_STRICT) { return; } $content = $errstr . "\n file " . $errfile . " line " . $errline; if (in_array($errno, self::$phpWarning)) { Notification::warning(1, $content, 'php_warning'); } else { Notification::error(1, $content, 'php_error'); } }