X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=1b05e67eaf5a99b512e39c62c832b93742a3aa87;hb=730a173a333507926e0029d8a96c3a26b55756e4;hp=536975fe93b3b6d7c856c1e54d75e51f0834eae2;hpb=b9c5309042c64aaa0bf61a367dba41e195079d1b;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 536975f..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; } // }}} @@ -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);