From fb9a56cbdb5d06330015981e18ff26c3b0342306 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 11 Jul 2006 20:12:18 +0000 Subject: [PATCH] trombino.php => photo/change git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@442 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/trombino.php | 58 -------------------------------------------- modules/profile.php | 57 ++++++++++++++++++++++++++++++++++++++++--- templates/login.tpl | 2 +- templates/profil/general.tpl | 2 +- templates/trombino.tpl | 2 +- 5 files changed, 57 insertions(+), 64 deletions(-) delete mode 100644 htdocs/trombino.php diff --git a/htdocs/trombino.php b/htdocs/trombino.php deleted file mode 100644 index 32f10a2..0000000 --- a/htdocs/trombino.php +++ /dev/null @@ -1,58 +0,0 @@ -submit(); - } - } else { - $page->trig('Fichier inexistant ou vide'); - } -} elseif (Env::has('trombi')) { - $myphoto = new PhotoReq(Session::getInt('uid'), file_get_contents($trombi_x)); - if ($myphoto) { - $myphoto->commit(); - $myphoto->clean(); - } -} elseif (Env::get('suppr')) { - $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', Session::getInt('uid')); - $globals->xdb->execute('DELETE FROM requests WHERE user_id = {?} AND type="photo"', Session::getInt('uid')); -} elseif (Env::get('cancel')) { - $sql = $globals->xdb->query('DELETE FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid')); -} - -$sql = $globals->xdb->query('SELECT COUNT(*) FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid')); -$page->assign('submited', $sql->fetchOneCell()); -$page->assign('has_trombi_x', file_exists($trombi_x)); - -$page->run(); - -// Affichage de la page principale -?> diff --git a/modules/profile.php b/modules/profile.php index 2d12210..7713e7b 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -24,8 +24,9 @@ class ProfileModule extends PLModule function handlers() { return array( - 'photo' => $this->make_hook('photo', AUTH_PUBLIC), - 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), + 'photo' => $this->make_hook('photo', AUTH_PUBLIC), + 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), + 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), ); } @@ -82,12 +83,62 @@ class ProfileModule extends PLModule echo $data; } else { Header('Content-type: image/png'); - echo file_get_contents(dirname(__FILE__).'../htdocs/images/none.png'); + echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png'); } } exit; } + function handler_photo_change(&$page) + { + global $globals; + + $page->changeTpl('trombino.tpl'); + + require_once('validations.inc.php'); + + $trombi_x = '/home/web/trombino/photos'.Session::get('promo') + .'/'.Session::get('forlife').'.jpg'; + + if (Env::has('upload')) { + $file = isset($_FILES['userfile']['tmp_name']) + ? $_FILES['userfile']['tmp_name'] + : Env::get('photo'); + if ($data = file_get_contents($file)) { + if ($myphoto = new PhotoReq(Session::getInt('uid'), $data)) { + $myphoto->submit(); + } + } else { + $page->trig('Fichier inexistant ou vide'); + } + } elseif (Env::has('trombi')) { + $myphoto = new PhotoReq(Session::getInt('uid'), + file_get_contents($trombi_x)); + if ($myphoto) { + $myphoto->commit(); + $myphoto->clean(); + } + } elseif (Env::get('suppr')) { + $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', + Session::getInt('uid')); + $globals->xdb->execute('DELETE FROM requests + WHERE user_id = {?} AND type="photo"', + Session::getInt('uid')); + } elseif (Env::get('cancel')) { + $sql = $globals->xdb->query('DELETE FROM requests + WHERE user_id={?} AND type="photo"', + Session::getInt('uid')); + } + + $sql = $globals->xdb->query('SELECT COUNT(*) FROM requests + WHERE user_id={?} AND type="photo"', + Session::getInt('uid')); + $page->assign('submited', $sql->fetchOneCell()); + $page->assign('has_trombi_x', file_exists($trombi_x)); + + return PL_OK; + } + function handler_trombi(&$page, $promo = null) { require_once 'trombi.inc.php'; diff --git a/templates/login.tpl b/templates/login.tpl index 3b3800d..f21628f 100644 --- a/templates/login.tpl +++ b/templates/login.tpl @@ -53,7 +53,7 @@ Bienvenue {$smarty.session.prenom} {if $photo_incitation}

Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage. - Clique ici si tu souhaites en ajouter une. + Clique ici si tu souhaites en ajouter une.

{/if} diff --git a/templates/profil/general.tpl b/templates/profil/general.tpl index dd3decb..d9c5e68 100644 --- a/templates/profil/general.tpl +++ b/templates/profil/general.tpl @@ -194,7 +194,7 @@ d'identité (dans un fichier au format JPEG, PNG ou GIF).
- Éditer ta photo + Éditer ta photo
diff --git a/templates/trombino.tpl b/templates/trombino.tpl index 7bbb9c7..1719ffc 100644 --- a/templates/trombino.tpl +++ b/templates/trombino.tpl @@ -23,7 +23,7 @@

Trombinoscope

-
+ -- 2.1.4