Beispiel #1
0
 private function sanitize()
 {
     if (false === ($this->pm = GWF_PM::getByID(Common::getGet('pmid')))) {
         return $this->module->error('err_pm');
     }
     if (false === $this->pm->canRead(GWF_Session::getUser())) {
         return $this->module->error('err_perm_read');
     }
     //		$this->term = Common::getGet('term', '');
     return false;
 }
Beispiel #2
0
 private function sanitize()
 {
     if (false === ($this->pm = GWF_PM::getByID(Common::getGet('pmid')))) {
         return $this->module->error('err_pm');
     }
     if ($this->pm->isRead()) {
         return $this->module->error('err_pm_read');
     }
     if (false === $this->pm->canEdit(GWF_Session::getUser())) {
         return $this->module->error('err_perm_write');
     }
     return false;
 }
Beispiel #3
0
 private function onDelete($id, $token, $uid)
 {
     if (false === ($pm = GWF_PM::getByID($id))) {
         return $this->module->error('err_pm');
     }
     if ($token != $pm->getHashcode()) {
         echo $pm->getHashcode();
         return $this->module->error('err_pm');
     }
     if (false === ($user = GWF_User::getByID($uid))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if (false === $pm->markDeleted($user)) {
         return $this->module->error('err_del_twice');
     }
     return $this->module->message('msg_deleted', array('1'));
 }
Beispiel #4
0
 private function onRestore($ids)
 {
     if (!is_array($ids)) {
         return '';
         #$this->module->error('err_delete');
     }
     $user = GWF_Session::getUser();
     $count = 0;
     foreach ($ids as $id => $stub) {
         if (false === ($pm = GWF_PM::getByID($id))) {
             continue;
         }
         if (false === $pm->canRead($user)) {
             continue;
         }
         if (false === $pm->markDeleted($user, false)) {
             continue;
         }
         $count++;
     }
     $this->sanitize();
     return $this->module->message('msg_restored', array($count));
 }
Beispiel #5
0
 private function send()
 {
     $form = $this->getForm();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateSend();
     }
     # Get reply to field
     if (false !== ($otherid = Common::getGetInt('reply', false))) {
     } elseif (false !== ($otherid = Common::getGetInt('quote', false))) {
     }
     $parent1 = $parent2 = 0;
     if ($otherid !== false) {
         if (false !== ($otherpm = GWF_PM::getByID($otherid))) {
             $parent1 = $otherpm->getID();
             if (false !== ($p2 = $otherpm->getOtherPM())) {
                 $parent2 = $p2;
             }
         }
     }
     $result = $this->module->deliver($this->user->getID(), $this->getReceiver()->getID(), $form->getVar('title'), $form->getVar('message'), $parent1, $parent2);
     $mail = '';
     switch ($result) {
         case '1':
             return $this->module->message('msg_mail_sent', array($this->getReceiver()->display('user_name')));
         case '0':
             break;
         case '-4':
             return GWF_HTML::err('ERR_MAIL_SENT');
         default:
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__ . ' - Code: ' . $result));
     }
     return $mail . $this->module->message('msg_sent');
 }
Beispiel #6
0
 private function onMove($ids = NULL)
 {
     $ids = Common::getPost('pm');
     if (!is_array($ids)) {
         return '';
     }
     $user = GWF_Session::getUser();
     if (false === ($folder = GWF_PMFolder::getByID(Common::getPost('folders')))) {
         return $this->module->error('err_folder');
     }
     if ($folder->getVar('pmf_uid') !== $user->getID()) {
         return $this->module->error('err_folder');
     }
     $count = 0;
     foreach ($ids as $id => $stub) {
         if (false === ($pm = GWF_PM::getByID($id))) {
             continue;
         }
         if (false === $pm->canRead($user)) {
             continue;
         }
         if (false === $pm->move($user, $folder)) {
             continue;
         }
         $count++;
     }
     $this->sanitize();
     return $this->module->message('msg_moved', array($count));
 }