Merge commit 'origin/master' into fusionax
[platal.git] / modules / profile.php
index 62a0ce7..322a13f 100644 (file)
@@ -24,46 +24,50 @@ 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/networking'   => $this->make_hook('networking',   AUTH_PUBLIC),
-            '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),
-            'profile/ajax/searchname'   => $this->make_hook('ajax_searchname',   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/networking' => $this->make_hook('admin_networking', 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/edu'           => $this->make_hook('ajax_edu',                   AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/medal'         => $this->make_hook('ajax_medal',                 AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/networking'         => $this->make_hook('networking',                 AUTH_PUBLIC),
+            '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),
+            'profile/ajax/searchname'    => $this->make_hook('ajax_searchname',            AUTH_COOKIE, 'user', NO_AUTH),
+            'javascript/education.js'    => $this->make_hook('education_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/education'            => $this->make_hook('admin_education',            AUTH_MDP, 'admin'),
+            'admin/education_field'      => $this->make_hook('admin_education_field',      AUTH_MDP, 'admin'),
+            'admin/education_degree'     => $this->make_hook('admin_education_degree',     AUTH_MDP, 'admin'),
+            'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP, 'admin'),
+            'admin/sections'             => $this->make_hook('admin_sections',             AUTH_MDP, 'admin'),
+            'admin/secteurs'             => $this->make_hook('admin_secteurs',             AUTH_MDP, 'admin'),
+            'admin/networking'           => $this->make_hook('admin_networking',           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'),
 
         );
     }
@@ -329,12 +333,12 @@ class ProfileModule extends PLModule
 
         // Build the page
         $page->addJsLink('ajax.js');
-        $page->addJsLink('applis.js');
+        $page->addJsLink('education.js');
         $page->addJsLink('grades.js');
         $page->addJsLink('profile.js');
         $page->addJsLink('jquery.autocomplete.js');
-        $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true);
-        require_once dirname(__FILE__) . '/profile/page.inc.php';
+        $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true);
+        $this->load('page.inc.php');
         $wiz->addPage('ProfileGeneral', 'Général', 'general');
         $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
         $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
@@ -356,15 +360,15 @@ class ProfileModule extends PLModule
        $page->setTitle('Mon Profil');
     }
 
-    function handler_applis_js(&$page)
+    function handler_education_js(&$page)
     {
         header('Content-Type: text/javascript; charset=utf-8');
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
-        $page->changeTpl('profile/applis.js.tpl', NO_SKIN);
-        require_once "applis.func.inc.php";
+        $page->changeTpl('profile/education.js.tpl', NO_SKIN);
+        require_once "education.func.inc.php";
     }
 
     function handler_grades_js(&$page)
@@ -412,6 +416,19 @@ class ProfileModule extends PLModule
         $page->assign('tel', array());
     }
 
+    function handler_ajax_edu(&$page, $eduid, $class)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $page->changeTpl('profile/edu.tpl', NO_SKIN);
+        $res = XDB::iterator("SELECT  id, field
+                                FROM  profile_education_field_enum
+                            ORDER BY  field");
+        $page->assign('edu_fields', $res->fetchAllAssoc());
+        $page->assign('eduid', $eduid);
+        $page->assign('class', $class);
+        require_once "education.func.inc.php";
+    }
+
     function handler_ajax_medal(&$page, $id)
     {
         header('Content-Type: text/html; charset=utf-8');
@@ -742,8 +759,9 @@ class ProfileModule extends PLModule
             $x = substr($x, 0, strlen($x) - 4);
         }
 
-        $vcard = new VCard($x);
-        $vcard->do_page($page);
+        $vcard = new VCard();
+        $vcard->addUser($x);
+        $vcard->show();
     }
 
     function handler_admin_trombino(&$page, $uid = null, $action = null) {
@@ -794,13 +812,39 @@ class ProfileModule extends PLModule
         $table_editor->describe('text','intitulé',true);
         $table_editor->apply($page, $action, $id);
     }
-    function handler_admin_formations(&$page, $action = 'list', $id = null) {
+    function handler_admin_education(&$page, $action = 'list', $id = null) {
         $page->setTitle('Administration - Formations');
         $page->assign('title', 'Gestion des formations');
-        $table_editor = new PLTableEditor('admin/formations','applis_def','id');
-        $table_editor->add_join_table('applis_ins','aid',true);
-        $table_editor->describe('text','intitulé',true);
-        $table_editor->describe('url','site web',false);
+        $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id');
+        $table_editor->add_join_table('profile_education', 'eduid', true);
+        $table_editor->add_join_table('profile_education_degree', 'eduid', true);
+        $table_editor->describe('name', 'intitulé', true);
+        $table_editor->describe('url', 'site web', false);
+        $table_editor->apply($page, $action, $id);
+    }
+    function handler_admin_education_field(&$page, $action = 'list', $id = null) {
+        $page->setTitle('Administration - Domaines de formation');
+        $page->assign('title', 'Gestion des domaines de formation');
+        $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true);
+        $table_editor->add_join_table('profile_education', 'fieldid', true);
+        $table_editor->describe('field', 'domaine', true);
+        $table_editor->apply($page, $action, $id);
+    }
+    function handler_admin_education_degree(&$page, $action = 'list', $id = null) {
+        $page->setTitle('Administration - Niveau de formation');
+        $page->assign('title', 'Gestion des niveau de formation');
+        $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id', true);
+        $table_editor->add_join_table('profile_education_degree', 'degreeid', true);
+        $table_editor->add_join_table('profile_education', 'degreeid', true);
+        $table_editor->describe('degree', 'niveau', true);
+        $table_editor->apply($page, $action, $id);
+    }
+    function handler_admin_education_degree_set(&$page, $action = 'list', $id = null) {
+        $page->setTitle('Administration - Correspondances formations - niveau de formation');
+        $page->assign('title', 'Gestion des correspondances formations - niveau de formation');
+        $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true);
+        $table_editor->describe('eduid', 'formation', true);
+        $table_editor->describe('degreeid', 'niveau', true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_sections(&$page, $action = 'list', $id = null) {