$this->$key = $val;
}
}
+
+ public function hasFlags($flags) {
+ return $this->hasType($flags) && $this->hasLink($flags);
+ }
+
+ /** Returns true if this phone's type matches the flags
+ */
+ public function hasType($flags) {
+ $flags = $flags & Profile::PHONE_TYPE_ANY;
+ return (
+ ($flags == Profile::PHONE_TYPE_ANY)
+ ||
+ (($flags & Profile::PHONE_TYPE_FAX) && $this->type == self::TYPE_FAX)
+ ||
+ (($flags & Profile::PHONE_TYPE_FIXED) && $this->type == self::TYPE_FIXED)
+ ||
+ (($flags & Profile::PHONE_TYPE_MOBILE) && $this->type == self::TYPE_MOBILE)
+ );
+ }
+
+ /** Returns true if this phone's link matches the flags
+ */
+ public function hasLink($flags) {
+ $flags = $flags & Profile::PHONE_LINK_ANY;
+ return (
+ ($flags == Profile::PHONE_LINK_ANY)
+ ||
+ (($flags & Profile::PHONE_LINK_COMPANY) && $this->link_type == self::LINK_COMPANY)
+ ||
+ (($flags & Profile::PHONE_LINK_JOB) && $this->link_type == self::LINK_JOB)
+ ||
+ (($flags & Profile::PHONE_LINK_ADDRESS) && $this->link_type == self::LINK_ADDRESS)
+ ||
+ (($flags & Profile::PHONE_LINK_PROFILE) && $this->link_type == self::LINK_PROFILE)
+ );
+ }
}
// }}}
// {{{ class Company
public function hasFlag($flag)
{
+ if (!$this->flags instanceof PlFlagSet) {
+ $this->flags = new PlFlagSet($this->flags);
+ }
return $this->flags->hasFlag($flag);
}
}
public static function fetchData(array $pids, ProfileVisibility $visibility)
{
- $data = XDB::iterator('SELECT pm.pid, pm.mid, pm.gid, pme.text, pme.img
+ $data = XDB::iterator('SELECT pm.pid, pm.mid, pm.gid, pme.text, pme.img, pmge.text AS grade
FROM profile_medals AS pm
LEFT JOIN profiles AS p ON (pm.pid = p.pid)
LEFT JOIN profile_medal_enum AS pme ON (pme.id = pm.mid)
+ LEFT JOIN profile_medal_grade_enum AS pmge ON (pmge.mid = pm.mid AND pmge.gid = pm.gid)
WHERE pm.pid IN {?} AND p.medals_pub IN {?}
ORDER BY ' . XDB::formatCustomOrder('pm.pid', $pids),
$pids, $visibility->levels());
{
private $networks = array();
- public function __construct(PlIterator $it)
+ public function __construct(PlInnerSubIterator $it)
{
+ $this->pid = $it->value();
while ($network = $it->next()) {
- $this->networks[$network['nwid']] = $network['address'];
+ $network['network_type'] = new PlFlagSet($network['network_type']);
+ $this->networks[$network['id']] = $network;
}
}
public static function fetchData(array $pids, ProfileVisibility $visibility)
{
- $data = XDB::iterator('SELECT pid, nwid, address, network_type
- FROM profile_networking
+ $data = XDB::iterator('SELECT pid, id, address, pne.nwid, pne.network_type, pne.link, pne.name
+ FROM profile_networking AS pn
+ LEFT JOIN profile_networking_enum AS pne USING(nwid)
WHERE pid IN {?} AND pub IN {?}
ORDER BY ' . XDB::formatCustomOrder('pid', $pids) . ',
- network_type, nwid',
+ pn.nwid, id',
$pids, $visibility->levels());
return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid'));
public function get($flags, $limit = null)
{
+ if (!$flags) {
+ $flags = Profile::NETWORKING_ALL;
+ }
$nws = array();
$nb = 0;
foreach ($this->networks as $id => $nw) {
- // XXX hardcoded reference to web site index
- if (
- (($flags & self::NETWORKING_WEB) && $nw['network_type'] == 0)
- ||
- (! ($flags & self::NETWORKING_WEB))
- ) {
+ if (($flags & Profile::NETWORKING_WEB) && $nw['network_type']->hasFlag('web') ||
+ ($flags & Profile::NETWORKING_IM) && $nw['network_type']->hasFlag('im') ||
+ ($flags & Profile::NETWORKING_SOCIAL) && $nw['network_type']->hasFlag('social') ||
+ ($flags & Profile::NETWORKING_ALL)) {
$nws[$id] = $nw;
++$nb;
- }
- if ($nb >= $limit) {
- break;
+ if (isset($limit) && $nb >= $limit) {
+ break;
+ }
}
}
return $nws;
LEFT JOIN profile_corps_enum AS pceo ON (pceo.id = pc.original_corpsid)
LEFT JOIN profile_corps_enum AS pcec ON (pcec.id = pc.current_corpsid)
LEFT JOIN profile_corps_rank_enum AS pcrec ON (pcrec.id = pc.rankid)
- WHERE pc.pid IN {?} AND pc.corps_pub IN {?}
+ WHERE pc.pid IN {?} AND pc.corps_pub IN {?} AND pceo.id != 1
ORDER BY ' . XDB::formatCustomOrder('pid', $pids),
$pids, $visibility->levels());
$phones = array();
$nb = 0;
foreach ($this->phones as $id => $phone) {
- $phones[$id] = $phone;
- ++$nb;
- if ($limit != null && $nb == $limit) {
- break;
+ if ($phone->hasFlags($flags)) {
+ $phones[$id] = $phone;
+ ++$nb;
+ if ($limit != null && $nb == $limit) {
+ break;
+ }
}
}
return $phones;
public static function fetchData(array $pids, ProfileVisibility $visibility)
{
- $data = XDB::iterator('SELECT tel_type AS type, search_tel AS search, display_tel AS display, link_type, comment
+ $data = XDB::iterator('SELECT tel_type AS type, search_tel AS search, display_tel AS display, link_type, comment, pid
FROM profile_phones
WHERE pid IN {?} AND pub IN {?}
ORDER BY ' . XDB::formatCustomOrder('pid', $pids),
}
}
- public static function addAddresses(ProfileAddresses $addresses)
+ public function addAddresses(ProfileAddresses $addresses)
{
$a = $addresses->get(Profile::ADDRESS_PRO);
foreach ($a as $address) {
}
}
- public static function addCompanies(array $companies)
+ public function addCompanies(array $companies)
{
- foreach ($this->jobs as $job)
- {
- $job->company = $companies[$job->jobid];
+ foreach ($this->jobs as $job) {
+ $this->company = $companies[$job->jobid];
}
}
}