Merge commit 'origin/master' into fusionax
[platal.git] / modules / profile.php
index 31677e4..f64d8c7 100644 (file)
@@ -40,6 +40,7 @@ class ProfileModule extends PLModule
             'profile/ajax/job'           => $this->make_hook('ajax_job',                   AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/sector'        => $this->make_hook('ajax_sector',                AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/sub_sector'    => $this->make_hook('ajax_sub_sector',            AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/alternates'    => $this->make_hook('ajax_alternates',            AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/skill'         => $this->make_hook('ajax_skill',                 AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/searchname'    => $this->make_hook('ajax_searchname',            AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/buildnames'    => $this->make_hook('ajax_buildnames',            AUTH_COOKIE, 'user', NO_AUTH),
@@ -56,6 +57,7 @@ class ProfileModule extends PLModule
             '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, 'user', NO_HTTPS),
             'admin/binets'               => $this->make_hook('admin_binets',               AUTH_MDP, 'admin'),
@@ -67,11 +69,10 @@ class ProfileModule extends PLModule
             'admin/sections'             => $this->make_hook('admin_sections',             AUTH_MDP, 'admin'),
             'admin/networking'           => $this->make_hook('admin_networking',           AUTH_MDP, 'admin'),
             'admin/trombino'             => $this->make_hook('admin_trombino',             AUTH_MDP, 'admin'),
-            'admin/fonctions'            => $this->make_hook('admin_fonctions',            AUTH_MDP, 'admin'),
+            'admin/sectors'              => $this->make_hook('admin_sectors',              AUTH_MDP, 'admin'),
             'admin/corps_enum'           => $this->make_hook('admin_corps_enum',           AUTH_MDP, 'admin'),
             'admin/corps_rank'           => $this->make_hook('admin_corps_rank',           AUTH_MDP, 'admin'),
             'admin/names'                => $this->make_hook('admin_names',                AUTH_MDP, 'admin'),
-
         );
     }
 
@@ -347,10 +348,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;
 
@@ -391,6 +392,9 @@ class ProfileModule extends PLModule
         }
 
        $page->setTitle('Mon Profil');
+       if (isset($success) && $success) {
+           $page->trigSuccess('Ton profil a bien été mis à jour.');
+       }
     }
 
     function handler_education_js(&$page)
@@ -477,13 +481,9 @@ class ProfileModule extends PLModule
         $page->assign('i', $id);
         $page->assign('job', array());
         $page->assign('new', true);
-        $res = XDB::query("SELECT  id, name
+        $res = XDB::query("SELECT  id, name AS label
                              FROM  profile_job_sector_enum");
         $page->assign('sectors', $res->fetchAllAssoc());
-        $res = XDB::query("SELECT  id, fonction_fr, FIND_IN_SET('titre', flags) AS title
-                             FROM  fonctions_def
-                         ORDER BY  id");
-        $page->assign('fonctions', $res->fetchAllAssoc());
         require_once "emails.combobox.inc.php";
         fill_email_combobox($page);
     }
@@ -517,6 +517,23 @@ class ProfileModule extends PLModule
         $page->assign('sel', $sssect);
     }
 
+    function handler_ajax_alternates(&$page, $id, $sssect)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $res = XDB::iterator('SELECT  name
+                                FROM  profile_job_alternates
+                               WHERE  subsubsectorid = {?}
+                            ORDER BY  id',
+                             $sssect);
+        $page->changeTpl('profile/jobs.alternates.tpl', NO_SKIN);
+        $alternate  = $res->next();
+        $alternates = $alternate['name'];
+        while ($alternate  = $res->next()) {
+            $alternates .= ', ' . $alternate['name'];
+        }
+        $page->assign('alternates', $alternates);
+    }
+
     function handler_ajax_skill(&$page, $cat, $id)
     {
         header('Content-Type: text/html; charset=utf-8');
@@ -759,6 +776,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)) {
@@ -873,13 +912,14 @@ class ProfileModule extends PLModule
         $table_editor->describe('text','intitulé',true);
         $table_editor->apply($page, $action, $id);
     }
-    function handler_admin_fonctions(&$page, $action = 'list', $id = null) {
-        $page->setTitle('Administration - Fonctions');
-        $page->assign('title', 'Gestion des fonctions');
-        $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true);
-        $table_editor->describe('fonction_fr', 'intitulé', true);
-        $table_editor->describe('fonction_en', 'intitulé (ang)', true);
-        $table_editor->describe('flags', 'titre', true);
+    function handler_admin_sectors(&$page, $action = 'list', $id = null) {
+        $page->setTitle('Administration - Secteurs');
+        $page->assign('title', 'Gestion des secteurs');
+        $table_editor = new PLTableEditor('admin/sectors', 'profile_job_subsubsector_enum', 'id', true);
+        $table_editor->describe('sectorid', 'id du secteur', false);
+        $table_editor->describe('subsectorid', 'id du sous-secteur', false);
+        $table_editor->describe('name', 'nom', true);
+        $table_editor->describe('flags', 'affichage', true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_networking(&$page, $action = 'list', $id = null) {