Exemplo n.º 1
0
 /**
  * User login.
  *
  */
 public function indexAction()
 {
     // Check whether logged in.
     $identity = Zend_Auth::getInstance()->getIdentity();
     if ($identity) {
         $this->_redirectByIdentity();
     }
     $form = new Form_Client_Login();
     if ($this->_request->isPost()) {
         $params = $this->_request->getPost();
         if ($form->isValid($params)) {
             $email = $form->getValue('email');
             $password = $form->getValue('password');
             if (($result = Auth_Wrapper_User::login($email, $password)) === false) {
                 $this->view->errorMessage = $result !== false ? $result : 'Wrong email or password.';
             } else {
                 $this->_redirectByIdentity();
             }
         } else {
             $form->populate($params);
         }
     }
     $this->view->form = $form;
 }
Exemplo n.º 2
0
 /**
  * List one level of threads. Used as a recursive function.
  *
  * @param array $threads
  * @param integer $parentId
  * @return string
  */
 public static function threadList($threads, $parentId = false)
 {
     $html = Functions_View::HTML_DEFAULT_EMPTY;
     $childHtml = '';
     if ($threads && is_array($threads)) {
         foreach ($threads as $_thread) {
             if ((int) $_thread['parent_id'] == (int) $parentId) {
                 $html .= '<li class="list-group-item">';
                 $html .= '<h6><div class="pull-right">';
                 $html .= '</div><!--<input class="comment-approved" type="checkbox" rel="' . $_thread['id'] . '" ' . ($_thread['is_approved'] ? ' checked="checked"' : '') . '/>--> ';
                 $html .= $_thread['firstname'] . ' ' . $_thread['surname'] . ' says on ';
                 $html .= '<span class="small">' . Functions_Common::formattedDay($_thread['post_datetime'], parent::STD_DATE_FORMAT) . '</span></h6>';
                 $html .= '<div class="row thread-update-' . $_thread['id'] . '-body">' . $_thread['body'];
                 $html .= '</div>';
                 $html .= '<div class="row thread-update-' . $_thread['id'] . '-action" style="display: none">
                                 <div class="btn-group"><button class="btn btn-primary edit-thread" rel="' . $_thread['id'] . '">Update Comment</button><button class="btn btn-warning edit-thread-cancel" rel="' . $_thread['id'] . '">Cancel</button></div>
                             </div>';
                 $html .= '<div>';
                 $html .= '<a class="reply-handle" href="#" rel="thread-reply-' . $_thread['id'] . '">Reply</a>';
                 $html .= $_thread['user_id'] == Auth_Wrapper_User::getUserId() ? ' | <a class="edit-handle" href="#" rel="thread-update-' . $_thread['id'] . '">Edit</a>' : '';
                 $html .= $_thread['user_id'] == Auth_Wrapper_User::getUserId() ? ' | <a class="delete-handle" href="#" rel="' . $_thread['id'] . '">Delete</a>' : '';
                 $html .= '</div>';
                 // Edit
                 /*$html .= '<div class="row thread-update-' . $_thread['id'] . '" . style="display: none">
                       <div class="col-md-8">
                           <textarea rows="3" width="100%" class="form-control edit-thread-content">' . $_thread['body'] . '</textarea>
                       </div>
                       <div class="col-md-4">
                           <div class="btn-group"><button class="btn btn-primary edit-thread" rel="' . $_thread['id'] . '">Update Comment</button><button class="btn btn-warning edit-thread-cancel" rel="' . $_thread['id'] . '">Cancel</button></div>
                       </div>
                   </div>';*/
                 // Reply
                 $html .= '<div class="row thread-reply-' . $_thread['id'] . '" . style="display: none">
                             <div class="col-md-8">
                                 <textarea rows="3" width="100%" class="form-control new-thread"></textarea>
                             </div>
                             <div class="col-md-4">
                                 <div class="btn-group"><button class="btn btn-primary add-new-thread" rel="' . $_thread['id'] . '">Reply</button><button class="btn btn-warning add-new-thread-cancel" rel="' . $_thread['id'] . '">Cancel</button></div>
                             </div>
                         </div>';
                 $childHtml = self::threadList($threads, $_thread['id']);
                 if (!empty($childHtml)) {
                     $html .= '<div>&nbsp;</div><ul>' . $childHtml . '</ul></li>';
                 } else {
                     $html .= '</li>';
                 }
             }
         }
     }
     return $html;
 }
Exemplo n.º 3
0
 /**
  * Update the user with the form data.
  *
  * @param Object_User $user
  * @return boolean
  */
 public function updateUser($user)
 {
     if (!is_a($user, 'Object_User')) {
         return false;
     }
     // Check email duplication
     if (Repo_User::getInstance()->emailExists($this->getValue('email'), $user->id)) {
         $this->getElement('email')->addError('Email exists: ' . $this->getValue('email'));
         return false;
     } else {
         $user->email = $this->getValue('email');
     }
     $newPassword = $this->getValue('password');
     if (!empty($newPassword)) {
         $user->password = Auth_Wrapper_User::getPasswordHash($this->getValue('password'));
     }
     $roleIds = $this->getValue('role');
     $user->firstname = $this->getValue('firstname');
     $user->surname = $this->getValue('surname');
     $user->UDID = $this->getValue('UDID');
     if (is_array($roleIds)) {
         $roleIds = implode(',', $roleIds);
     }
     $user->role_id = $roleIds;
     $user->client_id = $this->getValue('client');
     return $user->save();
 }
Exemplo n.º 4
0
 /**
  * Admin logout.
  */
 public function adminAction()
 {
     if (Auth_Wrapper_User::logout()) {
         $this->_redirect('/admin');
     }
 }
Exemplo n.º 5
0
 /**
  * Check password pair.
  *
  * @param string $userId
  * @param string $password
  * @return boolean
  */
 public function checkPassword($userId, $password)
 {
     $user = new Object_User($userId);
     if (Auth_Wrapper_User::verifyAuth($user->email, $password) !== false) {
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Change password by providing the current password.
  *
  * @param string $old
  * @param string $new
  * @return mixed
  */
 public function changePassword($old, $new)
 {
     if (Auth_Wrapper_User::verifyAuth($this->email, $old) === false) {
         return 'Invalid current password provided';
     }
     $this->password = Auth_Wrapper_User::getPasswordHash($new);
     $this->save();
     return true;
 }