예제 #1
0
파일: AddAttach.php 프로젝트: sinfocol/gwf3
 private function onAdd()
 {
     $form = $this->formAdd();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateAdd();
     }
     $file = $form->getVar('file');
     $tmp = $file['tmp_name'];
     $postid = $this->post->getID();
     $userid = GWF_Session::getUserID();
     $options = 0;
     $options |= isset($_POST['guest_view']) ? GWF_ForumAttachment::GUEST_VISIBLE : 0;
     $options |= isset($_POST['guest_down']) ? GWF_ForumAttachment::GUEST_DOWNLOAD : 0;
     # Put in db
     $attach = new GWF_ForumAttachment(array('fatt_aid' => 0, 'fatt_uid' => $userid, 'fatt_pid' => $postid, 'fatt_mime' => GWF_Upload::getMimeType($tmp), 'fatt_size' => filesize($tmp), 'fatt_downloads' => 0, 'fatt_filename' => $file['name'], 'fatt_options' => $options, 'fatt_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)));
     if (false === $attach->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $aid = $attach->getID();
     # Copy file
     $path = $attach->dbimgPath();
     if (false === GWF_Upload::moveTo($file, $path)) {
         @unlink($tmp);
         return GWF_HTML::err('ERR_WRITE_FILE', $path);
     }
     @unlink($tmp);
     $this->post->increase('post_attachments', 1);
     return $this->module->message('msg_attach_added', array($this->post->getShowHREF()));
 }
예제 #2
0
 public static function pushPost(GWF_ForumPost $post)
 {
     $history = new self(array('fph_pid' => $post->getID(), 'fph_euid' => $post->getUserID(), 'fph_gid' => $post->getGroupID(), 'fph_date' => $post->getDate(), 'fph_message' => $post->getVar('post_message'), 'fph_options' => $post->getOptions()));
     return $history->insert();
 }
예제 #3
0
 public static function sendModeratePost(Module_Forum $module, GWF_ForumPost $post)
 {
     $thread = $post->getThread();
     $boardtxt = self::getBoardTreeText($thread->getBoard());
     $threadtxt = $thread->display('thread_title');
     $usertxt = GWF_User::getStaticOrGuest()->display('user_name');
     $title = $post->displayTitle();
     $message = $post->displayMessage(array(), true);
     $pid = $post->getID();
     $token = $post->getToken();
     $addtxt = Common::getAbsoluteURL('index.php?mo=Forum&me=Moderate&yes_post=' . $pid . '&token=' . $token);
     $remtxt = Common::getAbsoluteURL('index.php?mo=Forum&me=Moderate&no_post=' . $pid . '&token=' . $token);
     return self::sendModMail($module, $boardtxt, $threadtxt, $usertxt, $title, $message, $addtxt, $remtxt);
 }
예제 #4
0
 public function getPostHREF(GWF_ForumPost $post, $term = '')
 {
     $module = Module_Forum::getInstance();
     $ipp = $module->getPostsPerThread();
     $tid = $this->getID();
     $cut = $post->getVar('post_date');
     $nItems = $post->countRows("post_tid={$tid} AND post_date<'{$cut}'");
     $page = GWF_PageMenu::getPagecount($ipp, $nItems + 1);
     return $this->getPageHREF($page, $term) . '#post' . $post->getID();
 }
예제 #5
0
 public function getPostID()
 {
     return $this->post->getID();
 }