public function action_showUser() { $user_id = $this->request->param('user_id'); if (!empty($user_id)) { $viewUser = Model_User::get($user_id); } else { $viewUser = $this->user; } if (!$viewUser->id) { $this->redirect('/'); } $this->title = $viewUser->name ?: 'Пользователь #' . $viewUser->id; $this->view['viewUser'] = $viewUser; $this->template->content = View::factory('templates/users/user', $this->view); }
/** * Заполняет текущий объект строкой из базы данных. * * @param $article_row array строка из базы данных с создаваемой статьёй * @return Model_Article модель, заполненная полями из статьи, либо пустая модель, если была передана пустая строка. */ private function fillByRow($article_row) { if (!empty($article_row['id'])) { $this->id = $article_row['id']; $this->title = $article_row['title']; $this->text = $article_row['text']; $this->description = $article_row['description']; $this->cover = $article_row['cover']; $this->user_id = $article_row['user_id']; $this->dt_create = $article_row['dt_create']; $this->dt_update = $article_row['dt_update']; $this->is_removed = $article_row['is_removed']; $this->is_published = $article_row['is_published']; $this->author = Model_User::get($this->user_id); $this->commentsCount = Model_Comment::countCommentsByArticle($this->id); } return $this; }
asort($optInstance); $instanceId = $env->getSession()->get('instanceId'); $optInstance = UI_HTML_Elements::Options($optInstance, $instanceId); $badges = array(); $infos = array($words['footer_info']['copyright'], sprintf($words['footer_info']['date'], date('d.m.Y')), sprintf($words['footer_info']['time'], date('H:i:s'))); if (!$config->get('app.production')) { $infos[] = sprintf($words['footer_info']['time_stopped'], $env->getClock()->stop(0, 2)); if ($env->has('dbc') && $env->getDatabase()->numberStatements) { $infos[] = sprintf($words['footer_info']['requests'], $env->getDatabase()->numberStatements); } } $userId = (int) $session->get('userId'); $roleId = (int) $session->get('roleId'); if ($userId) { $modelUser = new Model_User($env); $infos[] = 'Benutzer: ' . $modelUser->get($userId, 'username') . ' <small>(' . $userId . ')</small>'; } if ($roleId) { $modelRole = new Model_Role($env); $infos[] = 'Rolle: ' . $modelRole->get($userId, 'title') . ' <small>(' . $roleId . ')</small>'; } $badges[] = '<a href="http://validator.w3.org/check?uri=referer"><img style="border: 0; width: 48px; height: 16px" src="http://www.w3.org/Icons/valid-xhtml10" alt="validate HTML (as XHTML 1.0 Strict)"/></a>'; $badges[] = '<a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border: 0; width: 48px; height: 16px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="validate CSS"/></a>'; $infos = '<span>' . join('</span><span>', $infos) . '</span>'; $badges = '<span>' . join('</span><span>', $badges) . '</span>'; $linkReset = '<a href="./?resetInstanceId">Instanz</a>'; $path = $env->getRequest()->get('__path'); $body = ' <script> function selectInstanceId(id, forward){ var url = "./admin/instance/select/"+id;
public function signInAction() { if (!$this->_request->isXmlHttpRequest()) { return; } $arp = new AjaxResponse(); $arp->setStatus(AjaxResponse::STATUS_FAILED); $email = trim($this->_getParam('email')); $password = trim($this->_getParam('password')); if (empty($email) || empty($password)) { $arp->setMessage('E-mail and password can not be empty.'); $this->json($arp); return; } $hashedPassword = hash('sha256', $password); $user = new Model_User($email); if (!$user->exists() || $user->get('password') != $hashedPassword) { $arp->setMessage('Authentication failed, You entered an incorrect username, or password.'); $this->json($arp); return; } $this->setLoginCookie($email, $hashedPassword); $arp->setStatus(AjaxResponse::STATUS_OK); $this->json($arp); }