X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=9deb2f740f2a599cd4901d9094d0fbb6c426cb29;hb=87d72675e4a6d5e2ca377cde0f30666f6305ad2b;hp=6666e283544f635f12f9dfc2b5d1a696b85ce65c;hpb=1dc71da137a384e771723b8a893539a7f5cc9fab;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 6666e28..9deb2f7 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -1,6 +1,6 @@ stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; - $res = XDB::query("SELECT promo - FROM profile_display - WHERE pid={?}", $this->user->id()); - $this->promo = $res->fetchOneCell(); + $this->promo = $this->user->promo(); } // }}} @@ -100,11 +97,14 @@ abstract class Validate public function submit() { if ($this->unique) { - XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->user->id(), $this->type); + XDB::execute('DELETE FROM requests + WHERE uid = {?} AND type = {?}', + $this->user->id(), $this->type); } $this->stamp = date('YmdHis'); - XDB::execute('INSERT INTO requests (user_id, type, data, stamp) VALUES ({?}, {?}, {?}, {?})', + XDB::execute('INSERT INTO requests (uid, type, data, stamp) + VALUES ({?}, {?}, {?}, {?})', $this->user->id(), $this->type, $this, $this->stamp); global $globals; @@ -117,8 +117,9 @@ abstract class Validate protected function update() { - XDB::execute('UPDATE requests SET data={?}, stamp=stamp - WHERE user_id={?} AND type={?} AND stamp={?}', + XDB::execute('UPDATE requests + SET data = {?}, stamp = stamp + WHERE uid = {?} AND type = {?} AND stamp = {?}', $this, $this->user->id(), $this->type, $this->stamp); return true; } @@ -134,10 +135,12 @@ abstract class Validate global $globals; if ($this->unique) { - $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', + $success = XDB::execute('DELETE FROM requests + WHERE uid = {?} AND type = {?}', $this->user->id(), $this->type); } else { - $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}', + $success = XDB::execute('DELETE FROM requests + WHERE uid = {?} AND type = {?} AND stamp = {?}', $this->user->id(), $this->type, $this->stamp); } $globals->updateNbValid(); @@ -280,9 +283,15 @@ abstract class Validate static public function get_typed_request($uid, $type, $stamp = -1) { if ($stamp == -1) { - $res = XDB::query('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); + $res = XDB::query('SELECT data + FROM requests + WHERE uid = {?} and type = {?}', + $uid, $type); } else { - $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); + $res = XDB::query('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") + FROM requests + WHERE uid = {?} AND type = {?} and stamp = {?}', + $uid, $type, $stamp); } if ($result = $res->fetchOneCell()) { $result = Validate::unserialize($result); @@ -308,7 +317,10 @@ abstract class Validate */ static public function get_typed_requests($uid, $type) { - $res = XDB::iterRow('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); + $res = XDB::iterRow('SELECT data + FROM requests + WHERE uid = {?} and type = {?}', + $uid, $type); $array = array(); while (list($data) = $res->next()) { $array[] = Validate::unserialize($data); @@ -323,7 +335,10 @@ abstract class Validate */ static public function get_typed_requests_count($uid, $type) { - $res = XDB::query('SELECT COUNT(data) FROM requests WHERE user_id={?} and type={?}', $uid, $type); + $res = XDB::query('SELECT COUNT(data) + FROM requests + WHERE uid = {?} and type = {?}', + $uid, $type); return $res->fetchOneCell(); }