X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=1b05e67eaf5a99b512e39c62c832b93742a3aa87;hb=730a173a333507926e0029d8a96c3a26b55756e4;hp=81c3041c5f166dc83966ade841b0037c59ceb4db;hpb=eaf30d86cc99df2414cf4f171a9b0f11b0561e3b;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 81c3041..1b05e67 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -1,6 +1,6 @@ uid, $this->type, $this, $this->stamp); + global $globals; + update_NbValid(); return true; } @@ -138,12 +140,14 @@ abstract class Validate public function clean() { if ($this->unique) { - return XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', - $this->uid, $this->type); + $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', + $this->uid, $this->type); } else { - return XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}', - $this->uid, $this->type, $this->stamp); + $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}', + $this->uid, $this->type, $this->stamp); } + update_NbValid(); + return $success; } // }}} @@ -184,10 +188,10 @@ abstract class Validate // envoi d'un mail à hotliners global $globals; - $mailer = new PlMailer; + $mailer = new PlMailer(); $mailer->setSubject("Commentaires de validation {$this->type}"); $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); - $mailer->addTo($globals->core->admin_emails); + $mailer->addTo($globals->core->admin_email); $body = "Validation {$this->type} pour {$this->prenom} {$this->nom}\n\n" . S::v('bestalias')." a ajouté le commentaire :\n\n" @@ -309,6 +313,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);