TODO: fix naming of fields.
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
/* 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
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");
// 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)");
public function getBinets()
{
return XDB::fetchColumn('SELECT binet_id
- FROM binets_ins
+ FROM profile_binets
WHERE user_id = {?}', $this->id());
}
{
$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;
}
{
$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;
}
// {{{ 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';
}
// }}}
*/
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
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
//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();
}
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();
{
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);
$mid = $thumb ? @func_get_arg(2) : $mid;
$res = XDB::query("SELECT img
- FROM profile_medals
+ FROM profile_medal_enum
WHERE id = {?}",
$mid);
$img = $thumb ?
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()) {
$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()) {
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);
}
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);
}
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);
$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);
}
}
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();
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 {
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()) {
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()) {
{
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;
}
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()) {
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();
}
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']);
}
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',
$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'));
<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>
<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>
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');