<?php
/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
$value = array();
$value = XDB::fetchAllAssoc("SELECT eduid, degreeid, fieldid, grad_year, program
FROM profile_education
- WHERE uid = {?} AND !FIND_IN_SET('primary', flags)
+ WHERE pid = {?} AND !FIND_IN_SET('primary', flags)
ORDER BY id",
$page->pid());
} else {
public function save(ProfilePage &$page, $field, $value)
{
XDB::execute("DELETE FROM profile_education
- WHERE uid = {?} AND !FIND_IN_SET('primary', flags)",
+ WHERE pid = {?} AND !FIND_IN_SET('primary', flags)",
$page->pid());
foreach ($value as $eduid=>&$edu) {
if ($edu['eduid'] != '') {
XDB::execute("INSERT INTO profile_education
- SET id = {?}, uid = {?}, eduid = {?}, degreeid = {?},
+ SET id = {?}, pid = {?}, eduid = {?}, degreeid = {?},
fieldid = {?}, grad_year = {?}, program = {?}",
$eduid, $page->pid(), $edu['eduid'], $edu['degreeid'],
$edu['fieldid'], $edu['grad_year'], $edu['program']);
$value = XDB::fetchAllAssoc("SELECT n.address, n.network_type AS type, n.pub, m.name
FROM profile_networking AS n
INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type)
- WHERE n.uid = {?}",
+ WHERE n.pid = {?}",
$page->pid());
}
if (!is_array($value)) {
public function save(ProfilePage &$page, $field, $value)
{
XDB::execute("DELETE FROM profile_networking
- WHERE uid = {?}",
+ WHERE pid = {?}",
$page->pid());
if (!count($value)) {
return;
}
$insert = array();
foreach ($value as $id=>$network) {
- XDB::execute("INSERT INTO profile_networking (uid, nwid, network_type, address, pub)
+ XDB::execute("INSERT INTO profile_networking (pid, nwid, network_type, address, pub)
VALUES ({?}, {?}, {?}, {?}, {?})",
$page->pid(), $id, $network['type'], $network['address'], $network['pub']);
}
$res = XDB::query("SELECT p.promo, e.entry_year AS entry_year, e.grad_year AS grad_year,
pr.nationality1, pr.nationality2, pr.nationality3, pr.birthdate,
t.display_tel as mobile, t.pub as mobile_pub,
- d.email_directory as email_directory,
+ pr.email_directory as email_directory,
pr.freetext, pr.freetext_pub, pr.ax_id AS matricule_ax, p.yourself
FROM profiles AS pr
INNER JOIN profile_display AS p ON (p.pid = pr.pid)
- INNER JOIN profile_education AS e ON (e.uid = pr.pid AND FIND_IN_SET('primary', e.flags))
- LEFT JOIN profile_phones AS t ON (t.uid = pr.pid AND link_type = 'user')
- LEFT JOIN profile_directory AS d ON (d.uid = pr.pid)
+ INNER JOIN profile_education AS e ON (e.pid = pr.pid AND FIND_IN_SET('primary', e.flags))
+ LEFT JOIN profile_phones AS t ON (t.pid = pr.pid AND link_type = 'user')
WHERE pr.pid = {?}", $this->pid());
$this->values = $res->fetchOneAssoc();
if ($this->owner) {
// Retreive photo informations
$res = XDB::query("SELECT pub
- FROM photo
- WHERE uid = {?}", $this->pid());
+ FROM profile_photos
+ WHERE pid = {?}", $this->pid());
$this->values['photo_pub'] = $res->fetchOneCell();
if ($this->owner) {
$res = XDB::query("SELECT COUNT(*)
FROM requests
- WHERE type='photo' AND user_id = {?}",
+ WHERE type = 'photo' AND uid = {?}",
$this->owner->id());
$this->values['nouvellephoto'] = $res->fetchOneCell();
} else {
protected function _saveData()
{
if ($this->changed['nationality1'] || $this->changed['nationality2'] || $this->changed['nationality3']
- || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub']) {
+ || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub']
+ || $this->changed['email_directory']) {
if ($this->values['nationality3'] == "") {
$this->values['nationality3'] = NULL;
}
$this->values['nationality2'] = $this->values['nationality3'];
$this->values['nationality3'] = NULL;
}
+ $new_email = ($this->values['email_directory'] == "new@example.org") ?
+ $this->values['email_directory_new'] : $this->values['email_directory'];
+ if ($new_email == "") {
+ $new_email = NULL;
+ }
XDB::execute("UPDATE profiles
SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?},
- freetext = {?}, freetext_pub = {?}
+ freetext = {?}, freetext_pub = {?}, email_directory = {?}
WHERE pid = {?}",
$this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'],
preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['birthdate']),
- $this->values['freetext'], $this->values['freetext_pub'], $this->pid());
- }
- if ($this->changed['email_directory']) {
- $new_email = ($this->values['email_directory'] == "new@example.org") ?
- $this->values['email_directory_new'] : $this->values['email_directory'];
- if ($new_email == "") {
- $new_email = NULL;
- }
- XDB::execute("REPLACE INTO profile_directory (uid, email_directory)
- VALUES ({?}, {?})",
- $this->pid(), $new_email);
+ $this->values['freetext'], $this->values['freetext_pub'], $new_email, $this->pid());
}
if ($this->changed['photo_pub']) {
- XDB::execute("UPDATE photo
+ XDB::execute("UPDATE profile_photos
SET pub = {?}
- WHERE uid = {?}",
+ WHERE pid = {?}",
$this->values['photo_pub'], $this->pid());
}
if ($this->changed['yourself']) {