a0644023ffe382e7919c1b40f1a3565e57476766
2 /***************************************************************************
3 * Copyright (C) 2003-2010 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 ***************************************************************************/
24 static private $v_values = array('public' => array('public'),
25 'ax' => array('ax', 'public'),
26 'private' => array('private', 'ax', 'public'));
28 const VISIBILITY_PUBLIC
= 'public';
29 const VISIBILITY_AX
= 'ax';
30 const VISIBILITY_PRIVATE
= 'private';
33 const LASTNAME
= 'lastname';
34 const FIRSTNAME
= 'firstname';
35 const NICKNAME
= 'nickname';
36 const PSEUDONYM
= 'pseudonym';
39 const VN_MARITAL
= 'marital';
40 const VN_ORDINARY
= 'ordinary';
41 const VN_OTHER
= 'other';
44 const DN_FULL
= 'directory_name';
45 const DN_DISPLAY
= 'yourself';
46 const DN_YOURSELF
= 'yourself';
47 const DN_DIRECTORY
= 'directory_name';
48 const DN_PRIVATE
= 'private_name';
49 const DN_PUBLIC
= 'public_name';
50 const DN_SHORT
= 'short_name';
51 const DN_SORT
= 'sort_name';
52 /* education related names */
53 const EDU_X
= 'École polytechnique';
54 const DEGREE_X
= 'Ingénieur';
55 const DEGREE_M
= 'Master';
56 const DEGREE_D
= 'Doctorat';
58 static public $name_variants = array(
59 self
::LASTNAME
=> array(self
::VN_MARITAL
, self
::VN_ORDINARY
),
60 self
::FIRSTNAME
=> array(self
::VN_ORDINARY
, self
::VN_INI
, self
::VN_OTHER
)
63 const ADDRESS_MAIN
= 0x000001;
64 const ADDRESS_PERSO
= 0x000002;
65 const ADDRESS_PRO
= 0x000004;
66 const ADDRESS_ALL
= 0x000006;
67 const ADDRESS_POSTAL
= 0x000008;
69 const EDUCATION_MAIN
= 0x000010;
70 const EDUCATION_EXTRA
= 0x000020;
71 const EDUCATION_ALL
= 0x000040;
72 const EDUCATION_FINISHED
= 0x000080;
73 const EDUCATION_CURRENT
= 0x000100;
75 const JOBS_MAIN
= 0x001000;
76 const JOBS_ALL
= 0x002000;
77 const JOBS_FINISHED
= 0x004000;
78 const JOBS_CURRENT
= 0x008000;
80 const NETWORKING_ALL
= 0x000000;
81 const NETWORKING_WEB
= 0x010000;
82 const NETWORKING_IM
= 0x020000;
83 const NETWORKING_SOCIAL
= 0x040000;
85 const FETCH_ADDRESSES
= 0x00001;
86 const FETCH_CORPS
= 0x00002;
87 const FETCH_EDU
= 0x00004;
88 const FETCH_JOBS
= 0x00008;
89 const FETCH_MEDALS
= 0x00010;
90 const FETCH_NETWORKING
= 0x00020;
91 const FETCH_PHONES
= 0x00040;
92 const FETCH_PHOTO
= 0x00080;
94 const FETCH_ALL
= 0x000FF;
98 private $data = array();
100 private $visibility = null
;
102 private function __construct(array $data)
105 $this->pid
= $this->data
['pid'];
106 $this->hrpid
= $this->data
['hrpid'];
108 $this->setVisibilityLevel(self
::VISIBILITY_PUBLIC
);
112 static private $contexts = array();
114 /** Returns the best visibility context toward $visibility
115 * @param $visibility A wished visibility level
116 * @return An array of compatible visibilities
118 * if $visibility is null, the best visibility is returned
120 static public function getVisibilityContext($visibility = null
)
122 if (array_key_exists($visibility, self
::$contexts)) {
123 return self
::$contexts[$visibility];
126 $asked_vis = $visibility;
129 $minvis = self
::VISIBILITY_PRIVATE
;
131 $minvis = self
::VISIBILITY_PUBLIC
;
133 if ($visibility == null
) {
134 $visibility = $minvis;
137 if ($minvis == self
::VISIBILITY_PUBLIC
) {
138 $visibility = self
::VISIBILITY_PUBLIC
;
141 $visibility = self
::$v_values[$visibility];
142 self
::$contexts[$asked_vis] = $visibility;
152 public function hrid()
157 public function promo()
162 public function yearpromo()
164 return intval(substr($this->promo
, 1, 4));
167 /** Print a name with the given formatting:
175 public function name($format)
177 return str_replace(array('%s', '%f', '%l', '%F', '%S', '%p'),
178 array($this->isFemale() ?
'•' : '',
179 $this->firstName(), $this->lastName(),
180 $this->fullName(), $this->shortName(),
181 $this->promo()), $format);
184 public function fullName($with_promo = false
)
187 return $this->full_name
. ' (' . $this->promo
. ')';
189 return $this->full_name
;
192 public function shortName($with_promo = false
)
195 return $this->short_name
. ' (' . $this->promo
. ')';
197 return $this->short_name
;
200 public function firstName()
202 return $this->firstname
;
205 public function firstNames()
207 return $this->nameVariants(self
::FIRSTNAME
);
210 public function lastName()
212 return $this->lastname
;
215 public function lastNames()
217 return $this->nameVariants(self
::LASTNAME
);
220 public function isFemale()
222 return $this->sex
== PlUser
::GENDER_FEMALE
;
225 public function data()
231 private function nameVariants($type)
233 $vals = array($this->$type);
234 foreach (self
::$name_variants[$type] as $var) {
235 $vartype = $type . '_' . $var;
236 $varname = $this->$vartype;
237 if ($varname != null
&& $varname != "") {
241 return array_unique($vals);
244 public function nationalities()
247 if ($this->nationality1
) {
248 $nats[] = $this->nationality1
;
250 if ($this->nationality2
) {
251 $nats[] = $this->nationality2
;
253 if ($this->nationality3
) {
254 $nats[] = $this->nationality3
;
259 public function __get($name)
261 if (property_exists($this, $name)) {
265 if (isset($this->data
[$name])) {
266 return $this->data
[$name];
272 public function __isset($name)
274 return property_exists($this, $name) ||
isset($this->data
[$name]);
277 /** Sets the level of visibility of the profile
278 * Sets $this->visibility to a list of valid visibilities.
279 * @param one of the self::VISIBILITY_* values
281 public function setVisibilityLevel($visibility)
283 if ($visibility != self
::VISIBILITY_PRIVATE
284 && $visibility != self
::VISIBILITY_AX
285 && $visibility != self
::VISIBILITY_PUBLIC
) {
286 Platal
::page()->kill("Visibility invalide: " . $visibility);
288 $this->visibility
= self
::$v_values[$visibility];
289 if ($this->mobile
&& !in_array($this->mobile_pub
, $this->visibility
)) {
290 unset($this->data
['mobile']);
294 /** Determine whether an item with visibility $visibility can be displayed
295 * with the current level of visibility of the profile
296 * @param $visibility The level of visibility to be checked
298 public function isVisible($visibility)
300 return in_array($visibility, $this->visibility
);
303 public static function getCompatibleVisibilities($visibility)
305 return self
::$v_values[$visibility];
308 private function getProfileField($cls)
310 return ProfileField
::getForPID($cls, $this->id(), $this->visibility
);
315 private $photo = null
;
316 public function setPhoto(ProfilePhoto
$photo)
318 $this->photo
= $photo;
321 public function getPhoto($fallback = true
)
323 if ($this->photo
== null
) {
324 $this->setPhoto($this->getProfileField('ProfilePhoto'));
327 if ($this->photo
!= null
) {
328 return $this->photo
->pic
;
329 } else if ($fallback) {
330 return PlImage
::fromFile(dirname(__FILE__
).'/../htdocs/images/none.png',
338 private $addresses = null
;
339 public function setAddresses(ProfileAddresses
$addr)
341 $this->addresses
= $addr;
344 public function getAddresses($flags, $limit = null
)
346 if ($this->addresses
== null
) {
347 $this->setAddresses($this->getProfileField('ProfileAddresses'));
349 return $this->addresses
->get($flags, $limit);
352 public function getMainAddress()
354 $it = $this->getAddresses(self
::ADDRESS_PERSO | self
::ADDRESS_MAIN
);
355 if ($it->total() == 0) {
365 private $educations = null
;
366 public function setEducations(ProfileEducation
$edu)
368 $this->educations
= $edu;
371 public function getEducations($flags, $limit = null
)
373 if ($this->educations
== null
) {
374 $this->setEducations($this->getProfileField('ProfileEducation'));
376 return $this->educations
->get($flags, $limit);
379 public function getExtraEducations($limit = null
)
381 return $this->getEducations(self
::EDUCATION_EXTRA
, $limit);
387 private $networks = null
;
388 public function setNetworking(ProfileNetworking
$nw)
390 $this->networks
= $nw;
393 public function getNetworking($flags, $limit = null
)
395 if ($this->networks
== null
) {
396 $this->setNetworking($this->getProfileField('ProfileNetworking'));
398 return $this->networks
->get($flags, $limit);
401 public function getWebSite()
403 $site = $this->getNetworking(self
::NETWORKING_WEB
, 1);
404 if ($site->total() != 1) {
407 $site = $site->next();
408 return $site['address'];
415 public function getJobs($flags, $limit = null
)
417 $where = XDB
::format('pj.pid = {?}', $this->id());
419 if ($this->visibility
) {
420 $where .= ' AND pj.pub IN ' . XDB
::formatArray($this->visibility
);
421 $cond = 'pj.email_pub IN ' . XDB
::formatArray($this->visibility
);
423 $limit = is_null($limit) ?
'' : XDB
::format('LIMIT {?}', (int)$limit);
424 return XDB
::iterator('SELECT pje.name, pje.acronym, pje.url, pje.email, pje.NAF_code,
425 pj.description, pj.url AS user_site,
426 IF (' . $cond . ', pj.email, NULL) AS user_email,
427 pjse.name AS sector, pjsse.name AS subsector,
428 pjssse.name AS subsubsector
429 FROM profile_job AS pj
430 INNER JOIN profile_job_enum AS pje ON (pje.id = pj.jobid)
431 LEFT JOIN profile_job_sector_enum AS pjse ON (pjse.id = pj.sectorid)
432 LEFT JOIN profile_job_subsector_enum AS pjsse ON (pjsse.id = pj.subsectorid)
433 LEFT JOIN profile_job_subsubsector_enum AS pjssse ON (pjssse.id = pj.subsubsectorid)
439 public function getMailJob()
441 $job = $this->getJobs(self
::JOBS_MAIN
, 1);
442 if ($job->total() != 1) {
450 public function getBinets()
452 return XDB
::fetchColumn('SELECT binet_id
454 WHERE pid = {?}', $this->id());
458 public function owner()
460 return User
::getSilent($this);
463 public function compareNames($firstname, $lastname)
465 $_lastname = mb_strtoupper($this->lastName());
466 $_firstname = mb_strtoupper($this->firstName());
467 $lastname = mb_strtoupper($lastname);
468 $firstname = mb_strtoupper($firstname);
470 $isOk = (mb_strtoupper($_firstname) == mb_strtoupper($firstname));
471 $tokens = preg_split("/[ \-']/", $lastname, -1, PREG_SPLIT_NO_EMPTY
);
474 foreach ($tokens as $str) {
475 $isOk &= (strpos($_lastname, $str) !== false
);
476 $maxlen = max($maxlen, strlen($str));
479 return ($isOk && ($maxlen > 2 ||
$maxlen == strlen($_lastname)));
482 private static function fetchProfileData(array $pids, $respect_order = true
, $fields = 0x0000, $visibility = null
)
484 if (count($pids) == 0) {
488 if ($respect_order) {
489 $order = 'ORDER BY ' . XDB
::formatCustomOrder('p.pid', $pids);
495 $it = XDB
::Iterator('SELECT p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year,
496 pn_f.name AS firstname, pn_l.name AS lastname, pn_n.name AS nickname,
497 IF(pn_uf.name IS NULL, pn_f.name, pn_uf.name) AS firstname_ordinary,
498 IF(pn_ul.name IS NULL, pn_l.name, pn_ul.name) AS lastname_ordinary,
499 pd.promo AS promo, pd.short_name, pd.directory_name AS full_name,
500 pd.directory_name, pp.display_tel AS mobile, pp.pub AS mobile_pub,
501 ph.attach IS NOT NULL AS has_photo, ph.pub AS photo_pub,
502 p.last_change < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_old,
505 INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
506 INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
507 INNER JOIN profile_name AS pn_f ON (pn_f.pid = p.pid
508 AND pn_f.typeid = ' . self
::getNameTypeId('firstname', true
) . ')
509 INNER JOIN profile_name AS pn_l ON (pn_l.pid = p.pid
510 AND pn_l.typeid = ' . self
::getNameTypeId('lastname', true
) . ')
511 LEFT JOIN profile_name AS pn_uf ON (pn_uf.pid = p.pid
512 AND pn_uf.typeid = ' . self
::getNameTypeId('firstname_ordinary', true
) . ')
513 LEFT JOIN profile_name AS pn_ul ON (pn_ul.pid = p.pid
514 AND pn_ul.typeid = ' . self
::getNameTypeId('lastname_ordinary', true
) . ')
515 LEFT JOIN profile_name AS pn_n ON (pn_n.pid = p.pid
516 AND pn_n.typeid = ' . self
::getNameTypeId('nickname', true
) . ')
517 LEFT JOIN profile_phones AS pp ON (pp.pid = p.pid AND pp.link_type = \'user\' AND tel_type = \'mobile\')
518 LEFT JOIN profile_photos AS ph ON (ph.pid = p.pid)
519 LEFT JOIN account_profiles AS ap ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', ap.perms))
520 WHERE p.pid IN ' . XDB
::formatArray($pids) . '
523 return new ProfileIterator($it, $pids, $fields, $visibility);
526 public static function getPID($login)
528 if ($login instanceof PlUser
) {
529 return XDB
::fetchOneCell('SELECT pid
530 FROM account_profiles
531 WHERE uid = {?} AND FIND_IN_SET(\'owner\', perms)',
533 } else if (ctype_digit($login)) {
534 return XDB
::fetchOneCell('SELECT pid
536 WHERE pid = {?}', $login);
538 return XDB
::fetchOneCell('SELECT pid
540 WHERE hrpid = {?}', $login);
544 public static function getPIDsFromUIDs($uids, $respect_order = true
)
546 if ($respect_order) {
547 $order = 'ORDER BY ' . XDB
::formatCustomOrder('uid', $uids);
551 return XDB
::fetchAllAssoc('uid', 'SELECT ap.uid, ap.pid
552 FROM account_profiles AS ap
553 WHERE FIND_IN_SET(\'owner\', ap.perms)
554 AND ap.uid IN ' . XDB
::formatArray($uids) .'
558 /** Return the profile associated with the given login.
560 public static function get($login, $fields = 0x0000, $visibility = null
)
562 if (is_array($login)) {
563 return new Profile($login);
565 $pid = self
::getPID($login);
566 if (!is_null($pid)) {
567 $it = self
::iterOverPIDs(array($pid), false
, $fields, $visibility);
570 /* Let say we can identify a profile using the identifiers of its owner.
572 if (!($login instanceof PlUser
)) {
573 $user = User
::getSilent($login);
574 if ($user && $user->hasProfile()) {
575 return $user->profile();
582 public static function iterOverUIDs($uids, $respect_order = true
, $fields = 0x0000, $visibility = null
)
584 return self
::iterOverPIDs(self
::getPIDsFromUIDs($uids), $respect_order, $fields, $visibility);
587 public static function iterOverPIDs($pids, $respect_order = true
, $fields = 0x0000, $visibility = null
)
589 return self
::fetchProfileData($pids, $respect_order, $fields, $visibility);
592 /** Return profiles for the list of pids.
594 public static function getBulkProfilesWithPIDs(array $pids, $fields = self
::FETCH_ADDRESSES
, $visibility = null
)
596 if (count($pids) == 0) {
599 $it = self
::iterOverPIDs($pids, true
, $fields, $visibility);
601 while ($p = $it->next()) {
602 $profiles[$p->id()] = $p;
607 /** Return profiles for uids.
609 public static function getBulkProfilesWithUIDS(array $uids, $fields = 0x000, $visibility = null
)
611 if (count($uids) == 0) {
614 return self
::getBulkProfilesWithPIDs(self
::getPIDsFromUIDs($uids), $fields, $visibility);
617 public static function isDisplayName($name)
619 return $name == self
::DN_FULL ||
$name == self
::DN_DISPLAY
620 ||
$name == self
::DN_YOURSELF ||
$name == self
::DN_DIRECTORY
621 ||
$name == self
::DN_PRIVATE ||
$name == self
::DN_PUBLIC
622 ||
$name == self
::DN_SHORT ||
$name == self
::DN_SORT
;
625 public static function getNameTypeId($type, $for_sql = false
)
627 if (!S
::has('name_types')) {
628 $table = XDB
::fetchAllAssoc('type', 'SELECT id, type
629 FROM profile_name_enum');
630 S
::set('name_types', $table);
632 $table = S
::v('name_types');
635 return XDB
::escape($table[$type]);
637 return $table[$type];
641 public static function rebuildSearchTokens($pid)
643 XDB
::execute('DELETE FROM search_name
646 $keys = XDB
::iterator("SELECT CONCAT(n.particle, n.name) AS name, e.score,
647 FIND_IN_SET('public', e.flags) AS public
648 FROM profile_name AS n
649 INNER JOIN profile_name_enum AS e ON (n.typeid = e.id)
653 foreach ($keys as $i => $key) {
654 if ($key['name'] == '') {
657 $toks = preg_split('/[ \'\-]+/', $key['name']);
661 $token = strtolower(replace_accent(array_pop($toks) . $token));
662 $score = ($toks ?
0 : 10 +
$first) * ($key['score'] / 10);
663 XDB
::execute('REPLACE INTO search_name (token, pid, soundex, score, flags)
664 VALUES ({?}, {?}, {?}, {?}, {?})',
665 $token, $pid, soundex_fr($token), $score, $key['public']);
671 /** The school identifier consists of 6 digits. The first 3 represent the
672 * promotion entry year. The last 3 indicate the student's rank.
674 * Our identifier consists of 8 digits and both half have the same role.
675 * This enables us to deal with bigger promotions and with a wider range
678 * getSchoolId returns a school identifier given one of ours.
679 * getXorgId returns a X.org identifier given a school identifier.
681 public static function getSchoolId($xorgId)
683 if (!preg_match('/^[0-9]{8}$/', $xorgId)) {
687 $year = intval(substr($xorgId, 0, 4));
688 $rank = intval(substr($xorgId, 5, 3));
691 } elseif ($year < 2000) {
692 $year = intval(substr(1900 - $year, 1, 3));
693 return sprintf('%02u0%03u', $year, $rank);
695 $year = intval(substr(1900 - $year, 1, 3));
696 return sprintf('%03u%03u', $year, $rank);
700 public static function getXorgId($schoolId)
702 if (!preg_match('/^[0-9]{6}$/', $schoolId)) {
706 $year = intval(substr($schoolId, 0, 3));
707 $rank = intval(substr($schoolId, 3, 3));
715 return sprintf('%04u%04u', 1900 +
$year, $rank);
721 /** Iterator over a set of Profiles
723 class ProfileIterator
implements PlIterator
725 private $iterator = null
;
728 public function __construct(PlIterator
$it, array $pids, $fields = 0x0000, $visibility = null
)
730 require_once 'profilefields.inc.php';
731 $visibility = Profile
::getVisibilityContext($visibility);
732 $this->fields
= $fields;
735 $callbacks = array();
738 $callbacks[0] = PlIteratorUtils
::arrayValueCallback('pid');
739 $cb = PlIteratorUtils
::objectPropertyCallback('pid');
741 if ($fields & Profile
::FETCH_ADDRESSES
) {
742 $callbacks[Profile
::FETCH_ADDRESSES
] = $cb;
743 $subits[Profile
::FETCH_ADDRESSES
] = new ProfileFieldIterator('ProfileAddresses', $pids, $visibility);
746 if ($fields & Profile
::FETCH_CORPS
) {
747 $callbacks[Profile
::FETCH_CORPS
] = $cb;
748 $subits[Profile
::FETCH_CORPS
] = new ProfileFieldIterator('ProfileCorps', $pids, $visibility);
751 if ($fields & Profile
::FETCH_EDU
) {
752 $callbacks[Profile
::FETCH_EDU
] = $cb;
753 $subits[Profile
::FETCH_EDU
] = new ProfileFieldIterator('ProfileEducation', $pids, $visibility);
756 if ($fields & Profile
::FETCH_JOBS
) {
757 $callbacks[Profile
::FETCH_JOBS
] = $cb;
758 $subits[Profile
::FETCH_JOBS
] = new ProfileFieldIterator('ProfileJobs', $pids, $visibility);
761 if ($fields & Profile
::FETCH_MEDALS
) {
762 $callbacks[Profile
::FETCH_MEDALS
] = $cb;
763 $subits[Profile
::FETCH_MEDALS
] = new ProfileFieldIterator('ProfileMedals', $pids, $visibility);
766 if ($fields & Profile
::FETCH_NETWORKING
) {
767 $callbacks[Profile
::FETCH_NETWORKING
] = $cb;
768 $subits[Profile
::FETCH_NETWORKING
] = new ProfileFieldIterator('ProfileNetworking', $pids, $visibility);
771 if ($fields & Profile
::FETCH_PHONES
) {
772 $callbacks[Profile
::FETCH_PHONES
] = $cb;
773 $subits[Profile
::FETCH_PHONES
] = new ProfileFieldIterator('ProfilePhones', $pids, $visibility);
776 if ($fields & Profile
::FETCH_PHOTO
) {
777 $callbacks[Profile
::FETCH_PHOTO
] = $cb;
778 $subits[Profile
::FETCH_PHOTO
] = new ProfileFieldIterator('ProfilePhoto', $pids, $visibility);
781 $this->iterator
= PlIteratorUtils
::parallelIterator($subits, $callbacks, 0);
784 private function consolidateFields(array $pf)
786 if ($this->fields
& Profile
::FETCH_PHONES
) {
787 $phones = $pf[Profile
::FETCH_PHONES
];
789 if ($this->fields
& Profile
::FETCH_ADDRESSES
&& $pf[Profile
::FETCH_ADDRESSES
] != null
) {
790 $pf[Profile
::FETCH_ADDRESSES
]->addPhones($phones);
792 if ($this->fields
& Profile
::FETCH_JOBS
&& $pf[Profile
::FETCH_JOBS
] != null
) {
793 $pf[Profile
::FETCH_JOBS
]->addPhones($phones);
797 if ($this->fields
& Profile
::FETCH_ADDRESSES
) {
798 $addrs = $pf[Profile
::FETCH_ADDRESSES
];
799 if ($this->fields
& Profile
::FETCH_JOBS
&& $pf[Profile
::FETCH_JOBS
] != null
) {
800 $pf[Profile
::FETCH_JOBS
]->addAddresses($addrs);
807 private function fillProfile(array $vals)
809 $vals = $this->consolidateFields($vals);
811 $pf = Profile
::get($vals[0]);
812 if ($this->fields
& Profile
::FETCH_ADDRESSES
) {
813 if ($vals[Profile
::FETCH_ADDRESSES
] != null
) {
814 $pf->setAddresses($vals[Profile
::FETCH_ADDRESSES
]);
817 if ($this->fields
& Profile
::FETCH_CORPS
) {
818 $pf->setCorps($vals[Profile
::FETCH_CORPS
]);
820 if ($this->fields
& Profile
::FETCH_EDU
) {
821 $pf->setEdu($vals[Profile
::FETCH_EDU
]);
823 if ($this->fields
& Profile
::FETCH_JOBS
) {
824 $pf->setJobs($vals[Profile
::FETCH_JOBS
]);
826 if ($this->fields
& Profile
::FETCH_MEDALS
) {
827 $pf->setMedals($vals[Profile
::FETCH_MEDALS
]);
829 if ($this->fields
& Profile
::FETCH_NETWORKING
) {
830 $pf->setNetworking($vals[Profile
::FETCH_NETWORKING
]);
832 if ($this->fields
& Profile
::FETCH_PHONES
) {
833 $pf->setPhones($vals[Profile
::FETCH_PHONES
]);
835 if ($this->fields
& Profile
::FETCH_PHOTO
) {
836 if ($vals[Profile
::FETCH_PHOTO
] != null
) {
837 $pf->setPhoto($vals[Profile
::FETCH_PHOTO
]);
844 public function next()
846 $vals = $this->iterator
->next();
850 return $this->fillProfile($vals);
853 public function first()
855 return $this->iterator
->first();
858 public function last()
860 return $this->iterator
->last();
863 public function total()
865 return $this->iterator
->total();
869 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: