X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvcard.inc.php;h=2fb2e58a48198df2b39ec07b0f422c2d673fea9c;hb=2981f248b2db1adfdfbf4c294625bc382efe53fe;hp=6e29640483d97a84a1604b490a94b59739e556b8;hpb=0b53817f618e590864806947320868e11a355497;p=platal.git diff --git a/include/vcard.inc.php b/include/vcard.inc.php index 6e29640..2fb2e58 100644 --- a/include/vcard.inc.php +++ b/include/vcard.inc.php @@ -1,6 +1,6 @@ visibility = Visibility::defaultForRead(Visibility::VIEW_PRIVATE); $this->freetext = $freetext; $this->photos = $photos; } public function addProfile($profile) { - $profile = Profile::get($profile); + $profile = Profile::get($profile, Profile::FETCH_ALL, $this->visibility); if ($profile) { $this->profile_list[] = $profile; $this->count++; @@ -75,9 +77,10 @@ class VCard extends PlVCard // Emails if (!is_null($user)) { $entry->addMail(null, $user->bestalias, true); - $entry->addMail(null, $user->bestalias_alternate); if ($user->forlife != $user->bestalias) { $entry->addMail(null, $user->forlife); + } + if ($user->forlife_alternate != $user->bestalias) { $entry->addMail(null, $user->forlife_alternate); } } @@ -90,8 +93,7 @@ class VCard extends PlVCard null, $adr->administrativeArea, null, $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail')); } else { - // TODO : find a way to fetch only the "street" part of the address - $group = $entry->addHome($adr->text, null, null, $adr->postalCode, + $group = $entry->addHome(trim(Geocoder::getFirstLines($adr->text, $adr->postalCode, 4)), null, null, $adr->postalCode, $adr->locality, $adr->administrativeArea, $adr->country, $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail')); } @@ -106,23 +108,39 @@ class VCard extends PlVCard } // Pro - $adrs = $pf->iterAddresses(Profile::ADDRESS_PRO); - while ($adr = $adrs->next()) { - if (!$adr->postalCode || !$adr->locality || !$adr->country) { - $group = $entry->addWork(null, null, null, null, - $adr->text, null, null, null, - null, $adr->administrativeArea, null); + $jobs = $pf->getJobs(); + foreach ($jobs as $job) { + $terms_array = array(); + foreach ($job->terms as $term) { + $terms_array[] = $term->full_name; + } + $terms = implode(', ', $terms_array); + if ($job->address) { + if (!$job->address->postalCode || !$job->address->locality || !$job->address->country) { + $group = $entry->addWork($job->company->name, null, $job->description, $terms, + $job->address->text, null, null, null, + null, $job->address->administrativeArea, null); + } else { + $group = $entry->addWork($job->company->name, null, $job->description, $terms, + trim(Geocoder::getFirstLines($job->address->text, $job->address->postalCode, 4)), + null, null, $job->address->postalCode, + $job->address->locality, $job->address->administrativeArea, $job->address->country); + } } else { - // TODO : link address to company - $group = $entry->addWork(null, null, null, null, - $adr->text, null, null, $adr->postalCode, - $adr->locality, $adr->administrativeArea, $adr->country); + $group = $entry->addWork($job->company->name, null, $job->description, $terms, + null, null, null, null, + null, null, null); } - foreach ($adr->phones() as $phone) { - if ($phone->link_type == Phone::TYPE_FIXED) { - $entry->addTel($group, $phone->display); - } else if ($phone->link_type == Phone::TYPE_FAX) { + if ($job->user_email) { + $entry->addMail($group, $job->user_email); + } + foreach ($job->phones as $phone) { + if ($phone->type == Phone::TYPE_MOBILE) { + $entry->addTel($group, $phone->display, false, true, true, false, true); + } else if ($phone->type == Phone::TYPE_FAX) { $entry->addTel($group, $phone->display, true); + } else { + $entry->addTel($group, $phone->display, false, true, true); } } } @@ -130,7 +148,7 @@ class VCard extends PlVCard // Melix if (!is_null($user)) { $alias = $user->emailAlias(); - if (!is_null($alias) && $pf->alias_pub == 'pub') { + if (!is_null($alias) && $pf->alias_pub == 'public') { $entry->addMail(null, $alias); } } @@ -166,8 +184,9 @@ class VCard extends PlVCard if ($this->photos) { $res = XDB::query( "SELECT attach, attachmime - FROM profile_photos AS p - WHERE p.pid = {?}", $pf->id()); + FROM profile_photos + WHERE pid = {?} AND pub IN ('public', {?})", + $pf->id(), $this->visibility->level()); if ($res->numRows()) { list($data, $type) = $res->fetchOneRow(); $entry->setPhoto($data, strtoupper($type)); @@ -177,5 +196,5 @@ class VCard extends PlVCard } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>