X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fphotos.inc.php;h=f187307fb5f4f415cd3acc2c082ed5ab1d729123;hb=85b2b2257110a8c77d70624f0fa9bba402d99e5f;hp=1aac21673606df9ca6bad31532761d8b63671bad;hpb=0073747ac81cc9cff9e43847eb008f0e815255f0;p=platal.git diff --git a/include/validations/photos.inc.php b/include/validations/photos.inc.php index 1aac216..f187307 100644 --- a/include/validations/photos.inc.php +++ b/include/validations/photos.inc.php @@ -1,6 +1,6 @@ read($upload); } // }}} // {{{ function read - private function read(PlUpload &$upload) + private function read(PlUpload $upload) { $this->valid = $upload->resizeImage(240, 300, 160, 0, SIZE_MAX); if (!$this->valid) { - $this->trigError('Le fichier que tu as transmis n\'est pas une image valide, ou est trop gros pour être traité'); + $this->trigError('Le fichier que tu as transmis n\'est pas une image valide, ou est trop gros pour être traité.'); } $this->data = $upload->getContents(); list($this->x, $this->y, $this->mimetype) = $upload->imageInfo(); @@ -64,7 +64,7 @@ class PhotoReq extends Validate } // }}} - // {{{ function isValid() + // {{{ function isValid() public function isValid() { @@ -74,9 +74,9 @@ class PhotoReq extends Validate // }}} // {{{ function get_request() - static public function get_request($uid) + static public function get_request($pid) { - return parent::get_typed_request($uid, 'photo'); + return parent::get_typed_request($pid, 'photo'); } // }}} @@ -103,7 +103,7 @@ class PhotoReq extends Validate if (isset($_FILES['userfile'])) { $upload =& PlUpload::get($_FILES['userfile'], S::user()->login(), 'photo'); if (!$upload) { - $this->trigError('Une erreur est survenue lors du téléchargement du fichier'); + $this->trigError('Une erreur est survenue lors du téléchargement du fichier.'); return false; } $this->read($upload); @@ -137,11 +137,12 @@ class PhotoReq extends Validate public function commit() { - //require_once 'notifs.inc.php'; - XDB::execute('REPLACE INTO profile_photos (pid, attachmime, attach, x, y) - VALUES ({?},{?},{?},{?},{?})', - $this->user->profile()->id(), $this->mimetype, $this->data, $this->x, $this->y); - //register_watch_op($this->user->id(), WATCH_FICHE, '', 'photo'); + XDB::execute('INSERT INTO profile_photos (pid, attachmime, attach, x, y) + VALUES ({?}, {?}, {?}, {?}, {?}) + ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach), + x = VALUES(x), y = VALUES(y)', + $this->profile->id(), $this->mimetype, $this->data, $this->x, $this->y); + return true; }