<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
public function addUser($user)
{
- $forlife = get_user_forlife($user, '_silent_user_callback');
- if ($forlife) {
- $this->user_list[] = get_user_forlife($user);
+ $user = Profile::get($user);
+ if ($user) {
+ $this->user_list[] = $user;
$this->count++;
}
}
protected function fetch()
{
- return new PlArrayIterator($this->user_list);
+ return PlIteratorUtils::fromArray($this->user_list);
}
protected function buildEntry($entry)
{
global $globals;
$login = $entry['value'];
- $user = get_user_details($login);
+ $user = get_user_details($login->hrid());
if (empty($user['nom_usage'])) {
$entry = new PlVCardEntry($user['prenom'], $user['nom'], null, null, @$user['nickname']);
}
// Emails
+ // TODO: this logic is not hruid-compatible; replace it.
$entry->addMail(null, $user['bestalias'] . '@' . $globals->mail->domain, true);
$entry->addMail(null, $user['bestalias'] . '@' . $globals->mail->domain2);
if ($user['bestalias'] != $user['forlife']) {
}
// Pro
- foreach ($user['adr_pro'] as $pro) {
- $street = array($adr['adr1']);
- if (!empty($pro['adr2'])) {
- $street[] = $pro['adr2'];
- }
- if (!empty($pro['adr3'])) {
- $street[] = $pro['adr3'];
- }
- $group = $entry->addWork($pro['entreprise'], null, $pro['poste'], $pro['fonction'],
- $street, null, null, $pro['postcode'], $pro['city'], $pro['region'], @$pro['country']);
- if (!empty($pro['tel'])) {
- $entry->addTel($group, $pro['tel']);
- }
- if (!empty($pro['fax'])) {
- $entry->addTel($group, $pro['fax'], true);
- }
- if (!empty($pro['email'])) {
- $entry->addMail($group, $pro['email']);
+ if (!empty($user['adr_pro'])) {
+ foreach ($user['adr_pro'] as $pro) {
+ $street = array($adr['adr1']);
+ if (!empty($pro['adr2'])) {
+ $street[] = $pro['adr2'];
+ }
+ if (!empty($pro['adr3'])) {
+ $street[] = $pro['adr3'];
+ }
+ $group = $entry->addWork($pro['entreprise'], null, $pro['poste'], $pro['fonction'],
+ $street, null, null, $pro['postcode'], $pro['city'], $pro['region'], @$pro['country']);
+ if (!empty($pro['tel'])) {
+ $entry->addTel($group, $pro['tel']);
+ }
+ if (!empty($pro['fax'])) {
+ $entry->addTel($group, $pro['fax'], true);
+ }
+ if (!empty($pro['email'])) {
+ $entry->addMail($group, $pro['email']);
+ }
}
}
// Melix
$res = XDB::query(
"SELECT alias
- FROM virtual
- INNER JOIN virtual_redirect USING(vid)
+ FROM virtual AS v
+ INNER JOIN virtual_redirect AS vr ON (v.vid = vr.vid)
INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
WHERE ( redirect={?} OR redirect={?} )
AND alias LIKE '%@{$globals->mail->alias_dom}'",
// Photo
if ($this->photos) {
$res = XDB::query(
- "SELECT attach, attachmime
- FROM photo AS p
- INNER JOIN aliases AS a ON (a.id = p.uid AND a.type = 'a_vie')
- WHERE a.alias = {?}", $login);
+ "SELECT attach, attachmime
+ FROM photo AS p
+ WHERE p.uid = {?}", $login->id());
if ($res->numRows()) {
list($data, $type) = $res->fetchOneRow();
$entry->setPhoto($data, strtoupper($type));