{
return str_replace(array('%s', '%f', '%l', '%F', '%S', '%p'),
array($this->isFemale() ? '•' : '',
- $this->first_name, $this->last_name,
- $this->full_name, $this->short_name,
- $this->promo), $format);
+ $this->firstName(), $this->lastName(),
+ $this->fullName(), $this->shortName(),
+ $this->promo()), $format);
}
public function fullName($with_promo = false)
return array_unique($vals);
}
+ public function nationalities()
+ {
+ $nats = array();
+ if ($this->nationality1) {
+ $nats[] = $this->nationality1;
+ }
+ if ($this->nationality2) {
+ $nats[] = $this->nationality2;
+ }
+ if ($this->nationality3) {
+ $nats[] = $this->nationality3;
+ }
+ return $nats;
+ }
+
public function __get($name)
{
if (property_exists($this, $name)) {
{
$cond = '';
if ($this->visibility) {
- $cond = ' AND pub IN ' . XDB::formatArray($this->visibility);
+ $cond = XDB::format(' AND pub IN {?}', $this->visibility);
}
$res = XDB::query("SELECT *
FROM profile_photos
$where .= ' AND FIND_IN_SET(\'mail\', pa.flags)';
}
if ($this->visibility) {
- $where .= ' AND pa.pub IN ' . XDB::formatArray($this->visibility);
+ $where .= XDB::format(' AND pa.pub IN {?}', $this->visibility);
}
$type = array();
if ($flags & self::ADDRESS_PRO) {
$type[] = 'home';
}
if (count($type) > 0) {
- $where .= ' AND pa.type IN ' . XDB::formatArray($type);
+ $where .= XDB::format(' AND pa.type IN {?}', $type);
}
$limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
return XDB::iterator('SELECT pa.text, pa.postalCode, pa.type, pa.latitude, pa.longitude,
$where .= ' AND pn.network_type = 0'; // XXX hardcoded reference to web site index
}
if ($this->visibility) {
- $where .= ' AND pn.pub IN ' . XDB::formatArray($this->visibility);
+ $where .= XDB::format(' AND pn.pub IN {?}', $this->visibility);
}
$limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
return XDB::iterator('SELECT pne.name, pne.icon,
$where = XDB::format('pj.pid = {?}', $this->id());
$cond = 'TRUE';
if ($this->visibility) {
- $where .= ' AND pj.pub IN ' . XDB::formatArray($this->visibility);
- $cond = 'pj.email_pub IN ' . XDB::formatArray($this->visibility);
+ $where .= XDB::format(' AND pj.pub IN {?}', $this->visibility);
+ $cond = XDB::format('pj.email_pub IN {?}', $this->visibility);
}
$limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
return XDB::iterator('SELECT pje.name, pje.acronym, pje.url, pje.email, pje.NAF_code,
$order = '';
}
+ require_once 'directory.enums.inc.php';
return XDB::Iterator('SELECT p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year,
pn_f.name AS firstname, pn_l.name AS lastname, pn_n.name AS nickname,
IF(pn_uf.name IS NULL, pn_f.name, pn_uf.name) AS firstname_ordinary,
FROM profiles AS p
INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
- INNER JOIN profile_name AS pn_f ON (pn_f.pid = p.pid
- AND pn_f.typeid = ' . self::getNameTypeId('firstname', true) . ')
- INNER JOIN profile_name AS pn_l ON (pn_l.pid = p.pid
- AND pn_l.typeid = ' . self::getNameTypeId('lastname', true) . ')
- LEFT JOIN profile_name AS pn_uf ON (pn_uf.pid = p.pid
- AND pn_uf.typeid = ' . self::getNameTypeId('firstname_ordinary', true) . ')
- LEFT JOIN profile_name AS pn_ul ON (pn_ul.pid = p.pid
- AND pn_ul.typeid = ' . self::getNameTypeId('lastname_ordinary', true) . ')
- LEFT JOIN profile_name AS pn_n ON (pn_n.pid = p.pid
- AND pn_n.typeid = ' . self::getNameTypeId('nickname', true) . ')
+ INNER JOIN profile_name AS pn_f ON (pn_f.pid = p.pid AND pn_f.typeid = {?})
+ INNER JOIN profile_name AS pn_l ON (pn_l.pid = p.pid AND pn_l.typeid = {?})
+ LEFT JOIN profile_name AS pn_uf ON (pn_uf.pid = p.pid AND pn_uf.typeid = {?})
+ LEFT JOIN profile_name AS pn_ul ON (pn_ul.pid = p.pid AND pn_ul.typeid = {?})
+ LEFT JOIN profile_name AS pn_n ON (pn_n.pid = p.pid AND pn_n.typeid = {?})
LEFT JOIN profile_phones AS pp ON (pp.pid = p.pid AND pp.link_type = \'user\' AND tel_type = \'mobile\')
LEFT JOIN profile_photos AS ph ON (ph.pid = p.pid)
LEFT JOIN account_profiles AS ap ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', ap.perms))
- WHERE p.pid IN ' . XDB::formatArray($pids) . '
+ WHERE p.pid IN {?}
GROUP BY p.pid
- ' . $order);
+ ' . $order,
+ DirEnum::getID(DirEnum::NAMETYPES, 'firstname'),
+ DirEnum::getID(DirEnum::NAMETYPES, 'lastname'),
+ DirEnum::getID(DirEnum::NAMETYPES, 'firstname_ordinary'),
+ DirEnum::getID(DirEnum::NAMETYPES, 'lastname_ordinary'),
+ DirEnum::getID(DirEnum::NAMETYPES, 'nickname'), $pids);
}
public static function getPID($login)
return XDB::fetchAllAssoc('uid', 'SELECT ap.uid, ap.pid
FROM account_profiles AS ap
WHERE FIND_IN_SET(\'owner\', ap.perms)
- AND ap.uid IN ' . XDB::formatArray($uids) .'
- ' . $order);
+ AND ap.uid IN {?}
+ ' . $order, $uids);
}
/** Return the profile associated with the given login.
|| $name == self::DN_SHORT || $name == self::DN_SORT;
}
- public static function getNameTypeId($type, $for_sql = false)
- {
- if (!S::has('name_types')) {
- $table = XDB::fetchAllAssoc('type', 'SELECT id, type
- FROM profile_name_enum');
- S::set('name_types', $table);
- } else {
- $table = S::v('name_types');
- }
- if ($for_sql) {
- return XDB::escape($table[$type]);
- } else {
- return $table[$type];
- }
- }
-
public static function rebuildSearchTokens($pid)
{
XDB::execute('DELETE FROM search_name