本文整理汇总了PHP中Campaign::calcStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Campaign::calcStatus方法的具体用法?PHP Campaign::calcStatus怎么用?PHP Campaign::calcStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Campaign
的用法示例。
在下文中一共展示了Campaign::calcStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
if ($_SERVER['LOGNAME'] == 'safeballots') {
set_include_path($_SERVER['PWD'] . '/httpdocs/');
date_default_timezone_set('America/Halifax');
include_once 'core/Database.php';
include_once 'modules/Campaigns/include/Campaign.php';
include_once 'modules/Campaigns/include/CampaignUser.php';
include_once 'include/Site.php';
$sql = 'SELECT id FROM campaigns where autosend = 1';
$debug = false;
if (@$argv[1] == 'debug') {
$debug = true;
}
$results = Database::singleton()->query_fetch_all($sql);
foreach ($results as &$campaign) {
$campaign = new Campaign($campaign['id']);
switch ($campaign->calcStatus(true)) {
case 2:
break;
case 1:
$sql = 'SELECT aut_email FROM auth WHERE aut_agp_id = ' . $campaign->getGroup() . ' LIMIT 1';
$email = Database::singleton()->query_fetch($sql);
$email = $email['aut_email'];
$sql = 'SELECT agp_name FROM auth_groups WHERE agp_id = ' . $campaign->getGroup();
$group = Database::singleton()->query_fetch($sql);
$group = $group['agp_name'];
$campaign->mailOut('votes', $group, $email);
if ($debug) {
echo "Sent " . $campaign->getName() . " emails.\n";
}
default:
$sql = 'UPDATE campaigns SET autosend = 0 WHERE id = ' . $campaign->getId();
示例2: getByEmail
public static function getByEmail($addr)
{
if (eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.([a-zA-Z]{2,4})$', $addr)) {
$sql = 'SELECT id FROM campaign_recipients WHERE email = \'' . e($addr) . "'";
$result = Database::singleton()->query_fetch_all($sql);
if ($result && count($result) == 1) {
$id = $result[0]['id'];
$sql = 'INSERT INTO campaign_hash_requests SET IP = \'' . $_SERVER['REMOTE_ADDR'] . '\', email = \'' . e($addr) . '\'';
Database::singleton()->query($sql);
$sql = 'SELECT hash,campaign_id FROM campaign_hash WHERE user_id = ' . $id;
$results = Database::singleton()->query_fetch_all($sql);
$body = "This e-mail address was used to request the retrieval of hash keys on the SafeBallot system. " . "If you believe you have received this message in error, please contact the person in charge of voting " . "campaigns at your organization and ensure to keep the original copy of this contact.\n\nHash keys:\n";
if ($results) {
for ($i = 0; $i < count($results); $i++) {
$cid = $results[$i]["campaign_id"];
$hash = $results[$i]["hash"];
$campaign = new Campaign($cid);
if ($campaign->calcStatus(true) == 1) {
$body .= "\nCampaign '" . $campaign->getName() . "' -> " . $hash;
}
}
} else {
$body .= "There are currently no voting campaigns in progress.";
}
mail($addr, 'Hash Key Retrieval', $body, "From: Safeballot <safeballot@safeballot.com>");
return true;
}
}
return false;
}