X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fvalidations.inc.php;h=6af52e8454829c0408907a58082b0df10363b69e;hb=77254e96f9bb2fd88258f00bd72719b60dcd0456;hp=dc972599c30c045033cc21da8ea7bd5dc79afdc1;hpb=5e2307dcebc38ebb0ffe469967a377eb3baed571;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index dc97259..6af52e8 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -21,6 +21,8 @@ define('SIZE_MAX', 32768); +__autoload('XDB'); + /** * Iterator class, that lists objects through the database */ @@ -30,7 +32,7 @@ class ValidateIterator extends XOrgDBIterator function ValidateIterator () { - parent::XOrgDBIterator('SELECT data,stamp FROM requests ORDER BY stamp', MYSQL_NUM); + parent::__construct('SELECT data,stamp FROM requests ORDER BY stamp', MYSQL_NUM); } // }}} @@ -67,6 +69,7 @@ class Validate var $unique; // enable the refuse button var $refuse = true; + var $type; var $comments = Array(); // the validations rules : comments for admins @@ -156,9 +159,25 @@ class Validate return true; } + // mise à jour des informations + if (Env::has('edit')) { + if ($this->handle_editor()) { + $this->update(); + $this->trig('requête mise à jour'); + return true; + } + return false; + } + // ajout d'un commentaire if (Env::has('hold') && Env::has('comm')) { - $this->comments[] = Array(S::v('bestalias'), Env::v('comm')); + $formid = Env::i('formid'); + foreach ($this->comments as $comment) { + if ($comment[2] === $formid) { + return true; + } + } + $this->comments[] = Array(S::v('bestalias'), Env::v('comm'), $formid); // envoi d'un mail à hotliners global $globals; @@ -166,12 +185,12 @@ class Validate $mailer = new HermesMailer; $mailer->setSubject("Commentaires de validation {$this->type}"); $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); - $mailer->addTo("hotliners@{$globals->mail->domain}"); + $mailer->addTo("hotliners@staff.polytechnique.org"); $body = "Validation {$this->type} pour {$this->prenom} {$this->nom}\n\n" . S::v('bestalias')." a ajouté le commentaire :\n\n" . Env::v('comm')."\n\n" - . "cf la discussion sur : ".$globals->baseurl."/admin/valider.php"; + . "cf la discussion sur : ".$globals->baseurl."/admin/validate"; $mailer->setTxtBody(wordwrap($body)); $mailer->send(); @@ -294,6 +313,34 @@ class Validate { return null; } // }}} + // {{{ function editor() + + /** nom du formulaire d'édition */ + function editor() + { return null; } + + // }}} + // {{{ function answers() + + /** automatic answers table for this type of validation */ + function answers() { + 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); + } + return $answers_table[$this->type]; + } + + // }}} + // {{{ function id() + + function id() + { + return $this->uid . '_' . $this->type . '_' . $this->stamp; + } + + // }}} } foreach (glob(dirname(__FILE__).'/validations/*.inc.php') as $file) {