read($upload); } // }}} // {{{ function read 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->data = $upload->getContents(); list($this->x, $this->y, $this->mimetype) = $upload->imageInfo(); $upload->rm(); } // }}} // {{{ function isValid() public function isValid() { return $this->valid; } // }}} // {{{ function get_request() static public function get_request($pid) { return parent::get_typed_request($pid, 'photo'); } // }}} // {{{ function formu() public function formu() { return 'include/form.valid.photos.tpl'; } // }}} // {{{ function editor() public function editor() { return 'include/form.valid.edit-photo.tpl'; } // }}} // {{{ function handle_editor() protected function handle_editor() { 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.'); return false; } $this->read($upload); return $this->valid; } return false; } // }}} // {{{ function _mail_subj protected function _mail_subj() { return "[Polytechnique.org/PHOTO] Changement de photo"; } // }}} // {{{ function _mail_body protected function _mail_body($isok) { if ($isok) { return "Le changement de photo que tu as demandé vient d'être effectué."; } else { return "La demande de changement de photo que tu avais faite a été refusée."; } } // }}} // {{{ function commit() public function commit() { 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; } // }}} } // }}} // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>