Copy missing tables: all the tables needed by profile/edit are present.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 21 Feb 2010 17:10:17 +0000 (18:10 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 21 Feb 2010 17:10:17 +0000 (18:10 +0100)
TODO: fix naming of fields.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
14 files changed:
bin/cron/checkdb.php
bin/cron/clean.php
classes/profile.php
classes/userfilter.php
include/directory.enums.inc.php
include/user.func.inc.php
include/validations/medals.inc.php
modules/profile.php
modules/profile/decos.inc.php
modules/profile/groups.inc.php
modules/profile/skills.inc.php
modules/search/search.inc.php
templates/profile/groups.tpl
upgrade/account/copy_tables.php

index ede680b..d210de9 100755 (executable)
@@ -73,12 +73,12 @@ if ( PEAR::isError($opts) ) {
 
 /* Validite des flags de transmission */
 check("SELECT  u.user_id, nom, prenom, promo,
-               emails_alias_pub, profile_freetext_pub, profile_medals_pub
+               emails_alias_pub, profile_freetext_pub, profile_medal_enum_pub
          FROM  auth_user_md5 AS u
    INNER JOIN  auth_user_quick AS q USING(user_id)
         WHERE  (emails_alias_pub != 'private' AND emails_alias_pub != 'public')
            OR  (profile_freetext_pub != 'private' AND profile_freetext_pub != 'public')
-           OR  (profile_medals_pub != 'private' AND profile_medals_pub != 'public')",
+           OR  (profile_medal_enum_pub != 'private' AND profile_medal_enum_pub != 'public')",
     "Utilisateur n'ayant pas de flag de publicite pour leurs donnees de profil");
 check("SELECT  pid
          FROM  profile_addresses
@@ -102,8 +102,8 @@ check("select a.* from profile_education as a left join auth_user_md5 as u on u.
 check("select a.* from profile_education as a left join profile_education_enum as ad on ad.id=a.eduid where ad.name is null");
 
 /* validite de binet_users */
-check("select b.* from binets_ins as b left join auth_user_md5 as u on u.user_id=b.user_id where u.prenom is null");
-check("select b.* from binets_ins as b left join binets_def as bd on bd.id=b.binet_id where bd.text is null");
+check("select b.* from profile_binets as b left join auth_user_md5 as u on u.user_id=b.user_id where u.prenom is null");
+check("select b.* from profile_binets as b left join profile_binet_enum as bd on bd.id=b.binet_id where bd.text is null");
 
 /* validite de contacts */
 check("select c.* from contacts as c left join auth_user_md5 as u on u.user_id=c.uid where u.prenom is null");
index 66277f9..6a1fef8 100755 (executable)
@@ -38,12 +38,12 @@ query("DELETE FROM register_pending WHERE hash = 'INSCRIT'");
 
 // quelques tables sont triées pour que la lecture triée soit plus facile
 query("ALTER TABLE profile_education_enum ORDER BY name");
-query("ALTER TABLE binets_def ORDER BY text");
+query("ALTER TABLE profile_binet_enum ORDER BY text");
 query("ALTER TABLE groupesx_def ORDER BY text");
 query("ALTER TABLE profile_job_sector_enum ORDER BY name");
 query("ALTER TABLE profile_job_subsector_enum ORDER BY name");
 query("ALTER TABLE profile_job_subsubsector_enum ORDER BY name");
-query("ALTER TABLE sections ORDER BY text");
+query("ALTER TABLE profile_section_enum ORDER BY text");
 
 // Prunes older autocomplete queries.
 query("DELETE FROM search_autocomplete WHERE generated < DATE_SUB(NOW(), INTERVAL 1 DAY)");
index 3c782b6..a61d73a 100644 (file)
@@ -414,7 +414,7 @@ class Profile
     public function getBinets()
     {
         return XDB::fetchColumn('SELECT  binet_id
-                                   FROM  binets_ins
+                                   FROM  profile_binets
                                   WHERE  user_id = {?}', $this->id());
     }
 
index cd71249..efb03c6 100644 (file)
@@ -2057,10 +2057,10 @@ class UserFilter extends PlFilter
     {
         $joins = array();
         if ($this->with_bi) {
-            $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'binets_ins', '$ME.user_id = $PID');
+            $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binets', '$ME.user_id = $PID');
         }
         if ($this->with_bd) {
-            $joins['bd'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'binets_def', '$ME.id = bi.binet_id');
+            $joins['bd'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binet_enum', '$ME.id = bi.binet_id');
         }
         return $joins;
     }
@@ -2354,7 +2354,7 @@ class UserFilter extends PlFilter
     {
         $joins = array();
         if ($this->with_pmed) {
-            $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals_sub', '$ME.uid = $UID');
+            $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals', '$ME.uid = $UID');
         }
         return $joins;
     }
index 9b31f24..a5b7736 100644 (file)
@@ -418,19 +418,19 @@ class DE_NameTypes extends DirEnumeration
 // {{{ class DE_Binets
 class DE_Binets extends DirEnumeration
 {
-    protected $from = 'binets_def';
+    protected $from = 'profile_binet_enum';
 
-    protected $ac_join = 'INNER JOIN binets_ins ON (binets_def.id = binets_ins.binet_id)';
-    protected $ac_unique = 'binets_ins.user_id';
+    protected $ac_join = 'INNER JOIN profile_binets ON (profile_binet_enum.id = profile_binets.binet_id)';
+    protected $ac_unique = 'profile_binets.user_id';
 }
 // }}}
 
 // {{{ class DE_Sections
 class DE_Sections extends DirEnumeration
 {
-    protected $from = 'sections';
+    protected $from = 'profile_section_enum';
 
-    protected $ac_join = 'INNER JOIN profiles ON (profiles.section = sections.id)';
+    protected $ac_join = 'INNER JOIN profiles ON (profiles.section = profile_section_enum.id)';
     protected $ac_unique = 'profiles.pid';
 }
 // }}}
index 33869a6..20cabe2 100644 (file)
@@ -26,8 +26,8 @@
  */
 function user_clear_all_subs($user_id, $really_del=true)
 {
-    // keep datas in : aliases, adresses, tels, profile_education, binets_ins, contacts, groupesx_ins, homonymes, identification_ax, photo
-    // delete in     : competences_ins, emails, entreprises, langues_ins, mentor,
+    // keep datas in : aliases, adresses, tels, profile_education, profile_binets, contacts, groupesx_ins, homonymes, identification_ax, photo
+    // delete in     : profile_skills, emails, entreprises, profile_langskills, mentor,
     //                 mentor_pays, mentor_secteurs, newsletter_ins, perte_pass, requests, user_changes, virtual_redirect, watch_sub
     // + delete maillists
 
@@ -37,14 +37,14 @@ function user_clear_all_subs($user_id, $really_del=true)
     list($alias) = explode('@', $user->forlifeEmail());
 
     // TODO: clear profile.
-    $tables_to_clear = array('uid' => array('competences_ins', 'profile_job', 'langues_ins', 'profile_mentor_country',
+    $tables_to_clear = array('uid' => array('profile_skills', 'profile_job', 'profile_langskills', 'profile_mentor_country',
                                             'profile_mentor_sector', 'profile_mentor', 'perte_pass', 'watch_sub'),
                              'user_id' => array('requests', 'user_changes'));
 
     if ($really_del) {
         array_push($tables_to_clear['uid'], 'emails', 'group_members', 'contacts', 'adresses', 'profile_phones',
-                                            'photo', 'perte_pass', 'langues_ins', 'forum_subs', 'forum_profiles');
-        array_push($tables_to_clear['user_id'], 'newsletter_ins', 'binets_ins');
+                                            'photo', 'perte_pass', 'profile_langskills', 'forum_subs', 'forum_profiles');
+        array_push($tables_to_clear['user_id'], 'newsletter_ins', 'profile_binets');
         $tables_to_clear['id'] = array('aliases');
         $tables_to_clear['contact'] = array('contacts');
         XDB::execute("UPDATE accounts
index 4a2f6a9..efdca35 100644 (file)
@@ -77,8 +77,8 @@ class MedalReq extends Validate
         //var_dump($this);
         $r = XDB::query("
             SELECT IF (g.text IS NOT NULL, CONCAT(m.text,' - ', g.text), m.text)
-              FROM profile_medals AS m
-         LEFT JOIN profile_medals_grades AS g ON(g.mid = m.id AND g.gid = {?})
+              FROM profile_medal_enum AS m
+         LEFT JOIN profile_medal_enum_grades AS g ON(g.mid = m.id AND g.gid = {?})
              WHERE m.id = {?}", $this->gid, $this->mid);
         return $r->fetchOneCell();
     }
@@ -89,7 +89,7 @@ class MedalReq extends Validate
     public function submit()
     {
         $res = XDB::query("SELECT  FIND_IN_SET('validation', flags)
-                             FROM  profile_medals
+                             FROM  profile_medal_enum
                             WHERE  id = {?}", $this->mid);
         if ($res->fetchOneCell()) {
             parent::submit();
@@ -105,7 +105,7 @@ class MedalReq extends Validate
     {
         require_once 'notifs.inc.php';
         register_watch_op($this->user->id(), WATCH_FICHE, '', 'medals');
-        return XDB::execute('REPLACE INTO  profile_medals_sub
+        return XDB::execute('REPLACE INTO  profile_medals
                                    VALUES  ({?}, {?}, {?})',
                             $this->user->id(), $this->mid,
                             is_null($this->gid) ? 0 : $this->gid);
index da3b414..69dc2bf 100644 (file)
@@ -107,7 +107,7 @@ class ProfileModule extends PLModule
         $mid = $thumb ? @func_get_arg(2) : $mid;
 
         $res = XDB::query("SELECT  img
-                             FROM  profile_medals
+                             FROM  profile_medal_enum
                             WHERE  id = {?}",
                           $mid);
         $img  = $thumb ?
@@ -380,7 +380,7 @@ class ProfileModule extends PLModule
         pl_cached_content_headers("text/javascript", "utf-8");
         $page->changeTpl('profile/grades.js.tpl', NO_SKIN);
         $res    = XDB::iterator("SELECT  *
-                                   FROM  profile_medals_grades
+                                   FROM  profile_medal_enum_grades
                                ORDER BY  mid, pos");
         $grades = array();
         while ($tmp = $res->next()) {
@@ -389,7 +389,7 @@ class ProfileModule extends PLModule
         $page->assign('grades', $grades);
 
         $res    = XDB::iterator("SELECT  *, FIND_IN_SET('validation', flags) AS validate
-                                   FROM  profile_medals
+                                   FROM  profile_medal_enum
                                ORDER BY  type, text");
         $mlist  = array();
         while ($tmp = $res->next()) {
@@ -797,8 +797,8 @@ class ProfileModule extends PLModule
     function handler_admin_binets(&$page, $action = 'list', $id = null) {
         $page->setTitle('Administration - Binets');
         $page->assign('title', 'Gestion des binets');
-        $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
-        $table_editor->add_join_table('binets_ins','binet_id',true);
+        $table_editor = new PLTableEditor('admin/binets', 'profile_binet_enum', 'id');
+        $table_editor->add_join_table('profile_binets','binet_id',true);
         $table_editor->describe('text','intitulé',true);
         $table_editor->apply($page, $action, $id);
     }
@@ -840,7 +840,7 @@ class ProfileModule extends PLModule
     function handler_admin_sections(&$page, $action = 'list', $id = null) {
         $page->setTitle('Administration - Sections');
         $page->assign('title', 'Gestion des sections');
-        $table_editor = new PLTableEditor('admin/sections','sections','id');
+        $table_editor = new PLTableEditor('admin/sections','profile_section_enum','id');
         $table_editor->describe('text','intitulé',true);
         $table_editor->apply($page, $action, $id);
     }
@@ -884,7 +884,7 @@ class ProfileModule extends PLModule
     function handler_admin_medals(&$page, $action = 'list', $id = null) {
         $page->setTitle('Administration - Distinctions');
         $page->assign('title', 'Gestion des Distinctions');
-        $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
+        $table_editor = new PLTableEditor('admin/medals','profile_medal_enum','id');
         $table_editor->describe('text', 'intitulé',  true);
         $table_editor->describe('img',  'nom de l\'image', false);
         $table_editor->describe('flags', 'valider', true);
@@ -895,29 +895,29 @@ class ProfileModule extends PLModule
             $mid = $id;
 
             if (Post::v('act') == 'del') {
-                XDB::execute('DELETE FROM  profile_medals_grades
+                XDB::execute('DELETE FROM  profile_medal_enum_grades
                                     WHERE  mid={?} AND gid={?}', $mid, Post::i('gid'));
             } else {
                 foreach (Post::v('grades', array()) as $gid=>$text) {
                     if ($gid === 0) {
                         if (!empty($text)) {
                             $res = XDB::query('SELECT  MAX(gid)
-                                                 FROM  profile_medals_grades
+                                                 FROM  profile_medal_enum_grades
                                                 WHERE  mid = {?}', $mid);
                             $gid = $res->fetchOneCell() + 1;
 
-                            XDB::execute('INSERT INTO  profile_medals_grades (mid, gid, text, pos)
+                            XDB::execute('INSERT INTO  profile_medal_enum_grades (mid, gid, text, pos)
                                                VALUES  ({?}, {?}, {?}, {?})',
                                 $mid, $gid, $text, $_POST['pos']['0']);
                         }
                     } else {
-                        XDB::execute('UPDATE  profile_medals_grades
+                        XDB::execute('UPDATE  profile_medal_enum_grades
                                          SET  pos={?}, text={?}
                                        WHERE  gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid);
                     }
                 }
             }
-            $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
+            $res = XDB::iterator('SELECT gid, text, pos FROM profile_medal_enum_grades WHERE mid={?} ORDER BY pos', $mid);
             $page->assign('grades', $res);
         }
     }
index bbf26b3..7a88b61 100644 (file)
@@ -27,8 +27,8 @@ class ProfileDeco implements ProfileSetting
         if (is_null($value)) {
             // Fetch already attributed medals
             $res = XDB::iterRow("SELECT  m.id AS id, s.gid AS grade
-                                   FROM  profile_medals_sub    AS s
-                             INNER JOIN  profile_medals        AS m ON ( s.mid = m.id )
+                                   FROM  profile_medals    AS s
+                             INNER JOIN  profile_medal_enum        AS m ON ( s.mid = m.id )
                                   WHERE  s.uid = {?}",
                                 $page->pid());
             $value = array();
@@ -61,7 +61,7 @@ class ProfileDeco implements ProfileSetting
         foreach ($orig as $id=>&$val) {
             if (!isset($value[$id]) || $val['grade'] != $value[$id]['grade']) {
                 if ($val['valid']) {
-                    XDB::execute("DELETE FROM  profile_medals_sub
+                    XDB::execute("DELETE FROM  profile_medals
                                         WHERE  uid = {?} AND mid = {?}",
                                  $page->pid(), $id);
                 } else {
@@ -118,7 +118,7 @@ class ProfileDecos extends ProfilePage
     public function _prepare(PlPage &$page, $id)
     {
         $res    = XDB::iterator("SELECT  *, FIND_IN_SET('validation', flags) AS validate
-                                   FROM  profile_medals
+                                   FROM  profile_medal_enum
                                ORDER BY  type, text");
         $mlist  = array();
         while ($tmp = $res->next()) {
index 7948519..3090443 100644 (file)
@@ -61,8 +61,8 @@ class ProfileGroup implements ProfileSetting
         if (is_null($value)) {
             $value = array();
             $res = XDB::iterRow("SELECT  g.id, g.text
-                                   FROM  {$this->table}_def AS g
-                             INNER JOIN  {$this->table}_ins AS i ON (i.{$this->group_field} = g.id)
+                                   FROM  profile_{$this->table}_enum AS g
+                             INNER JOIN  profile_{$this->table}s AS i ON (i.{$this->group_field} = g.id)
                                   WHERE  i.{$this->user_field} = {?}",
                                 $page->pid());
             while (list($gid, $text) = $res->next()) {
@@ -102,7 +102,7 @@ class ProfileGroups extends ProfilePage
     {
         parent::__construct($wiz);
         $this->settings['section']  = new ProfileSection();
-        $this->settings['binets']   = new ProfileGroup('binets', 'user_id', 'binet_id');
+        $this->settings['binets']   = new ProfileGroup('binet', 'user_id', 'binet_id');
         $this->watched['section'] = $this->watched['binets'] = true;
     }
 
index 8260222..144fe50 100644 (file)
@@ -37,8 +37,8 @@ class ProfileSkill implements ProfileSetting
         if (is_null($value)) {
             $value = array();
             $res = XDB::iterRow("SELECT  s.id, s.{$this->text_field}, i.level
-                                   FROM  {$this->table}_def AS s
-                             INNER JOIN  {$this->table}_ins AS i ON(s.id = i.{$this->skill_field})
+                                   FROM  profile_{$this->table}_enum AS s
+                             INNER JOIN  profile_{$this->table}s AS i ON(s.id = i.{$this->skill_field})
                                   WHERE  i.uid = {?}",
                                 $page->pid());
             while (list($sid, $text, $level) = $res->next()) {
@@ -51,7 +51,7 @@ class ProfileSkill implements ProfileSetting
             foreach ($value as $id=>&$skill) {
                 if (!isset($skill['text']) || empty($skill['text'])) {
                     $res = XDB::query("SELECT  {$this->text_field}
-                                         FROM  {$this->table}_def
+                                         FROM  profile_{$this->table}_enum
                                         WHERE  id = {?}", $id);
                     $skill['text'] = $res->fetchOneCell();
                 }
@@ -64,14 +64,14 @@ class ProfileSkill implements ProfileSetting
 
     public function save(ProfilePage &$page, $field, $value)
     {
-        XDB::execute("DELETE FROM  {$this->table}_ins
+        XDB::execute("DELETE FROM  profile_{$this->table}s
                             WHERE  uid = {?}",
                      $page->pid());
         if (!count($value)) {
             return;
         }
         foreach ($value as $id=>&$skill) {
-            XDB::execute("INSERT INTO  {$this->table}_ins (uid, {$this->skill_field}, level)
+            XDB::execute("INSERT INTO  profile_{$this->table}s (uid, {$this->skill_field}, level)
                                VALUES  ({?}, {?}, {?})",
                          $page->pid(), $id, $skill['level']);
         }
@@ -85,19 +85,19 @@ class ProfileSkills extends ProfilePage
     public function __construct(PlWizard &$wiz)
     {
         parent::__construct($wiz);
-        $this->settings['competences'] = new ProfileSkill('competences', 'cid', 'text_fr');
-        $this->settings['langues'] = new ProfileSkill('langues', 'lid', 'langue_fr');
+        $this->settings['competences'] = new ProfileSkill('skill', 'cid', 'text_fr');
+        $this->settings['langues'] = new ProfileSkill('langskill', 'lid', 'langue_fr');
     }
 
     public function _prepare(PlPage &$page, $id)
     {
         $page->assign('comp_list', XDB::iterator("SELECT  id, text_fr, FIND_IN_SET('titre',flags) AS title
-                                                    FROM  competences_def"));
+                                                    FROM  profile_skill_enum"));
         $page->assign('comp_level', array('initié' => 'initié',
                                           'bonne connaissance' => 'bonne connaissance',
                                           'expert' => 'expert'));
         $page->assign('lang_list', XDB::iterator("SELECT  id, langue_fr
-                                                    FROM  langues_def"));
+                                                    FROM  profile_langskill_enum"));
         $page->assign('lang_level', array(1 => 'connaissance basique',
                                           2 => 'maîtrise des bases',
                                           3 => 'maîtrise limitée',
index 26ee250..1cc5058 100644 (file)
@@ -58,7 +58,7 @@ function advancedSearchFromInput()
     $cvField            = new RefSField('cv', array('u.cv'), '', '', '', false);
 
     $natField           = new RefSField('nationalite', array('u.nationalite', 'u.nationalite2', 'u.nationalite3'), '', '', '');
-    $binetField         = new RefSField('binet', array('b.binet_id'), 'binets_ins', 'b', 'u.user_id=b.user_id');
+    $binetField         = new RefSField('binet', array('b.binet_id'), 'profile_binets', 'b', 'u.user_id=b.user_id');
     $groupexField       = new RefSField('groupex', array('g.id'), array('groups', 'group_members'), array('g', 'gm'),
                                         array("(g.cat = 'GroupesX' OR g.cat = 'Institutions') AND g.pub = 'public'",
                                               'gm.asso_id = g.id AND u.user_id = gm.uid'));
index 607c52d..9aed51f 100644 (file)
@@ -34,7 +34,7 @@
     <td class="titre" style="width: 30%">{if $old}ex-{/if}Section</td>
     <td>
       <select name="section">
-        {select_db_table table="sections" valeur=$section}
+        {select_db_table table="profile_section_enum" valeur=$section}
       </select>
     </td>
   </tr>
@@ -43,7 +43,7 @@
     <td class="titre">{if $old}ex-{/if}Binet(s)</td>
     <td>
       <select name="binets_sel" onchange="updateElement('binets')">
-        {select_db_table table="binets_def" valeur=0 champ="text" pad='1'}
+        {select_db_table table="profile_binet_enum" valeur=0 champ="text" pad='1'}
       </select>
       <a id="binets_add" style="display: none"
          href="javascript:addBinet()">{icon name="add" title="Ajouter ce binet"}</a>
index 027b3e7..aa4b443 100755 (executable)
@@ -99,6 +99,15 @@ copyTable('#x4dat#.postfix_mailseen', 'postfix_mailseen');
 copyTable('#x4dat#.postfix_whitelist', 'postfix_whitelist');
 
 copyTable('#x4dat#.photo', 'profile_photos');
+copyTable('#x4dat#.binets_def', 'profile_binet_enum');
+copyTable('#x4dat#.binets_ins', 'profile_binets');
+copyTable('#x4dat#.sections', 'profile_section_enum');
+copyTable('#x4dat#.profile_medals', 'profile_medal_enum');
+copyTable('#x4dat#.profile_medals_sub', 'profile_medals');
+copyTable('#x4dat#.competences_def', 'profile_skill_enum');
+copyTable('#x4dat#.competences_ins', 'profile_skills');
+copyTable('#x4dat#.langues_def', 'profile_langskill_enum');
+copyTable('#x4dat#.langues_ins', 'profile_langskills');
 
 copyTable('#x4dat#.register_marketing', 'register_marketing');
 copyTable('#x4dat#.register_pending', 'register_pending');