/** Receive a POST to enable or disable people in a campaign */ function dolistAction() { global $view; $id = intval($_REQUEST["id"]); if ($id) { $old = mqone("SELECT * FROM campaign WHERE id={$id};"); if (!$old) { not_found(); } } $list = mqassoc("SELECT id,enabled FROM lists WHERE campaign={$id};"); $score = mqassoc("SELECT id,pond_scores FROM lists WHERE campaign={$id};"); // Validate the fields : mq("UPDATE lists SET enabled=0 WHERE campaign={$id};"); foreach ($_REQUEST["callee"] as $cid => $action) { $cid = intval($cid); $action = intval($action); /* if ($list[$cid]!=$action) { */ mq("UPDATE lists SET enabled='{$action}' WHERE campaign={$id} AND id='{$cid}';"); /* if ($action) { $view["messages"].="$cid enabled. "; } else { $view["messages"].="$cid disabled. "; } } */ } foreach ($_REQUEST["score"] as $cid => $pscore) { $cid = intval($cid); $pscore = intval($pscore); if ($score[$cid] != $pscore) { if ($pscore > 100) { $pscore = 100; } if ($pscore < 0) { $pscore = 0; } mq("UPDATE lists SET pond_scores='{$pscore}' WHERE campaign={$id} AND id='{$cid}';"); $view["messages"] .= "{$cid} score is {$pscore}. "; } } $this->indexAction(); }
/** Validate the account */ function validateAction() { global $view, $params; if (!isset($params[0])) { not_found(); } $id = intval($params[0]); if (!isset($params[1])) { not_found(); } $token = $params[1]; // Get the token stored in database $data = mqassoc("SELECT id, token FROM user WHERE id = '{$id}'"); $view["message"] .= "Account validated, you can now login"; if (strcmp($token, $data[$id]) != 0) { not_found(); } mq("UPDATE user SET enabled='1', token='' WHERE id='{$id}'"); render("loginauth"); }