From: Vincent Zanotti Date: Sun, 24 Aug 2008 17:38:46 +0000 (+0200) Subject: Updates the cron for homonymes, and its validation task. X-Git-Tag: xorg/0.10.0~86^2~26 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=64b8f057d537f4f78c2b8fb6ea8fcf3b3248628a;p=platal.git Updates the cron for homonymes, and its validation task. Signed-off-by: Vincent Zanotti --- diff --git a/bin/cron/homonymes.php b/bin/cron/homonymes.php index 90e106a..608e3ba 100755 --- a/bin/cron/homonymes.php +++ b/bin/cron/homonymes.php @@ -19,27 +19,31 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -/* vim: set sw=4 ts=4 sts=4 tw=100: +/** * crée des demandes de validation pour les kill d'alias * une demande 10 jours avant pour un warning, puis une autre pour le robot -*/ + */ -$W_PERIOD = "INTERVAL 7 DAY"; // temps d'envoi du warning avant la deadline +require('connect.db.inc.php'); +require_once('validations/homonymes.inc.php'); -require('./connect.db.inc.php'); +$resRobot = XDB::iterator( + "SELECT id, alias, expire + FROM aliases + WHERE (expire = NOW() + INTERVAL 7 DAY OR expire <= NOW()) + AND type = 'alias'"); +while ($old = $resRobot->next()) { + $res = XDB::query( + "SELECT u.hruid + FROM homonymes AS h + INNER JOIN auth_user_md5 AS u USING (user_id) + WHERE homonyme_id = {?}", + $old['id']); + $hruids = $res->fetchColumn(); -$resRobot = XDB::iterator("SELECT id, alias, expire FROM aliases WHERE (expire = NOW() + $W_PERIOD OR expire <= NOW()) AND type = 'alias'"); - -if ($resRobot->total()) { - require_once('validations/homonymes.inc.php'); - while ($old = $resRobot->next()) { - $res = XDB::query("SELECT alias AS forlife FROM homonymes INNER JOIN aliases ON(user_id = id) WHERE homonyme_id = {?} AND type='a_vie'", $old['id']); - $forlifes = $res->fetchColumn(); - - $user = User::getSilent($old['id']); - $req = new HomonymeReq($user, $old['alias'], $forlifes, $old['expire'] > date("Y-m-d")); - $req->submit(); - } + $homonyme = User::getSilent($old['id']); + $req = new HomonymeReq($homonyme, $old['alias'], $hruids, $old['expire'] > date("Y-m-d")); + $req->submit(); } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index d163c11..44f0234 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -30,14 +30,14 @@ class HomonymeReq extends Validate public $warning = true; - public $homonymes_forlife; + public $homonymes_hruid; public $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus ... manuellement"; // }}} // {{{ constructor - public function __construct(User &$_user, $_loginbis, $_homonymes_forlife, $warning=true) + public function __construct(User &$_user, $_loginbis, $_homonymes_hruid, $warning=true) { $this->warning = $warning; @@ -45,7 +45,7 @@ class HomonymeReq extends Validate $this->refuse = false; $this->loginbis = $_loginbis; - $this->homonymes_forlife = $_homonymes_forlife; + $this->homonymes_hruid = $_homonymes_hruid; } // }}}