Adds content caching for static content (css, images, javascript).
[platal.git] / modules / profile.php
index 1c6466e..58a485f 100644 (file)
@@ -24,43 +24,44 @@ class ProfileModule extends PLModule
     function handlers()
     {
         return array(
-            'photo'        => $this->make_hook('photo',        AUTH_PUBLIC),
-            'photo/change' => $this->make_hook('photo_change', AUTH_MDP),
-
-            'fiche.php'        => $this->make_hook('fiche',      AUTH_PUBLIC),
-            'profile'          => $this->make_hook('profile',    AUTH_PUBLIC),
-            'profile/private'  => $this->make_hook('profile',    AUTH_COOKIE),
-            'profile/ax'       => $this->make_hook('ax',         AUTH_COOKIE, 'admin'),
-            'profile/edit'     => $this->make_hook('p_edit',     AUTH_MDP),
-            'profile/ajax/address' => $this->make_hook('ajax_address', AUTH_COOKIE, 'user', NO_AUTH),
-            'profile/ajax/tel'     => $this->make_hook('ajax_tel',     AUTH_COOKIE, 'user', NO_AUTH),
-            'profile/ajax/medal'   => $this->make_hook('ajax_medal',   AUTH_COOKIE, 'user', NO_AUTH),
-            'profile/ajax/job'     => $this->make_hook('ajax_job',     AUTH_COOKIE, 'user', NO_AUTH),
-            'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH),
-            'profile/ajax/skill'   => $this->make_hook('ajax_skill',   AUTH_COOKIE, 'user', NO_AUTH),
-            'javascript/applis.js' => $this->make_hook('applis_js', AUTH_COOKIE),
-            'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE),
-            'profile/medal'    => $this->make_hook('medal', AUTH_PUBLIC),
-            'profile/orange'   => $this->make_hook('p_orange',   AUTH_MDP),
-            'profile/usage'    => $this->make_hook('p_usage',    AUTH_MDP),
-
-            'referent'         => $this->make_hook('referent',   AUTH_COOKIE),
-            'emploi'           => $this->make_hook('ref_search', AUTH_COOKIE),
-            'referent/search'  => $this->make_hook('ref_search', AUTH_COOKIE),
-            'referent/ssect'   => $this->make_hook('ref_sect',   AUTH_COOKIE, 'user', NO_AUTH),
-            'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE, 'user', NO_AUTH),
-
-            'groupes-x'        => $this->make_hook('xnet',      AUTH_COOKIE),
-
-            'vcard'   => $this->make_hook('vcard',  AUTH_COOKIE, 'user', NO_HTTPS),
-            'admin/binets'     => $this->make_hook('admin_binets', AUTH_MDP, 'admin'),
-            'admin/medals'     => $this->make_hook('admin_medals', AUTH_MDP, 'admin'),
-            'admin/formations' => $this->make_hook('admin_formations', AUTH_MDP, 'admin'),
-            'admin/sections'  => $this->make_hook('admin_sections', AUTH_MDP, 'admin'),
-            'admin/secteurs'  => $this->make_hook('admin_secteurs', AUTH_MDP, 'admin'),
-            'admin/trombino'   => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'),
-            'admin/ss_secteurs'  => $this->make_hook('admin_ss_secteurs', AUTH_MDP, 'admin'),
-            'admin/fonctions'  => $this->make_hook('admin_fonctions', AUTH_MDP, 'admin'),
+            'photo'                => $this->make_hook('photo',             AUTH_PUBLIC),
+            'photo/change'         => $this->make_hook('photo_change',      AUTH_MDP),
+
+            'fiche.php'            => $this->make_hook('fiche',             AUTH_PUBLIC),
+            'profile'              => $this->make_hook('profile',           AUTH_PUBLIC),
+            'profile/private'      => $this->make_hook('profile',           AUTH_COOKIE),
+            'profile/ax'           => $this->make_hook('ax',                AUTH_COOKIE, 'admin'),
+            'profile/edit'         => $this->make_hook('p_edit',            AUTH_MDP),
+            'profile/ajax/address' => $this->make_hook('ajax_address',      AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/tel'     => $this->make_hook('ajax_tel',          AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/medal'   => $this->make_hook('ajax_medal',        AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/job'     => $this->make_hook('ajax_job',          AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/secteur' => $this->make_hook('ajax_secteur',      AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/skill'   => $this->make_hook('ajax_skill',        AUTH_COOKIE, 'user', NO_AUTH),
+            'javascript/applis.js' => $this->make_hook('applis_js',         AUTH_COOKIE),
+            'javascript/grades.js' => $this->make_hook('grades_js',         AUTH_COOKIE),
+            'profile/medal'        => $this->make_hook('medal',             AUTH_PUBLIC),
+            'profile/orange'       => $this->make_hook('p_orange',          AUTH_MDP),
+            'profile/usage'        => $this->make_hook('p_usage',           AUTH_MDP),
+
+            'referent'             => $this->make_hook('referent',          AUTH_COOKIE),
+            'emploi'               => $this->make_hook('ref_search',        AUTH_COOKIE),
+            'referent/search'      => $this->make_hook('ref_search',        AUTH_COOKIE),
+            'referent/ssect'       => $this->make_hook('ref_sect',          AUTH_COOKIE, 'user', NO_AUTH),
+            'referent/country'     => $this->make_hook('ref_country',       AUTH_COOKIE, 'user', NO_AUTH),
+
+            'groupes-x'            => $this->make_hook('xnet',              AUTH_COOKIE),
+            'groupes-x/logo'       => $this->make_hook('xnetlogo',          AUTH_PUBLIC),
+
+            'vcard'                => $this->make_hook('vcard',             AUTH_COOKIE),
+            'admin/binets'         => $this->make_hook('admin_binets',      AUTH_MDP,    'admin'),
+            'admin/medals'         => $this->make_hook('admin_medals',      AUTH_MDP,    'admin'),
+            'admin/formations'     => $this->make_hook('admin_formations',  AUTH_MDP,    'admin'),
+            'admin/sections'       => $this->make_hook('admin_sections',    AUTH_MDP,    'admin'),
+            'admin/secteurs'       => $this->make_hook('admin_secteurs',    AUTH_MDP,    'admin'),
+            'admin/trombino'       => $this->make_hook('admin_trombino',    AUTH_MDP,    'admin'),
+            'admin/ss_secteurs'    => $this->make_hook('admin_ss_secteurs', AUTH_MDP,    'admin'),
+            'admin/fonctions'      => $this->make_hook('admin_fonctions',   AUTH_MDP,    'admin'),
 
         );
     }
@@ -311,10 +312,10 @@ class ProfileModule extends PLModule
         if (!intval($mat)) {
             $page->kill("Le matricule AX de {$user->login()} est inconnu");
         }
-        http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
+        http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&ancc_id=$mat");
     }
 
-    function handler_p_edit(&$page, $opened_tab = null, $mode = null)
+    function handler_p_edit(&$page, $opened_tab = null, $mode = null, $success = null)
     {
         global $globals;
 
@@ -351,10 +352,13 @@ class ProfileModule extends PLModule
                             WHERE  user_id = {?} AND naissance = '0000-00-00'", S::i('uid'));
         if ($res->numRows()) {
             $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser"
-                      . " la procédure de récupération de mot de passe si un jour tu le perdais");
+                      . " la procédure de récupération de mot de passe si un jour tu le perdais.");
         }
 
        $page->setTitle('Mon Profil');
+       if (isset($success) && $success) {
+           $page->trigSuccess('Ton profil a bien été mis à jour.');
+       }
     }
 
     function handler_applis_js(&$page)
@@ -671,8 +675,7 @@ class ProfileModule extends PLModule
         $page->assign('usage_old', $usage_old);
         $page->assign('alias_old',  $alias_old);
 
-        $nom_usage = replace_accent(trim(Env::v('nom_usage')));
-        $nom_usage = strtoupper($nom_usage);
+        $nom_usage = mb_strtoupper(trim(Env::v('nom_usage')));
         $page->assign('usage_req', $nom_usage);
 
         if (Env::has('submit') && ($nom_usage != $usage_old)) {
@@ -711,6 +714,28 @@ class ProfileModule extends PLModule
         $page->assign('assos', $req->fetchAllAssoc());
     }
 
+    function handler_xnetlogo(&$page, $id)
+    {
+        if (is_null($id)) {
+            return PL_NOT_FOUND;
+        }
+
+        $res = XDB::query('SELECT  logo, logo_mime
+                             FROM  groupex.asso
+                            WHERE  id = {?}', $id);
+        list($logo, $logo_mime) = $res->fetchOneRow();
+
+        if (!empty($logo)) {
+            header("Content-type: $mime");
+            echo $logo;
+        } else {
+            header('Content-type: image/jpeg');
+            readfile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg');
+        }
+
+        exit;
+    }
+
     function handler_vcard(&$page, $x = null)
     {
         if (is_null($x)) {