Пример #1
1
function fetch_keywords_list($threadinfo, $pagetext = '')
{
    global $vbphrase, $vbulletin;
    require_once DIR . '/includes/functions_search.php';
    require_once DIR . '/includes/class_taggablecontent.php';
    $keywords = vB_Taggable_Content_Item::filter_tag_list($threadinfo['taglist'], $errors, false);
    if (!empty($threadinfo['prefixid'])) {
        $prefix = $vbphrase["prefix_{$threadinfo['prefixid']}_title_plain"];
        $keywords[] = trim($prefix);
    }
    if (!empty($pagetext)) {
        // title has already been htmlspecialchar'd, pagetext has not
        $words = fetch_postindex_text(unhtmlspecialchars($threadinfo['title']) . ' ' . $pagetext);
        $wordarray = split_string($words);
        $sorted_counts = array_count_values($wordarray);
        arsort($sorted_counts);
        require DIR . '/includes/searchwords.php';
        // get the stop word list; allow multiple requires
        $badwords = array_merge($badwords, preg_split('/\\s+/s', $vbulletin->options['badwords'], -1, PREG_SPLIT_NO_EMPTY));
        foreach ($sorted_counts as $word => $count) {
            $word = trim($word);
            if (in_array(vbstrtolower($word), $badwords)) {
                continue;
            }
            if (vbstrlen($word) <= $vbulletin->options['minsearchlength'] and !in_array(vbstrtolower($word), $goodwords)) {
                continue;
            }
            $word = htmlspecialchars_uni($word);
            if (!in_array($word, $keywords)) {
                $keywords[] = $word;
            }
            if (sizeof($keywords) >= 50) {
                break;
            }
        }
    }
    return implode(', ', $keywords);
}
Пример #2
0
 public function fetch_return_url()
 {
     $url = parent::fetch_return_url();
     if (!$url) {
         $contentinfo = $this->fetch_content_info();
         $this->registry->input->clean_array_gpc('r', array('albumid' => UINT));
         $url = "album.php?albumid=" . $this->registry->GPC['albumid'] . "&pictureid={$contentinfo['pictureid']}#taglist";
     }
     return $url;
 }
Пример #3
0
 $db->query_write("\r\n\t\tUPDATE IGNORE " . TABLE_PREFIX . "reputation\r\n\t\tSET whoadded = {$destinfo['userid']}\r\n\t\tWHERE whoadded = {$sourceinfo['userid']}\r\n\t");
 // Update infractions
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "infraction\r\n\t\tSET userid = {$destinfo['userid']}\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t");
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "infraction\r\n\t\tSET whoadded = {$destinfo['userid']}\r\n\t\tWHERE whoadded = {$sourceinfo['userid']}\r\n\t");
 // Update Private Messages
 $db->query_write("\r\n \t\tUPDATE " . TABLE_PREFIX . "pm\r\n\t\tSET userid = {$destinfo['userid']}\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t\t\tAND folderid = -1\r\n\t");
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "pm\r\n\t\tSET userid = {$destinfo['userid']}, folderid = 0\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t");
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "pmreceipt\r\n\t\tSET userid = {$destinfo['userid']}\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t");
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "pmreceipt\r\n\t\tSET touserid = {$destinfo['userid']},\r\n\t\ttousername = '******'username']) . "'\r\n\t\tWHERE touserid = {$sourceinfo['userid']}\r\n\t");
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "pmtext\r\n\t\tSET fromuserid = {$destinfo['userid']},\r\n\t\tfromusername = '******'username']) . "'\r\n\t\tWHERE fromuserid = {$sourceinfo['userid']}\r\n\t");
 // Update Visitor Messages
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "visitormessage\r\n\t\tSET postuserid = {$destinfo['userid']},\r\n\t\t\tpostusername = '******'username']) . "'\r\n\t\tWHERE postuserid = {$sourceinfo['userid']}\r\n\t");
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "visitormessage\r\n\t\tSET userid = {$destinfo['userid']}\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t");
 // Update tags
 require_once 'includes/class_taggablecontent.php';
 vB_Taggable_Content_Item::merge_users($sourceinfo['userid'], $destinfo['userid']);
 // Update Group Messages
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "groupmessage\r\n\t\tSET postuserid = {$destinfo['userid']},\r\n\t\t\tpostusername = '******'username']) . "'\r\n\t\tWHERE postuserid = {$sourceinfo['userid']}\r\n\t");
 // Clear Group Transfers
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "socialgroup\r\n\t\tSET transferowner = 0\r\n\t\tWHERE transferowner = {$sourceinfo['userid']}\r\n\t");
 // Delete requests if the dest user already has them
 $db->query_write("\r\n\t\tDELETE FROM " . TABLE_PREFIX . "usergrouprequest\r\n\t\tWHERE userid = {$sourceinfo['userid']} AND\r\n\t\t\t(usergroupid = {$destinfo['usergroupid']} " . ($destinfo['membergroupids'] != '' ? "OR usergroupid IN (0,{$destinfo['membergroupids']})" : '') . ")\r\n\t");
 // Convert remaining requests to dest user.
 $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "usergrouprequest\r\n\t\tSET userid = {$destinfo['userid']}\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t");
 $olduser = strlen($sourceinfo['username']);
 $newuser = strlen($destinfo['username']);
 $db->query_write("UPDATE " . TABLE_PREFIX . "pmtext\r\n\t\tSET touserarray = REPLACE(touserarray, 'i:{$sourceinfo['userid']};s:{$olduser}:\"" . $db->escape_string($sourceinfo['username']) . "\";','i:{$destinfo['userid']};s:{$newuser}:\"" . $db->escape_string($destinfo['username']) . "\";')\r\n\t");
 $groups = array();
 $groupids = array();
 $memberships_dest = array();
 $memberships_source = array();
Пример #4
0
 /**
  * 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);
 }
Пример #5
0
	public function fetch_return_url()
	{
		$contentinfo = $this->fetch_content_info();
		$url = parent::fetch_return_url();
		if(!$url)
		{
			$url = 'blog.php?' . $this->registry->session->vars['sessionurl'] . 
				"b=$contentinfo[blogid]#blogtaglist_$contentinfo[blogid]";
		}
		return $url;
	}
Пример #6
0
function tagdomerge()
{
	global $vbulletin, $vbphrase, $db;

	$taglist = tagcp_fetch_tag_list();
	if (!sizeof($taglist))
	{
		print_cp_header($vbphrase['tag_manager']);
		print_stop_message('no_tags_selected');
	}

	$vbulletin->input->clean_array_gpc('p', array(
		'tagtext' => TYPE_NOHTML
	));

	$tagtext = $vbulletin->GPC['tagtext'];

	$name_changed = false;
	$tagdm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY);
	if (!$tagdm->fetch_by_tagtext($tagtext))
	{
		//bail on errors
		if ($tagdm->errors)
		{
			print_cp_header($vbphrase['tag_manager']);
			print_stop_message('generic_error_x', implode('<br /><br />', $tagdm->errors));
		}

		//otherwise create tag
		$errors = array();
		$valid = vB_Taggable_Content_Item::filter_tag_list(array($vbulletin->GPC['tagtext']), $errors);

		if ($errors)
		{
			print_cp_header($vbphrase['tag_manager']);
			print_stop_message('generic_error_x', implode('<br /><br />', $errors));
		}

		if (!empty($valid))
		{
			$tagdm->set('tagtext', $valid[0]);
			$tagdm->set('dateline', TIMENOW);

			if ($tagdm->errors)
			{
				print_cp_header($vbphrase['tag_manager']);
				print_stop_message('generic_error_x', implode('<br /><br />', $tagdm->errors));
			}

			$tagdm->save();
		}
	}
	else
	{
		//if the old tag and new differ only by case, then update
		if ($tagtext != $tagdm->fetch_field('tagtext') AND
			vbstrtolower($tagtext) == vbstrtolower($tagdm->fetch_field('tagtext'))
		)
		{
			$name_changed = true;
			$tagdm->set('tagtext', $tagtext);
			$tagdm->save();
		}
	}

	$targetid = $tagdm->fetch_field('tagid');
	if (!$targetid)
	{
		print_cp_header($vbphrase['tag_manager']);
		print_stop_message('no_changes_made');
	}

	// check if source and targed are the same
	if (sizeof($taglist) == 1 AND in_array($targetid, $taglist))
	{
		if ($name_changed)
		{
			print_cp_header($vbphrase['tag_manager']);
			print_stop_message('tags_edited_successfully');
		}
		else
		{
			print_cp_header($vbphrase['tag_manager']);
		 	print_stop_message('no_changes_made');
		}
	}

	if (false !== ($selected = array_search($targetid, $taglist)))
	{
		// ensure targetid is not in taglist
		unset($taglist[$selected]);
	}


	foreach ($taglist as $mergetagid)
	{
		if ($mergetagid != $targetid)
		{
			$mergetagdm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY);
			if ($mergetagdm->fetch_by_id($mergetagid))
			{
				$mergetagdm->make_synonym($targetid);
			}
		}
	}

	// need to invalidate the search and tag cloud caches
	build_datastore('tagcloud', '', 1);
	build_datastore('searchcloud', '', 1);

	setcookie('vbulletin_inlinetag', '', TIMENOW - 3600, '/');
	print_cp_header($vbphrase['tag_manager']);
	print_stop_message('tags_edited_successfully');
}
Пример #7
0
	/**
	*
	* @param	boolean	Do the query?
	*/
	function post_delete($doquery = true)
	{
		// A user's blog entries can only be found from searching after the user is deleted.
		if (!$this->info['skip_blog_entries'])
		{
			$blogids = array();
			$blogs = $this->dbobject->query_read_slave("
				SELECT *
				FROM " . TABLE_PREFIX . "blog
				WHERE userid = " . intval($this->fetch_field('bloguserid')
			));
			while ($blog = $this->dbobject->fetch_array($blogs))
			{
				$blogids[] = intval($blog['blogid']);
			}

			if (sizeof($blogids))
			{
				$blogids = implode(',', $blogids);

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_deletionlog WHERE primaryid IN ($blogids) AND type = 'blogid'
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid IN ($blogids) AND type = 'blogid'
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_pinghistory WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_rate WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_read WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_tachyentry WHERE blogid IN ($blogids)
				");

				$this->dbobject->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 IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_trackback WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_views WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_hash
					WHERE blogid IN ($blogids)
				");

				require_once(DIR . '/includes/class_taggablecontent.php');
				vB_Taggable_Content_Item::delete_tag_attachments_list("vBBlog_BlogEntry", explode(',', $blogids));

				$attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT);
				$attachdata->condition = "a.contentid IN ($blogids)";
				$attachdata->delete();

				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 IN ($blogids) AND a.contenttypeid = " . intval($contenttypeid);
				$attachdata->delete(true, false);

				$this->dbobject->query_write("
					DELETE  FROM " . TABLE_PREFIX . "blog WHERE blogid IN ($blogids)
				");
			}
		}
		else
		{
			$this->dbobject->query_write("
				UPDATE " . TABLE_PREFIX . "blog SET
					username = '******'verifyuser']['username']) . "',
					userid = 0
				WHERE userid = " . intval($this->fetch_field('bloguserid'))
			);
		}

		// User's comments
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "blog_text SET
				username = '******'verifyuser']['username']) . "',
				userid = 0
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Deleted items belonging to user
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "blog_deletionlog
			SET username = '******'verifyuser']['username']) . "'
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's category to post list
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_categoryuser
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's categories
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_category
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's read status
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_read
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's search records
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_search
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Blog Subscriptions
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Post Subscriptions
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_subscribeuser
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_subscribeuser
			WHERE bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's read status for blogs and anyone for they're blog
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_userread
			WHERE userid = " . intval($this->fetch_field('bloguserid')) . " OR bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		// Groups
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "blog
			SET
				postedby_userid = userid,
				postedby_username = username
			WHERE postedby_userid = " . intval($this->fetch_field('bloguserid'))
		);

		$users = $this->dbobject->query_read_slave("
			SELECT userid
			FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		while ($user = $this->dbobject->fetch_array($users))
		{
			build_blog_memberblogids($user['userid']);
		}

		$groups = $this->dbobject->query_read_slave("
			SELECT bloguserid
			FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Blog Customizations
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_usercss
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_usercsscache
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		while ($group = $this->dbobject->fetch_array($groups))
		{
			build_blog_memberids($group['bloguserid']);
		}

		($hook = vBulletinHook::fetch_hook('blog_userdata_delete')) ? eval($hook) : false;
	}
Пример #8
0
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
	");
}
Пример #9
0
 public function insertTags($tagtext)
 {
     $response = array();
     $exception = new vB_Exception_Api();
     $tagdm = new vB_DataManager_Tag(vB_DataManager_Constants::ERRTYPE_ARRAY);
     if ($tagdm->fetch_by_tagtext($tagtext)) {
         $exception->add_error("tag_exists", array());
     }
     if ($tagtext and is_string($tagtext)) {
         require_once DIR . '/includes/class_taggablecontent.php';
         $valid = vB_Taggable_Content_Item::filter_tag_list(array($tagtext), $errors, false);
     } else {
         $exception->add_error("invalid_tag_value", array());
     }
     if (!empty($valid)) {
         $tagdm->set('tagtext', $valid[0]);
         $tagdm->set('dateline', vB::getRequest()->getTimeNow());
         if ($tagdm->errors) {
             $exception->add_error($tagdm->errors, array());
         }
         $tagdm->save();
         $response['result'] = true;
     } else {
         if (!empty($errors)) {
             foreach ($errors as $error) {
                 $phraseid = $error[0];
                 unset($error[0]);
                 $exception->add_error($phraseid, $error);
             }
         } else {
             $exception->add_error("invalid_tag_value", array());
         }
     }
     //Exception Handling
     if ($exception->has_errors()) {
         throw $exception;
     }
     return $response;
 }
Пример #10
0
		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;
	}
Пример #11
0
 /**
  *	Add a filter for a tag
  *
  *	@param string $tag - the tag string to filter on
  */
 public function add_tag_filter($tags)
 {
     require_once DIR . '/includes/class_taggablecontent.php';
     if (!is_array($tags)) {
         $tags = vB_Taggable_Content_Item::split_tag_list($tags);
     }
     $existing_tags = array();
     $query = vB::getDbAssertor()->assertQuery('vBForum:tag', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'tagtext' => $tags));
     while ($query and $query->valid()) {
         $row = $query->current();
         $existing_tags[$row['tagtext']] = $row['tagid'];
         $index = array_search($row['tagtext'], $tags);
         if ($index !== false) {
             unset($tags[$index]);
         }
         $row = $query->next();
     }
     /** @todo rewrite this part */
     //		foreach ($tags as $key => $tag)
     //		{
     //			$tag = trim($tag);
     //
     //			$verified_tag = datamanager_init('tag', vB::getDatastore(), vB_DataManager_Constants::ERRTYPE_ARRAY);
     //			if (!$verified_tag->fetch_by_tagtext($tag))
     //			{
     //				//$this->errors[] = 'invalid_tag_specified';
     //				$this->add_error('invalid_tag_specified');
     //				unset($tags[$key]);
     //			}
     //			else
     //			{
     //				//if this is a synonym search against the canonical tag.
     //				if ($verified_tag->is_synonym())
     //				{
     //					$synonym = $verified_tag;
     //					$verified_tag = $verified_tag->fetch_canonical_tag();
     //					$this->set_tag_display_string($verified_tag, $synonym);
     //				}
     //				else
     //				{
     //					$this->set_tag_display_string($verified_tag);
     //				}
     //				$tags[$key] = $verified_tag->fetch_field("tagid");
     //			}
     //
     //		}
     $this->add_filter('tag', vB_Search_Core::OP_EQ, $existing_tags, true);
     if (!empty($tags)) {
         foreach ($tags as $tag) {
             $this->add_null_filter("Tag {$tag} does not exist.");
         }
     }
     return $existing_tags;
 }
Пример #12
0
 /**
  *	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();
             }
         }
     }
 }
Пример #13
0
function fr_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('/&#0*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']);
    // 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 firstpostid AS postid FROM " . TABLE_PREFIX . "thread WHERE threadid = {$threadinfo['threadid']}");
            $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 ($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("\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') {
            json_error(ERR_DUPE_THREAD, RV_POST_ERROR);
        } else {
            json_error(ERR_DUPE_POST, RV_POST_ERROR);
        }
    }
    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)) {
        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;
}
Пример #14
0
	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;
	}
Пример #15
0
 public function fetch_return_url()
 {
     $url = parent::fetch_return_url();
     if (!$url) {
         $url = fetch_seo_url('thread', $this->fetch_content_info()) . '#taglist';
     }
     return $url;
 }
Пример #16
0
$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));
Пример #17
0
 /**
  *	Add a filter for a tag
  *
  *	@param $tag -- the tag string to filter on
  */
 public function add_tag_filter($tag)
 {
     if (!trim($tag)) {
         return;
     }
     global $vbphrase;
     require_once DIR . '/includes/class_taggablecontent.php';
     $tags = vB_Taggable_Content_Item::split_tag_list($tag);
     foreach ($tags as $key => $tag) {
         $tag = trim($tag);
         $verified_tag = datamanager_init('tag', $GLOBALS['vbulletin'], ERRTYPE_ARRAY);
         if (!$verified_tag->fetch_by_tagtext($tag)) {
             //$this->errors[] = 'invalid_tag_specified';
             $this->add_error('invalid_tag_specified');
             unset($tags[$key]);
         } else {
             //if this is a synonym search against the canonical tag.
             if ($verified_tag->is_synonym()) {
                 $synonym = $verified_tag;
                 $verified_tag = $verified_tag->fetch_canonical_tag();
                 $this->set_tag_display_string($verified_tag, $synonym);
             } else {
                 $this->set_tag_display_string($verified_tag);
             }
             $tags[$key] = $verified_tag->fetch_field("tagid");
         }
     }
     //for now, only allow one tag in a search.
     $this->add_filter('tag', vB_Search_Core::OP_EQ, $tags[0], true);
 }
Пример #18
0
	/**
	 * 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");

	}
Пример #19
0
         // 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 {
Пример #20
0
 /**
  * Merge two users
  *
  * @param integer $sourceuserid
  * @param integer $destuserid
  */
 public function merge($sourceuserid, $destuserid)
 {
     $this->checkHasAdminPermission('canadminusers');
     $assertor = vB::getDbAssertor();
     if (!($sourceinfo = $assertor->getRow('user_fetchwithtextfield', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $sourceuserid)))) {
         throw new vB_Exception_Api('invalid_source_username_specified');
     }
     if (!($destinfo = $assertor->getRow('user_fetchwithtextfield', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $destuserid)))) {
         throw new vB_Exception_Api('invalid_destination_username_specified');
     }
     /*
     		// Update Subscribed Forums
     		$assertor->assertQuery('userInsertSubscribeforum', array(
     			vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD,
     			'sourceuserid' => $sourceinfo['userid'],
     			'destuserid' => $destinfo['userid'],
     		));
     
     		$assertor->assertQuery('user_updatesubscribethread', array(
     			'userid' => $destinfo['userid'],
     		));
     
     		$assertor->assertQuery('userInsertSubscribethread', array(
     			vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD,
     			'sourceuserid' => $sourceinfo['userid'],
     			'destuserid' => $destinfo['userid'],
     		));
     
     		require_once(DIR . '/includes/functions_databuild.php');
     		update_subscriptions(array('userids' => array($destinfo['userid'])));
     */
     // Update Subscribed Events
     $assertor->assertQuery('userInsertSubscribeevent', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     /*
     REPLACE INTO
     */
     // Merge relevant data in the user table
     // It is ok to have duplicate ids in the buddy/ignore lists
     $userdm = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_SILENT);
     $userdm->set_existing($destinfo);
     $options = vB::getDatastore()->getValue('options');
     $userdm->set('posts', "posts + {$sourceinfo['posts']}", false);
     $userdm->set_ladder_usertitle_relative($sourceinfo['posts']);
     $userdm->set('reputation', "reputation + {$sourceinfo['reputation']} - " . $options['reputationdefault'], false);
     $userdm->set('lastvisit', "IF(lastvisit < {$sourceinfo['lastvisit']}, {$sourceinfo['lastvisit']}, lastvisit)", false);
     $userdm->set('lastactivity', "IF(lastactivity < {$sourceinfo['lastactivity']}, {$sourceinfo['lastactivity']}, lastactivity)", false);
     $userdm->set('lastpost', "IF(lastpost < {$sourceinfo['lastpost']}, {$sourceinfo['lastpost']}, lastpost)", false);
     $userdm->set('pmtotal', "pmtotal + {$sourceinfo['pmtotal']}", false);
     $userdm->set('pmunread', "pmunread + {$sourceinfo['pmunread']}", false);
     $userdm->set('gmmoderatedcount', "gmmoderatedcount + {$sourceinfo['gmmoderatedcount']}", false);
     if ($sourceinfo['joindate'] > 0) {
         // get the older join date, but only if we actually have a date
         $userdm->set('joindate', "IF(joindate > {$sourceinfo['joindate']}, {$sourceinfo['joindate']}, joindate)", false);
     }
     $userdm->set('ipoints', "ipoints + " . intval($sourceinfo['ipoints']), false);
     $userdm->set('warnings', "warnings + " . intval($sourceinfo['warnings']), false);
     $userdm->set('infractions', "infractions + " . intval($sourceinfo['infractions']), false);
     $assertor->assertQuery('user_insertuserlist', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     $assertor->assertQuery('user_updateuserlist', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     $myfriendcount = $assertor->getField('user_fetchuserlistcount', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $destinfo['userid']));
     $userdm->set('friendcount', $myfriendcount);
     $userdm->save();
     unset($userdm);
     require_once DIR . '/includes/functions_databuild.php';
     build_userlist($destinfo['userid']);
     // if the source user has infractions, then we need to update the infraction groups on the dest
     // easier to do it this way to make sure we get fresh info about the destination user
     if ($sourceinfo['ipoints']) {
         unset($usercache["{$destinfo['userid']}"]);
         $new_user = vB_User::fetchUserInfo($destinfo['userid']);
         $infractiongroups = array();
         $groups = $assertor->assertQuery('user_fetchinfractiongroup', array());
         foreach ($groups as $group) {
             $infractiongroups["{$group['usergroupid']}"]["{$group['pointlevel']}"][] = array('orusergroupid' => $group['orusergroupid'], 'override' => $group['override']);
         }
         $userdm = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_SILENT);
         $userdm->set_existing($new_user);
         $infractioninfo = vB_Library::instance('Content_Infraction')->fetchInfractionGroups($infractiongroups, $new_user['userid'], $new_user['ipoints'], $new_user['usergroupid']);
         $userdm->set('infractiongroupids', $infractioninfo['infractiongroupids']);
         $userdm->set('infractiongroupid', $infractioninfo['infractiongroupid']);
         $userdm->save();
         unset($userdm);
     }
     // Update announcements
     $assertor->assertQuery('user_updateannouncement', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Update Read Announcements
     $assertor->assertQuery('userInsertAnnouncementread', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Update Deletion Log
     $assertor->assertQuery('user_updatedeletionlog', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid'], 'destusername' => $destinfo['username']));
     // Update Edit Log
     $assertor->assertQuery('user_updateeditlog', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid'], 'destusername' => $destinfo['username']));
     // Update Edit Log
     $assertor->assertQuery('user_updatepostedithistory', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid'], 'destusername' => $destinfo['username']));
     // Update Poll Votes - find any poll where we both voted
     // we need to remove the source user's vote
     $pollconflicts = array();
     $polls = $assertor->assertQuery('user_fetchpollvote', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     foreach ($polls as $poll) {
         $pollconflicts["{$poll['nodeid']}"] = $poll;
     }
     $assertor->assertQuery('user_updatepollvote', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     if (!empty($pollconflicts)) {
         $assertor->assertQuery('user_deletepollvote', array('userid' => $sourceinfo['userid']));
         // Polls that need to be rebuilt now
         foreach ($pollconflicts as $pollconflict) {
             vB_Api::instanceInternal('poll')->updatePollCache($pollconflict['nodeid']);
             $pollvotes = $assertor->assertQuery('user_fetchpollvote2', array('nodeid' => $pollconflict['nodeid']));
             $lastvote = 0;
             foreach ($pollvotes as $pollvote) {
                 if ($pollvote['votedate'] > $lastvote) {
                     $lastvote = $pollvote['votedate'];
                 }
             }
             // It appears that pollvote.votedate wasn't always set in the past so we could have votes with no datetime, hence the check on lastvote below
             $assertor->assertQuery('userUpdatePoll', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'nodeid' => $pollconflict['nodeid'], 'lastvote' => $lastvote));
         }
     }
     // Update User Notes
     $assertor->assertQuery('user_updateusernote', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     $assertor->assertQuery('user_updateusernote2', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Update Calendar Events
     $assertor->assertQuery('user_updateevent', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Update Reputation Details
     $assertor->assertQuery('user_updatereputation', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     $assertor->assertQuery('user_updatereputation2', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Update infractions
     $assertor->assertQuery('user_updateinfraction', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     $assertor->assertQuery('user_updateinfraction2', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Update tags
     require_once DIR . '/includes/class_taggablecontent.php';
     vB_Taggable_Content_Item::merge_users($sourceinfo['userid'], $destinfo['userid']);
     // Clear Group Transfers
     //		$assertor->assertQuery('user_updatesocialgroup', array(
     //			'userid' => $sourceinfo['userid'],
     //		));
     // Delete requests if the dest user already has them
     $assertor->assertQuery('userDeleteUsergrouprequest', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'sourceuserid' => $sourceinfo['userid'], 'destusergroupid' => $destinfo['usergroupid'], 'destmembergroupids' => $destinfo['membergroupids']));
     // Convert remaining requests to dest user.
     $assertor->assertQuery('user_updateusergrouprequest', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Paid Subscriptions
     $assertor->assertQuery('user_updatepaymentinfo', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     // Move subscriptions over
     $assertor->assertQuery('user_updatesubscriptionlog', array('sourceuserid' => $sourceinfo['userid'], 'destuserid' => $destinfo['userid']));
     $list = $remove = $update = array();
     // Combine active subscriptions
     $subs = $assertor->assertQuery('user_fetchsubscriptionlog', array('userid' => $destinfo['userid']));
     foreach ($subs as $sub) {
         $subscriptionid = $sub['subscriptionid'];
         $existing = $list[$subscriptionid];
         if ($existing) {
             if ($sub['expirydate'] > $existing['expirydate']) {
                 $remove[] = $existing['subscriptionlogid'];
                 unset($update[$existing['subscriptionlogid']]);
                 $list[$subscriptionid] = $sub;
                 $update[$sub['subscriptionlogid']] = $sub['expirydate'];
             } else {
                 $remove[] = $sub['subscriptionlogid'];
             }
         } else {
             $list[$subscriptionid] = $sub;
         }
     }
     if (!empty($remove)) {
         $assertor->assertQuery('user_deletesubscriptionlog', array('ids' => $remove));
     }
     foreach ($update as $subscriptionlogid => $expirydate) {
         $assertor->assertQuery('user_updatesubscriptionlog2', array('expirydate' => $expirydate, 'subscriptionlogid' => $subscriptionlogid));
     }
     //fix the names on any nodes that the user may be attached to.
     $assertor->assertQuery('vBForum:node', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array('userid' => $sourceinfo['userid']), 'authorname' => $destinfo['username'], 'userid' => $destinfo['userid']));
     $assertor->assertQuery('vBForum:node', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array('lastauthorid' => $sourceinfo['userid']), 'lastcontentauthor' => $destinfo['username'], 'lastauthorid' => $destinfo['userid']));
     // Remove remnants of source user
     $userdm = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_SILENT);
     $userdm->set_existing($sourceinfo);
     $userdm->delete();
     unset($userdm);
     return true;
 }
Пример #21
0
	/**
	 * 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,'?') ? '&amp;' : '?';
			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,'?') ? '&amp;' : '?';
			$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,'?') ? '&amp;' : '?';
			$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;
	}
Пример #22
0
	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;
	}
Пример #23
0
	/**
	 * 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,'?') ? '&amp;' : '?';
			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, '?' ) ? '&amp;p=' :  '?p=') . $view->postid .
							'#post' . $view->postid;
						$view->post_url = $post_url;
					}
				}

				$view->comment_count = $this->content->getReplyCount();
				$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
				$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,'?') ? '&amp;' : '?';
				$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;
	}
Пример #24
0
	/**
	* 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);
	}
Пример #25
0
				$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&amp;b=$blogcomment";
							eval(print_standard_redirect('blog_entrythanks_notify'));
						}
					}
				}