function delete() { global $vbulletin; if ($blogid = $this->existing['blogid']) { $db =& $this->registry->db; require_once(DIR . '/includes/blog_functions_log_error.php'); if ($this->info['hard_delete']) { require_once(DIR . '/vb/search/indexcontroller/queue.php'); vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogEntry', 'delete', $blogid); vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogComment', 'delete_group', $blogid); /* NOTE: There queries are all used in the post delete function in class_dm_blog_user.php, if you add another please add it there too */ $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_categoryuser WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_deletionlog WHERE primaryid = $blogid AND type = 'blogid' "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid = $blogid AND type = 'blogid' "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_pinghistory WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_rate WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_read WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_tachyentry WHERE blogid = $blogid "); // 4.0 doesn't like aliases, 4.1 requires the alias be used :rolleyes:!!! $db->query_write(" DELETE " . TABLE_PREFIX . "blog_text, " . TABLE_PREFIX . "blog_textparsed, " . TABLE_PREFIX . "blog_editlog, " . TABLE_PREFIX . "blog_moderation, " . TABLE_PREFIX . "blog_deletionlog FROM " . TABLE_PREFIX . "blog_text LEFT JOIN " . TABLE_PREFIX . "blog_textparsed ON (" . TABLE_PREFIX . "blog_textparsed.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid) LEFT JOIN " . TABLE_PREFIX . "blog_editlog ON (" . TABLE_PREFIX . "blog_editlog.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid) LEFT JOIN " . TABLE_PREFIX . "blog_moderation ON (" . TABLE_PREFIX . "blog_moderation.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_moderation.type = 'blogtextid') LEFT JOIN " . TABLE_PREFIX . "blog_deletionlog ON (" . TABLE_PREFIX . "blog_deletionlog.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_deletionlog.type = 'blogtextid') WHERE " . TABLE_PREFIX . "blog_text.blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_trackback WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_views WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_hash WHERE blogid = $blogid AND blogtextid = " . intval($this->fetch_field('firstblogtextid')) ); require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBBlog_BlogEntry", $blogid); $content->delete_tag_attachments(); require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/vb/types.php'); vB_Bootstrap_Framework::init(); $contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry'); $attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment'); $attachdata->condition = "a.contentid = $blogid AND a.contenttypeid = " . intval($contenttypeid); $attachdata->delete(true, false); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog WHERE blogid = $blogid "); if (!$this->info['skip_moderator_log']) { blog_moderator_action($this->existing, 'blogentry_removed'); $db->query_write(" UPDATE " . TABLE_PREFIX . "moderatorlog SET threadtitle = '". $db->escape_string($this->existing['title']) ."' WHERE id2 = $blogid "); } } else { $this->set('state', 'deleted'); $this->save(); if (!$this->info['skip_moderator_log']) { blog_moderator_action($this->existing, 'blogentry_softdeleted'); } // soft delete $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "blog_deletionlog (primaryid, type, userid, username, reason, dateline) VALUES ($blogid, 'blogid', " . $this->registry->userinfo['userid'] . ", '" . $db->escape_string($this->registry->userinfo['username']) . "', '" . $db->escape_string($this->info['reason']) . "', " . TIMENOW . ") "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid = $blogid AND type = 'blogid' "); if (!$this->info['keep_attachments']) { require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/vb/types.php'); vB_Bootstrap_Framework::init(); $contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry'); $attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment'); $attachdata->condition = "a.contentid = $blogid AND a.contenttypeid = " . intval($contenttypeid); $attachdata->delete(true, false); } } if (!$this->info['skip_build_blog_counters']) { build_blog_user_counters($this->fetch_field('userid')); build_blog_stats(); } ($hook = vBulletinHook::fetch_hook('blog_data_delete')) ? eval($hook) : false; return true; } return false; }
/** * Additional tasks to perform before a delete. * * Return false to indicate that the entire delete process was not a success. * * @param mixed - The result of execDelete() */ protected function preDelete($result) { $this->assertItem(); require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, vB_Types::instance()->getContentTypeID("vBCms_Article"), intval($this->item->getId())); $taggable->delete_tag_attachments(); vB::$db->query_write(" DELETE FROM " . TABLE_PREFIX . "cms_nodecategory WHERE nodeid = " . intval($this->item->getNodeId()) ); vB::$db->query_write(" DELETE FROM " . TABLE_PREFIX . "cms_article WHERE contentid = " . intval($this->item->getId()) ); vB_Cache::instance()->event('categories_updated'); return parent::preDelete($result); }
/** * Populates a view with the expected info from a content item. * Note: The view type should be based on the VIEW constants defined by the * content handler class. * * Child classes will need to extend or override this for custom content. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->SaveData(); $this->content->reloadContent(); } if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } parent::populateViewContent($view, $viewtype); $view->url = $this->content->getUrl(); $view->html = $this->content->getHtml(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->font = $this->content->getConfig('font'); $view->fontsize = $this->content->getConfig('size'); $view->update_url = vB_Router::getURL(); $view->parenttitle = $this->content->getParentTitle(); $view->setpublish = $this->content->getSetPublish(); $view->dateformat = vB::$vbulletin->options['dateformat']; //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getContentId(), $this->content); $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; $view->categories = $this->content->getCategories(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_StaticHtml"); }
/** * Creates a new post * * @param string 'thread' for the first post in a new thread, 'reply' otherwise * @param array Forum Information * @param array Thread Information * @param array Post Information for the "Parent" post * @param array Post Information for the post being created * @param array (return) Array of errors * */ function build_new_post($type = 'thread', $foruminfo, $threadinfo, $postinfo, &$post, &$errors) { //NOTE: permissions are not checked in this function // $post is passed by reference, so that any changes (wordwrap, censor, etc) here are reflected on the copy outside the function // $post[] includes: // title, iconid, message, parseurl, email, signature, preview, disablesmilies, rating // $errors will become any error messages that come from the checks before preview kicks in global $vbulletin, $vbphrase, $forumperms; // ### PREPARE OPTIONS AND CHECK VALID INPUT ### $post['disablesmilies'] = intval($post['disablesmilies']); $post['enablesmilies'] = $post['disablesmilies'] ? 0 : 1; $post['folderid'] = intval($post['folderid']); $post['emailupdate'] = intval($post['emailupdate']); $post['rating'] = intval($post['rating']); $post['podcastsize'] = intval($post['podcastsize']); // Make sure the posthash is valid if (md5($post['poststarttime'] . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']) != $post['posthash']) { $post['posthash'] = 'invalid posthash'; // don't phrase me } // OTHER SANITY CHECKS $threadinfo['threadid'] = intval($threadinfo['threadid']); // Doublepost // $dp_flag = false; // create data manager if ($type == 'thread') { $dataman =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $dataman->set('prefixid', $post['prefixid']); } else { $dataman =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $dupehash = md5($foruminfo['forumid'] . $post['title'] . $post['message'] . $vbulletin->userinfo['userid'] . $type); // Doublepost Check // if ($vbulletin->options['dp_timespan'] and VB_API !== true and $cutoff = TIMENOW - $vbulletin->options['dp_timespan'] * 60 and $threadinfo['lastpost'] > $cutoff and !$post['preview'] and $threadinfo['lastposter'] == $vbulletin->userinfo['username'] and !($foruminfo['options'] & $vbulletin->bf_misc_forumoptions['bypassdp']) and !($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['bypassdoublepost']) and $doublepost = $vbulletin->db->query_first("\n\t\t\t\tSELECT post.*, posthash.userid AS dupe_userid\n\t\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "posthash AS posthash ON (\n\t\t\t\t\tposthash.threadid = {$threadinfo['threadid']}\n\t\t\t\t\t\tAND\n\t\t\t\t\tposthash.dupehash = '" . $vbulletin->db->escape_string($dupehash) . "'\n\t\t\t\t\t\tAND\n\t\t\t\t\tposthash.userid = {$vbulletin->userinfo['userid']}\n\t\t\t\t\t\tAND\n\t\t\t\t\tposthash.dateline > " . (TIMENOW - 300) . "\n\t\t\t\t)\n\t\t\t\tWHERE\n\t\t\t\t\tpost.visible = 1\n\t\t\t\t\t\tAND\n\t\t\t\t\tpost.postid = " . $threadinfo['lastpostid'] . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tpost.threadid = " . $threadinfo['threadid'] . "\n\t\t\t\tLIMIT 1\t") and $attach = $vbulletin->db->query_first("\n\t\t\t\tSELECT count(attachmentid) AS attach\n\t\t\t\tFROM " . TABLE_PREFIX . "attachment\n\t\t\t\tWHERE state = 'visible'\n\t\t\t\tAND posthash = '" . $post['posthash'] . "'") and ($vbulletin->options['attachlimit'] == 0 or $attach['attach'] + $doublepost['attach'] <= $vbulletin->options['attachlimit'])) { $cstate = $vbulletin->options['dp_color'] ? 1 : 0; $minchar = intval($vbulletin->options['postminchars']) <= 0 ? 1 : intval($vbulletin->options['postminchars']); if (vbstrlen(strip_bbcode($post['message'], $vbulletin->options['ignorequotechars'])) < $minchar) { require_once DIR . '/includes/functions_misc.php'; $errors[] = construct_phrase(fetch_phrase('tooshort', 'error'), $minchar); return false; } if ($doublepost['dupe_userid']) { require_once DIR . '/includes/functions_misc.php'; $errors[] = fetch_phrase('duplicate_post', 'error'); return false; } switch ($vbulletin->options['dp_spacer']) { case 1: // None $cstate = 2; break; case 2: // Custom $spacer = $vbulletin->options['dp_text']; break; default: $spacer = $vbphrase['dp_spacer_default']; break; } switch ($cstate) { case 1: // Coloured spacer $spacer = "\n\n" . '[COLOR="' . $vbulletin->options['dp_color'] . '"]' . $spacer . '[/COLOR]' . "\n\n"; break; case 2: // No spacer. $spacer = "\n\n"; break; default: $spacer = "\n\n" . $spacer . "\n\n"; break; } $dp_flag = true; $id = $doublepost['postid']; // Need to set valid values for later // $doublepost['signature'] = $doublepost['showsignature']; $doublepost['disablesmilies'] = intval($doublepost['disablesmilies']); $doublepost['enablesmilies'] = $doublepost['disablesmilies'] ? 0 : 1; $doublepost['folderid'] = intval($doublepost['folderid']); $doublepost['emailupdate'] = intval($doublepost['emailupdate']); $doublepost['rating'] = intval($doublepost['rating']); $doublepost['podcastsize'] = intval($doublepost['podcastsize']); $doublepost['doublepost'] = $dp_flag; $doublepost['posthash'] = $post['posthash']; $doublepost['oldmessage'] = $post['message']; $doublepost['message'] = $doublepost['pagetext'] . $spacer . $post['message']; $post = $doublepost; unset($doublepost); $dataman->set_existing($post); if ($vbulletin->options['dp_bump']) { $post['dateline'] = TIMENOW; $dataman->set('dateline', $post['dateline']); } } else { $dp_flag = false; } } // set info $dataman->set_info('dpflag', $dp_flag); $dataman->set_info('preview', $post['preview']); $dataman->set_info('parseurl', $post['parseurl']); $dataman->set_info('posthash', $post['posthash']); $dataman->set_info('forum', $foruminfo); $dataman->set_info('thread', $threadinfo); if (!$vbulletin->GPC['fromquickreply']) { $dataman->set_info('show_title_error', true); } if ($foruminfo['podcast'] and (!empty($post['podcasturl']) or !empty($post['podcastexplicit']) or !empty($post['podcastauthor']) or !empty($post['podcastsubtitle']) or !empty($post['podcastkeywords']))) { $dataman->set_info('podcastexplicit', $post['podcastexplicit']); $dataman->set_info('podcastauthor', $post['podcastauthor']); $dataman->set_info('podcastkeywords', $post['podcastkeywords']); $dataman->set_info('podcastsubtitle', $post['podcastsubtitle']); $dataman->set_info('podcasturl', $post['podcasturl']); if ($post['podcastsize']) { $dataman->set_info('podcastsize', $post['podcastsize']); } } // set options $dataman->setr('showsignature', $post['signature']); $dataman->setr('allowsmilie', $post['enablesmilies']); $dataman->setr('htmlstate', $post['htmlstate']); // set data $dataman->setr('userid', $vbulletin->userinfo['userid']); if ($vbulletin->userinfo['userid'] == 0) { $dataman->setr('username', $post['username']); } $dataman->setr('title', $post['title']); $dataman->setr('pagetext', $post['message']); $dataman->setr('iconid', $post['iconid']); // see if post has to be moderated or if poster in a mod if (($foruminfo['moderatenewthread'] and $type == 'thread' or $foruminfo['moderatenewpost'] and $type == 'reply' or !($forumperms & $vbulletin->bf_ugp_forumpermissions['followforummoderation'])) and !can_moderate($foruminfo['forumid']) or $type == 'reply' and ($postinfo['postid'] and !$postinfo['visible'] and !empty($postinfo['specifiedpost']) or !$threadinfo['visible'])) { // note: specified post comes from a variable passed into newreply.php $dataman->set('visible', 0); $post['visible'] = 0; } else { $dataman->set('visible', 1); $post['visible'] = 1; } if ($type != 'thread') { if ($dp_flag) { $parentid = $post['parentid']; } else { if ($postinfo['postid']) { // get parentid of the new post // we're not posting a new thread, so make this post a child of the first post in the thread if (!empty($threadinfo['firstpostid'])) { //we have the postid in the thread table (firstpostid) $parentid = $threadinfo['firstpostid']; } else { //for some reason it might not be available in the $threadinfo array, need to fetch it $getfirstpost = $vbulletin->db->query_first("SELECT postid FROM " . TABLE_PREFIX . "post WHERE threadid={$threadinfo['threadid']} ORDER BY dateline LIMIT 1"); $parentid = $getfirstpost['postid']; } } else { $parentid = $postinfo['postid']; } } $dataman->setr('parentid', $parentid); $dataman->setr('threadid', $threadinfo['threadid']); } else { $dataman->setr('forumid', $foruminfo['forumid']); } $errors = array(); // done! ($hook = vBulletinHook::fetch_hook('newpost_process')) ? eval($hook) : false; if ($vbulletin->GPC['fromquickreply'] and $post['preview']) { $errors = array(); return; } if (fetch_require_hvcheck('post') and !$post['preview']) { require_once DIR . '/includes/class_humanverify.php'; $verify =& vB_HumanVerify::fetch_library($vbulletin); if (!$verify->verify_token($post['humanverify'])) { $dataman->error($verify->fetch_error()); } } if ($dataman->info['podcastsize']) { $post['podcastsize'] = $dataman->info['podcastsize']; } // check if this forum requires a prefix if ($type == 'thread' and !$dataman->fetch_field('prefixid') and $foruminfo['options'] & $vbulletin->bf_misc_forumoptions['prefixrequired']) { // only require a prefix if we actually have options for this forum require_once DIR . '/includes/functions_prefix.php'; if (fetch_prefix_array($foruminfo['forumid'])) { $dataman->error('thread_prefix_required'); } } if ($type == 'thread' and $post['taglist']) { $threadinfo['postuserid'] = $vbulletin->userinfo['userid']; require_once DIR . '/includes/class_taggablecontent.php'; $content = vB_Taggable_Content_Item::create($vbulletin, "vBForum_Thread", $dataman->thread['threadid'], $threadinfo); $limits = $content->fetch_tag_limits(); $content->filter_tag_list_content_limits($post['taglist'], $limits, $tag_errors, true, false); if ($tag_errors) { foreach ($tag_errors as $error) { $dataman->error($error); } } $dataman->setr('taglist', $post['taglist']); } if ($type == 'reply' and $vbulletin->GPC['return_node']) { $dataman->set_info('nodeid', $vbulletin->GPC['return_node']); } $dataman->pre_save(); $errors = array_merge($errors, $dataman->errors); if ($post['preview']) { return; } // ### DUPE CHECK ### $dupehash = md5($foruminfo['forumid'] . $post['title'] . $post['message'] . $vbulletin->userinfo['userid'] . $type); $prevpostfound = false; $prevpostthreadid = 0; if ($prevpost = $vbulletin->db->query_first("\n\t\tSELECT posthash.threadid, thread.title\n\t\tFROM " . TABLE_PREFIX . "posthash AS posthash\n\t\tLEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (thread.threadid = posthash.threadid)\n\t\tWHERE posthash.userid = " . $vbulletin->userinfo['userid'] . " AND\n\t\t\tposthash.dupehash = '" . $vbulletin->db->escape_string($dupehash) . "' AND\n\t\t\tposthash.dateline > " . (TIMENOW - 300) . "\n\t")) { if ($type == 'thread' and $prevpost['threadid'] == 0 or $type == 'reply' and $prevpost['threadid'] == $threadinfo['threadid']) { $prevpostfound = true; $prevpostthreadid = $prevpost['threadid']; } } // Redirect user to forumdisplay since this is a duplicate post if ($prevpostfound) { if ($type == 'thread') { $vbulletin->url = fetch_seo_url('forum', $foruminfo); print_standard_redirect('redirect_duplicatethread', true, true); } else { // with ajax quick reply we need to use the error system if ($vbulletin->GPC['ajax']) { $dataman->error('duplicate_post'); $errors = $dataman->errors; return; } else { $vbulletin->url = fetch_seo_url('thread', $prevpost, array('goto' => 'newpost')); if ($post['ajaxqrfailed']) { // ajax qr failed. While this is a dupe, most likely the user didn't // see the initial post, so act like it went through. print_standard_redirect('redirect_postthanks'); } else { print_standard_redirect('redirect_duplicatepost', true, true); } } } } if (sizeof($errors) > 0) { return; } if ($post['doublepost']) { $dataman->save(); } else { $id = $dataman->save(); } if ($type == 'thread') { $post['threadid'] = $id; $threadinfo =& $dataman->thread; $post['postid'] = $dataman->fetch_field('firstpostid'); clear_autosave_text('vBForum_Thread', 0, 0, $vbulletin->userinfo['userid']); } else { $post['postid'] = $id; if ($vbulletin->GPC_exists['return_node'] and intval($vbulletin->GPC['return_node'])) { clear_autosave_text('vBCms_ArticleComment', 0, $vbulletin->GPC['return_node'], $vbulletin->userinfo['userid']); } else { clear_autosave_text('vBForum_Post', 0, $threadinfo['threadid'], $vbulletin->userinfo['userid']); } } post_vb_api_details('vBForum_Post', $post['postid']); $post['visible'] = $dataman->fetch_field('visible'); $set_open_status = false; $set_sticky_status = false; if ($vbulletin->GPC['openclose'] and ($threadinfo['postuserid'] != 0 and $threadinfo['postuserid'] == $vbulletin->userinfo['userid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'] or can_moderate($threadinfo['forumid'], 'canopenclose'))) { $set_open_status = true; } if ($vbulletin->GPC['stickunstick'] and can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $set_sticky_status = true; } if ($set_open_status or $set_sticky_status) { $thread =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); if ($type == 'thread') { $thread->set_existing($dataman->thread); if ($set_open_status) { $post['postpoll'] = false; } } else { $thread->set_existing($threadinfo); } if ($set_open_status) { $thread->set('open', $thread->fetch_field('open') == 1 ? 0 : 1); } if ($set_sticky_status) { $thread->set('sticky', $thread->fetch_field('sticky') == 1 ? 0 : 1); } $thread->save(); } if ($type == 'thread') { require_once DIR . '/includes/class_taggablecontent.php'; $content = vB_Taggable_Content_Item::create($vbulletin, "vBForum_Thread", $dataman->thread['threadid'], $threadinfo); $limits = $content->fetch_tag_limits(); $content->add_tags_to_content($post['taglist'], $limits); } // ### DO THREAD RATING ### build_thread_rating($post['rating'], $foruminfo, $threadinfo); // ### DO EMAIL NOTIFICATION ### if ($post['visible'] and $type != 'thread' and !in_coventry($vbulletin->userinfo['userid'], true)) { exec_send_notification($threadinfo['threadid'], $vbulletin->userinfo['userid'], $post['postid']); } // ### DO THREAD SUBSCRIPTION ### if ($vbulletin->userinfo['userid'] != 0) { require_once DIR . '/includes/functions_misc.php'; $post['emailupdate'] = verify_subscription_choice($post['emailupdate'], $vbulletin->userinfo, 9999); ($hook = vBulletinHook::fetch_hook('newpost_subscribe')) ? eval($hook) : false; if (!$threadinfo['issubscribed'] and $post['emailupdate'] != 9999) { // user is not subscribed to this thread so insert it /*insert query*/ $vbulletin->db->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\tVALUES (" . $vbulletin->userinfo['userid'] . ", {$threadinfo['threadid']}, {$post['emailupdate']}, {$post['folderid']}, 1)"); } else { // User is subscribed, see if they changed the settings for this thread if ($post['emailupdate'] == 9999) { // Remove this subscription, user chose 'No Subscription' $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = {$threadinfo['threadid']} AND userid = " . $vbulletin->userinfo['userid']); } else { if ($threadinfo['emailupdate'] != $post['emailupdate'] or $threadinfo['folderid'] != $post['folderid']) { // User changed the settings so update the current record /*insert query*/ $vbulletin->db->query_write("REPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\tVALUES (" . $vbulletin->userinfo['userid'] . ", {$threadinfo['threadid']}, {$post['emailupdate']}, {$post['folderid']}, 1)"); } } } } ($hook = vBulletinHook::fetch_hook('newpost_complete')) ? eval($hook) : false; }
$contenttypeid = vB_Types::instance()->getContentTypeID($contenttypeid); //******************************************************************* //Figure out the content id if ($vbulletin->GPC_exists['contentid']) { $contentid = $vbulletin->GPC['contentid']; } else { $contentid = $vbulletin->GPC['threadid']; } if (!$vbulletin->options['threadtagging']) { print_no_permission(); } if (!$contenttypeid) { eval(standard_error("~~Content type is not taggable~~")); } //this will terminate if there are permission errors $content = vB_Taggable_Content_Item::create($vbulletin, $contenttypeid, $contentid); if (!$content) { //do we need a phrase? This really shouldn't happen under normal operation. eval(standard_error("~~Content type is not taggable~~")); } $content->verify_ui_permissions(); //$contentinfo = $content->fetch_content_info(); $show['add_option'] = $content->can_add_tag(); $show['manage_existing_option'] = $content->can_manage_tag(); ($hook = vBulletinHook::fetch_hook('threadtag_start')) ? eval($hook) : false; if (!$show['add_option'] and !$show['manage_existing_option']) { print_no_permission(); } // ############################################################################## if ($_POST['do'] == 'managetags') { $vbulletin->input->clean_array_gpc('p', array('tagskept' => TYPE_ARRAY_UINT, 'tagsshown' => TYPE_ARRAY_UINT, 'taglist' => TYPE_NOHTML));
function delete_thread($threadid, $countposts = true, $physicaldel = true, $delinfo = NULL, $dolog = true, $threadinfo = NULL) { global $vbulletin, $vbphrase; // valid threadinfo array will contain: threadid, forumid, visible, open, pollid, title if (!$threadinfo AND !$threadinfo = fetch_threadinfo($threadid)) { return; } if (!$physicaldel AND $threadinfo['visible'] == 2) { // thread is already soft deleted return; } if ($dolog AND can_moderate()) { // is a moderator, so log it fetch_phrase_group('threadmanage'); if ($threadinfo['open'] == 10) { $type = 'thread_redirect_removed'; } else if (!$physicaldel) { $type = 'thread_softdeleted'; } else { $type = 'thread_removed'; } require_once(DIR . '/includes/functions_log_error.php'); log_moderator_action($threadinfo, $type); } if ($physicaldel) { // Grab the inline moderation cookie (if it exists) $vbulletin->input->clean_array_gpc('c', array( 'vbulletin_inlinethread' => TYPE_STR, 'vbulletin_inlinepost' => TYPE_STR, )); if (!empty($vbulletin->GPC['vbulletin_inlinethread']) AND !headers_sent()) { $newcookie = array(); $found = false; $temp = explode('-', $vbulletin->GPC['vbulletin_inlinethread']); foreach($temp AS $inlinethreadid) { if ($inlinethreadid == $threadid) { $found = true; } else { $newcookie[] = intval($inlinethreadid); } } // this thread is in the inline thread cookie so delete it by rewriting cookie without it if ($found) { setcookie('vbulletin_inlinethread', implode('-', $newcookie), TIMENOW + 3600, '/'); } } $plist = array(); if (!empty($vbulletin->GPC['vbulletin_inlinepost'])) { $temp = explode('-', $vbulletin->GPC['vbulletin_inlinepost']); foreach($temp AS $inlinepostid) { $plist["$inlinepostid"] = true; } } if ($threadinfo['open'] == 10) { // this is a redirect, delete it $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "thread WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "threadredirect WHERE threadid = $threadid"); return; } } $postids = array(); $posts = $vbulletin->db->query_read(" SELECT post.userid, post.postid, post.attach, post.visible FROM " . TABLE_PREFIX . "post AS post WHERE post.threadid = $threadid "); $removepostid = array(); $userbyuserid = array(); while ($post = $vbulletin->db->fetch_array($posts)) { if ($countposts AND $post['visible'] == 1 AND $post['userid']) { // deleted posts have already been subtracted, ignore guest posts, hidden posts never had posts added if (!isset($userbyuserid["$post[userid]"])) { $userbyuserid["$post[userid]"] = 1; } else { $userbyuserid["$post[userid]"]++; } } $postids[] = $post['postid']; if ($physicaldel) { delete_post_index($post['postid']); //remove search engine entries // mark posts that are in the inline moderation cookie if (!empty($plist["$post[postid]"])) { $removepostid["$post[postid]"] = true; } } } if (!empty($userbyuserid) AND $threadinfo['visible'] == 1) { // if the thread is moderated the posts have already been reduced $userbypostcount = array(); foreach ($userbyuserid AS $postuserid => $postcount) { $alluserids .= ",$postuserid"; $userbypostcount["$postcount"] .= ",$postuserid"; } foreach($userbypostcount AS $postcount => $userids) { $casesql .= " WHEN userid IN (0$userids) AND posts > $postcount THEN posts - $postcount\n"; } // postcounts are already negative, so we don't want to do -(-1) $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX ."user SET posts = CASE $casesql ELSE 0 END WHERE userid IN (0$alluserids) "); } if (!empty($postids)) { if ($physicaldel OR (!$delinfo['keepattachments'] AND can_moderate($threadinfo['forumid'], 'canremoveposts'))) { require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/vb/types.php'); vB_Bootstrap_Framework::init(); $types = vB_Types::instance(); $contenttypeid = intval($types->getContentTypeID('vBForum_Post')); $attachdata =& datamanager_init('Attachment', $vbulletin, ERRTYPE_SILENT, 'attachment'); $attachdata->condition = "a.contentid IN (" . implode(", ", $postids) . ") AND a.contenttypeid = " . intval($contenttypeid); $attachdata->delete(true, false); } } if (!$threadinfo['visible']) { // clear out spamlog if its deleted, it was probably really spam $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = $threadid AND type = 'thread'"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "spamlog WHERE postid = " . intval($threadinfo['firstpostid'])); } if (!$physicaldel) { if (!is_array($delinfo)) { $delinfo = array('userid' => $vbulletin->userinfo['userid'], 'username' => $vbulletin->userinfo['username'], 'reason' => ''); } $deletionman =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog'); $deletionman->set('primaryid', $threadinfo['threadid']); $deletionman->set('type', 'thread'); $deletionman->set('userid', $delinfo['userid']); $deletionman->set('username', $delinfo['username']); $deletionman->set('reason', $delinfo['reason']); $deletionman->save(); unset($deletionman); $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); $threadman->set_existing($threadinfo); $threadman->set('visible', 2); if (!$delinfo['keepattachments']) { $threadman->set('attach', 0); } $threadman->save(); // Delete any redirects to this thread $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "thread WHERE open = 10 AND pollid = $threadid"); return; } if (!empty($postids)) { $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "post WHERE postid IN (" . implode(", ", $postids) . ")"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "postparsed WHERE postid IN (" . implode(", ", $postids) . ")"); //$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "reputation WHERE postid IN (" . implode(", ", $postids) . ")"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderation WHERE type = 'reply' AND primaryid IN (" . implode(", ", $postids) . ")"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "editlog WHERE postid IN (" . implode(", ", $postids) . ")"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "postedithistory WHERE postid IN (" . implode(", ", $postids) . ")"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "deletionlog WHERE type= 'post' AND primaryid IN (" . implode(", ", $postids) . ")"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "podcastitem WHERE postid = " . intval($threadinfo['firstpostid'])); // remove deleted posts from inline moderation cookie if (!empty($removepostid) AND !headers_sent()) { $newcookie = array(); foreach($plist AS $inlinepostid => $value) { if (empty($removepostid["$inlinepostid"])) { $newcookie[] = intval($inlinepostid); } } setcookie('vbulletin_inlinepost', implode('-', $newcookie), TIMENOW + 3600, '/'); } } if ($threadinfo['pollid'] != 0 AND $threadinfo['open'] != 10) { $pollman =& datamanager_init('Poll', $vbulletin, ERRTYPE_SILENT); $pollid = array ('pollid' => $threadinfo['pollid']); $pollman->set_existing($pollid); $pollman->delete(); } $deletiondata =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog'); $deletioninfo = array('type' => 'thread', 'primaryid' => $threadid); $deletiondata->set_existing($deletioninfo); $deletiondata->delete(); unset($deletiondata, $deletioninfo); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "thread WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "thread WHERE open=10 AND pollid = $threadid"); // delete redirects $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "threadrate WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "threadread WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "tachythreadpost WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "tachythreadcounter WHERE threadid = $threadid"); require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBForum_Thread", $threadid, $threadinfo); if ($threadinfo['open'] == 10) { $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "threadredirect WHERE threadid = $threadid"); } $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "moderatorlog SET threadtitle = '". $vbulletin->db->escape_string($threadinfo['title']) ."' WHERE threadid = $threadid "); }
/** * Deletes a thread with the first post * * @param boolean Whether to consider updating post counts, regardless of forum's settings * @param boolean Whether to physically remove the thread from the database * @param array Array of information for a soft delete * @param boolean Whether to add an entry to the moderator log * * @return mixed The number of affected rows */ function delete($countposts = true, $physicaldel = true, $delinfo = NULL, $dolog = true) { require_once DIR . '/vb/search/core.php'; // TODO: follow up on and check $this->existing['threadid'] if ($threadid = $this->existing['threadid']) { // Search index maintenance if ($physicaldel) { require_once DIR . '/vb/search/indexcontroller/queue.php'; vb_Search_Indexcontroller_Queue::indexQueue('vBForum', 'Post', 'delete', $threadid); require_once DIR . '/includes/class_taggablecontent.php'; $content = vB_Taggable_Content_Item::create($this->registry, "vBForum_Thread", $threadid); $content->delete_tag_attachments(); } } ($hook = vBulletinHook::fetch_hook('threadfpdata_delete')) ? eval($hook) : false; return parent::delete($countposts, $physicaldel, $delinfo, $this->info['skip_moderator_log'] !== null ? !$this->info['skip_moderator_log'] : $dolog); }
private function fetch_tagcloud($type = 'usage') { $vbulletin = &$this->registry; $tags = array(); if ($vbulletin->options['tagcloud_usergroup'] > 0 AND !isset($vbulletin->usergroupcache[$vbulletin->options['tagcloud_usergroup']])) { // handle a usergroup being deleted: default to live permission checking $vbulletin->options['tagcloud_usergroup'] = -1; } require_once(DIR . '/includes/class_taggablecontent.php'); $collection = new vB_Collection_ContentType(); $collection->filterTaggable(true); //create dummy content item objects. We use these to call a couple of (what? - Darren) $type_objects = array(); foreach ($collection AS $contenttype) { $type_objects[$contenttype->getID()] = vB_Taggable_Content_Item::create($vbulletin, $contenttype->getID(), null); } unset($collection, $contenttype); $cacheable = true; foreach ($type_objects AS $content) { if (!$content->is_cloud_cachable()) { $cacheable = false; break; } } if (!$cacheable) { $cloud = null; } else { switch ($type) { case 'search': if (isset($vbulletin->searchcloud)) { $cloud = $vbulletin->searchcloud; } break; case 'usage': default: $cloud = $vbulletin->tagcloud; break; } } $cloud = null; if (!is_array($cloud) OR $cloud['dateline'] < (TIMENOW - (60 * $vbulletin->options['tagcloud_cachetime']))) { if ($type == 'search') { $tags_result = $vbulletin->db->query_read_slave(" SELECT tagsearch.tagid, tag.tagtext, COUNT(*) AS searchcount FROM " . TABLE_PREFIX . "tagsearch AS tagsearch INNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagsearch.tagid = tag.tagid) " . ($vbulletin->options['tagcloud_searchhistory'] ? "WHERE tagsearch.dateline > " . (TIMENOW - (60 * 60 * 24 * $vbulletin->options['tagcloud_searchhistory'])) : '') . " GROUP BY tagsearch.tagid, tag.tagtext ORDER BY searchcount DESC LIMIT " . $vbulletin->options['tagcloud_tags'] ); } else { //get the query bits from the type objects. If two objects return the same exact join/where information //we can collapse the subqueries. This is particularly useful for the cms content types which are //largely the same under the hood. $bit_ids = array(); $bit_values = array(); foreach ($type_objects AS $type => $content) { $contenttypeid = vB_Types::instance()->getContentTypeID($type); $bits = $content->fetch_tag_cloud_query_bits(); if ($bits) { $pos = array_search($bits, $bit_values); if ($pos === false) { $bit_ids[] = array($contenttypeid); $bit_values[] = $bits; } else { $bit_ids[$pos][] = $contenttypeid; } } } //build the subqueries from the bits. $subqueries = array(); foreach ($bit_values AS $key => $bits) { $timelimit = (TIMENOW - (60 * 60 * 24 * $vbulletin->options['tagcloud_usagehistory'])); $query = " SELECT tagcontent.tagid, tag.tagtext, COUNT(*) AS searchcount FROM " . TABLE_PREFIX . "tagcontent AS tagcontent INNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagcontent.tagid = tag.tagid) " . implode("\n", $bits['join']) . " WHERE tagcontent.contenttypeid IN (" . implode(",", $bit_ids[$key]) . ") AND tagcontent.dateline > $timelimit AND " . implode(" AND ", $bits['where']) . " GROUP BY tagcontent.tagid, tag.tagtext "; $subqueries[] = $query; } if (count($subqueries)) { $query = " SELECT data.tagid, data.tagtext, SUM(data.searchcount) AS searchcount FROM (" . implode(" UNION ALL ", $subqueries) . ") AS data GROUP BY data.tagid, data.tagtext ORDER BY searchcount DESC LIMIT " . $vbulletin->options['tagcloud_tags']; $tags_result = $vbulletin->db->query_read_slave($query); while ($currenttag = $vbulletin->db->fetch_array($tags_result)) { $tags["$currenttag[tagtext]"] = $currenttag; $totals[$currenttag['tagid']] = $currenttag['searchcount']; } } } while ($currenttag = $vbulletin->db->fetch_array($tags_result)) { $tags["$currenttag[tagtext]"] = $currenttag; $totals[$currenttag['tagid']] = $currenttag['searchcount']; } // fetch the stddev levels $levels = fetch_standard_deviated_levels($totals, $vbulletin->options['tagcloud_levels']); // assign the levels back to the tags foreach ($tags AS $tagtext => $tag) { $tags[$tagtext]['level'] = $levels[$tag['tagid']]; $tags[$tagtext]['tagtext_url'] = urlencode(unhtmlspecialchars($tag['tagtext'])); } // sort the categories by title uksort($tags, 'strnatcasecmp'); $cloud = array( 'tags' => $tags, 'count' => sizeof($tags), 'dateline' => TIMENOW ); if ($cacheable) { if ($type == 'search' OR $type == 'selectlist') { $vbulletin->searchcloud = $cloud; } else { $vbulletin->tagcloud = $cloud; } } } if (empty($cloud['tags'])) { return ''; } $cloud['links'] = ''; return $cloud; }
/** * Populates a view with the expected info from a content item. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { global $show; if (empty($this->config)) { $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->config = $this->content->getConfig(); } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->saveData($view); $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); $this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION); $this->config = $this->content->getConfig(); } else { $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); $this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION); } if ($_REQUEST['goto'] == 'newcomment') { require_once DIR . '/includes/functions_bigthree.php' ; $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; $threadinfo = verify_id('thread', $threadid, 1, 1); if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid']) { vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400)); } else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit']) { vB::$vbulletin->userinfo['lastvisit'] = $tview; } $coventry = fetch_coventry('string'); $posts = vB::$vbulletin->db->query_first(" SELECT MIN(postid) AS postid FROM " . TABLE_PREFIX . "post WHERE threadid = $threadinfo[threadid] AND visible = 1 AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . " ". ($coventry ? "AND userid NOT IN ($coventry)" : "") . " LIMIT 1 "); $target_url = vB_Router::getURL(); $join_char = strpos($target_url,'?') ? '&' : '?'; if ($posts['postid']) { exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]"); } else { exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]"); } } if ($_REQUEST['commentid']) { vB::$vbulletin->input->clean_array_gpc('r', array( 'commentid' => vB_Input::TYPE_INT, )); $postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1); $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; // if comment id and node id do not match, we ignore commentid if ($postinfo['threadid'] == $threadid) { $getpagenum = vB::$vbulletin->db->query_first(" SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid AND visible = 1 AND dateline <= $postinfo[dateline] "); $_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20); } } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->saveData($view); } ($hook = vBulletinHook::fetch_hook($this->startpopulatehook)) ? eval($hook) : false; //Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply // the settings to the current page, and there are the six "show" variables. if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } //When we come from the link to upgrade a blog post, blog, or forum post, the // router puts us here. $settings_for = $this->content->getSettingsForboth(); $showfor_this = (((self::VIEW_PAGE == $viewtype) AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype) AND ($settings_for == 2))) ? 0 : 1; $view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1; $view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; $view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1; $view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1; $view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1; $view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1; $view->lastupdated = $this->content->getLastUpdated(); $view->previewtext = $this->config['previewtext']; if ((self::VIEW_PREVIEW != $viewtype) OR !$view->showpreviewonly) { $view->pagetext = $this->config['pagetext']; } $view->previewimage = $this->config['preview_image']; $view->nodeid = $this->content->getNodeId(); parent::populateViewContent($view, $viewtype); $segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view'); $view->page_url = vBCms_Route_Content::getURL($segments); $view->pagetext = $this->config['pagetext']; if (self::VIEW_PAGE == $viewtype) { if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getNodeId(), $this->content); if ($taggable) { $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; } else { $view->showtags = false; } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); //check to see if there is an associated thread. if ($associatedthreadid = $this->content->getAssociatedThreadId() and $this->content->getComments_Enabled()) { $comment_block = new vBCms_Comments(); $view->comment_block = $comment_block->getPageView($this->content->getNodeId(), $view->page_url); } } else if (self::VIEW_PREVIEW == $viewtype) { if ($showpreviewonly) { $view->previewtext = isset($this->config['previewtext']) ? $this->config['previewtext'] : substr(strip_tags( $this->config['pagetext'], '<br />'), 0, $this->config['previewlength']); $view->preview_chopped = 1; } else { $view->previewtext = $view->pagetext; } $segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit'); $view->edit_url = vBCms_Route_Content::getURL($segments) ; $view->read_more_phrase = new vB_Phrase('vbcms', 'read_more'); $view->parenttitle = $this->content->getParentTitle(); $view->pagetext = $pagetext; $view->setpublish = $view->published = $this->content->getPublished(); $view->publishdate = $this->content->getPublishDateLocal(); $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); if (($associatedthreadid = $this->content->getAssociatedThreadId()) AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0) { $view->echo_comments = 1; $view->comment_count = $this->content->getReplyCount(); } else { $view->echo_comments = 0; $view->comment_count = 0; } } $view->setpublish = $this->content->getSetPublish(); $view->publishdate = $this->content->getPublishDate(); $view->published = $this->content->getPublished() ? 1 : 0; $view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate()); $view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() ); //Get links to the author, section, and categories search pages //categories- this comes as an array $view->categories = $this->content->getCategories(); $route_info = 'author/' . $this->content->getUserid() . ($this->content->getUsername() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : ''); $view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL(); // prepare the member action drop-down menu $view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId())); //Section $route_info = 'section/' .$this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL(); //and the content $route_info = $this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $view->dateformat = vB::$vbulletin->options['dateformat']; $view->showrating = $this->content->getShowRating(); ($hook = vBulletinHook::fetch_hook($this->endpopulatehook)) ? eval($hook) : false; if (method_exists($this->content, 'cacheNow')) { $this->content->cacheNow(); } return $view; }
/** * Populates a view with the expected info from a content item. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { global $show; $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); if ($_REQUEST['goto'] == 'newcomment') { require_once DIR . '/includes/functions_bigthree.php' ; $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; $threadinfo = verify_id('thread', $threadid, 1, 1); if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid']) { vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400)); } else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit']) { vB::$vbulletin->userinfo['lastvisit'] = $tview; } $coventry = fetch_coventry('string'); $posts = vB::$vbulletin->db->query_first(" SELECT MIN(postid) AS postid FROM " . TABLE_PREFIX . "post WHERE threadid = $threadinfo[threadid] AND visible = 1 AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . " ". ($coventry ? "AND userid NOT IN ($coventry)" : "") . " LIMIT 1 "); $target_url = vB_Router::getURL(); $join_char = strpos($target_url,'?') ? '&' : '?'; if ($posts['postid']) { exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]"); } else { exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]"); } } if ($_REQUEST['commentid']) { vB::$vbulletin->input->clean_array_gpc('r', array( 'commentid' => vB_Input::TYPE_INT, )); $postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1); $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; // if comment id and node id do not match, we ignore commentid if ($postinfo['threadid'] == $threadid) { $getpagenum = vB::$vbulletin->db->query_first(" SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid AND visible = 1 AND dateline <= $postinfo[dateline] "); $_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20); } } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->SaveData($view); } ($hook = vBulletinHook::fetch_hook('vbcms_article_populate_start')) ? eval($hook) : false; //Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply // the settings to the current page, and there are the six "show" variables. if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } //When we come from the link to upgrade a blog post, blog, or forum post, the // router puts us here. $settings_for = $this->content->getSettingsForboth(); $showfor_this = (((self::VIEW_PAGE == $viewtype) AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype) AND ($settings_for == 2))) ? 0 : 1; $view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1; $view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; $view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1; $view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1; $view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1; $view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1; $view->lastupdated = $this->content->getLastUpdated(); $showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; parent::populateViewContent($view, $viewtype); $segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view'); $view->page_url = vBCms_Route_Content::getURL($segments); if ($this->editing) { $view->pagetext = $this->content->getPageText(); } else { $rendered = $this->content->getRendered($this->data_saved); $view->pagetext = $rendered['pages'][$this->parameters['page']]; if ($this->content->canDownload()) { $view->attachments = $rendered['attachments']; $view->showattachments = empty($rendered['viewinfo']) ? 0 : 1 ; if (!empty($rendered['viewinfo'])) { foreach ($rendered['viewinfo'] as $key => $viewbit) { $view->$key = $viewbit; } } } $view->parenttitle = $this->content->getParentTitle(); $view->showattachments = empty($view->attachments) ? 0 : 1 ; if (!empty($viewinfo)) { foreach ($viewinfo as $key => $viewbit) { $view->$key = $viewbit; } } $view->pagelist = $rendered['pagelist']; $view->nodesegment = $this->content->getUrlSegment(); $view->current_page = $this->parameters['page']; if ($this->content->canDownload()) { $show['lightbox'] = (vB::$vbulletin->options['lightboxenabled'] AND vB::$vbulletin->options['usepopups']); } } // Only break pages for the page view if ((self::VIEW_PAGE == $viewtype) OR (self::VIEW_PREVIEW == $viewtype)) { if (self::VIEW_PAGE == $viewtype) { if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getContentId(), $this->content); $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; // promoted threadid if ($promoted_threadid = $this->content->getThreadId()) { if ($promoted_threadid = verify_id('thread', $promoted_threadid, false)) { // get threadinfo $threadinfo = fetch_threadinfo($promoted_threadid); $forumperms = fetch_permissions($threadinfo['forumid']); $view->threadinfo = $threadinfo; // check permissions if ($threadinfo['visible'] != 1) { $promoted_threadid = false; } else if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != vB::$vbulletin->userinfo['userid'] OR vB::$vbulletin->userinfo['userid'] == 0) )) { $promoted_threadid = false; } else { // check forum password $foruminfo = fetch_foruminfo($threadinfo['forumid']); if ($foruminfo['password'] AND !verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false)) { $promoted_threadid = false; } } $view->promoted_threadid = $promoted_threadid; } } // get pagelist for navigation $view->postitle = $this->content->getPostTitle(); $view->poststarter = $this->content->getPostStarter(); $view->postauthor = $this->content->getPostAuthor(); $view->postid = ($this->content->getPostId()); $view->threadid = $this->content->getThreadId(); $view->blogpostid = ($this->content->getBlogPostId()); $view->post_started = ($this->content->getPostStarted()); $view->post_posted = ($this->content->getPostPosted()); $view->promoted_blogid = $this->content->getBlogId(); //make links to original post and/or blog if appropriate if ($view->promoted_blogid) { $view->blog_url = fetch_seo_url('blog', array('userid' => $this->content->getPostStarter(), 'blog_title' => $this->content->getPostTitle())); } else if ($view->threadid) { $threadinfo = vB::$vbulletin->db->query_first("SELECT threadid, title FROM " . TABLE_PREFIX . "thread where threadid = " . $view->threadid); if ($threadinfo) { $post_url = fetch_seo_url('thread', $threadinfo); $post_url .= (strpos($post_url, '?' ) ? '&p=' : '?p=') . $view->postid . '#post' . $view->postid; $view->post_url = $post_url; } } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); // facebook options if (is_facebookenabled()) { // display the like button for this article? $view->fblikebutton = construct_fblikebutton(); } //check to see if there is an associated thread. if ($associatedthreadid = $this->content->getAssociatedThreadId() and $this->content->getComments_Enabled()) { $comment_block = new vBCms_Comments(); $view->comment_block = $comment_block->getPageView($this->content->getNodeId(), $view->page_url); } } else if (self::VIEW_PREVIEW == $viewtype) { if ($showpreviewonly) { $view->previewtext = $this->content->getPreviewText(); $view->preview_chopped = 1; } else { $view->previewtext = $view->pagetext; if (count($view->pagelist) > 1) { $view->preview_chopped = 1; } } $segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit'); $view->edit_url = vBCms_Route_Content::getURL($segments) ; $view->read_more_phrase = new vB_Phrase('vbcms', 'read_more'); $view->parenttitle = $this->content->getParentTitle(); $view->pagetext = $pagetext; $view->setpublish = $view->published = $this->content->getPublished(); $view->publishdate = $this->content->getPublishDateLocal(); $view->promoted_blogid = $this->content->getBlogId(); $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->postid = ($this->content->getPostId()); $view->blogpostid = $this->content->getBlogPostId(); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); $view->post_started = $this->content->getPostStarted(); $view->post_posted = $this->content->getPostPosted(); //We need to check rights. If this user doesn't have download rights we hide the image. if ($this->content->canDownload()) { if ($view->previewimage= $this->content->getPreviewImage()) { $view->imagewidth= $this->content->getImageWidth(); $view->imageheight= $this->content->getImageHeight(); } if ($view->previewvideo= $this->content->getPreviewVideo()) { $view->haspreviewvideo = true; } } else { $view->previewimage = false; $view->previewvideo = false; } if (($associatedthreadid = $this->content->getAssociatedThreadId()) AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0) { $view->echo_comments = 1; $view->comment_count = $this->content->getReplyCount(); } else { $view->echo_comments = 0; $view->comment_count = 0; } } } //If this was promoted from a blog or post, we need to verify the permissions. if (intval($view->blogpostid)) { $view->can_view_post = (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) ? 0 : 1 ; } else if (intval($view->postid)) { $user = new vB_Legacy_CurrentUser(); if ($post = vB_Legacy_Post::create_from_id($view->postid)) { $view->can_view_post = $post->can_view($user) ? 1 : 0; } } $view->poststarter = array('userid' => $this->content->getPostStarter(), 'username' => $this->content->getPostAuthor()); $view->setpublish = $this->content->getSetPublish(); $view->publishdate = $this->content->getPublishDate(); $view->published = $this->content->getPublished() ? 1 : 0; $view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate()); $view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() ); //Get links to the author, section, and categories search pages //categories- this comes as an array $view->categories = $this->content->getCategories(); $route_info = 'author/' . $this->content->getUserid() . ($this->content->getUsername() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : ''); $view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL(); // prepare the member action drop-down menu $view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId())); //Section $route_info = 'section/' .$this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL(); //and the content $route_info = $this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $view->dateformat = vB::$vbulletin->options['dateformat']; $view->showrating = $this->content->getShowRating(); ($hook = vBulletinHook::fetch_hook('vbcms_article_populate_end')) ? eval($hook) : false; $this->content->cacheNow(); return $view; }
// bypassing the verify_* calls; this data should be valid as is $threadcopy->setr($field, $newthreadinfo["{$field}"], true, false); } } if ($updatetitle and $vbulletin->options['similarthreadsearch']) { require_once DIR . '/vb/search/core.php'; $searchcontroller = vB_Search_Core::get_instance()->get_search_controller(); $similarthreads = $searchcontroller->get_similar_threads(fetch_censored_text($vbulletin->GPC['title']), $threadinfo['threadid']); $threadcopy->set('similar', implode(',', $similarthreads)); } ($hook = vBulletinHook::fetch_hook('threadmanage_move_copy_threadcopy')) ? eval($hook) : false; $newthreadid = $threadcopy->save(); $newthreadinfo['threadid'] = $newthreadid; require_once DIR . '/includes/class_taggablecontent.php'; require_once DIR . '/vb/search/core.php'; $content = vB_Taggable_Content_Item::create($vbulletin, vB_Search_Core::get_instance()->get_contenttypeid("vBForum", "Thread"), $newthreadid); $content->copy_tag_attachments(vB_Search_Core::get_instance()->get_contenttypeid("vBForum", "Thread"), $threadid); unset($threadcopy); require_once DIR . '/includes/functions_file.php'; // duplicate posts $posts = $db->query_read_slave("\n\t\t\t\tSELECT post.*,\n\t\t\t\t\tdeletionlog.userid AS deleteduserid, deletionlog.username AS deletedusername, deletionlog.reason AS deletedreason,\n\t\t\t\t\tNOT ISNULL(deletionlog.primaryid) AS isdeleted, deletionlog.dateline AS deleteddateline,\n\t\t\t\t\tmoderation.dateline AS moderateddateline\n\t\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (deletionlog.primaryid = post.postid AND deletionlog.type = 'post')\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "moderation AS moderation ON (moderation.primaryid = post.postid AND moderation.type = 'reply')\n\t\t\t\tWHERE post.threadid = {$threadid}\n\t\t\t\tORDER BY dateline\n\t\t\t"); $done_firstpost = false; $userbyuserid = array(); $postarray = array(); $postassoc = array(); $deleteinfo = array(); while ($post = $db->fetch_array($posts)) { if ($post['title'] == $oldtitle and $updatetitle) { $post['title'] = $threadinfo['title']; $update_post_title = true; } else {
/** * Creates a new post * * @param string 'thread' for the first post in a new thread, 'reply' otherwise * @param array Forum Information * @param array Thread Information * @param array Post Information for the "Parent" post * @param array Post Information for the post being created * @param array (return) Array of errors * */ function build_new_post($type = 'thread', $foruminfo, $threadinfo, $postinfo, &$post, &$errors) { //NOTE: permissions are not checked in this function // $post is passed by reference, so that any changes (wordwrap, censor, etc) here are reflected on the copy outside the function // $post[] includes: // title, iconid, message, parseurl, email, signature, preview, disablesmilies, rating // $errors will become any error messages that come from the checks before preview kicks in global $vbulletin, $vbphrase, $forumperms; // ### PREPARE OPTIONS AND CHECK VALID INPUT ### $post['disablesmilies'] = intval($post['disablesmilies']); $post['enablesmilies'] = ($post['disablesmilies'] ? 0 : 1); $post['folderid'] = intval($post['folderid']); $post['emailupdate'] = intval($post['emailupdate']); $post['rating'] = intval($post['rating']); $post['podcastsize'] = intval($post['podcastsize']); /*$post['parseurl'] = intval($post['parseurl']); $post['email'] = intval($post['email']); $post['signature'] = intval($post['signature']); $post['preview'] = iif($post['preview'], 1, 0); $post['iconid'] = intval($post['iconid']); $post['message'] = trim($post['message']); $post['title'] = trim(preg_replace('/�*32;/', ' ', $post['title'])); $post['username'] = trim($post['username']); $post['posthash'] = trim($post['posthash']); $post['poststarttime'] = trim($post['poststarttime']);*/ // Make sure the posthash is valid if (md5($post['poststarttime'] . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']) != $post['posthash']) { $post['posthash'] = 'invalid posthash'; // don't phrase me } // OTHER SANITY CHECKS $threadinfo['threadid'] = intval($threadinfo['threadid']); // create data manager if ($type == 'thread') { $dataman =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $dataman->set('prefixid', $post['prefixid']); } else { $dataman =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); } // set info $dataman->set_info('preview', $post['preview']); $dataman->set_info('parseurl', $post['parseurl']); $dataman->set_info('posthash', $post['posthash']); $dataman->set_info('forum', $foruminfo); $dataman->set_info('thread', $threadinfo); if (!$vbulletin->GPC['fromquickreply']) { $dataman->set_info('show_title_error', true); } if ($foruminfo['podcast'] AND (!empty($post['podcasturl']) OR !empty($post['podcastexplicit']) OR !empty($post['podcastauthor']) OR !empty($post['podcastsubtitle']) OR !empty($post['podcastkeywords']))) { $dataman->set_info('podcastexplicit', $post['podcastexplicit']); $dataman->set_info('podcastauthor', $post['podcastauthor']); $dataman->set_info('podcastkeywords', $post['podcastkeywords']); $dataman->set_info('podcastsubtitle', $post['podcastsubtitle']); $dataman->set_info('podcasturl', $post['podcasturl']); if ($post['podcastsize']) { $dataman->set_info('podcastsize', $post['podcastsize']); } } // set options $dataman->setr('showsignature', $post['signature']); $dataman->setr('allowsmilie', $post['enablesmilies']); $dataman->setr('htmlstate', $post['htmlstate']); // set data $dataman->setr('userid', $vbulletin->userinfo['userid']); if ($vbulletin->userinfo['userid'] == 0) { $dataman->setr('username', $post['username']); } $dataman->setr('title', $post['title']); $dataman->setr('pagetext', $post['message']); $dataman->setr('iconid', $post['iconid']); // see if post has to be moderated or if poster in a mod if ( (( ( ($foruminfo['moderatenewthread'] AND $type == 'thread') OR ($foruminfo['moderatenewpost'] AND $type == 'reply') ) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['followforummoderation']) ) AND !can_moderate($foruminfo['forumid'])) OR ($type == 'reply' AND (($postinfo['postid'] AND !$postinfo['visible'] AND !empty($postinfo['specifiedpost'])) OR !$threadinfo['visible'])) ) { // note: specified post comes from a variable passed into newreply.php $dataman->set('visible', 0); $post['visible'] = 0; } else { $dataman->set('visible', 1); $post['visible'] = 1; } if ($type != 'thread') { if ($postinfo['postid'] == 0) { // get parentid of the new post // we're not posting a new thread, so make this post a child of the first post in the thread $getfirstpost = $vbulletin->db->query_first("SELECT postid FROM " . TABLE_PREFIX . "post WHERE threadid=$threadinfo[threadid] ORDER BY dateline LIMIT 1"); $parentid = $getfirstpost['postid']; } else { $parentid = $postinfo['postid']; } $dataman->setr('parentid', $parentid); $dataman->setr('threadid', $threadinfo['threadid']); } else { $dataman->setr('forumid', $foruminfo['forumid']); } $errors = array(); // done! ($hook = vBulletinHook::fetch_hook('newpost_process')) ? eval($hook) : false; if ($vbulletin->GPC['fromquickreply'] AND $post['preview']) { $errors = array(); return; } if (fetch_require_hvcheck('post') AND !$post['preview']) { require_once(DIR . '/includes/class_humanverify.php'); $verify =& vB_HumanVerify::fetch_library($vbulletin); if (!$verify->verify_token($post['humanverify'])) { $dataman->error($verify->fetch_error()); } } if ($dataman->info['podcastsize']) { $post['podcastsize'] = $dataman->info['podcastsize']; } // check if this forum requires a prefix if ($type == 'thread' AND !$dataman->fetch_field('prefixid') AND ($foruminfo['options'] & $vbulletin->bf_misc_forumoptions['prefixrequired'])) { // only require a prefix if we actually have options for this forum require_once(DIR . '/includes/functions_prefix.php'); if (fetch_prefix_array($foruminfo['forumid'])) { $dataman->error('thread_prefix_required'); } } if ($type == 'thread' AND $post['taglist']) { $threadinfo['postuserid'] = $vbulletin->userinfo['userid']; require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBForum_Thread", $dataman->thread['threadid'], $threadinfo); $limits = $content->fetch_tag_limits(); $content->filter_tag_list_content_limits($post['taglist'], $limits, $tag_errors, true, false); if ($tag_errors) { foreach ($tag_errors AS $error) { $dataman->error($error); } } $dataman->setr('taglist', $post['taglist']); } $dataman->pre_save(); $errors = array_merge($errors, $dataman->errors); if ($post['preview']) { return; } // ### DUPE CHECK ### $dupehash = md5($foruminfo['forumid'] . $post['title'] . $post['message'] . $vbulletin->userinfo['userid'] . $type); $prevpostfound = false; $prevpostthreadid = 0; if ($prevpost = $vbulletin->db->query_first(" SELECT posthash.threadid, thread.title FROM " . TABLE_PREFIX . "posthash AS posthash LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (thread.threadid = posthash.threadid) WHERE posthash.userid = " . $vbulletin->userinfo['userid'] . " AND posthash.dupehash = '" . $vbulletin->db->escape_string($dupehash) . "' AND posthash.dateline > " . (TIMENOW - 300) . " ")) { if (($type == 'thread' AND $prevpost['threadid'] == 0) OR ($type == 'reply' AND $prevpost['threadid'] == $threadinfo['threadid'])) { $prevpostfound = true; $prevpostthreadid = $prevpost['threadid']; } } // Redirect user to forumdisplay since this is a duplicate post if ($prevpostfound) { if ($type == 'thread') { $vbulletin->url = fetch_seo_url('forum', $foruminfo); eval(print_standard_redirect('redirect_duplicatethread', true, true)); } else { // with ajax quick reply we need to use the error system if ($vbulletin->GPC['ajax']) { $dataman->error('duplicate_post'); $errors = $dataman->errors; return; } else { $vbulletin->url = fetch_seo_url('thread', $prevpost, array('goto' => 'newpost')); if ($post['ajaxqrfailed']) { // ajax qr failed. While this is a dupe, most likely the user didn't // see the initial post, so act like it went through. eval(print_standard_redirect('redirect_postthanks')); } else { eval(print_standard_redirect('redirect_duplicatepost', true, true)); } } } } if (sizeof($errors) > 0) { return; } $id = $dataman->save(); if ($type == 'thread') { $post['threadid'] = $id; $threadinfo =& $dataman->thread; $post['postid'] = $dataman->fetch_field('firstpostid'); } else { $post['postid'] = $id; } $post['visible'] = $dataman->fetch_field('visible'); $set_open_status = false; $set_sticky_status = false; if ($vbulletin->GPC['openclose'] AND (($threadinfo['postuserid'] != 0 AND $threadinfo['postuserid'] == $vbulletin->userinfo['userid'] AND $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose']) OR can_moderate($threadinfo['forumid'], 'canopenclose'))) { $set_open_status = true; } if ($vbulletin->GPC['stickunstick'] AND can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $set_sticky_status = true; } if ($set_open_status OR $set_sticky_status) { $thread =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); if ($type == 'thread') { $thread->set_existing($dataman->thread); if ($set_open_status) { $post['postpoll'] = false; } } else { $thread->set_existing($threadinfo); } if ($set_open_status) { $thread->set('open', ($thread->fetch_field('open') == 1 ? 0 : 1)); } if ($set_sticky_status) { $thread->set('sticky', ($thread->fetch_field('sticky') == 1 ? 0 : 1)); } $thread->save(); } if ($type == 'thread') { require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBForum_Thread", $dataman->thread['threadid'], $threadinfo); $limits = $content->fetch_tag_limits(); $content->add_tags_to_content($post['taglist'], $limits); } // ### DO THREAD RATING ### build_thread_rating($post['rating'], $foruminfo, $threadinfo); // ### DO EMAIL NOTIFICATION ### if ($post['visible'] AND $type != 'thread' AND !in_coventry($vbulletin->userinfo['userid'], true)) // AND !$prevpostfound (removed as redundant - bug #22935) { exec_send_notification($threadinfo['threadid'], $vbulletin->userinfo['userid'], $post['postid']); } // ### DO THREAD SUBSCRIPTION ### if ($vbulletin->userinfo['userid'] != 0) { require_once(DIR . '/includes/functions_misc.php'); $post['emailupdate'] = verify_subscription_choice($post['emailupdate'], $vbulletin->userinfo, 9999); ($hook = vBulletinHook::fetch_hook('newpost_subscribe')) ? eval($hook) : false; if (!$threadinfo['issubscribed'] AND $post['emailupdate'] != 9999) { // user is not subscribed to this thread so insert it /*insert query*/ $vbulletin->db->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview) VALUES (" . $vbulletin->userinfo['userid'] . ", $threadinfo[threadid], $post[emailupdate], $post[folderid], 1)"); } else { // User is subscribed, see if they changed the settings for this thread if ($post['emailupdate'] == 9999) { // Remove this subscription, user chose 'No Subscription' $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $threadinfo[threadid] AND userid = " . $vbulletin->userinfo['userid']); } else if ($threadinfo['emailupdate'] != $post['emailupdate'] OR $threadinfo['folderid'] != $post['folderid']) { // User changed the settings so update the current record /*insert query*/ $vbulletin->db->query_write("REPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview) VALUES (" . $vbulletin->userinfo['userid'] . ", $threadinfo[threadid], $post[emailupdate], $post[folderid], 1)"); } } } ($hook = vBulletinHook::fetch_hook('newpost_complete')) ? eval($hook) : false; }
SET threadid = $destthread[threadid] WHERE threadid IN(" . implode(',', array_keys($threadarray)) . ") "); // kill the post cache for the dest thread delete_post_cache_threads(array($destthread['threadid'])); // Update subscribed threads $db->query_write(" UPDATE IGNORE " . TABLE_PREFIX . "subscribethread SET threadid = $destthread[threadid] WHERE threadid IN(" . implode(',', array_keys($threadarray)) . ") "); require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBForum_Thread", $destthread['threadid'], $destthread); $content->merge_tag_attachments(array_keys($threadarray)); $users = array(); $ratings = $db->query_read_slave(" SELECT threadrateid, threadid, userid, vote, ipaddress FROM " . TABLE_PREFIX . "threadrate WHERE threadid IN(" . implode(',', array_keys($threadarray)) . ") "); while ($rating = $db->fetch_array($ratings)) { $id = (!empty($rating['userid'])) ? $rating['userid'] : $rating['ipaddress']; $users["$id"]['vote'] += $rating['vote']; $users["$id"]['total'] += 1; }
/** * Propogate any content specific effects for removing this tag from a content item * * Some content tables may store the list of associated tags in as part of the record * in addition to the main association table. While this is more efficient for lookups * we need to keep track of it when tags are removed. This can happen because a tag * was deleted or because it was replaced with another tag. * * @param Array $associated_content An array of the form 'contenttypeid' => 'contentids' * containing all of the content ids associated with a particular tag */ private function handle_associated_content_removals($associated_content) { //As we add additional content types, we should look at how this logic can be //generalized // update thread taglists foreach ($associated_content as $contenttypeid => $contendids) { foreach ($contendids as $contendid) { $item = vB_Taggable_Content_Item::create($this->registry, $contenttypeid, $contendid); if ($item) { $item->rebuild_content_tags(); } } } }
$vbulletin->url = 'blog.php?' . $vbulletin->session->vars['sessionurl'] . "b=$prevcomment[blogid]"; eval(print_standard_redirect('blog_duplicate_comment', true, true)); } else { if ($show['tag_option'] AND $blog['taglist']) { $blogman->set_info('addtags', true); } if ($blogcomment = $blogman->save()) { // Parse Notify Links build_blog_user_counters($userinfo['userid']); if ($show['tag_option'] AND $blog['taglist']) { require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBBlog_BlogEntry", $blogman->blog['blogid'], $blogman->blog); $limits = $content->fetch_tag_limits(); $content->add_tags_to_content($blog['taglist'], $limits); } if ($show['notify'] AND $blog['notify']) { if ($urls = fetch_urls($vbulletin->GPC['message'])) { $vbulletin->url = 'blog_post.php?' . $vbulletin->session->vars['sessionurl'] . "do=notify&b=$blogcomment"; eval(print_standard_redirect('blog_entrythanks_notify')); } } }