コード例 #1
0
 /**
  * IS: Parameter oldPassword, newPassword, newPassword2 terdeklarasi
  * FS: -
  * Desc: Fungsi yang mengatur aksi untuk proses change password
  */
 public function changeAction()
 {
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->layout()->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         // Param
         $oldPassword = $this->_getParam('oldPassword');
         $newPassword = $this->_getParam('newPassword');
         $newPassword2 = $this->_getParam('newPassword2');
         // Form
         $form = new Form_ChangePasswordForm();
         // Model
         $userDb = new Model_DbTable_User();
         // Data
         $userId = $userDb->getUserById($this->_sess->userId);
         header('Cache-Control: no-cache');
         if ($userId['password'] != md5($oldPassword)) {
             echo 'Your old password is incorrect';
         } elseif ($newPassword != $newPassword2) {
             echo 'Your confirm password is not match';
         } else {
             $userDb->resetPass(md5($newPassword), $this->_sess->userId);
             echo 'success';
         }
     }
 }
コード例 #2
0
 /**
  * Fungsi untuk memasukkan data comment
  * @return array
  */
 public function insertCommentUsercon($contentId, $contentType, $input, $userId, $fbname = '')
 {
     if (!preg_match('@^http://|https://@', $input['website']) and empty($fbname)) {
         $input['website'] = 'http://' . $input['website'];
     }
     date_default_timezone_set('Asia/Jakarta');
     $defaultData = array('content_id' => $contentId, 'content_type' => $contentType, 'comment_author_url' => $input['website'], 'comment_content' => $input['comment'], 'parent_id' => $input['parent_id'], 'level' => $input['level'], 'comment_date' => date('Y-m-d H:i:s'));
     if (isset($userId)) {
         $userDb = new Model_DbTable_User();
         $user = $userDb->getUserById($userId);
         $data = array('comment_author' => $user['name'], 'comment_author_email' => $user['email'], 'user_id' => $userId);
         if (!empty($fbname)) {
             $data['isfb'] = 1;
             $data['comment_author'] = $user['username'];
         }
         $defaultData = array_merge($defaultData, $data);
         return $this->insert($defaultData);
     } else {
         $data = array('comment_author' => $input['author'], 'comment_author_email' => $input['email']);
         $defaultData = array_merge($defaultData, $data);
         if (isset($input['author']) and isset($input['email'])) {
             return $this->insert($defaultData);
         }
     }
 }