2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
24 class PhotoReq
extends ProfileValidate
33 public $unique = true
;
34 public $valid = false
;
36 public $rules = "Refuser les photos copyrightées, de mineurs, ou ayant
37 un caractère pornographique, violent… Si une photo est mal
38 cadrée (20% de photo et 80% de blanc par exemple), si c'est un
39 camarade antique, on lui arrange sinon on lui
40 refuse en lui expliquant gentiment le problème. Idem si les dimensions de
41 la photo sont archi trop grandes ou archi trop petites.";
46 public function __construct(User
$_user, Profile
$_profile, PlUpload
$upload, $_stamp = 0)
48 parent
::__construct($_user, $_profile, true
, 'photo', $_stamp);
55 private function read(PlUpload
$upload)
57 $this->valid
= $upload->resizeImage(240, 300, 160, 0, SIZE_MAX
);
59 $this->trigError('Le fichier que tu as transmis n\'est pas une image valide, ou est trop gros pour être traité.');
61 $this->data
= $upload->getContents();
62 list($this->x
, $this->y
, $this->mimetype
) = $upload->imageInfo();
67 // {{{ function isValid()
69 public function isValid()
75 // {{{ function get_request()
77 static public function get_request($pid)
79 return parent
::get_typed_request($pid, 'photo');
83 // {{{ function formu()
85 public function formu()
87 return 'include/form.valid.photos.tpl';
91 // {{{ function editor()
93 public function editor()
95 return 'include/form.valid.edit-photo.tpl';
99 // {{{ function handle_editor()
101 protected function handle_editor()
103 if (isset($_FILES['userfile'])) {
104 $upload =& PlUpload
::get($_FILES['userfile'], S
::user()->login(), 'photo');
106 $this->trigError('Une erreur est survenue lors du téléchargement du fichier.');
109 $this->read($upload);
116 // {{{ function _mail_subj
118 protected function _mail_subj()
120 return "[Polytechnique.org/PHOTO] Changement de photo";
124 // {{{ function _mail_body
126 protected function _mail_body($isok)
129 return "Le changement de photo que tu as demandé vient d'être effectué.";
131 return "La demande de changement de photo que tu avais faite a été refusée.";
136 // {{{ function commit()
138 public function commit()
140 XDB
::execute('INSERT INTO profile_photos (pid, attachmime, attach, x, y)
141 VALUES ({?}, {?}, {?}, {?}, {?})
142 ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach),
143 x = VALUES(x), y = VALUES(y)',
144 $this->profile
->id(), $this->mimetype
, $this->data
, $this->x
, $this->y
);
154 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: