-Subproject commit 179658ec4de09ec088235d91977013f64eed49db
+Subproject commit 66297a8c8e4104f27ad2b3db4e35dc3cc77aa6db
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function fill_email_combobox(PlPage& $page)
+function fill_email_combobox(PlPage& $page, $user = null, $profile = null)
{
global $globals;
- $user = S::user();
+ if (is_null($user) && is_null($profile)) {
+ $user = S::user();
+ $profile = $user->profile();
+ }
$email_type = "directory";
- $res = XDB::query(
- "SELECT email_directory
- FROM profile_directory
- WHERE uid = {?}", $user->id());
- $email_directory = $res->fetchOneCell();
- if ($email_directory) {
- $page->assign('email_directory', $email_directory);
- list($alias, $domain) = explode('@', $email_directory);
- } else {
- $page->assign('email_directory', '');
- $email_type = NULL;
- $alias = $domain = '';
+ if ($profile) {
+ $res = XDB::query(
+ "SELECT email_directory
+ FROM profile_directory
+ WHERE uid = {?}", $profile->id());
+ $email_directory = $res->fetchOneCell();
+ if ($email_directory) {
+ $page->assign('email_directory', $email_directory);
+ list($alias, $domain) = explode('@', $email_directory);
+ } else {
+ $page->assign('email_directory', '');
+ $email_type = NULL;
+ $alias = $domain = '';
+ }
}
- $res = XDB::query(
- "SELECT alias
- FROM virtual
- INNER JOIN virtual_redirect USING(vid)
- WHERE (redirect = {?} OR redirect = {?})
- AND alias LIKE '%@{$globals->mail->alias_dom}'",
- $user->forlifeEmail(),
- // TODO: remove this über-ugly hack. The issue is that you need
- // to remove all @m4x.org addresses in virtual_redirect first.
- $user->login() . '@' . $globals->mail->domain2);
- $melix = $res->fetchOneCell();
- if ($melix) {
- list($melix) = explode('@', $melix);
- $page->assign('melix', $melix);
- if (($domain == $globals->mail->alias_dom) || ($domain == $globals->mail->alias_dom2)) {
- $email_type = "melix";
+ if ($user) {
+ $melix = $user->emailAlias();
+ if ($melix) {
+ list($melix) = explode('@', $melix);
+ $page->assign('melix', $melix);
+ if (($domain == $globals->mail->alias_dom) || ($domain == $globals->mail->alias_dom2)) {
+ $email_type = "melix";
+ }
}
- }
- $res = XDB::query(
- "SELECT alias
- FROM aliases
- WHERE id={?} AND (type='a_vie' OR type='alias')", $user->id());
- $res = $res->fetchAllAssoc();
- $page->assign('list_email_X', $res);
- if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) {
- foreach ($res as $res_it) {
- if ($alias == $res_it['alias']) {
- $email_type = "X";
+ $res = XDB::query(
+ "SELECT alias
+ FROM aliases
+ WHERE id={?} AND (type='a_vie' OR type='alias')", $user->id());
+ $res = $res->fetchAllAssoc();
+ $page->assign('list_email_X', $res);
+ if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) {
+ foreach ($res as $res_it) {
+ if ($alias == $res_it['alias']) {
+ $email_type = "X";
+ }
}
}
- }
- require_once 'emails.inc.php';
- $redirect = new Redirect($user);
- $redir = array();
- foreach ($redirect->emails as $redirect_it) {
- if ($redirect_it instanceof EmailRedirection) {
- $redir[] = $redirect_it->email;
- if ($email_directory == $redirect_it->email) {
- $email_type = "redir";
+ require_once 'emails.inc.php';
+ $redirect = new Redirect($user);
+ $redir = array();
+ foreach ($redirect->emails as $redirect_it) {
+ if ($redirect_it instanceof EmailRedirection) {
+ $redir[] = $redirect_it->email;
+ if ($email_directory == $redirect_it->email) {
+ $email_type = "redir";
+ }
}
}
- }
- $page->assign('list_email_redir', $redir);
+ $page->assign('list_email_redir', $redir);
- $res = XDB::query(
- "SELECT email
- FROM profile_job
- WHERE uid = {?}", $user->id());
- $res = $res->fetchAllAssoc();
- $pro = array();
- foreach ($res as $res_it) {
- if ($res_it['email'] != '') {
- $pro[] = $res_it['email'];
- if ($email_directory == $res_it['email']) {
- $email_type = "pro";
+ $res = XDB::query(
+ "SELECT email
+ FROM profile_job
+ WHERE uid = {?}", $user->id());
+ $res = $res->fetchAllAssoc();
+ $pro = array();
+ foreach ($res as $res_it) {
+ if ($res_it['email'] != '') {
+ $pro[] = $res_it['email'];
+ if ($email_directory == $res_it['email']) {
+ $email_type = "pro";
+ }
}
}
- }
- $page->assign('list_email_pro', $pro);
+ $page->assign('list_email_pro', $pro);
+ $page->assign('email_type', $email_type);
- $page->assign('email_type', $email_type);
+ } else {
+ $page->assign('list_email_X', array());
+ $page->assign('list_email_redir', array());
+ $page->assign('list_email_pro', array());
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
$page->addJsLink('grades.js');
$page->addJsLink('profile.js');
$page->addJsLink('jquery.autocomplete.js');
- $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true);
+ $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true, false);
+ $wiz->addUserData('profile', $user);
+ $wiz->addUserData('owner', $user->owner());
$this->load('page.inc.php');
$wiz->addPage('ProfileGeneral', 'Général', 'general');
$wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
return $value;
}
- private function saveTel($adrid, $telid, array &$tel)
- {
- XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type,
- search_tel, display_tel, pub)
- VALUES ({?}, 'address', {?}, {?}, {?},
- {?}, {?}, {?})",
- S::i('uid'), $adrid, $telid, $tel['type'],
- format_phone_number($tel['tel']), $tel['tel'], $tel['pub']);
- }
-
- private function saveAddress($adrid, array &$address)
+ private function saveAddress($pid, $adrid, array &$address)
{
$flags = new PlFlagSet();
- if ($address['secondaire']) {
- $flags->addFlag('res-secondaire');
- }
- if ($address['mail']) {
- $flags->addFlag('courrier');
- }
- if ($address['temporary']) {
- $flags->addFlag('temporaire');
- }
- if ($address['current']) {
- $flags->addFlag('active');
- }
- if ($address['checked']) {
- $flags->addFlag('coord-checked');
- }
+ $flags->addFlag('res-secondaire', $address['secondaire']);
+ $flags->addFlag('courrier', $address['mail']);
+ $flags->addFlag('temporaire', $address['temporary']);
+ $flags->addFlag('active', $address['current']);
+ $flags->addFlag('coord-checked', $address['checked']);
XDB::execute("INSERT INTO adresses (adr1, adr2, adr3,
postcode, city, cityid,
country, region, regiontxt,
$address['postcode'], $address['city'], $address['cityid'],
$address['country'], $address['region'], $address['regiontxt'],
$address['pub'], $address['datemaj'], $flags,
- S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon'], $address['comment']);
+ $pid, $adrid, $address['precise_lat'], $address['precise_lon'], $address['comment']);
}
public function save(ProfilePage &$page, $field, $value)
{
XDB::execute("DELETE FROM adresses
WHERE uid = {?}",
- S::i('uid'));
+ $page->pid());
XDB::execute("DELETE FROM profile_phones
WHERE uid = {?} AND link_type = 'address'",
- S::i('uid'));
+ $page->pid());
foreach ($value as $adrid=>&$address) {
- $this->saveAddress($adrid, $address);
+ $this->saveAddress($page->pid(), $adrid, $address);
$profiletel = new ProfilePhones('address', $adrid);
- $profiletel->saveTels('tel', $address['tel']);
+ $profiletel->saveTels($page->pid(), 'tel', $address['tel']);
}
}
}
INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut)
ORDER BY adrid",
- S::i('uid'));
+ $this->pid());
if ($res->numRows() == 0) {
$this->values['addresses'] = array();
} else {
FROM profile_phones
WHERE uid = {?} AND link_type = 'address'
ORDER BY link_id",
- S::i('uid'));
+ $this->pid());
$i = 0;
$adrNb = count($this->values['addresses']);
while ($tel = $res->next()) {
FROM profile_medals_sub AS s
INNER JOIN profile_medals AS m ON ( s.mid = m.id )
WHERE s.uid = {?}",
- S::i('uid'));
+ $page->pid());
$value = array();
while (list($id, $grade) = $res->next()) {
$value[$id] = array('grade' => $grade,
if ($val['valid']) {
XDB::execute("DELETE FROM profile_medals_sub
WHERE uid = {?} AND mid = {?}",
- S::i('uid'), $id);
+ $page->pid(), $id);
} else {
$req = MedalReq::get_request(S::i('uid'), $id);
if ($req) {
protected function _fetchData()
{
- $res = XDB::query("SELECT profile_medals_pub
- FROM auth_user_quick
- WHERE user_id = {?}",
- S::i('uid'));
+ $res = XDB::query("SELECT medals_pub
+ FROM profiles
+ WHERE pid = {?}",
+ $this->pid());
$this->values['medals_pub'] = $res->fetchOneCell();
}
protected function _saveData()
{
if ($this->changed['medals_pub']) {
- XDB::execute("UPDATE auth_user_quick
- SET profile_medals_pub = {?}
- WHERE user_id = {?}",
- $this->values['medals_pub'], S::i('uid'));
+ XDB::execute("UPDATE profiles
+ SET medals_pub = {?}
+ WHERE pid = {?}",
+ $this->values['medals_pub'], $this->pid());
}
}
class ProfileNom implements ProfileSetting
{
- private function matchWord($old, $new, $newLen) {
+ private function matchWord($old, $new, $newLen)
+ {
return ($i = strpos($old, $new)) !== false
&& ($i == 0 || $old{$i-1} == ' ')
&& ($i + $newLen == strlen($old) || $old{$i + $newLen} == ' ');
class ProfileEdu implements ProfileSetting
{
- public function __construct(){}
+ public function __construct() {
+ }
static function sortByGradYear($line1, $line2) {
$a = (int) $line1['grad_year'];
FROM profile_education
WHERE uid = {?} AND !FIND_IN_SET('primary', flags)
ORDER BY id",
- S::v('uid'));
+ $page->pid());
while($edu = $res->next()) {
$value[] = $edu;
}
{
XDB::execute("DELETE FROM profile_education
WHERE uid = {?} AND !FIND_IN_SET('primary', flags)",
- S::i('uid'));
+ $page->pid());
foreach ($value as $eduid=>&$edu) {
if ($edu['eduid'] != '') {
XDB::execute("INSERT INTO profile_education
SET id = {?}, uid = {?}, eduid = {?}, degreeid = {?},
fieldid = {?}, grad_year = {?}, program = {?}",
- $eduid, S::i('uid'), $edu['eduid'], $edu['degreeid'],
+ $eduid, $page->pid(), $edu['eduid'], $edu['degreeid'],
$edu['fieldid'], $edu['grad_year'], $edu['program']);
}
}
FROM profile_networking AS n
INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type)
WHERE n.uid = {?}",
- S::i('uid'));
+ $page->pid());
while($network = $res->next()) {
$value[] = $network;
}
{
XDB::execute("DELETE FROM profile_networking
WHERE uid = {?}",
- S::i('uid'));
+ $page->pid());
if (!count($value)) {
return;
}
foreach ($value as $id=>$network) {
XDB::execute("INSERT INTO profile_networking (uid, nwid, network_type, address, pub)
VALUES ({?}, {?}, {?}, {?}, {?})",
- S::i('uid'), $id, $network['type'], $network['address'], $network['pub']);
+ $page->pid(), $id, $network['type'], $network['address'], $network['pub']);
}
}
}
parent::__construct($wiz);
$this->settings['nom'] = $this->settings['prenom']
= new ProfileNom();
- $this->settings['naissance'] = new ProfileDate();
+ $this->settings['birthdate'] = new ProfileDate();
$this->settings['freetext_pub']
= $this->settings['photo_pub']
= new ProfilePub();
$this->settings['freetext']
- = $this->settings['nationalite']
- = $this->settings['nationalite2']
- = $this->settings['nationalite3']
+ = $this->settings['nationality1']
+ = $this->settings['nationality2']
+ = $this->settings['nationality3']
= $this->settings['nick']
= $this->settings['yourself']
= $this->settings['display_name']
$this->settings['edus'] = new ProfileEdu();
$this->watched= array('nom' => true, 'freetext' => true, 'tels' => true,
'networking' => true, 'edus' => true,
- 'nationalite' => true, 'nationalite2' => true,
- 'nationalite3' => true, 'nick' => true);
+ 'nationality1' => true, 'nationality2' => true,
+ 'nationality3' => true, 'nick' => true);
}
protected function _fetchData()
{
// Checkout all data...
$res = XDB::query("SELECT p.promo AS promo_display, e.entry_year AS entry_year, e.grad_year AS grad_year,
- u.nom_usage, u.nationalite, u.nationalite2, u.nationalite3, u.naissance,
+ pr.nationality1, pr.nationality2, pr.nationality3, pr.birthdate,
t.display_tel as mobile, t.pub as mobile_pub,
d.email_directory as email_directory,
- q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub,
- q.profile_nick as nick, q.profile_from_ax as synchro_ax, u.matricule_ax,
+ pr.freetext, pr.freetext_pub as freetext_pub,
n.yourself, n.display AS display_name, n.sort AS sort_name,
n.tooltip AS tooltip_name
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q ON (u.user_id = q.user_id)
- INNER JOIN profile_names_display AS n ON (n.user_id = u.user_id)
- INNER JOIN profile_display AS p ON (p.pid = u.user_id)
- INNER JOIN profile_education AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags))
- LEFT JOIN profile_phones AS t ON (u.user_id = t.uid AND link_type = 'user')
- LEFT JOIN profile_directory AS d ON (d.uid = u.user_id)
- WHERE u.user_id = {?}", S::v('uid', -1));
+ FROM profiles AS pr
+ INNER JOIN profile_names_display AS n ON (n.user_id = pr.pid)
+ 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)
+ WHERE pr.pid = {?}", $this->pid());
$this->values = $res->fetchOneAssoc();
// Retreive photo informations
$res = XDB::query("SELECT pub
FROM photo
- WHERE uid = {?}", S::v('uid'));
+ WHERE uid = {?}", $this->pid());
$this->values['photo_pub'] = $res->fetchOneCell();
- $res = XDB::query("SELECT COUNT(*)
- FROM requests
- WHERE type='photo' AND user_id = {?}",
- S::v('uid'));
- $this->values['nouvellephoto'] = $res->fetchOneCell();
+ if ($this->owner) {
+ $res = XDB::query("SELECT COUNT(*)
+ FROM requests
+ WHERE type='photo' AND user_id = {?}",
+ $this->owner->id());
+ $this->values['nouvellephoto'] = $res->fetchOneCell();
+ } else {
+ $this->values['nouvellephoto'] = 0;
+ }
// Retreive search names info
$this->values['search_names'] = XDB::iterator("
FROM profile_names_search AS sn
WHERE sn.user_id = {?}
ORDER BY sn.name_type, search_score, search_name",
- S::v('uid'));
+ $this->pid());
// Proposes choice for promo_display
if ($this->values['entry_year'] != $this->values['grad_year'] - 3) {
protected function _saveData()
{
- if ($this->changed['nationalite'] || $this->changed['nationalite2'] || $this->changed['nationalite3']
- || $this->changed['nom'] || $this->changed['prenom'] || $this->changed['naissance']) {
- if ($this->values['nationalite3'] == "") {
- $this->values['nationalite3'] = NULL;
+ if ($this->changed['nationality1'] || $this->changed['nationality2'] || $this->changed['nationality3']
+ || $this->changed['nom'] || $this->changed['prenom'] || $this->changed['naissance']
+ || $this->changed['freetext'] || $this->changed['freetext_pub']) {
+ if ($this->values['nationality3'] == "") {
+ $this->values['nationality3'] = NULL;
}
- if ($this->values['nationalite2'] == "") {
- $this->values['nationalite2'] = $this->values['nationalite3'];
- $this->values['nationalite3'] = NULL;
+ if ($this->values['nationality2'] == "") {
+ $this->values['nationality2'] = $this->values['nationality3'];
+ $this->values['nationality3'] = NULL;
}
- if ($this->values['nationalite'] == "") {
- $this->values['nationalite'] = $this->values['nationalite2'];
- $this->values['nationalite2'] = $this->values['nationalite3'];
- $this->values['nationalite3'] = NULL;
+ if ($this->values['nationality1'] == "") {
+ $this->values['nationality1'] = $this->values['nationality2'];
+ $this->values['nationality2'] = $this->values['nationality3'];
+ $this->values['nationality3'] = NULL;
}
- XDB::execute("UPDATE auth_user_md5
- SET nationalite = {?}, nationalite2 = {?}, nationalite3 = {?}, nom={?}, prenom={?}, naissance={?}
+ XDB::execute("UPDATE profiles
+ SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?},
+ freetext = {?}, freetext_pub = {?}
WHERE user_id = {?}",
- $this->values['nationalite'], $this->values['nationalite2'], $this->values['nationalite3'],
- $this->values['nom'], $this->values['prenom'],
- preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']),
- S::v('uid'));
- }
- if ($this->changed['nick'] || $this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) {
- XDB::execute("UPDATE auth_user_quick
- SET profile_nick= {?},
- profile_freetext={?},
- profile_freetext_pub={?}, profile_from_ax = {?}
- WHERE user_id = {?}",
- $this->values['nick'],
- $this->values['freetext'], $this->values['freetext_pub'],
- $this->values['synchro_ax'], S::v('uid'));
+ $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") ?
}
XDB::execute("REPLACE INTO profile_directory (uid, email_directory)
VALUES ({?}, {?})",
- S::v('uid'), $new_email);
+ $this->pid(), $new_email);
}
if ($this->changed['nick']) {
require_once('user.func.inc.php');
XDB::execute("UPDATE photo
SET pub = {?}
WHERE uid = {?}",
- $this->values['photo_pub'], S::v('uid'));
+ $this->values['photo_pub'], $this->pid());
}
if ($this->changed['yourself'] || $this->changed['sort_name'] ||
$this-> changed['display_name'] || $this->changed['tooltip_name']) {
$this->values['sort_name'],
$this->values['display_name'],
$this->values['tooltip_name'],
- S::v('uid'));
+ $this->pid());
}
if ($this->changed['promo_display']) {
XDB::execute("UPDATE profile_display
SET promo = {?}
WHERE pid = {?}",
- $this->values['promo_display'], S::v('uid'));
+ $this->values['promo_display'], $this->pid());
}
}
$page->assign('edu_fields', $res->fetchAllAssoc());
require_once "emails.combobox.inc.php";
- fill_email_combobox($page);
+ fill_email_combobox($page, $this->owner, $this->profile);
$res = XDB::iterator("SELECT nw.network_type AS type, nw.name
FROM profile_networking_enum AS nw
$success = true;
if (is_null($value)) {
$res = XDB::query("SELECT section
- FROM auth_user_md5
- WHERE user_id = {?}",
- S::i('uid'));
+ FROM profiles
+ WHERE pid = {?}",
+ $page->pid());
return intval($res->fetchOneCell());
}
return intval($value);
public function save(ProfilePage &$page, $field, $value)
{
- XDB::execute("UPDATE auth_user_md5
+ XDB::execute("UPDATE profiles
SET section = {?}
- WHERE user_id = {?}",
- $value, S::i('uid'));
+ WHERE pid = {?}",
+ $value, $page->pid());
}
}
FROM {$this->table}_def AS g
INNER JOIN {$this->table}_ins AS i ON (i.{$this->group_field} = g.id)
WHERE i.{$this->user_field} = {?}",
- S::i('uid'));
+ $page->pid());
while (list($gid, $text) = $res->next()) {
$value[intval($gid)] = $text;
}
{
XDB::execute("DELETE FROM {$this->table}_ins
WHERE {$this->user_field} = {?}",
- S::i('uid'));
+ $page->pid());
if (!count($value)) {
return;
}
$insert = array();
foreach ($value as $id=>$text) {
- $insert[] = '(' . S::i('uid') . ", $id)";
+ $insert[] = XDB::format('({?}, {?})', $page->pid(), $id);
}
XDB::execute("INSERT INTO {$this->table}_ins ({$this->user_field}, {$this->group_field})
VALUES " . implode(',', $insert));
FROM groupex.asso AS a
INNER JOIN groupex.membres AS m ON (m.asso_id = a.id)
WHERE m.uid = {?} AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')",
- S::i('uid')));
+ $this->pid()));
$page->assign('listgroups', XDB::iterator("SELECT a.nom, a.diminutif, a.sub_url,
IF (a.cat = 'Institutions', a.cat, d.nom) AS dom
FROM groupex.asso AS a
WHERE a.inscriptible != 0
AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')
ORDER BY a.cat, a.dom, a.nom"));
+ # XXX: FIXME: promo_sortie
$page->assign('old', (int)date('Y') >= S::i('promo_sortie'));
}
}
{
// Checkout the CV
$res = XDB::query("SELECT cv
- FROM auth_user_md5
- WHERE user_id = {?}",
- S::i('uid'));
+ FROM profiles
+ WHERE pid = {?}",
+ $this->pid());
$this->values['cv'] = $res->fetchOneCell();
// Checkout the corps
rankid AS rank, corps_pub AS pub
FROM profile_corps
WHERE uid = {?}",
- S::i('uid'));
+ $this->pid());
$this->values['corps'] = $res->fetchOneAssoc();
// Build the jobs tree
LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.country)
LEFT JOIN profile_job_subsubsector_enum AS s ON (s.id = j.subsubsectorid)
WHERE j.uid = {?}
- ORDER BY entrid", S::i('uid'));
+ ORDER BY entrid", $this->pid());
$this->values['jobs'] = array();
while (list($id, $name, $function, $secteur, $ss_secteur, $sss_secteur, $description,
$w_adr1, $w_adr2, $w_adr3, $w_postcode, $w_city, $w_cityid,
FROM profile_phones
WHERE uid = {?} AND link_type = 'pro'
ORDER BY link_id",
- S::i('uid'));
+ $this->pid());
$i = 0;
$jobNb = count($this->values['jobs']);
while ($tel = $res->next()) {
protected function _saveData()
{
if ($this->changed['cv']) {
- XDB::execute("UPDATE auth_user_md5
+ XDB::execute("UPDATE profiles
SET cv = {?}
- WHERE user_id = {?}",
- $this->values['cv'], S::i('uid'));
+ WHERE pid = {?}",
+ $this->values['cv'], $this->pid());
}
if ($this->changed['corps']) {
rankid = {?}, corps_pub = {?}
WHERE uid = {?}",
$this->values['corps']['original'], $this->values['corps']['current'],
- $this->values['corps']['rank'], $this->values['corps']['pub'], S::i('uid'));
+ $this->values['corps']['rank'], $this->values['corps']['pub'], $this->pid());
}
}
public function _prepare(PlPage &$page, $id)
{
require_once "emails.combobox.inc.php";
- fill_email_combobox($page);
+ fill_email_combobox($page, $this->owner, $this->profile);
$res = XDB::query("SELECT id, name AS label
FROM profile_job_sector_enum");
INNER JOIN profile_job_sector_enum AS s ON (m.sectorid = s.id)
INNER JOIN profile_job_subsector_enum AS ss ON (s.id = ss.sectorid AND m.subsectorid = ss.id)
WHERE m.uid = {?}",
- S::i('uid'));
+ $page->pid());
while (list($s, $ss, $ssname) = $res->next()) {
if (!isset($value[$s])) {
$value[$s] = array($ss => $ssname);
XDB::execute("DELETE FROM profile_mentor_sector
WHERE uid = {?}",
- S::i('uid'));
+ $page->pid());
if (!count($value)) {
return;
}
foreach ($sect as $sid=>&$name) {
XDB::execute("INSERT INTO profile_mentor_sector (uid, sectorid, subsectorid)
VALUES ({?}, {?}, {?})",
- S::i('uid'), $id, $sid);
+ $page->pid(), $id, $sid);
}
}
}
FROM profile_mentor_country AS m
INNER JOIN geoloc_pays AS p ON (m.country = p.a2)
WHERE m.uid = {?}",
- S::i('uid'));
+ $page->pid());
while (list($id, $name) = $res->next()) {
$value[$id] = $name;
}
{
XDB::execute("DELETE FROM profile_mentor_country
WHERE uid = {?}",
- S::i('uid'));
+ $page->pid());
foreach ($value as $id=>&$name) {
XDB::execute("INSERT INTO profile_mentor_country (uid, country)
VALUES ({?}, {?})",
- S::i('uid'), $id);
+ $page->pid(), $id);
}
}
}
$res = XDB::query("SELECT expertise
FROM mentor
WHERE uid = {?}",
- S::i('uid'));
+ $this->pid());
$this->values['expertise'] = $res->fetchOneCell();
}
if (empty($expertise)) {
XDB::execute("DELETE FROM mentor
WHERE uid = {?}",
- S::i('uid'));
+ $this->pid());
$this->values['expertise'] = null;
} else {
XDB::execute("REPLACE INTO mentor (uid, expertise)
VALUES ({?}, {?})",
- S::i('uid'), $expertise);
+ $this->pid(), $expertise);
$this->values['expertise'] = $expertise;
}
}
{
private $tel;
private $pub;
- protected $id;
protected $link_type;
protected $link_id;
- public function __construct($type, $link_id, $id = 0)
+ public function __construct($type, $link_id)
{
- if ($id != 0) {
- $this->id = $id;
- } else {
- $this->id = S::i('uid');
- }
$this->tel = new ProfileTel();
$this->pub = new ProfilePub();
$this->link_type = $type;
FROM profile_phones AS t
WHERE t.uid = {?} AND t.link_type = {?}
ORDER BY t.tel_id",
- $this->id, $this->link_type);
+ $page->pid(), $this->link_type);
$value = $res->fetchAllAssoc();
}
foreach ($value as $key=>&$phone) {
return $value;
}
- private function saveTel($telid, array &$phone)
+ private function saveTel($pid, $telid, array &$phone)
{
if ($phone['tel'] != '') {
XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type,
search_tel, display_tel, pub, comment)
VALUES ({?}, {?}, {?}, {?}, {?},
{?}, {?}, {?}, {?})",
- $this->id, $this->link_type, $this->link_id, $telid, $phone['type'],
+ $pid, $this->link_type, $this->link_id, $telid, $phone['type'],
format_phone_number($phone['tel']), $phone['tel'], $phone['pub'], $phone['comment']);
}
}
{
XDB::execute("DELETE FROM profile_phones
WHERE uid = {?} AND link_type = {?} AND link_id = {?}",
- $this->id, $this->link_type, $this->link_id);
- $this->saveTels($field, $value);
+ $page->pid(), $this->link_type, $this->link_id);
+ $this->saveTels($page->pid(), $field, $value);
}
//Only saves phones without a delete operation
- public function saveTels($field, $value)
+ public function saveTels($pid, $field, $value)
{
foreach ($value as $telid=>&$phone) {
- $this->saveTel($telid, $phone);
+ $this->saveTel($pid, $telid, $phone);
}
}
}
public $orig = array();
public $values = array();
+ public $profile = null;
+ public $owner = null;
public function __construct(PlWizard &$wiz)
{
$this->wizard =& $wiz;
+ $this->profile = $this->wizard->getUserData('profile');
+ $this->owner = $this->wizard->getUserData('owner');
}
protected function _fetchData()
$setting->save($this, $field, $this->values[$field]);
}
if ($this->changed[$field] && @$this->watched[$field]) {
- register_profile_update(S::i('uid'), $field);
+ register_profile_update($profile->id(), $field);
}
}
$this->_saveData();
// Update the last modification date
XDB::execute('REPLACE INTO user_changes
- SET user_id = {?}', S::v('uid'));
+ SET user_id = {?}', $profile->id());
if (!S::suid()) {
- register_watch_op(S::i('uid'), WATCH_FICHE);
+ register_watch_op($profile->id(), WATCH_FICHE);
}
global $platal;
- S::logger()->log('profil', $platal->pl_self(1));
+ S::logger()->log('profil', $platal->pl_self(2));
}
protected function checkChanges()
return 'profile/base.tpl';
}
+ public function pid()
+ {
+ return $this->profile->id();
+ }
+
+ public function hrpid()
+ {
+ return $this->profile->hrpid();
+ }
+
protected function _prepare(PlPage &$page, $id)
{
}
$page->assign($field, $value);
}
$this->_prepare($page, $id);
+ $page->assign('profile', $this->profile);
+ $page->assign('owner', $this->owner);
$page->assign('profile_page', $this->pg_template);
$page->assign('errors', $this->errors);
}
FROM {$this->table}_def AS s
INNER JOIN {$this->table}_ins AS i ON(s.id = i.{$this->skill_field})
WHERE i.uid = {?}",
- S::i('uid'));
+ $page->pid());
while (list($sid, $text, $level) = $res->next()) {
$value[$sid] = array('text' => $text, 'level' => $level);
}
{
XDB::execute("DELETE FROM {$this->table}_ins
WHERE uid = {?}",
- S::i('uid'));
+ $page->pid());
if (!count($value)) {
return;
}
foreach ($value as $id=>&$skill) {
XDB::execute("INSERT INTO {$this->table}_ins (uid, {$this->skill_field}, level)
VALUES ({?}, {?}, {?})",
- S::i('uid'), $id, $skill['level']);
+ $page->pid(), $id, $skill['level']);
}
}
}
<td>
<span class="titre">Date de naissance</span>
</td>
- <td><input type="text" {if $errors.naissance}class="error"{/if} name="naissance" value="{$naissance}" /></td>
+ <td><input type="text" {if $errors.birthdate}class="error"{/if} name="naissance" value="{$birthdate}" /></td>
</tr>
<tr>
<td>
<span class="titre">Nationalité</span>
</td>
<td>
- <select name="nationalite">
- {select_nat valeur=$nationalite pad=1}
+ <select name="nationality1">
+ {select_nat valeur=$nationality1 pad=1}
</select>
<a href="javascript:addNationality();">{icon name=add title="Ajouter une nationalité"}</a>
</td>
</tr>
- <tr id="nationalite2" {if !$nationalite2}style="display: none"{/if}>
+ <tr id="nationality2" {if !$nationality2}style="display: none"{/if}>
<td></td>
<td>
- <select name="nationalite2">
- {select_nat valeur=$nationalite2 pad=1}
+ <select name="nationality2">
+ {select_nat valeur=$nationality2 pad=1}
</select>
<a href="javascript:delNationality('2');">{icon name=cross title="Supprimer cette nationalité"}</a>
</td>
</tr>
- <tr id="nationalite3" {if !$nationalite3}style="display: none"{/if}>
+ <tr id="nationality3" {if !$nationality3}style="display: none"{/if}>
<td></td>
<td>
- <select name="nationalite3">
- {select_nat valeur=$nationalite3 pad=1}
+ <select name="nationality3">
+ {select_nat valeur=$nationality3 pad=1}
</select>
<a href="javascript:delNationality('3');">{icon name=cross title="Supprimer cette nationalité"}</a>
</td>
</tr>
</table>
-{if !$no_private_key}
-<table class="bicol" style="margin-bottom: 1em"
- summary="Profil : Informations générales">
- <tr>
- <th>
- Synchronisation avec l'AX
- </th>
- </tr>
- <tr>
- <td class="flags">
- <input type="checkbox" name="synchro_ax" {if $synchro_ax}checked="checked" {/if}/>
- {icon name="flag_orange" title="transmis à l'AX"}
- <span class="texte">
- Autoriser la synchronisation vers l'AX par des administrateurs ou des scripts automatiques.
- </span>
- </td>
- </tr>
- <tr>
- <td>
- <p>
- Le service annuaire de l'<a href='http://www.polytechniciens.com'>AX</a> met à jour l'annuaire papier à partir des informations que tu lui fournis. Tu peux choisir ici d'envoyer directement les données de ta fiche Polytechnique.org vers ta <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id={$matricule_ax}">fiche AX</a>.
- </p>
- <p>
- L'opération de synchronisation prend en compte toutes les informations que tu as marquées comme transmises à l'AX (en orange ou en vert). Elle peut alors effacer, modifier ou rajouter des informations sur ta <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id={$matricule_ax}">fiche AX</a> selon ce qui s'y trouve déjà.
- </p>
- <p class="center">
- <a href="profile/edit/general?synchro_ax=confirm" onclick="return confirm('Es-tu sûr de vouloir lancer la synchronisation ?')"><input type="button" value="Synchroniser"/></a>
- </p>
- </td>
- </tr>
-</table>
-{/if}
-
<table class="bicol" style="margin-bottom: 1em"
summary="Profil : Trombinoscope">
<tr>
<tr>
<td {if !$nouvellephoto}colspan="2"{/if} class="center" style="width: 49%">
<div class="titre">Ta photo actuelle</div>
- <img src="photo/{$smarty.session.hruid}" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
+ <img src="photo/{$profile->hrid()}" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
</td>
{if $nouvellephoto}
<td class="center" style="width: 49%">
<div class="titre">Photo en attente de validation</div>
<div>
- <a href="profile/{$smarty.session.hruid}?modif=new" class="popup2">
+ <a href="profile/{$profile->hrid()}?modif=new" class="popup2">
Ta fiche avec cette photo
</a>
</div>
- <img src="photo/{$smarty.session.hruid}/req" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
+ <img src="photo/{$profile->hrid()}/req" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
</td>
{/if}
</tr>