Fix naming convention.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 25 Feb 2010 20:42:28 +0000 (21:42 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 25 Feb 2010 20:42:28 +0000 (21:42 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/profile.php
classes/userfilter.php
include/directory.enums.inc.php
include/validations/medals.inc.php
modules/profile/decos.inc.php
modules/profile/groups.inc.php
modules/profile/skills.inc.php
upgrade/account/20_naming_convention.sql

index a1ddca2..63da84c 100644 (file)
@@ -415,7 +415,7 @@ class Profile
     {
         return XDB::fetchColumn('SELECT  binet_id
                                    FROM  profile_binets
-                                  WHERE  user_id = {?}', $this->id());
+                                  WHERE  pid = {?}', $this->id());
     }
 
 
index 24d4c82..c54ddac 100644 (file)
@@ -2057,7 +2057,7 @@ class UserFilter extends PlFilter
     {
         $joins = array();
         if ($this->with_bi) {
-            $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binets', '$ME.user_id = $PID');
+            $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binets', '$ME.pid = $PID');
         }
         if ($this->with_bd) {
             $joins['bd'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binet_enum', '$ME.id = bi.binet_id');
@@ -2354,7 +2354,7 @@ class UserFilter extends PlFilter
     {
         $joins = array();
         if ($this->with_pmed) {
-            $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals', '$ME.uid = $UID');
+            $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals', '$ME.pid = $PID');
         }
         return $joins;
     }
index d44a111..c116284 100644 (file)
@@ -421,7 +421,7 @@ class DE_Binets extends DirEnumeration
     protected $from = 'profile_binet_enum';
 
     protected $ac_join = 'INNER JOIN profile_binets ON (profile_binet_enum.id = profile_binets.binet_id)';
-    protected $ac_unique = 'profile_binets.user_id';
+    protected $ac_unique = 'profile_binets.pid';
 }
 // }}}
 
index efdca35..46bf272 100644 (file)
@@ -107,7 +107,7 @@ class MedalReq extends Validate
         register_watch_op($this->user->id(), WATCH_FICHE, '', 'medals');
         return XDB::execute('REPLACE INTO  profile_medals
                                    VALUES  ({?}, {?}, {?})',
-                            $this->user->id(), $this->mid,
+                            $this->user->profile()->id(), $this->mid,
                             is_null($this->gid) ? 0 : $this->gid);
     }
 
index 7a88b61..36a27d4 100644 (file)
@@ -29,7 +29,7 @@ class ProfileDeco implements ProfileSetting
             $res = XDB::iterRow("SELECT  m.id AS id, s.gid AS grade
                                    FROM  profile_medals    AS s
                              INNER JOIN  profile_medal_enum        AS m ON ( s.mid = m.id )
-                                  WHERE  s.uid = {?}",
+                                  WHERE  s.pid = {?}",
                                 $page->pid());
             $value = array();
             while (list($id, $grade) = $res->next()) {
@@ -62,7 +62,7 @@ class ProfileDeco implements ProfileSetting
             if (!isset($value[$id]) || $val['grade'] != $value[$id]['grade']) {
                 if ($val['valid']) {
                     XDB::execute("DELETE FROM  profile_medals
-                                        WHERE  uid = {?} AND mid = {?}",
+                                        WHERE  pid = {?} AND mid = {?}",
                                  $page->pid(), $id);
                 } else {
                     $req = MedalReq::get_request(S::i('uid'), $id);
index 3090443..461ba13 100644 (file)
@@ -43,17 +43,10 @@ class ProfileSection implements ProfileSetting
     }
 }
 
-class ProfileGroup implements ProfileSetting
+class ProfileBinets implements ProfileSetting
 {
-    private $table;
-    private $user_field;
-    private $group_field;
-
-    public function __construct($table, $user, $group)
+    public function __construct()
     {
-        $this->table       = $table;
-        $this->user_field  = $user;
-        $this->group_field = $group;
     }
 
     public function value(ProfilePage &$page, $field, $value, &$success)
@@ -61,9 +54,9 @@ class ProfileGroup implements ProfileSetting
         if (is_null($value)) {
             $value = array();
             $res = XDB::iterRow("SELECT  g.id, g.text
-                                   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} = {?}",
+                                   FROM  profile_binet_enum AS g
+                             INNER JOIN  profile_binets AS i ON (i.binet_id = g.id)
+                                  WHERE  i.pid = {?}",
                                 $page->pid());
             while (list($gid, $text) = $res->next()) {
                 $value[intval($gid)] = $text;
@@ -79,8 +72,8 @@ class ProfileGroup implements ProfileSetting
 
     public function save(ProfilePage &$page, $field, $value)
     {
-        XDB::execute("DELETE FROM  {$this->table}_ins
-                            WHERE  {$this->user_field} = {?}",
+        XDB::execute("DELETE FROM  profile_binets
+                            WHERE  pid = {?}",
                      $page->pid());
         if (!count($value)) {
             return;
@@ -89,7 +82,7 @@ class ProfileGroup implements ProfileSetting
         foreach ($value as $id=>$text) {
             $insert[] = XDB::format('({?}, {?})', $page->pid(), $id);
         }
-        XDB::execute("INSERT INTO  {$this->table}_ins ({$this->user_field}, {$this->group_field})
+        XDB::execute("INSERT INTO  profile_binets (pid, binet_id)
                            VALUES  " . implode(',', $insert));
     }
 }
@@ -102,7 +95,7 @@ class ProfileGroups extends ProfilePage
     {
         parent::__construct($wiz);
         $this->settings['section']  = new ProfileSection();
-        $this->settings['binets']   = new ProfileGroup('binet', 'user_id', 'binet_id');
+        $this->settings['binets']   = new ProfileBinets();
         $this->watched['section'] = $this->watched['binets'] = true;
     }
 
index 144fe50..ad4bef5 100644 (file)
@@ -65,7 +65,7 @@ class ProfileSkill implements ProfileSetting
     public function save(ProfilePage &$page, $field, $value)
     {
         XDB::execute("DELETE FROM  profile_{$this->table}s
-                            WHERE  uid = {?}",
+                            WHERE  pid = {?}",
                      $page->pid());
         if (!count($value)) {
             return;
index fcbbf58..75cdebd 100644 (file)
@@ -16,8 +16,16 @@ CHANGE COLUMN  montant_max amount_max DECIMAL(10,2) NOT NULL DEFAULT 0.00;
 CHANGE COLUMN  montant amount VARCHAR(15) NOT NULL DEFAULT '0.00',
 CHANGE COLUMN  cle pkey VARCHAR(5) NOT NULL;
 
-# photo
+# profile
   ALTER TABLE  profile_photos
 CHANGE COLUMN  uid pid INT(6) not null;
+  ALTER TABLE  profile_skills
+CHANGE COLUMN  uid pid INT(11) not null;
+  ALTER TABLE  profile_langskills
+CHANGE COLUMN  uid pid INT(11) not null;
+  ALTER TABLE  profile_binets
+CHANGE COLUMN  user_id pid INT(11) not null;
+  ALTER TABLE  profile_medals
+CHANGE COLUMN  uid pid INT(11) not null;
 
 # vim:set ft=mysql: