/** * Constructor * * @access public * @param object ipsRegistry reference * @return void */ public function __construct(ipsRegistry $registry) { parent::__construct($registry); /* Load and init forums */ if (ipsRegistry::isClassLoaded('class_forums') !== TRUE) { try { require_once IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php"; $this->registry->setClass('class_forums', new class_forums($registry)); } catch (Exception $error) { IPS_exception_error($error); } $this->registry->getClass('class_forums')->strip_invisible = 1; $this->registry->getClass('class_forums')->forumsInit(); } }
/** * Constructor * * @param object ipsRegistry reference * @return @e void */ public function __construct(ipsRegistry $registry) { parent::__construct($registry); /* Load and init forums */ if (ipsRegistry::isClassLoaded('class_forums') !== TRUE) { try { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums'); $this->registry->setClass('class_forums', new $classToLoad($registry)); } catch (Exception $error) { IPS_exception_error($error); } $this->registry->getClass('class_forums')->strip_invisible = 1; $this->registry->getClass('class_forums')->forumsInit(); $this->memberData = IPSMember::setUpModerator($this->memberData); } /* Load topic class */ if (!$this->registry->isClassLoaded('topics')) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums'); $this->registry->setClass('topics', new $classToLoad($this->registry)); } }
/** * Show PM form * * @access private * @param array Array of errors * @return string returns HTML */ private function _showNewTopicForm($errors = '') { //----------------------------------------- // INIT //----------------------------------------- /* Check max per day */ if ($this->messengerFunctions->checkHasHitMax()) { $this->registry->getClass('output')->showError('maxperday_hit', 10271); } /* Check PM flood */ if ($this->messengerFunctions->floodControlCheck() !== TRUE) { $this->registry->getClass('output')->showError(sprintf($this->lang->words['pm_flood_stop'], $this->messengerFunctions->exceptionData[0]), 010271); } $_msg_id = 0; $formMemberID = intval($this->request['fromMemberID']); # WAS MID $topicID = intval($this->request['topicID']); $preview = $this->request['preview']; $inviteUsers = array(); $displayData = array('errors' => $errors, 'topicID' => $topicID, 'preview' => '', 'name' => '', 'title' => '', 'message' => ''); $_POST['Post-NS'] = isset($_POST['Post']) ? $_POST['Post'] : ''; $_POST['Post'] = IPSText::removeMacrosFromInput(IPSText::raw2form(isset($_POST['Post']) ? $_POST['Post'] : '')); //----------------------------------------- // Preview post? //----------------------------------------- if ($preview) { /* Grab language for attachment previews */ $this->registry->getClass('class_localization')->loadLanguageFile(array("public_topic"), 'forums'); IPSText::getTextClass('bbcode')->parse_html = $this->settings['msg_allow_html']; IPSText::getTextClass('bbcode')->parse_nl2br = 1; IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['msg_allow_code']; IPSText::getTextClass('bbcode')->parsing_section = 'pms'; IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others']; $this->settings['max_emos'] = 0; $old_msg = IPSText::getTextClass('editor')->processRawPost('Post-NS'); $old_msg = IPSText::getTextClass('bbcode')->preDisplayParse(IPSText::getTextClass('bbcode')->preDbParse($old_msg)); if (!is_object($this->class_attach)) { //----------------------------------------- // Grab render attach class //----------------------------------------- require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $this->class_attach = new class_attach($this->registry); } //----------------------------------------- // Continue... //----------------------------------------- $this->class_attach->type = 'msg'; $this->class_attach->attach_post_key = $this->_postKey; $this->class_attach->init(); $attachData = $this->class_attach->renderAttachments(array(0 => $old_msg)); $displayData['preview'] = $attachData[0]['html'] . $attachData[0]['attachmentHtml']; } //----------------------------------------- // Errors //----------------------------------------- if ($errors or IPSText::getTextClass('bbcode')->error != "") { if (IPSText::getTextClass('bbcode')->error) { $displayData['errors'][] = $this->lang->words[IPSText::getTextClass('bbcode')->error]; } $preview = 1; } //----------------------------------------- // Did we come from a button with a user ID? //----------------------------------------- if ($formMemberID) { $name = IPSMember::load($formMemberID, 'core'); if ($name['member_id']) { $displayData['name'] = $name['members_display_name']; } } else { $displayData['name'] = $this->request['entered_name'] ? $this->request['entered_name'] : ''; } //----------------------------------------- // Are we quoting an old message? //----------------------------------------- if ($preview) { $displayData['message'] = $_POST['Post-NS']; $displayData['title'] = str_replace("'", "'", str_replace('"', '"', IPSText::stripslashes($_POST['msg_title']))); } else { if ($topicID) { $draftTopic = $this->messengerFunctions->fetchTopicDataWithMessage($topicID, TRUE); if ($draftTopic['mt_to_member_id']) { $displayData['name'] = $draftTopic['from_name']; } if ($draftTopic['mt_title']) { $_member = IPSMember::load($draftTopic['mt_to_member_id'], 'core'); $displayData['name'] = $_member['members_display_name']; $displayData['title'] = $draftTopic['mt_title']; $_msg_id = $draftTopic['msg_id']; $this->_postKey = $draftTopic['msg_post_key']; IPSText::getTextClass('bbcode')->parse_html = $this->settings['msg_allow_html']; IPSText::getTextClass('bbcode')->parse_nl2br = 1; IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['msg_allow_code']; IPSText::getTextClass('bbcode')->parsing_section = 'pms'; $displayData['message'] = IPSText::getTextClass('bbcode')->preEditParse($draftTopic['msg_post']); } } } //----------------------------------------- // CC Boxes //----------------------------------------- if ($this->memberData['g_max_mass_pm'] > 0) { if ($_POST['inviteUsers']) { $displayData['inviteUsers'] = $_POST['inviteUsers']; } else { if ($draftTopic['mt_invited_members']) { $_inviteUsers = $this->messengerFunctions->getInvitedUsers($draftTopic['mt_invited_members']); $__inviteUsers = IPSMember::load($_inviteUsers, 'core'); if (is_array($__inviteUsers)) { $_tmp = array(); foreach ($__inviteUsers as $id => $data) { $_tmp[] = $data['members_display_name']; } if (is_array($_tmp)) { $displayData['inviteUsers'] = implode(", ", $_tmp); } } } } } //----------------------------------------- // Remove side panel //----------------------------------------- IPSText::getTextClass('editor')->remove_side_panel = 1; //----------------------------------------- // PM returns //----------------------------------------- if (IPSText::getTextClass('editor')->method == 'rte' and $displayData['message'] and $fromMsgID) { $displayData['message'] = IPSText::getTextClass('bbcode')->convertForRTE(nl2br($displayData['message'])); } else { if (IPSText::getTextClass('editor')->method == 'std' and $displayData['message'] and $fromMsgID) { $displayData['message'] = IPSText::getTextClass('bbcode')->preEditParse($displayData['message']); } } //----------------------------------------- // Is this RTE? If so, convert BBCode //----------------------------------------- if (IPSText::getTextClass('editor')->method == 'rte' and $displayData['message']) { if (count($errors) or $preview) { $displayData['message'] = stripslashes($displayData['message']); } $displayData['message'] = IPSText::getTextClass('bbcode')->convertForRTE($displayData['message']); } else { if ($displayData['message']) { $displayData['message'] = IPSText::stripslashes($displayData['message']); } } $displayData['editor'] = IPSText::getTextClass('editor')->showEditor($displayData['message'], 'Post'); //----------------------------------------- // More Data... //----------------------------------------- $displayData['uploadData'] = $this->_canUpload ? array('canUpload' => 1) : array('canUpload' => 0); $displayData['postKey'] = $this->_postKey; //----------------------------------------- // Load attachments so we get some stats //----------------------------------------- require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = 'msg'; $class_attach->init(); $class_attach->getUploadFormSettings(); $displayData['uploadData']['attach_stats'] = $class_attach->attach_stats; //----------------------------------------- // Build up the HTML for the send form //----------------------------------------- $this->_title = $this->lang->words['sendMsgTitle']; $this->_navigation[] = array($this->lang->words['sendMsgTitle'], ''); return $this->registry->getClass('output')->getTemplate('messaging')->sendNewPersonalTopicForm($displayData); }
/** * Makes attachments permananent * * @access private * @param string Post Key * @param int Msg ID * @param int Topic ID * @return int */ private function _makeAttachmentsPermanent($postKey, $msgID, $topicID) { //----------------------------------------- // INIT //----------------------------------------- $cnt = array('cnt' => 0); //----------------------------------------- // Attachments: Re-affirm... //----------------------------------------- require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = 'msg'; $class_attach->attach_post_key = $postKey; $class_attach->attach_rel_id = $msgID; $class_attach->init(); $return = $class_attach->postProcessUpload(array('mt_id' => $topicID)); return intval($return['count']); }
/** * Show the reply form * * @access protected * @param string Type of form (new/reply/add) * @param array Array of extra data * @return void [Passes data to classOutput] */ protected function _displayForm($formType, $extraData = array()) { //----------------------------------------- // Set up //----------------------------------------- $output = ''; $titleText = ''; $buttonText = ''; $doCode = ''; $topText = ''; $checkFunc = ''; //----------------------------------------- // Work out function type //----------------------------------------- switch ($formType) { default: case 'reply': $checkFunc = 'replySetUp'; break; case 'new': $checkFunc = 'topicSetUp'; break; case 'edit': $checkFunc = 'editSetUp'; break; } //----------------------------------------- // Global checks and functions //----------------------------------------- try { $this->globalSetUp(); } catch (Exception $error) { throw new Exception($error->getMessage()); } //----------------------------------------- // Form specific... //----------------------------------------- try { $topic = $this->{$checkFunc}(); } catch (Exception $error) { throw new Exception($error->getMessage()); } //----------------------------------------- // Work out elements //----------------------------------------- switch ($formType) { default: case 'reply': $doCode = 'reply_post_do'; $titleText = $this->lang->words['top_txt_reply'] . ' ' . $topic['title']; $buttonText = $this->lang->words['submit_reply']; $topText = $this->lang->words['replying_in'] . ' ' . $topic['title']; break; case 'new': $doCode = 'new_post_do'; $titleText = $this->lang->words['top_txt_new'] . $this->getForumData('name'); $buttonText = $this->lang->words['submit_new']; $topText = $this->lang->words['posting_new_topic']; break; case 'edit': $doCode = 'edit_post_do'; $titleText = $this->lang->words['top_txt_edit'] . ' ' . $topic['title']; $buttonText = $this->lang->words['submit_edit']; $topText = $this->lang->words['editing_post'] . ' ' . $topic['title']; /* Reset reason for edit */ $extraData['reasonForEdit'] = $this->request['post_edit_reason'] ? $this->request['post_edit_reason'] : $this->_originalPost['post_edit_reason']; /* Reset check boxes and such */ $this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'], 'enableEmoticons' => $this->_originalPost['use_emo'], 'post_htmlstatus' => $this->_originalPost['post_htmlstate'], 'enableTracker' => (intval($this->request['enabletrack']) != 0 or $this->getIsPreview() !== TRUE) ? 1 : 0)); break; } //----------------------------------------- // Parse the post, and check for any errors. //----------------------------------------- $post = $this->compilePostData(); $postContent = $this->getPostContentPreFormatted() ? $this->getPostContentPreFormatted() : $this->getPostContent(); //----------------------------------------- // Hmmmmm.... //----------------------------------------- $postContent = $this->_afterPostCompile($postContent, $formType); //----------------------------------------- // Compile the poll //----------------------------------------- $this->poll_questions = $this->compilePollData(); //----------------------------------------- // Are we quoting posts? //----------------------------------------- $postContent = $this->_checkMultiQuote($postContent); //----------------------------------------- // RTE? Convert RIGHT tags that QUOTE would // have put there // Commented out 14/7/08 - _afterPostCompile handles this for edit, and should // also handle for any other type if they need it... //----------------------------------------- /*if ( IPSText::getTextClass('editor')->method == 'rte' ) { $postContent = IPSText::getTextClass('bbcode')->convertForRTE( $postContent ); }*/ //----------------------------------------- // Do we have any posting errors? //----------------------------------------- if ($this->_postErrors) { $output .= $this->registry->getClass('output')->getTemplate('post')->errors($this->lang->words[$this->_postErrors]); } if ($this->getIsPreview()) { $output .= $this->registry->getClass('output')->getTemplate('post')->preview($this->_generatePostPreview($this->getPostContentPreFormatted() ? $this->getPostContentPreFormatted() : $this->getPostContent(), $this->post_key)); } /* Defaults */ if (!isset($extraData['checked'])) { $extraData['checked'] = ''; } //----------------------------------------- // Gather status messages //----------------------------------------- /* status from mod posts */ $this->registry->getClass('class_forums')->checkGroupPostPerDay($this->getAuthor(), TRUE); $_statusMsg[] = $this->registry->getClass('class_forums')->ppdStatusMessage; $_statusMsg[] = $this->registry->getClass('class_forums')->fetchPostModerationStatusMessage($this->getAuthor(), $this->getForumData(), $topic, $formType); //----------------------------------------- // Load attachments so we get some stats //----------------------------------------- require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = 'post'; $class_attach->attach_post_key = $this->post_key; $class_attach->init(); $class_attach->getUploadFormSettings(); //----------------------------------------- // START TABLE //----------------------------------------- $output .= $this->registry->getClass('output')->getTemplate('post')->postFormTemplate(array('title' => $titleText, 'captchaHTML' => $this->_generateGuestCaptchaHTML(), 'checkBoxes' => $this->_generateCheckBoxes($formType, isset($topic['tid']) ? $topic['tid'] : 0, $this->getForumData('id')), 'editor' => IPSText::getTextClass('editor')->showEditor($postContent, 'Post'), 'buttonText' => $buttonText, 'uploadForm' => $this->can_upload ? $this->registry->getClass('output')->getTemplate('post')->uploadForm($this->post_key, 'post', $class_attach->attach_stats, $this->getPostID(), $this->getForumData('id')) : "", 'postIconSelected' => $this->_generatePostIcons(), 'topicSummary' => $this->_generateTopicSummary($topic['tid']), 'formType' => $formType, 'extraData' => $extraData, 'modOptionsData' => $this->_generateModOptions($topic, $formType), 'pollBoxHTML' => $this->_generatePollBox($formType), 'canEditTitle' => $this->edit_title, 'topicTitle' => $this->_topicTitle ? $this->_topicTitle : $topic['title'], 'topicDesc' => $this->_topicDescription ? $this->_topicDescription : $topic['description'], 'seoTopic' => $topic['title_seo'], 'seoForum' => $this->getForumData('name_seo'), 'statusMsg' => $_statusMsg), array('doCode' => $doCode, 'p' => $this->getPostID(), 't' => $topic['tid'], 'f' => $this->getForumData('id'), 'parent' => ipsRegistry::$request['parent_id'] ? intval(ipsRegistry::$request['parent_id']) : 0, 'attach_post_key' => $this->post_key)); //----------------------------------------- // Reset multi-quote cookie //----------------------------------------- IPSCookie::set('mqtids', ',', 0); //----------------------------------------- // Send for output //----------------------------------------- $this->registry->getClass('output')->setTitle($topText . ' - ' . $this->settings['board_name']); $this->registry->getClass('output')->addContent($output); $this->nav = $this->registry->getClass('class_forums')->forumsBreadcrumbNav($this->getForumData('id')); if (isset($topic['tid']) and $topic['tid']) { $this->nav[] = array($topic['title'], "showtopic={$topic['tid']}", $topic['title_seo'], 'showtopic'); } if (is_array($this->nav) and count($this->nav)) { foreach ($this->nav as $_nav) { $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1], $_nav[2], $_nav[3]); } } $this->registry->getClass('output')->sendOutput(); }
/** * Upload any attachments that were not handled by the flash or JS uploaders * * @access public * @param string $post_key * @param integer $rel_id * @return array **/ public function uploadAttachments($post_key, $rel_id) { /* Setup Attachment Handler */ require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = 'post'; $class_attach->attach_post_key = $post_key; $class_attach->attach_rel_id = $rel_id; $class_attach->init(); return $class_attach->processMultipleUploads(); }
/** * XMLRPC_server::deletePost() * * Deletes a Blog entry. * * @access public * @param string $appkey Appkey (ignored) * @param int $postid Entry ID * @param string $username Username * @param string $password Password * @param bool $publish Publish (ignored) * @return string xml **/ public function deletePost($appkey, $postid, $username, $password, $publish) { $this->registry->class_localization->loadLanguageFile(array('public_portal'), 'blog'); //----------------------------------------- // Authenticate //----------------------------------------- if ($this->_authenticate($username, $password)) { if (!$this->registry->blog_std->allowDelEntry($this->blog)) { $this->classApiServer->apiSendError(100, $this->registry->class_localization->words['blogger_error_1']); exit; } //----------------------------------------- // find the entry //----------------------------------------- $eid = intval($postid); $entry = $this->registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'blog_entries', 'where' => "entry_id = " . $eid)); if (!$entry['entry_id']) { $this->classApiServer->apiSendError(100, sprintf($this->registry->class_localization->words['blogger_error_2'], $eid)); exit; } //----------------------------------------- // delete the entry //----------------------------------------- $this->registry->DB()->delete('blog_comments', "entry_id=" . $eid); require_once IPSLib::getAppDir('core') . 'sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = 'blogentry'; $class_attach->init(); $class_attach->bulkRemoveAttachment(array($eid)); $this->registry->DB()->delete('blog_trackback', "entry_id = {$eid}"); $this->registry->DB()->delete('blog_polls', "entry_id = {$eid}"); $this->registry->DB()->delete('blog_voters', "entry_id = {$eid}"); $this->registry->DB()->delete('blog_entries', "entry_id = {$eid}"); $this->registry->blog_std->rebuildBlog($this->blog['blog_id']); $this->registry->DB()->update('blog_blogs', array('blog_last_delete' => time()), "blog_id={$this->blog['blog_id']}"); //------------------------------------------------- // Update the Blog stats //------------------------------------------------- $r = $this->registry->cache()->getCache('blog_stats'); $r['blog_stats']['stats_num_entries']--; $r['blog_stats']['stats_num_comments'] -= $entry['entry_num_comments']; $this->registry->cache()->setCache('blog_stats', $r, array('array' => 1, 'deletefirst' => 0, 'donow' => 1)); $this->addModlog($this->registry->class_localization->words['blogger_blog_prefix'] . "({$this->blog['blog_id']}) '{$this->blog['blog_name']}': {$this->registry->class_localization->words['blogger_deleted_log']} '{$entry['entry_name']}'"); //------------------------------------------------- // Return //------------------------------------------------- $this->classApiServer->apiSendReply(); exit; } else { $this->classApiServer->apiSendError(100, $this->error); exit; } }
/** * Delete a topic * * @access public * @param mixed Topic id | Array of topic ids * @param boolean Skip updating the stats * @return boolean */ public function topicDelete($id, $nostats = 0) { $posts = array(); $attach = array(); $this->error = ""; if (is_array($id)) { $id = IPSLib::cleanIntArray($id); if (count($id) > 0) { $tid = " IN(" . implode(",", $id) . ")"; } else { return false; } } else { if (intval($id)) { $tid = "={$id}"; } else { return false; } } //----------------------------------------- // Remove polls assigned to this topic //----------------------------------------- $this->DB->delete('polls', "tid" . $tid); $this->DB->delete('voters', "tid" . $tid); $this->DB->delete('tracker', "topic_id" . $tid); $this->DB->delete('topic_ratings', "rating_tid" . $tid); $this->DB->delete('topic_views', "views_tid" . $tid); $this->DB->delete('topics', "tid" . $tid); //----------------------------------------- // Get PIDS for attachment deletion //----------------------------------------- $this->DB->build(array('select' => 'pid', 'from' => 'posts', 'where' => "topic_id" . $tid)); $this->DB->execute(); while ($r = $this->DB->fetch()) { $posts[] = $r['pid']; } /* Remove cache content */ IPSContentCache::drop('post', $posts); //----------------------------------------- // Remove the attachments //----------------------------------------- require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = 'post'; $class_attach->init(); $class_attach->bulkRemoveAttachment($posts); //----------------------------------------- // Remove the posts //----------------------------------------- $this->DB->delete('posts', "topic_id" . $tid); $this->DB->delete('search_index', "type='forum' AND type_2='topic' AND type_id_2 " . $tid); $this->DB->delete('reputation_cache', "app='forums' AND type='pid' AND type_id " . $tid); $this->DB->delete('reputation_index', "app='forums' AND type='pid' AND type_id " . $tid); //----------------------------------------- // Recount forum... //----------------------------------------- if (!$nostats) { if ($this->forum['id']) { $this->registry->class_forums->allForums[$this->forum['id']]['_update_deletion'] = 1; $this->forumRecount($this->forum['id']); } $this->statsRecount(); } return TRUE; }
/** * Rebuild Export Cache * * @access public * @param mixed $rss_export_id Which export id to execute * @param bool $return Whether to return afterwards or output to page * @return mixed **/ public function rssExportRebuildCache($rss_export_id = '', $return = true) { /* INIT */ if (!$rss_export_id) { $rss_export_id = $this->request['rss_export_id'] == 'all' ? 'all' : intval($this->request['rss_export_id']); } /* Check ID */ if (!$rss_export_id) { $this->registry->output->global_message = $this->lang->words['ex_noid']; $this->rssExportOverview(); return; } /* Get RSS Clas */ require_once IPS_KERNEL_PATH . 'classRss.php'; $class_rss = new classRss(); $class_rss->use_sockets = $this->use_sockets; $class_rss->doc_type = IPS_DOC_CHAR_SET; /* Reset rss_export cache */ $this->cache->updateCacheWithoutSaving('rss_export', array()); /* Go loopy */ $this->DB->build(array('select' => '*', 'from' => 'rss_export')); $outer = $this->DB->execute(); $cache = array(); while ($row = $this->DB->fetch($outer)) { /* Update RSS Cache */ if ($row['rss_export_enabled']) { $cache[] = array('url' => $this->settings['board_url'] . '/index.php?act=rssout&id=' . $row['rss_export_id'], 'title' => $row['rss_export_title']); } /* Add to cache? */ if ($rss_export_id == 'all' or $row['rss_export_id'] == $rss_export_id) { /* Build DB Query */ if ($row['rss_export_include_post']) { $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.forum_id IN( " . $row['rss_export_forums'] . " ) AND t.state != 'link' AND t.approved=1", 'order' => 't.' . $row['rss_export_order'] . ' ' . $row['rss_export_sort'], 'limit' => array(0, $row['rss_export_count']), 'add_join' => array(array('select' => 'p.pid, p.post, p.use_emo, p.post_htmlstate', 'from' => array('posts' => 'p'), 'where' => 't.topic_firstpost=p.pid', 'type' => 'left')))); } else { $this->DB->build(array('select' => '*', 'from' => 'topics', 'where' => "forum_id IN( " . $row['rss_export_forums'] . " ) AND state != 'link' AND approved=1", 'order' => $row['rss_export_order'] . ' ' . $row['rss_export_sort'], 'limit' => array(0, $row['rss_export_count']))); } /* Exec Query */ $inner = $this->DB->execute(); /* Set var. Doing this so we can set pubDate to start date or last post date appropriately... */ $channelCreated = false; /* Loop through topics and display */ while ($topic = $this->DB->fetch($inner)) { //----------------------------------------- // Create channel if not already crated //----------------------------------------- if (!$channelCreated) { /* Create Channel */ $channel_id = $class_rss->createNewChannel(array('title' => $row['rss_export_title'], 'description' => $row['rss_export_desc'], 'link' => $this->settings['board_url'] . '/index.php', 'pubDate' => $class_rss->formatDate($row['rss_export_order'] == 'start_date' ? $topic['start_date'] : $topic['last_post']), 'ttl' => $row['rss_export_cache_time'])); if ($row['rss_export_image']) { $class_rss->addImageToChannel($channel_id, array('title' => $row['rss_export_title'], 'url' => $row['rss_export_image'], 'link' => $this->settings['board_url'] . '/index.php')); } $channelCreated = true; } //----------------------------------------- // Parse the post //----------------------------------------- $this->settings['__noTruncateUrl'] = 1; IPSText::getTextClass('bbcode')->parse_smilies = $topic['use_emo']; IPSText::getTextClass('bbcode')->parse_html = ($this->registry->class_forums->forum_by_id[$topic['forum_id']]['use_html'] and $topic['post_htmlstate']) ? 1 : 0; IPSText::getTextClass('bbcode')->parse_nl2br = $topic['post_htmlstate'] == 2 ? 1 : 0; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'topics'; $topic['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($topic['post']); if ($row['rss_export_include_post'] and $topic['topic_hasattach']) { if (!is_object($_attachments)) { //----------------------------------------- // Grab render attach class //----------------------------------------- require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $_attachments = new class_attach($this->registry); } $_attachments->type = 'post'; $_attachments->init(); # attach_pids is generated in the func_topic_xxxxx files $attachHTML = $_attachments->renderAttachments(array($topic['pid'] => $topic['post']), array($topic['pid'] => $topic['pid'])); /* Now parse back in the rendered posts */ if (is_array($attachHTML) and count($attachHTML)) { foreach ($attachHTML as $id => $data) { /* Get rid of any lingering attachment tags */ if (stristr($data['html'], "[attachment=")) { $data['html'] = IPSText::stripAttachTag($data['html']); } $topic['post'] = $data['html']; $topic['post'] .= $data['attachmentHtml']; } } } /* Parse */ //$topic['post'] = preg_replace( "#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is", "<a href='{$this->settings['board_url']}/index.php?app=core&module=attach§ion=attach&attach_rel_module=post&attach_id=\\1'>".$this->settings['board_url']."/index.php?app=forums&module=forums§ion=attach&type=post&attach_id=\\1</a>", $topic['post'] ); /* Fix up relative URLs */ $topic['post'] = preg_replace("#([^/])style_images/(<\\#IMG_DIR\\#>)#is", "\\1" . $this->settings['board_url'] . "/style_images/\\2", $topic['post']); $topic['post'] = preg_replace("#([\"'])style_emoticons/#is", "\\1" . $this->settings['board_url'] . "/style_emoticons/", $topic['post']); $topic['post'] = $this->registry->output->replaceMacros($topic['post']); $topic['last_poster_name'] = $topic['last_poster_name'] ? $topic['last_poster_name'] : 'Guest'; $topic['starter_name'] = $topic['starter_name'] ? $topic['starter_name'] : 'Guest'; /* Add item */ $class_rss->addItemToChannel($channel_id, array('title' => $topic['title'], 'link' => $this->registry->output->buildSEOUrl('showtopic=' . $topic['tid'], 'public', $topic['title_seo'], 'showtopic'), 'description' => $topic['post'], 'pubDate' => $class_rss->formatDate($row['rss_export_order'] == 'last_post' ? $topic['last_post'] : $topic['start_date']), 'guid' => $this->registry->output->buildSEOUrl('showtopic=' . $topic['tid'], 'public', $topic['title_seo'], 'showtopic'))); } /* Build document */ $class_rss->createRssDocument(); /* Update the cache */ $this->DB->update('rss_export', array('rss_export_cache_last' => time(), 'rss_export_cache_content' => $class_rss->rss_document), 'rss_export_id=' . $row['rss_export_id']); } } /* Update cache */ $this->cache->setCache('rss_export', $cache, array('deletefirst' => 1, 'donow' => 1, 'array' => 1)); $this->cache->rebuildCache('rss_output_cache'); /* Return */ if ($return) { $this->registry->output->global_message = $this->lang->words['ex_recached']; $this->rssExportOverview(); return; } else { return $class_rss->rss_document; } }
/** * Post multi-mod: Merge posts * * @access private * @return void [Outputs to screen] */ private function _multiMergePost() { $this->_resetModerator($this->topic['forum_id']); $this->_genericPermissionCheck('delete_post'); if (count($this->pids) < 2) { $this->_showError('mod_only_one_pid', 10383); } //----------------------------------------- // Form or print? //----------------------------------------- if (!$this->request['checked']) { //----------------------------------------- // Get post data //----------------------------------------- $master_post = ""; $dropdown = array(); $authors = array(); $seen_author = array(); $upload_html = ""; $seoTitle = ''; //----------------------------------------- // Grab teh posts //----------------------------------------- $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => "p.pid IN (" . implode(",", $this->pids) . ")", 'add_join' => array(array('select' => 't.forum_id, t.title_seo', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($p = $this->DB->fetch($outer)) { if (IPSMember::checkPermissions('read', $p['forum_id']) == TRUE) { $master_post .= "<br /><br />" . $p['post']; $dropdown[] = array($p['pid'], ipsRegistry::getClass('class_localization')->getDate($p['post_date'], 'LONG') . " (#{$p['pid']})"); if (!in_array($p['author_id'], $seen_author)) { $authors[] = array($p['author_id'], "{$p['author_name']} (#{$p['pid']})"); $seen_author[] = $p['author_id']; } $seoTitle = $p['title_seo']; } } //----------------------------------------- // Get Attachment Data //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module='post' AND attach_rel_id IN (" . implode(",", $this->pids) . ")")); $this->DB->execute(); while ($row = $this->DB->fetch()) { $row['image'] = $this->caches['attachtypes'][$row['attach_ext']]['atype_img']; $row['size'] = IPSLib::sizeFormat($row['attach_filesize']); $row['attach_file'] = IPSText::truncate($row['attach_file'], 50); $attachments[] = $row; } //----------------------------------------- // Print form //----------------------------------------- if (IPSText::getTextClass('editor')->method == 'rte') { IPSText::getTextClass('bbcode')->parse_wordwrap = 0; IPSText::getTextClass('bbcode')->parse_html = 0; $master_post = IPSText::getTextClass('bbcode')->convertForRTE(trim($master_post)); } else { IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_nl2br = 0; IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'topics'; if (IPSText::getTextClass('bbcode')->parse_html) { if (!IPSText::getTextClass('bbcode')->parse_nl2br) { $master_post = str_replace(array('<br />', '<br>'), "", trim($master_post)); } } $master_post = IPSText::getTextClass('bbcode')->preEditParse($master_post); } $editor = IPSText::getTextClass('editor')->showEditor($master_post, 'Post'); $this->output .= $this->registry->getClass('output')->getTemplate('mod')->mergePostForm($editor, $dropdown, $authors, $attachments, $seoTitle); if ($this->topic['tid']) { $this->registry->getClass('output')->addNavigation($this->topic['title'], "{$this->settings['_base_url']}showtopic={$this->topic['tid']}"); } $this->registry->getClass('output')->addNavigation($this->lang->words['cm_title'], ''); $this->registry->getClass('output')->setTitle($this->lang->words['cm_title']); $this->registry->output->addContent($this->output); $this->registry->getClass('output')->sendOutput(); } else { //----------------------------------------- // DO THE THING, WITH THE THING!! //----------------------------------------- $this->request['postdate'] = intval($this->request['postdate']); if (!$this->request['selectedpids'] or !$this->request['postdate'] or !$this->request['postauthor'] or !$this->request['Post']) { $this->_showError('mod_merge_posts', 10384); } IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'topics'; $post = IPSText::getTextClass('editor')->processRawPost('Post'); $post = IPSText::getTextClass('bbcode')->preDbParse($post); //----------------------------------------- // Post to keep... //----------------------------------------- $posts = array(); $author = array(); $post_to_delete = array(); $new_post_key = md5(time()); $topics = array(); $forums = array(); $append_edit = 0; //----------------------------------------- // Grab teh posts //----------------------------------------- $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => "p.pid IN (" . implode(",", $this->pids) . ")", 'add_join' => array(array('select' => 't.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($p = $this->DB->fetch($outer)) { $posts[$p['pid']] = $p; $topics[$p['topic_id']] = $p['topic_id']; $forums[$p['forum_id']] = $p['forum_id']; if ($p['author_id'] == $this->request['postauthor']) { $author = array('id' => $p['author_id'], 'name' => $p['author_name']); } if ($p['pid'] != $this->request['postdate']) { $post_to_delete[] = $p['pid']; } if ($p['append_edit']) { $append_edit = 1; } } //----------------------------------------- // Update main post... //----------------------------------------- $this->DB->update('posts', array('author_id' => $author['id'], 'author_name' => $author['name'], 'post' => $post, 'post_key' => $new_post_key, 'post_parent' => 0, 'edit_time' => time(), 'edit_name' => $this->memberData['members_display_name'], 'append_edit' => ($append_edit or !$this->memberData['g_append_edit']) ? 1 : 0), 'pid=' . $this->request['postdate']); //----------------------------------------- // Fix attachments //----------------------------------------- $attach_keep = array(); $attach_kill = array(); foreach ($_POST as $key => $value) { if (preg_match("/^attach_(\\d+)\$/", $key, $match)) { if ($this->request[$match[0]] == 'keep') { $attach_keep[] = $match[1]; } else { $attach_kill[] = $match[1]; } } } $attach_keep = IPSLib::cleanIntArray($attach_keep); $attach_kill = IPSLib::cleanIntArray($attach_kill); //----------------------------------------- // Keep //----------------------------------------- if (count($attach_keep)) { $this->DB->update('attachments', array('attach_rel_id' => $this->request['postdate'], 'attach_post_key' => $new_post_key, 'attach_member_id' => $author['id']), 'attach_id IN(' . implode(",", $attach_keep) . ')'); } //----------------------------------------- // Kill Attachments //----------------------------------------- if (count($attach_kill)) { require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php'; $class_attach = new class_attach($this->registry); $class_attach->type = $rel_module; $class_attach->attach_post_key = $post_key; $class_attach->attach_rel_id = $rel_id; $class_attach->init(); $class_attach->bulkRemoveAttachment($attach_kill, 'attach_id'); } //----------------------------------------- // Kill old posts //----------------------------------------- if (count($post_to_delete)) { $this->DB->delete('posts', 'pid IN(' . implode(",", $post_to_delete) . ')'); } foreach ($topics as $t) { $this->modLibrary->rebuildTopic($t, 0); } foreach ($forums as $f) { $this->modLibrary->forumRecount($f); } $this->modLibrary->statsRecount(); /* Clear the content cache */ IPSContentCache::drop('post', $this->pids); $this->_addModeratorLog(sprintf($this->lang->words['acp_merged_posts'], implode(", ", $this->pids))); } }