X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=981451088ff9382ec3611b318dfb6d798b24db18;hb=59887c4a8a1f014c1f4107c43deda0d1be994f5d;hp=4bab494192afa8fceb929cda198e51c94f6603cc;hpb=a7c29df3b9bf8f3c3b23fec0f1d2feb814cb61fe;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 4bab494..9814510 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -153,13 +153,13 @@ abstract class Validate // }}} // {{{ function handle_formu() - /** fonction à réaliser en cas de valistion du formulaire + /** fonction à réaliser en cas de validation du formulaire */ public function handle_formu() { if (Env::has('delete')) { $this->clean(); - $this->trig('requete supprimée'); + $this->trigSuccess('Requête supprimée'); return true; } @@ -167,7 +167,7 @@ abstract class Validate if (Env::has('edit')) { if ($this->handle_editor()) { $this->update(); - $this->trig('requête mise à jour'); + $this->trigSuccess('Requête mise à jour'); return true; } return false; @@ -202,7 +202,7 @@ abstract class Validate $mailer->send(); $this->update(); - $this->trig('commentaire ajouté'); + $this->trigSuccess('Commentaire ajouté'); return true; } @@ -210,10 +210,10 @@ abstract class Validate if ($this->commit()) { $this->sendmail(true); $this->clean(); - $this->trig('mail envoyé'); + $this->trigSuccess('Mail de validation envoyé'); return true; } else { - $this->trig('erreur lors de la validation'); + $this->trigError('Erreur lors de la validation'); return false; } } @@ -222,10 +222,10 @@ abstract class Validate if (Env::v('comm')) { $this->sendmail(false); $this->clean(); - $this->trig('mail envoyé'); + $this->trigSuccess('Mail de refus envoyé'); return true; } else { - $this->trig('pas de motivation pour le refus !!!'); + $this->trigError('pas de motivation pour le refus !!!'); } } @@ -256,10 +256,22 @@ abstract class Validate // }}} // {{{ function trig() - protected function trig($msg) + protected function trigError($msg) { global $page; - $page->trig($msg); + $page->trigError($msg); + } + + protected function trigWarning($msg) + { + global $page; + $page->trigWarning($msg); + } + + protected function trigSuccess($msg) + { + global $page; + $page->trigSuccess($msg); } // }}} @@ -313,6 +325,17 @@ abstract class Validate } // }}} + // {{{ function get_typed_requests_count() + + /** same as get_typed_requests() but return the count of available requests. + */ + static public function get_typed_requests_count($uid, $type) + { + $res = XDB::query('SELECT COUNT(data) FROM requests WHERE user_id={?} and type={?}', $uid, $type); + return $res->fetchOneCell(); + } + + // }}} // {{{ function _mail_body abstract protected function _mail_body($isok);