function getBiographicalFeature(User $user, $feature) { switch ($feature) { case "name": $feat_str = $user->getName("%f %l"); break; case "group": $feat_str = $user->getGroup(); break; case "role": $feat_str = $user->getRole(); break; case "photo": $official_photo = UserPhoto::get($user->getID(), UserPhoto::OFFICIAL); $feat_str = $official_photo->getFilename(); break; case "organisation": $organisation = $user->getOrganisation(); $feat_str = $organisation->getTitle(); break; case "email": $feat_str = $user->getEmail(); break; case "email_alt": $feat_str = $user->getEmailAlternate(); break; case "address": $address = $user->getAddress(); $postcode = $user->getPostalCode(); $city = $user->getCity(); $province = $user->getProvince(); $prov_name = $province->getName(); $country = $user->getCountry(); $country_name = $country->getName(); $feat_str = html_encode($address) . "<br />" . html_encode($city); if ($prov_name) { $feat_str .= ", " . html_encode($prov_name); } $feat_str .= "<br />"; $feat_str .= html_encode($country_name); if ($postcode) { $feat_str .= ", " . html_encode($postcode); } break; case "phone": $feat_str = $user->getTelephone(); break; case "fax": $feat_str = $user->getFax(); break; default: Zend_Debug::dump($feature); return; } return $feat_str; }
/** * This displays a person's name, picture etc. including basic biographical information and assistant info if relevant * @param User $user */ function display_person(User $user) { global $ENTRADA_ACL; $photos = $user->getPhotos(); $user_id = $user->getID(); $is_administrator = $ENTRADA_ACL->amIallowed('user', 'update'); $prefix = $user->getPrefix(); $firstname = $user->getFirstname(); $lastname = $user->getLastname(); $fullname = $user->getName("%f %l"); $departments = $user->getDepartments(); if (0 < count($departments)) { $dep_titles = array(); foreach ($departments as $department) { $dep_titles[] = ucwords($department->getTitle()); } $group_line = implode("<br />", $dep_titles); } else { $group = $user->getGroup(); $role = $user->getRole(); $group_line = ucwords($group . " > " . ($group == "student" ? "Class of " : "") . $role); } $privacy_level = $user->getPrivacyLevel(); $organisation = $user->getOrganisation(); $org_name = $organisation ? $organisation->getTitle() : ""; $email = 1 < $privacy_level || $is_administrator ? $user->getEmail() : ""; $email_alt = $user->getAlternateEmail(); if (2 < $privacy_level || $is_administrator) { $show_address = true; $city = $user->getCity(); $province = $user->getProvince(); $prov_name = $province->getName(); $country = $user->getCountry(); $country_name = $country->getName(); $phone = $user->getTelephone(); $fax = $user->getFax(); $address = $user->getAddress(); $postcode = $user->getPostalCode(); $office_hours = $user->getOfficeHours(); } $assistants = $user->getAssistants(); //there are 4 photo cases (at time of writing): no photos, official only, uploaded only, or both. //privacy options also need to be considered here. ob_start(); ?> <div id="result-<?php echo $user_id; ?> " class="person-result"> <div id="img-holder-<?php echo $user_id; ?> " class="img-holder"> <?php $num_photos = count($photos); if (0 === $num_photos) { echo display_photo_placeholder(); } else { foreach ($photos as $photo) { echo display_photo($photo); } if (2 <= $num_photos) { $label = 0; foreach ($photos as $photo) { echo display_photo_link($photo, ++$label); } } echo display_zoom_controls($user_id); } ?> </div> <div class="person-data"> <div class="basic"> <span class="person-name"><?php echo html_encode($fullname); ?> </span> <span class="person-group"><?php echo html_encode($group_line); ?> </span> <span class="person-organisation"><?php echo html_encode($org_name); ?> </span> <div class="email-container"> <?php if ($email) { echo display_person_email($email); if ($email_alt) { echo display_person_email($email_alt); } } ?> </div> </div> <div class="address"> <?php if ($show_address) { if ($phone) { ?> <div> <span class="address-label">Telephone:</span> <span class="address-value"><?php echo html_encode($phone); ?> </span> </div> <?php } if ($fax) { ?> <div> <span class="address-label">Fax:</span> <span class="address-value"><?php echo html_encode($fax); ?> </span> </div> <?php } if ($address && $city) { ?> <div> <span class="address-label">Address:</span><br /> <span class="address-value"> <?php echo html_encode($address) . "<br />" . html_encode($city); if ($prov_name) { echo ", " . html_encode($prov_name); } echo "<br />"; echo html_encode($country_name); if ($postcode) { echo ", " . html_encode($postcode); } ?> </span> </div> <?php } if ($office_hours) { ?> <div> <span class="address-label">Office Hours:</span> <span class="address-value"><?php echo html_encode($office_hours); ?> </span> </div> <?php } } ?> </div> <div class="assistant"><?php if (count($assistants) > 0) { ?> <span class="content-small">Administrative Assistants:</span> <ul class="assistant-list"> <?php foreach ($assistants as $assistant) { echo "<li>" . display_person_email($assistant->getEmail(), $assistant->getName("%f %l")) . "</li>"; } ?> </ul><?php } ?> </div> </div> <div></div> <div class="clearfix"> </div> </div> <?php return ob_get_clean(); }