From bdd977d7134cbd9783745d4bfd0ed84c58961c5f Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 25 Feb 2010 21:42:28 +0100 Subject: [PATCH] Fix naming convention. Signed-off-by: Florent Bruneau --- classes/profile.php | 2 +- classes/userfilter.php | 4 ++-- include/directory.enums.inc.php | 2 +- include/validations/medals.inc.php | 2 +- modules/profile/decos.inc.php | 4 ++-- modules/profile/groups.inc.php | 25 +++++++++---------------- modules/profile/skills.inc.php | 2 +- upgrade/account/20_naming_convention.sql | 10 +++++++++- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index a1ddca2..63da84c 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -415,7 +415,7 @@ class Profile { return XDB::fetchColumn('SELECT binet_id FROM profile_binets - WHERE user_id = {?}', $this->id()); + WHERE pid = {?}', $this->id()); } diff --git a/classes/userfilter.php b/classes/userfilter.php index 24d4c82..c54ddac 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -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; } diff --git a/include/directory.enums.inc.php b/include/directory.enums.inc.php index d44a111..c116284 100644 --- a/include/directory.enums.inc.php +++ b/include/directory.enums.inc.php @@ -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'; } // }}} diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index efdca35..46bf272 100644 --- a/include/validations/medals.inc.php +++ b/include/validations/medals.inc.php @@ -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); } diff --git a/modules/profile/decos.inc.php b/modules/profile/decos.inc.php index 7a88b61..36a27d4 100644 --- a/modules/profile/decos.inc.php +++ b/modules/profile/decos.inc.php @@ -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); diff --git a/modules/profile/groups.inc.php b/modules/profile/groups.inc.php index 3090443..461ba13 100644 --- a/modules/profile/groups.inc.php +++ b/modules/profile/groups.inc.php @@ -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; } diff --git a/modules/profile/skills.inc.php b/modules/profile/skills.inc.php index 144fe50..ad4bef5 100644 --- a/modules/profile/skills.inc.php +++ b/modules/profile/skills.inc.php @@ -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; diff --git a/upgrade/account/20_naming_convention.sql b/upgrade/account/20_naming_convention.sql index fcbbf58..75cdebd 100644 --- a/upgrade/account/20_naming_convention.sql +++ b/upgrade/account/20_naming_convention.sql @@ -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: -- 2.1.4