/** * Index Action */ public function indexAction() { if ($this->auth->logged_in()) { $this->pageName = 'account'; if (Users::getUserRoles($this->auth->get_user()->id, 'unconfirmed')) { $this->flashSession->warning('<i class="close icon"></i>' . '<div class="ui header">Email activation required!</div> ' . '<div class="content">We sent you an email with instructions on how to activate your account. Please check your inbox. If you did not receive the email, you can <a href="' . $this->config->app->base_uri . 'user/resend/">get another one sent here</a>.</div>'); } if ($this->request->isPost()) { $validation = new \Baseapp\Extension\Validation(); if ($this->request->getPost('email')) { $validation->add('email', new \Phalcon\Validation\Validator\Email()); $validation->add('email', new \Baseapp\Extension\Uniqueness(array('model' => '\\Baseapp\\Models\\Users'))); $validation->setLabels(array('email' => __('Email'))); $messages = $validation->validate($_POST); if (count($messages)) { $errors = $validation->getMessages(); $this->view->setVar('errors', $errors); } else { $users = new Users(); if ($users->resend($this->auth->get_user()->id, $this->request->getPost('email', 'email'))) { $this->flashSession->notice('<i class="close icon"></i>' . '<div class="ui header">Email activation required!</div> ' . '<div class="content">Please confirm your email address by folowing the instructions in the email we just sent you. Please check your inbox. If you did not receive the email, you can <a href="' . $this->config->app->base_uri . 'user/resend/">get another one sent here</a>.</div>'); } } } if ($this->request->getPost('password')) { $validation->add('password', new \Baseapp\Extension\Password()); $validation->add('repeatPassword', new \Phalcon\Validation\Validator\Confirmation(array('with' => 'password'))); $validation->setLabels(array('password' => __('Password'), 'repeatPassword' => __('Repeat password'))); $messages = $validation->validate($_POST); if (count($messages)) { $errors = $validation->getMessages(); $this->view->setVar('errors', $errors); } else { $users = new Users(); if ($users->editPassword($this->auth->get_user()->id, $this->request->getPost('password'))) { $this->flashSession->success('<i class="close icon"></i>' . '<div class="ui header">Password changed!</div> ' . '<div class="content">Your password has been updated.</div>'); } } } } } else { $this->view->pick('msg'); $this->tag->setTitle(__('No access')); $this->view->setVar('title', __('No access')); $this->view->setVar('redirect', 'user/signin'); $this->flashSession->error($this->tag->linkTo(array('#', 'class' => 'close', 'title' => __("Close"), '×')) . '<strong>' . __('Error') . '!</strong> ' . __("Please log in to access.")); } }
/** * Get a list of all roles a user has. * This works better than the above * for getting a quick list! * * @param $user_id * @return array */ public function get_user_roles($user_id, $role = FALSE) { $roles = Users::getUserRoles($user_id, $role); return $roles; }