Vergleich inc/tasks/promotions.php - 1.6.8 - 1.6.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: promotions.php 5828 2012-05-08 16:06:16Z Tomm $

 * $Id$

 */

function task_promotions($task)
{
global $mybb, $db, $lang, $cache;

 */

function task_promotions($task)
{
global $mybb, $db, $lang, $cache;

	



	$usergroups = $cache->read("usergroups");
// Iterate through all our promotions
$query = $db->simple_select("promotions", "*", "enabled = '1'");

	$usergroups = $cache->read("usergroups");
// Iterate through all our promotions
$query = $db->simple_select("promotions", "*", "enabled = '1'");

Zeile 28Zeile 28
			$db->update_query("promotions", $update, "pid = '" . intval($promotion['pid']) . "'");
continue;
}

			$db->update_query("promotions", $update, "pid = '" . intval($promotion['pid']) . "'");
continue;
}

		



		$and = "";
$sql_where = "";

		$and = "";
$sql_where = "";

		



		// Based on the promotion generate criteria for user selection
$requirements = explode(',', $promotion['requirements']);
if(in_array('postcount', $requirements) && intval($promotion['posts']) >= 0 && !empty($promotion['posttype']))
{
$sql_where .= "{$and}postnum {$promotion['posttype']} '{$promotion['posts']}'";

		// Based on the promotion generate criteria for user selection
$requirements = explode(',', $promotion['requirements']);
if(in_array('postcount', $requirements) && intval($promotion['posts']) >= 0 && !empty($promotion['posttype']))
{
$sql_where .= "{$and}postnum {$promotion['posttype']} '{$promotion['posts']}'";

			
$and = " AND ";
}



$and = " AND ";
}


		if(in_array('reputation', $requirements) && !empty($promotion['reputationtype']))

		if(in_array('reputation', $requirements) && !empty($promotion['reputationtype']))

		{

		{

			$sql_where .= "{$and}reputation {$promotion['reputationtype']} '{$promotion['reputations']}'";

			$sql_where .= "{$and}reputation {$promotion['reputationtype']} '{$promotion['reputations']}'";

			
$and = " AND ";
}



$and = " AND ";
}


		if(in_array('referrals', $requirements) && intval($promotion['referrals']) >= 0 && !empty($promotion['referralstype']))
{
$sql_where .= "{$and}referrals {$promotion['referralstype']} '{$promotion['referrals']}'";

		if(in_array('referrals', $requirements) && intval($promotion['referrals']) >= 0 && !empty($promotion['referralstype']))
{
$sql_where .= "{$and}referrals {$promotion['referralstype']} '{$promotion['referrals']}'";

			



			$and = " AND ";
}

			$and = " AND ";
}

		



		if(in_array('timeregistered', $requirements) && intval($promotion['registered']) > 0 && !empty($promotion['registeredtype']))

		if(in_array('timeregistered', $requirements) && intval($promotion['registered']) > 0 && !empty($promotion['registeredtype']))

		{

		{

			switch($promotion['registeredtype'])
{
case "hours":
$regdate = $promotion['registered']*60*60;

			switch($promotion['registeredtype'])
{
case "hours":
$regdate = $promotion['registered']*60*60;

					break;

					break;

				case "days":
$regdate = $promotion['registered']*60*60*24;

				case "days":
$regdate = $promotion['registered']*60*60*24;

					break;

					break;

				case "weeks":
$regdate = $promotion['registered']*60*60*24*7;

				case "weeks":
$regdate = $promotion['registered']*60*60*24*7;

 
					break;

				case "months":
$regdate = $promotion['registered']*60*60*24*30;
break;

				case "months":
$regdate = $promotion['registered']*60*60*24*30;
break;

Zeile 79Zeile 80
			$sql_where .= "{$and}regdate <= '".(TIME_NOW-$regdate)."'";
$and = " AND ";
}

			$sql_where .= "{$and}regdate <= '".(TIME_NOW-$regdate)."'";
$and = " AND ";
}

		



		if(!empty($promotion['originalusergroup']) && $promotion['originalusergroup'] != '*')

		if(!empty($promotion['originalusergroup']) && $promotion['originalusergroup'] != '*')

		{

		{

			$sql_where .= "{$and}usergroup IN ({$promotion['originalusergroup']})";

			$sql_where .= "{$and}usergroup IN ({$promotion['originalusergroup']})";

				
$and = " AND ";
}



$and = " AND ";
}


		if(!empty($promotion['newusergroup']))
{
$sql_where .= "{$and}usergroup != '{$promotion['newusergroup']}'";

		if(!empty($promotion['newusergroup']))
{
$sql_where .= "{$and}usergroup != '{$promotion['newusergroup']}'";

					



			$and = " AND ";
}

			$and = " AND ";
}

		



		$sql_where .= "{$and}lastactive >= '{$task['lastrun']}'";

		$sql_where .= "{$and}lastactive >= '{$task['lastrun']}'";

		





// Exclude super admins
$sql_where .= not_super_admins(true);


		$uid = array();
$log_inserts = array();

		$uid = array();
$log_inserts = array();

		



		if($promotion['usergrouptype'] == "secondary")
{
$usergroup_select = "additionalgroups";

		if($promotion['usergrouptype'] == "secondary")
{
$usergroup_select = "additionalgroups";

Zeile 107Zeile 111
		{
$usergroup_select = "usergroup";
}

		{
$usergroup_select = "usergroup";
}

		



		$query2 = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
while($user = $db->fetch_array($query2))
{

		$query2 = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
while($user = $db->fetch_array($query2))
{

Zeile 118Zeile 122
					'pid' => $promotion['pid'],
'uid' => $user['uid'],
'oldusergroup' => $user['additionalgroups'],

					'pid' => $promotion['pid'],
'uid' => $user['uid'],
'oldusergroup' => $user['additionalgroups'],

					'newusergroup' => $promotion['newusergroup'],

					'newusergroup' => $promotion['newusergroup'],

					'dateline' => TIME_NOW,
'type' => "secondary",

					'dateline' => TIME_NOW,
'type' => "secondary",

				);

				);

			}
else
{

			}
else
{

Zeile 134Zeile 138
					'type' => "primary",
);
}

					'type' => "primary",
);
}

		



			$uids[] = $user['uid'];

			$uids[] = $user['uid'];

			





			if($usergroup_select == "additionalgroups")

			if($usergroup_select == "additionalgroups")

			{

			{

				if(join_usergroup($user['uid'], $promotion['newusergroup']) === false)
{
// Did the user already have the additional usergroup?

				if(join_usergroup($user['uid'], $promotion['newusergroup']) === false)
{
// Did the user already have the additional usergroup?

Zeile 147Zeile 151
					array_pop($uids);
}
}

					array_pop($uids);
}
}

			



			if((count($uids) % 20) == 0)
{
if($usergroup_select == "usergroup")

			if((count($uids) % 20) == 0)
{
if($usergroup_select == "usergroup")

				{

				{

					$db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(".implode(",", $uids).")");

					$db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(".implode(",", $uids).")");

				}


				}


				if(!empty($log_inserts))
{
$db->insert_query_multiple("promotionlogs", $log_inserts);
}

				if(!empty($log_inserts))
{
$db->insert_query_multiple("promotionlogs", $log_inserts);
}

				



				$uids = array();
$log_inserts = array();
}
}

				$uids = array();
$log_inserts = array();
}
}

		



		if(count($uids) > 0)
{
if($usergroup_select == "usergroup")

		if(count($uids) > 0)
{
if($usergroup_select == "usergroup")

			{

			{

				$db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(".implode(",", $uids).")");

				$db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(".implode(",", $uids).")");

			}


			}


			if(!empty($log_inserts))
{
$db->insert_query_multiple("promotionlogs", $log_inserts);
}

			if(!empty($log_inserts))
{
$db->insert_query_multiple("promotionlogs", $log_inserts);
}

				



			$uids = array();
$log_inserts = array();
}
}

			$uids = array();
$log_inserts = array();
}
}

	



	$cache->update_moderators();

	$cache->update_moderators();

	



	add_task_log($task, $lang->task_promotions_ran);
}
?>

	add_task_log($task, $lang->task_promotions_ran);
}
?>