X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=f7f1ee6f42390eecf631df3cac001bce64e6bd41;hb=353f2d2b11c4e3c6c0bc3553813368b6f42fa9c6;hp=734a4077a7892ceb4f6318f4c42bcbd1654e27a9;hpb=805f3d1679a53bb04fff34619c171a1381068612;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 734a407..f7f1ee6 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -1,6 +1,6 @@ stamp = $stamp; return($result); } else { @@ -85,6 +85,7 @@ abstract class Validate $this->stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; + $this->promo = $this->user->promo(); } // }}} @@ -183,7 +184,7 @@ abstract class Validate $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); $mailer->addTo($globals->core->admin_email); - $body = "Validation {$this->type} pour {$this->user->id()}\n\n" + $body = "Validation {$this->type} pour {$this->user->login()}\n\n" . S::user()->login() . " a ajouté le commentaire :\n\n" . Env::v('comm') . "\n\n" . "cf la discussion sur : " . $globals->baseurl . "/admin/validate"; @@ -215,7 +216,7 @@ abstract class Validate $this->trigSuccess('Email de refus envoyé'); return true; } else { - $this->trigError('pas de motivation pour le refus !!!'); + $this->trigError('Pas de motivation pour le refus !!!'); } } @@ -236,8 +237,9 @@ abstract class Validate $body = ($this->user->isFemale() ? "Chère camarade,\n\n" : "Cher camarade,\n\n") . $this->_mail_body($isok) - . (Env::has('comm') ? "\n\n".Env::v('comm') : '') - . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n"; + . (Env::has('comm') ? "\n\n" . Env::v('comm') : '') + . "\n\nCordialement,\n-- \nL'équipe de Polytechnique.org\n" + . $this->_mail_ps($isok); $mailer->setTxtBody(wordwrap($body)); $mailer->send(); @@ -280,7 +282,7 @@ abstract class Validate $res = XDB::query('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") FROM requests WHERE user_id={?} AND type={?} and stamp={?}', $uid, $type, $stamp); } if ($result = $res->fetchOneCell()) { - $result = unserialize($result); + $result = Validate::unserialize($result); } else { $result = false; } @@ -306,7 +308,7 @@ abstract class Validate $res = XDB::iterRow('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); $array = array(); while (list($data) = $res->next()) { - $array[] = unserialize($data); + $array[] = Validate::unserialize($data); } return $array; } @@ -333,6 +335,14 @@ abstract class Validate abstract protected function _mail_subj(); // }}} + // {{{ function _mail_ps + + protected function _mail_ps($isok) + { + return ''; + } + + // }}} // {{{ function commit() /** fonction à utiliser pour insérer les données dans x4dat @@ -363,7 +373,7 @@ abstract class Validate static $answers_table; if (!isset($answers_table[$this->type])) { $r = XDB::query("SELECT id, title, answer FROM requests_answers WHERE category = {?}", $this->type); - $answers_table[$this->type] = $r->fetchAllAssoc($r); + $answers_table[$this->type] = $r->fetchAllAssoc(); } return $answers_table[$this->type]; } @@ -385,6 +395,17 @@ abstract class Validate } // }}} + // {{{ function unserialize() + public static function unserialize($data) + { + $obj = unserialize($data); + /* XXX: Temporary for hruid migration */ + if (!isset($obj->user) || !is_object($obj)) { + $obj->user =& User::get($obj->forlife); + } + /* XXX: End temporary block */ + return $obj; + } } foreach (glob(dirname(__FILE__).'/validations/*.inc.php') as $file) {