Exemplo n.º 1
0
 public function request()
 {
     if (is_null($this->getRequestVar('commentid'))) {
         $this->redirect('comments/list');
     }
     $this->comment = new \fpcm\model\comments\comment($this->getRequestVar('commentid'));
     if (!$this->comment->exists()) {
         $this->view->setNotFound('LOAD_FAILED_COMMENT', 'comments/list');
         return true;
     }
     if (!$this->comment->getEditPermission()) {
         $this->view = new \fpcm\model\view\error();
         $this->view->addErrorMessage('PERMISSIONS_REQUIRED');
         $this->view->render();
         return false;
     }
     if ($this->buttonClicked('commentSave') && $this->getRequestVar('comment')) {
         $commentData = $this->getRequestVar('comment', array(4, 7));
         $this->comment->setText($commentData['text']);
         unset($commentData['text']);
         foreach ($commentData as &$value) {
             $value = \fpcm\classes\http::filter($value, array(1, 3));
         }
         $this->comment->setName($commentData['name']);
         $this->comment->setEmail($commentData['email']);
         $this->comment->setWebsite($commentData['website']);
         if ($this->approve) {
             $this->comment->setApproved(isset($commentData['approved']) ? true : false);
             $this->comment->setSpammer(isset($commentData['spam']) ? true : false);
         }
         if ($this->private) {
             $this->comment->setPrivate(isset($commentData['private']) ? true : false);
         }
         $this->comment->setChangetime(time());
         $this->comment->setChangeuser($this->session->getUserId());
         if ($this->comment->update()) {
             $this->view->addNoticeMessage('SAVE_SUCCESS_COMMENT');
         } else {
             $this->view->addErrorMessage('SAVE_FAILED_COMMENT');
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public function request()
 {
     if (is_null($this->getRequestVar('id'))) {
         $this->redirect('users/list');
     }
     $userRoll = new \fpcm\model\users\userRoll($this->getRequestVar('id'));
     if (!$userRoll->exists()) {
         $this->view->setNotFound('LOAD_FAILED_ROLL', 'users/list');
         return true;
     }
     if ($this->buttonClicked('saveRoll')) {
         $userRoll->setRollName($this->getRequestVar('rollname'));
         if ($userRoll->update()) {
             $this->redirect('users/list', array('edited' => 2));
         } else {
             $this->view->addErrorMessage('SAVE_FAILED_ROLL');
         }
     }
     $this->view->assign('userRoll', $userRoll);
     $this->view->addJsVars(array('fpcmNavigationActiveItemId' => 'submenu-itemnav-item-users'));
     return true;
 }
Exemplo n.º 3
0
 public function request()
 {
     if (is_null($this->getRequestVar('userid'))) {
         $this->redirect('users/list');
     }
     $this->userId = $this->getRequestVar('userid', array(9));
     $author = new \fpcm\model\users\author($this->userId);
     if (!$author->exists()) {
         $this->view->setNotFound('LOAD_FAILED_USER', 'users/list');
         return true;
     }
     $checkPageToken = $this->checkPageToken();
     if (($this->buttonClicked('userSave') || $this->buttonClicked('resetProfileSettings')) && !$checkPageToken) {
         $this->view->addErrorMessage('CSRF_INVALID');
     }
     if ($this->buttonClicked('resetProfileSettings') && $checkPageToken) {
         $author->setUserMeta(array());
         $author->disablePasswordSecCheck();
         if ($author->update() === false) {
             $this->view->addErrorMessage('SAVE_FAILED_USER_PROFILE');
         } else {
             $this->view->addNoticeMessage('SAVE_SUCCESS_RESETPROFILE');
             $this->view->assign('reloadSite', true);
         }
     }
     if ($this->buttonClicked('userSave') && $checkPageToken) {
         $author->setUserName($this->getRequestVar('username'));
         $author->setEmail($this->getRequestVar('email'));
         $author->setDisplayName($this->getRequestVar('displayname'));
         $author->setRoll($this->getRequestVar('roll', array(9)));
         $author->setUserMeta($this->getRequestVar('usermeta'));
         if ($this->getRequestVar('disabled') !== null) {
             $author->setDisabled($this->getRequestVar('disabled', array(9)));
         }
         $newpass = $this->getRequestVar('password');
         $newpass_confirm = $this->getRequestVar('password_confirm');
         $save = true;
         if ($newpass && $newpass_confirm) {
             if (md5($newpass) == md5($newpass_confirm)) {
                 $author->setPassword($newpass);
             } else {
                 $save = false;
                 $this->view->addErrorMessage('SAVE_FAILED_PASSWORD_MATCH');
             }
         } else {
             $author->disablePasswordSecCheck();
         }
         if ($save) {
             $res = $author->update();
             if ($res === false) {
                 $this->view->addErrorMessage('SAVE_FAILED_USER');
             } elseif ($res === true) {
                 $this->redirect('users/list', array('edited' => 1));
             } elseif ($res === \fpcm\model\users\author::AUTHOR_ERROR_PASSWORDINSECURE) {
                 $this->view->addErrorMessage('SAVE_FAILED_PASSWORD_SECURITY');
             } elseif ($res === \fpcm\model\users\author::AUTHOR_ERROR_EXISTS) {
                 $this->view->addErrorMessage('SAVE_FAILED_USER_EXISTS');
             } elseif ($res === \fpcm\model\users\author::AUTHOR_ERROR_NOEMAIL) {
                 $this->view->addErrorMessage('SAVE_FAILED_USER_EMAIL');
             }
         }
     }
     $this->userEnabled = $author->getDisabled();
     $this->view->assign('author', $author);
     return true;
 }