Exemple #1
0
	public static function create_array($ids)
	{
		global $vbulletin, $usercache;
		//where going to punt a little.  The permissions logic is nasty and complex
		//and tied to the current user.  I don't want to try to rewrite it.
		//So we'll pull in the current user here and go with it.

		$perm_parts = build_blog_permissions_query($vbulletin->userinfo);

		$blog_user_join = "";
		if (strpos($perm_parts['join'], 'blog_user AS blog_user') === false)
		{
			$blog_user_join = "LEFT JOIN " . TABLE_PREFIX .
				"blog_user AS blog_user ON (blog_user.bloguserid = blog.userid)\n";
		}

		$set = $vbulletin->db->query_read_slave("
			SELECT blog.*, IF(blog_user.title <> '', blog_user.title, blog.username) AS blogtitle,
			blog_text.pagetext
			FROM " . TABLE_PREFIX ."blog AS blog
			LEFT JOIN " . TABLE_PREFIX ."blog_text AS blog_text on blog_text.blogtextid = blog.firstblogtextid
			$blog_user_join $perm_parts[join]
			WHERE blog.blogid IN (" . implode(',', array_map('intval', $ids)) . ") AND ($perm_parts[where])
		");

		$items = array();
		while ($record = $vbulletin->db->fetch_array($set))
		{
			$item = new vBBlog_Search_Result_BlogEntry();
			$item->record = $record;
			$items[$record['blogid']] = $item;
		}

		return $items;
	}
Exemple #2
0
		$search->set_sort($criteria['sort'], $criteria['sortorder']);

		if ($search->has_errors())
		{
			$searcherrors = $search->generator->errors;
		}

		if (!$search->has_criteria())
		{
			$searcherrors[] = fetch_error('blog_need_search_criteria');
		}

		if (empty($searcherrors))
		{
			$search_perms = build_blog_permissions_query($vbulletin->userinfo);
			$searchid = $search->execute($search_perms);
			($hook = vBulletinHook::fetch_hook('blog_search_dosearch_complete')) ? eval($hook) : false;

			if ($search->has_errors())
			{
				$searcherrors = $search->generator->errors;
			}
			else
			{
				$vbulletin->url = 'blog_search.php?' . $vbulletin->session->vars['sessionurl'] . "do=searchresults&searchid=$searchid";
				eval(print_standard_redirect('blog_search_executed'));
			}
		}
	}
Exemple #3
0
 /**
  * Adds the blog URLs to $this->content
  *
  * @param 	int		forumdid to start at
  * @param 	int		perpage limit defaults to 30000
  */
 public function generate_sitemap($startat = 0, $perpage = 30000)
 {
     //See if we need to bootstrap
     require_once DIR . '/includes/blog_functions_search.php';
     require_once DIR . '/includes/functions.php';
     $guestuser = array('userid' => 0, 'usergroupid' => 0);
     cache_permissions($guestuser, false);
     $perms = build_blog_permissions_query($guestuser);
     $this->blogs = array();
     $sql = "SELECT blog.blogid, blog.title, blog.userid, blog.dateline,\n\t\t\tblog.lastcomment, blog.comments_visible, count(bt.blogtextid) AS qty\n\t\t \tFROM " . TABLE_PREFIX . "blog AS blog\n\t\t \tLEFT JOIN " . TABLE_PREFIX . "blog_text AS bt ON blog.blogid = bt.blogid\n\t\t\t" . $perms['join'] . "\n\t\t\tWHERE " . $perms['where'] . "\n\t\t\tGROUP BY blog.blogid, blog.title, blog.userid, blog.dateline,\n\t\t\tblog.lastcomment, blog.comments_visible LIMIT {$startat}, {$perpage}";
     $rst = $this->registry->db->query_read_slave($sql);
     $authorkeys = array_keys($this->custom_priority['blog']['authors']);
     while ($blog = $this->registry->db->fetch_array($rst)) {
         $this->pagecount++;
         $this->lastid = $blog['blogid'];
         //get the two ages- post and last comment, and the author points
         $postmonths = intval($blog['lastcomment']) ? floor((TIMENOW - $blog['lastcomment']) / (30 * 86400)) : 0;
         $agemonths = intval($blog['dateline']) ? floor((TIMENOW - $blog['dateline']) / (30 * 86400)) : 0;
         $commentmult = (intval($blog['qty']) and intval($blog['comments_visible'])) ? floor($blog['qty'] / 10) : 0;
         $authpoints = in_array($blog['userid'], $authorkeys) ? floatval($this->custom_priority['blog']['authors'][$blog['userid']]) : 0;
         //and calculate the rating
         $priority = $this->custom_priority['blog']['default'] - min($postmonths * $this->custom_priority['blog']['age_pts'], $this->custom_priority['blog']['age_max']) - min($agemonths * $this->custom_priority['blog']['c_age_pts'], $this->custom_priority['blog']['c_age_max']) + min($commentmult * $this->custom_priority['blog']['comm_pts'], $this->custom_priority['blog']['comm_max']);
         //We want a two-digit number between 0 and 1
         $priority = max(min($priority, 1), 0);
         $priority = round($priority, 2);
         //and the url
         $url = fetch_seo_url('entry', array('blogid' => $blog['blogid'], 'page' => 1, 'blogtitle' => $blog['title'], 'title' => $blog['title'], 'id' => $blog['blogid']), $pageinfo);
         $this->content .= $this->url_block($registry->options['bburl'] . $url, $blog['lastcomment'], $priority);
         if ($this->pagecount >= $perpage) {
             $this->has_more = true;
             break;
         }
     }
     // Return the amout done
     return $this->pagecount;
 }