<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.6.4
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000-2006 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

error_reporting(E_ALL & ~E_NOTICE);

// #############################################################################
/**
* Checks whether or not an administrator can post announcements
*
* @param	integer	Forum ID
*
* @return	integer	The return value of this function is really rubbish... who wrote this?
*/
function fetch_announcement_permission_error($forumid)
{
	global $vbulletin, $phrase;

	if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
	{
		if ($forumid == -1 AND !($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']))
		{
			return 1;
		}
		else if ($forumid != -1 AND !can_moderate($forumid, 'canannounce'))
		{
			return 2;
		}
	}

	return 0;
}

// #############################################################################
/**
* Returns the phrase name for an error message
*
* @param	integer	Magic error number
*
* @return	string
*/
function fetch_announcement_permission_error_phrase($errno)
{
	global $vbphrase;
	switch($errno)
	{
		case 1:
			return 'you_do_not_have_permission_global';
			break;
		case 2:
			return 'you_do_not_have_permission_forum';
			break;
		default:
			return construct_phrase($vbphrase['unknown_error'], $errno);
	}
}
 // VBZH - PHPForce - Joey修改开始
 function build_announcement_cache()
 {
 	global $vbulletin;
 	$data = array();
	$allam = $vbulletin->options['displaymannounceonlyglobal'] ? 'AND forumid = \'-1\'' : '';
 	$announcements = $vbulletin->db->query_read("
 		SELECT announcementid, startdate, enddate, title, views,	forumid ,user.username, user.userid
 		FROM " . TABLE_PREFIX . "announcement AS announcement
 		LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = announcement.userid)
 		WHERE startdate <= " . (TIMENOW + 86400 * 1 ). "
 			AND enddate >= " . TIMENOW. " 
 			$allam
 		ORDER BY startdate DESC");
 
 	while ($announcement = $vbulletin->db->fetch_array($announcements))
 	{		
 		$data[] = $announcement;
 		unset($announcement['announcementid']);		
 	}
 	$vbulletin->db->free_result($announcements);
 
 	build_datastore('announcecache', serialize($data));
 }
 // VBZH - PHPForce - Joey修改结束

/*======================================================================*\
|| ####################################################################
|| # CVS: $RCSfile$ - $Revision: 14142 $
|| ####################################################################
\*======================================================================*/
?>