2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 // {{{ class ProfileField
23 /** To store a "field" from the profile
24 * Provides functions for loading a batch of such data
26 abstract class ProfileField
28 public static $fields = array(
29 Profile
::FETCH_ADDRESSES
=> 'ProfileAddresses',
30 Profile
::FETCH_CORPS
=> 'ProfileCorps',
31 Profile
::FETCH_EDU
=> 'ProfileEducation',
32 Profile
::FETCH_JOBS
=> 'ProfileJobs',
33 Profile
::FETCH_MEDALS
=> 'ProfileMedals',
34 Profile
::FETCH_NETWORKING
=> 'ProfileNetworking',
35 Profile
::FETCH_PHONES
=> 'ProfilePhones',
36 Profile
::FETCH_MENTOR_COUNTRY
=> 'ProfileMentoringCountries',
37 Profile
::FETCH_JOB_TERMS
=> 'ProfileJobTerms',
38 Profile
::FETCH_MENTOR_TERMS
=> 'ProfileMentoringTerms',
39 Profile
::FETCH_SKILL
=> 'ProfileSkills',
40 Profile
::FETCH_LANGUAGE
=> 'ProfileLanguages',
41 Profile
::FETCH_PARTNER
=> 'ProfilePartnerSharing',
44 /** The profile to which this field belongs
48 /** Fetches data from the database for the given pids, compatible with
49 * the visibility context.
50 * @param $pids An array of pids
51 * @param $visibility The level of visibility fetched fields must have
52 * @return a PlIterator yielding data suitable for a "new ProfileBlah($data)"
54 * MUST be reimplemented for each kind of ProfileField.
56 public static function fetchData(array $pids, Visibility
$visibility)
58 return PlIteratorUtils
::emptyIterator();
61 public static function buildForPID($cls, $pid, Visibility
$visibility)
63 $res = self
::buildFromPIDs($cls, array($pid), $visibility);
64 return array_pop($res);
67 /** Build a list of ProfileFields from a set of pids
68 * @param $cls The name of the field to create ('ProfileMedals', ...)
69 * @param $pids An array of pids
70 * @param $visibility An array of allowed visibility contexts
71 * @return An array of $pid => ProfileField
73 public static function buildFromPIDs($cls, array $pids, Visibility
$visibility)
75 $it = new ProfileFieldIterator($cls, $pids, $visibility);
77 while ($pf = $it->next()) {
83 public static function getForPID($cls, $pid, Visibility
$visibility)
85 $it = new ProfileFieldIterator($cls, array($pid), $visibility);
91 // {{{ class ProfileFieldIterator
92 class ProfileFieldIterator
implements PlIterator
97 public function __construct($cls, array $pids, Visibility
$visibility)
99 if (is_numeric($cls) && isset(ProfileField
::$fields[$cls])) {
100 $cls = ProfileField
::$fields[$cls];
102 $this->data
= call_user_func(array($cls, 'fetchData'), $pids, $visibility);
106 public function next()
108 $d = $this->data
->next();
117 public function total()
119 return $this->data
->total();
122 public function first()
124 return $this->data
->first();
127 public function last()
129 return $this->data
->last();
141 public $phone = null
;
142 public $address = null
;
145 * $id, $name, $acronym, $url
147 public function __construct($data)
149 foreach ($data as $key => $val) {
154 public function setPhone(Phone
$phone)
156 if ($phone->link_type
== Phone
::LINK_COMPANY
&& $phone->link_id
== $this->id
) {
157 $this->phone
= $phone;
161 public function setAddress(Address
$address)
163 if ($address->type
== Address
::LINK_COMPANY
&& $address->jobid
== $this->id
) {
164 $this->address
= $address;
171 /** profile_job describes a Job, links to:
172 * - a Profile, through `pid`
173 * - a Company, through `jobid`
174 * The `id` field is the id of this job in the list of the jobs of its profile
176 * For the documentation of the phone table, please see classes/phone.php.
177 * For the documentation of the address table, please see classes/address.php.
179 * The possible relations are as follow:
180 * A Job is linked to a Company and a Profile
187 public $company = null
;
188 public $phones = array();
189 public $address = null
;
190 public $terms = array();
202 * pid, id, company_id, description, url, email
204 public function __construct($data)
206 foreach ($data as $key => $val) {
209 $this->company
= CompanyList
::get($this->jobid
);
210 if (is_null($this->company
)) {
211 $entreprises = ProfileValidate
::get_typed_requests($this->pid
, 'entreprise');
212 foreach ($entreprises as $entreprise) {
213 if ($entreprise->id
== $this->id
) {
214 $this->company
= new Company(array('name' => $entreprise->name
));
220 public function phones()
222 return $this->phones
;
225 public function address()
227 return $this->address
;
230 public function addPhone(Phone
$phone)
232 if ($phone->link_type
== Phone
::LINK_JOB
&& $phone->link_id
== $this->id
&& $phone->pid
== $this->pid
) {
233 $this->phones
[$phone->uniqueId()] = $phone;
237 public function setAddress(Address
$address)
239 if ($address->type
== Address
::LINK_JOB
&& $address->id
== $this->id
&& $address->pid
== $this->pid
) {
240 $this->address
= $address;
244 public function addTerm(JobTerm
$term)
246 $this->terms
[$term->jtid
] = $term;
259 * pid, jid, jtid, full_name
261 public function __construct($data)
263 foreach ($data as $key => $val) {
269 // {{{ class Education
281 public $school_short;
286 public $degree_short;
287 public $degree_level;
291 public function __construct(array $data)
293 foreach ($data as $key => $val) {
296 $this->flags
= new PlFlagSet($this->flags
);
301 // {{{ class ProfileEducation [ Field ]
302 class ProfileEducation
extends ProfileField
304 private $educations = array();
306 public function __construct(PlInnerSubIterator
$it)
308 $this->pid
= $it->value();
309 while ($edu = $it->next()) {
310 $this->educations
[$edu['id']] = new Education($edu);
314 public function get($flags, $limit)
316 $educations = array();
318 $year = $year['year'];
320 foreach ($this->educations
as $id => $edu) {
322 (($flags & Profile
::EDUCATION_MAIN
) && $edu->flags
->hasFlag('primary'))
324 (($flags & Profile
::EDUCATION_EXTRA
) && !$edu->flags
->hasFlag('primary'))
326 (($flags & Profile
::EDUCATION_FINISHED
) && $edu->grad_year
<= $year)
328 (($flags & Profile
::EDUCATION_CURRENT
) && $edu->grad_year
> $year)
330 ($flags & Profile
::EDUCATION_ALL
)
332 $educations[$id] = $edu;
335 if ($limit != null
&& $nb >= $limit) {
342 public static function fetchData(array $pids, Visibility
$visibility)
344 $data = XDB
::iterator('SELECT pe.id, pe.pid,
345 pe.entry_year, pe.grad_year, pe.program, pe.flags,
346 pee.name AS school, pee.abbreviation AS school_short,
347 pee.url AS school_url, gc.country,
348 pede.degree, pede.abbreviation AS degree_short, pede.level AS degree_level,
350 FROM profile_education AS pe
351 LEFT JOIN profile_education_enum AS pee ON (pee.id = pe.eduid)
352 LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = pee.country)
353 LEFT JOIN profile_education_degree_enum AS pede ON (pede.id = pe.degreeid)
354 LEFT JOIN profile_education_field_enum AS pefe ON (pefe.id = pe.fieldid)
356 ORDER BY ' . XDB
::formatCustomOrder('pid', $pids) . ',
357 NOT FIND_IN_SET(\'primary\', pe.flags), pe.entry_year, pe.id',
360 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
364 // {{{ class ProfileMedals [ Field ]
365 class ProfileMedals
extends ProfileField
367 public $medals = array();
369 public function __construct(PlInnerSubIterator
$it)
371 $this->pid
= $it->value();
372 while ($medal = $it->next()) {
373 $this->medals
[$medal['mid']] = $medal;
377 public static function fetchData(array $pids, Visibility
$visibility)
379 $data = XDB
::iterator('SELECT pm.pid, pm.mid, pm.gid, pme.text, pme.img, pmge.text AS grade, pm.level
380 FROM profile_medals AS pm
381 LEFT JOIN profiles AS p ON (pm.pid = p.pid)
382 LEFT JOIN profile_medal_enum AS pme ON (pme.id = pm.mid)
383 LEFT JOIN profile_medal_grade_enum AS pmge ON (pmge.mid = pm.mid AND pmge.gid = pm.gid)
384 LEFT JOIN profile_visibility_enum AS pve ON (pve.access_level = {?})
385 WHERE pm.pid IN {?} AND pve.best_display_level + 0 <= p.medals_pub + 0
386 ORDER BY ' . XDB
::formatCustomOrder('pm.pid', $pids),
387 $visibility->level(), $pids);
389 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
393 // {{{ class ProfileNetworking [ Field ]
394 class ProfileNetworking
extends ProfileField
396 private $networks = array();
398 public function __construct(PlInnerSubIterator
$it)
400 $this->pid
= $it->value();
401 while ($network = $it->next()) {
402 $network['network_type'] = new PlFlagSet($network['network_type']);
403 $this->networks
[$network['id']] = $network;
407 public static function fetchData(array $pids, Visibility
$visibility)
409 $data = XDB
::iterator('SELECT pid, id, address, pne.nwid, pne.network_type, pne.link, pne.name
410 FROM profile_networking AS pn
411 LEFT JOIN profile_networking_enum AS pne USING(nwid)
412 LEFT JOIN profile_visibility_enum AS pve ON (pve.access_level = {?})
413 WHERE pn.pid IN {?} AND pve.best_display_level + 0 <= pn.pub + 0
414 ORDER BY ' . XDB
::formatCustomOrder('pid', $pids) . ',
416 $visibility->level(), $pids);
418 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
421 public function get($flags, $limit = null
)
425 foreach ($this->networks
as $id => $nw) {
426 if (($flags & Profile
::NETWORKING_WEB
) && $nw['network_type']->hasFlag('web') ||
427 ($flags & Profile
::NETWORKING_IM
) && $nw['network_type']->hasFlag('im') ||
428 ($flags & Profile
::NETWORKING_SOCIAL
) && $nw['network_type']->hasFlag('social') ||
429 ($flags == Profile
::NETWORKING_ALL
)) {
432 if (isset($limit) && $nb >= $limit) {
441 // {{{ class ProfileCorps [ Field ]
442 class ProfileCorps
extends ProfileField
447 public $original_name;
448 public $original_abbrev;
449 public $original_still_exists;
451 public $current_name;
452 public $current_abbrev;
453 public $current_still_exists;
454 public $current_rank;
455 public $current_rank_abbrev;
457 public function __construct(array $data)
459 foreach ($data as $key => $val) {
464 public static function fetchData(array $pids, Visibility
$visibility)
466 $data = XDB
::iterator('SELECT pc.pid, pc.original_corpsid AS original, pc.current_corpsid AS current,
467 pceo.name AS original_name, pceo.abbreviation AS original_abbrev,
468 pceo.still_exists AS original_still_exists,
469 pcec.name AS current_name, pcec.abbreviation AS current_abbrev,
470 pcec.still_exists AS current_still_exists,
471 pcrec.name AS current_rank, pcrec.abbreviation AS current_rank_abbrev,
473 FROM profile_corps AS pc
474 LEFT JOIN profile_corps_enum AS pceo ON (pceo.id = pc.original_corpsid)
475 LEFT JOIN profile_corps_enum AS pcec ON (pcec.id = pc.current_corpsid)
476 LEFT JOIN profile_corps_rank_enum AS pcrec ON (pcrec.id = pc.rankid)
477 LEFT JOIN profile_visibility_enum AS pve ON (pve.access_level = {?})
478 WHERE pc.pid IN {?} AND pve.best_display_level + 0 <= pc.corps_pub + 0 AND pceo.id != 1
479 ORDER BY ' . XDB
::formatCustomOrder('pid', $pids),
480 $visibility->level(), $pids);
486 // {{{ class ProfileMentoringCountries [ Field ]
487 class ProfileMentoringCountries
extends ProfileField
489 public $countries = array();
491 public function __construct(PlInnerSubIterator
$it)
493 $this->pid
= $it->value();
494 while ($country = $it->next()) {
495 $this->countries
[$country['id']] = $country['name'];
499 public static function fetchData(array $pids, Visibility
$visibility)
501 $data = XDB
::iterator('SELECT pmc.pid, pmc.country AS id, gc.country AS name
502 FROM profile_mentor_country AS pmc
503 LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = pmc.country)
505 ORDER BY ' . XDB
::formatCustomOrder('pmc.pid', $pids),
508 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
512 // {{{ class ProfileAddresses [ Field ]
513 class ProfileAddresses
extends ProfileField
515 private $addresses = array();
517 public function __construct(PlInnerSubIterator
$it)
519 $this->pid
= $it->value();
520 while ($address = $it->next()) {
521 $this->addresses
[] = new Address($address);
525 public function get($flags, $limit = null
)
527 $addresses = array();
529 foreach ($this->addresses
as $address) {
530 if ((($flags & Profile
::ADDRESS_MAIN
) && $address->hasFlag('current'))
531 ||
(($flags & Profile
::ADDRESS_POSTAL
) && $address->hasFlag('mail'))
532 ||
(($flags & Profile
::ADDRESS_PERSO
) && $address->type
== Address
::LINK_PROFILE
)
533 ||
(($flags & Profile
::ADDRESS_PRO
) && $address->type
== Address
::LINK_JOB
)
535 $addresses[] = $address;
538 if ($limit != null
&& $nb == $limit) {
545 public static function fetchData(array $pids, Visibility
$visibility)
547 $it = Address
::iterate($pids, array(), array(), $visibility);
548 return PlIteratorUtils
::subIterator($it->value(), PlIteratorUtils
::arrayValueCallback('pid'));
551 public function addPhones(ProfilePhones
$phones)
553 $p = $phones->get(Profile
::PHONE_LINK_ADDRESS | Profile
::PHONE_TYPE_ANY
);
554 foreach ($p as $phone) {
555 /* We must iterate on the addresses because id is not uniq thus,
556 * $this->addresse[$phone->link_id] is invalid.
558 foreach ($this->addresses
as $address) {
559 if ($address->type
== Address
::LINK_PROFILE
&& $address->id
== $phone->link_id
) {
560 $address->addPhone($phone);
567 // {{{ class ProfilePhones [ Field ]
568 class ProfilePhones
extends ProfileField
570 private $phones = array();
572 public function __construct(PlInnerSubIterator
$it)
574 $this->pid
= $it->value();
575 while ($phone = $it->next()) {
576 $this->phones
[] = new Phone($phone);
580 public function get($flags, $limit = null
)
584 foreach ($this->phones
as $id => $phone) {
585 if ($phone->hasFlags($flags)) {
586 $phones[$id] = $phone;
588 if ($limit != null
&& $nb == $limit) {
596 public static function fetchData(array $pids, Visibility
$visibility)
598 $it = Phone
::iterate($pids, array(), array(), $visibility);
599 return PlIteratorUtils
::subIterator($it->value(), PlIteratorUtils
::arrayValueCallback('pid'));
603 // {{{ class ProfileJobs [ Field ]
604 class ProfileJobs
extends ProfileField
606 private $jobs = array();
608 public function __construct(PlInnerSubIterator
$jobs)
610 $this->pid
= $jobs->value();
611 while ($job = $jobs->next()) {
612 $this->jobs
[$job['id']] = new Job($job);
616 public static function fetchData(array $pids, Visibility
$visibility)
618 CompanyList
::preload($pids);
619 $data = XDB
::iterator('SELECT id, pid, description, url as user_site, jobid, pub, IF(pve.best_display_level + 0 <= email_pub + 0, email, NULL) AS user_email, email_pub
621 LEFT JOIN profile_visibility_enum AS pve ON (pve.access_level = {?})
622 WHERE pid IN {?} AND pve.best_display_level + 0 <= pub + 0
623 ORDER BY ' . XDB
::formatCustomOrder('pid', $pids) . ', id',
624 $visibility->level(), $pids);
625 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
628 public function get($flags, $limit = null
)
632 foreach ($this->jobs
as $id => $job) {
635 if ($limit != null
&& $nb >= $limit) {
642 public function addPhones(ProfilePhones
$phones)
644 $p = $phones->get(Profile
::PHONE_LINK_JOB | Profile
::PHONE_TYPE_ANY
);
645 foreach ($p as $phone) {
646 if ($phone->link_type
== Phone
::LINK_JOB
&& array_key_exists($phone->link_id
, $this->jobs
)) {
647 $this->jobs
[$phone->link_id
]->addPhone($phone);
652 public function addAddresses(ProfileAddresses
$addresses)
654 $a = $addresses->get(Profile
::ADDRESS_PRO
);
655 foreach ($a as $address) {
656 if ($address->type
== Address
::LINK_JOB
&& array_key_exists($address->id
, $this->jobs
)) {
657 $this->jobs
[$address->id
]->setAddress($address);
662 public function addCompanies(array $companies)
664 foreach ($this->jobs
as $job) {
665 $this->company
= $companies[$job->jobid
];
669 public function addJobTerms(ProfileJobTerms
$jobterms)
671 $terms = $jobterms->get();
672 foreach ($terms as $term) {
673 if ($this->pid
== $term->pid
&& array_key_exists($term->jid
, $this->jobs
)) {
674 $this->jobs
[$term->jid
]->addTerm($term);
680 // {{{ class ProfileJobTerms [ Field ]
681 class ProfileJobTerms
extends ProfileField
683 private $jobterms = array();
685 public function __construct(PlInnerSubIterator
$it)
687 $this->pid
= $it->value();
688 while ($term = $it->next()) {
689 $this->jobterms
[] = new JobTerm($term);
693 public function get()
695 return $this->jobterms
;
698 public static function fetchData(array $pids, Visibility
$visibility)
700 $data = XDB
::iterator('SELECT jt.jtid, jte.full_name, jt.pid, jt.jid
701 FROM profile_job_term AS jt
702 INNER JOIN profile_job AS j ON (jt.pid = j.pid AND jt.jid = j.id)
703 LEFT JOIN profile_job_term_enum AS jte USING(jtid)
704 LEFT JOIN profile_visibility_enum AS pve ON (pve.access_level = {?})
705 WHERE jt.pid IN {?} AND pve.best_display_level + 0 <= j.pub + 0
706 ORDER BY ' . XDB
::formatCustomOrder('jt.pid', $pids),
707 $visibility->level(), $pids);
708 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
712 // {{{ class ProfileMentoringTerms [ Field ]
713 class ProfileMentoringTerms
extends ProfileJobTerms
715 public static function fetchData(array $pids, Visibility
$visibility)
717 $data = XDB
::iterator('SELECT mt.jtid, jte.full_name, mt.pid
718 FROM profile_mentor_term AS mt
719 LEFT JOIN profile_job_term_enum AS jte USING(jtid)
721 ORDER BY ' . XDB
::formatCustomOrder('mt.pid', $pids),
723 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
727 // {{{ class ProfileSkills [ Field ]
728 class ProfileSkills
extends ProfileField
730 public $skills = array();
732 public function __construct(PlInnerSubIterator
$it)
734 $this->pid
= $it->value();
735 while ($skill = $it->next()) {
736 $this->skills
[$skill['cid']] = $skill;
740 public static function fetchData(array $pids, Visibility
$visibility)
742 $data = XDB
::iterator('SELECT ps.cid, pse.text_fr, ps.level, ps.pid
743 FROM profile_skills AS ps
744 INNER JOIN profile_skill_enum AS pse ON (pse.id = ps.cid)
746 ORDER BY ' . XDB
::formatCustomOrder('ps.pid', $pids),
748 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
752 // {{{ class ProfileLanguages [ Field ]
753 class ProfileLanguages
extends ProfileField
755 public $languages = array();
757 public function __construct(PlInnerSubIterator
$it)
759 static $levels = array(
760 1 => 'connaissance basique',
761 2 => 'maîtrise des bases',
762 3 => 'maîtrise limitée',
763 4 => 'maîtrise générale',
764 5 => 'bonne maîtrise',
765 6 => 'maîtrise complète'
768 $this->pid
= $it->value();
769 while ($language = $it->next()) {
770 $this->languages
[$language['lid']] = $language;
771 $this->languages
[$language['lid']]['level'] = $levels[$language['level']];
775 public static function fetchData(array $pids, Visibility
$visibility)
777 $data = XDB
::iterator('SELECT ps.lid, pse.language, ps.level, ps.pid
778 FROM profile_langskills AS ps
779 INNER JOIN profile_langskill_enum AS pse ON (pse.iso_639_2b = ps.lid)
781 ORDER BY ' . XDB
::formatCustomOrder('ps.pid', $pids),
783 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
787 // {{{ class ProfilePartnerSharing [ Field ]
788 class ProfilePartnerSharing
extends ProfileField
790 public function __construct(PlInnerSubIterator
$it)
792 require_once 'partnersharing.inc.php';
794 $this->pid
= $it->value();
795 while ($partner_settings = $it->next()) {
796 $settings = new PartnerSettings($partner_settings);
797 $this->partners_settings
[$settings->partner
->id
] = $settings;
801 public static function fetchData(array $pids, Visibility
$visibility)
803 $data = XDB
::iterator('SELECT ppss.pid, ppss.exposed_uid, ppss.sharing_level,
804 ppss.allow_email, ppss.partner_id,
805 ppse.shortname AS partner_shortname,
806 ppse.name AS partner_name,
807 ppse.url AS partner_url
808 FROM profile_partnersharing_settings AS ppss
809 LEFT JOIN profile_partnersharing_enum AS ppse ON (ppss.partner_id = ppse.id)
810 WHERE ppss.pid IN {?}
811 ORDER BY ' . XDB
::formatCustomOrder('ppss.pid', $pids),
813 return PlIteratorUtils
::subIterator($data, PlIteratorUtils
::arrayValueCallback('pid'));
816 public function get($partner_id)
818 if (isset($this->partners_settings
[$partner_id])) {
819 return $this->partners_settings
[$partner_id];
821 return PartnerSettings
::getEmpty($partner_id);
826 // {{{ class CompanyList
829 static private $fullload = false
;
830 static private $companies = array();
832 static public function preload($pids = array())
834 if (self
::$fullload) {
839 $join = 'LEFT JOIN profile_job ON (profile_job.jobid = pje.id)';
840 $where = 'WHERE profile_job.pid IN ' . XDB
::formatArray($pids);
846 $it = XDB
::iterator('SELECT pje.id, pje.name, pje.acronym, pje.url,
847 pa.flags, pa.text, pa.type, pa.pub
848 FROM profile_job_enum AS pje
849 LEFT JOIN profile_addresses AS pa ON (pje.id = pa.jobid AND pa.type = \'hq\')
852 $newcompanies = array();
853 while ($row = $it->next()) {
854 $cp = new Company($row);
855 $addr = new Address($row);
856 $cp->setAddress($addr);
857 if (!array_key_exists($row['id'], self
::$companies)) {
858 $newcompanies[] = $row['id'];
860 self
::$companies[$row['id']] = $cp;
864 if (count($newcompanies)) {
865 $it = Phone
::iterate(array(), array(Phone
::LINK_COMPANY
), $newcompanies, Visibility
::defaultForRead());
866 while ($phone = $it->next()) {
867 self
::$companies[$phone->link_id
]->setPhone($phone);
871 if (count($pids) == 0) {
872 self
::$fullload = true
;
876 static public function get($id)
878 if (!is_null($id) && !array_key_exists($id, self
::$companies)) {
881 if (isset(self
::$companies[$id])) {
882 return self
::$companies[$id];
889 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: