{
return XDB::fetchColumn('SELECT binet_id
FROM profile_binets
- WHERE user_id = {?}', $this->id());
+ WHERE pid = {?}', $this->id());
}
{
$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');
{
$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;
}
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';
}
// }}}
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);
}
$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()) {
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);
}
}
-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)
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;
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;
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));
}
}
{
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;
}
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;
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: