From: Stéphane Jacob Date: Tue, 1 Mar 2011 09:57:53 +0000 (+0100) Subject: Adds jobs to vcards (Closes #1324, #1352). X-Git-Tag: xorg/1.1.0~94 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=801adeec34eada13769fd991c99026c824bbdef3;p=platal.git Adds jobs to vcards (Closes #1324, #1352). Signed-off-by: Stéphane Jacob --- diff --git a/ChangeLog b/ChangeLog index f48b63c..16f815d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ Bug/Wish: * Profile: - #1270: Adapts default picture to main education -JAC + - #1324,1352: Adds jobs to vcards -JAC - #1340: Allows secretaries and admin to fully edit profiles' name -JAC - #1354: Do not notify death to a deceased user -JAC - #1356: Indicates delivery issues on addresses -JAC diff --git a/include/vcard.inc.php b/include/vcard.inc.php index 22ab927..ddaa420 100644 --- a/include/vcard.inc.php +++ b/include/vcard.inc.php @@ -35,7 +35,7 @@ class VCard extends PlVCard public function addProfile($profile) { - $profile = Profile::get($profile); + $profile = Profile::get($profile, Profile::FETCH_ALL); if ($profile) { $this->profile_list[] = $profile; $this->count++; @@ -105,23 +105,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, - trim(Geocoder::getFirstLines($adr->text, $adr->postalCode, 4)), 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); } } } diff --git a/modules/carnet.php b/modules/carnet.php index 4f80b49..06b3a2e 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -419,7 +419,7 @@ class CarnetModule extends PLModule { $pf = new ProfileFilter(new UFC_Contact(S::user())); $vcard = new VCard($photos == 'photos'); - $vcard->addProfiles($pf->getProfiles()); + $vcard->addProfiles($pf->getProfiles(null, Profile::FETCH_ALL)); $vcard->show(); } diff --git a/modules/profile.php b/modules/profile.php index d76b821..e93a86f 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -667,7 +667,7 @@ class ProfileModule extends PLModule } $vcard = new VCard(); - $vcard->addProfile(Profile::get($x)); + $vcard->addProfile(Profile::get($x, Profile::FETCH_ALL)); $vcard->show(); } diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index b38b9e4..05319f0 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -384,7 +384,7 @@ class XnetGrpModule extends PLModule { global $globals; $vcard = new VCard($photos == 'photos', 'Membre du groupe ' . $globals->asso('nom')); - $vcard->addProfiles($globals->asso()->getMembersFilter()->getProfiles()); + $vcard->addProfiles($globals->asso()->getMembersFilter()->getProfiles(null, Profile::FETCH_ALL)); $vcard->show(); }