/** * * @return String Full formatted name of the user */ public function getName($sort = false) { if (!$sort) { if (GO::user()) { $sort = GO::user()->sort_name; } else { $sort = 'first_name'; } } return \GO\Base\Util\String::format_name($this->last_name, $this->first_name, $this->middle_name, $sort); }
/** * Fill the response array with the birthdays of the contacts in the * addressbooks between the start and end time * * @param array $response * @param \GO\Calendar\Model\Calendar $calendar * @param string $startTime * @param string $endTime * @return array */ private function _getBirthdayResponseForPeriod($response, $calendar, $startTime, $endTime) { $adressbooks = \GO\Addressbook\Model\Addressbook::model()->find(\GO\Base\Db\FindParams::newInstance()->permissionLevel(\GO\Base\Model\Acl::READ_PERMISSION, $calendar->user_id)); $resultCount = 0; $dayString = \GO::t('full_days'); $addressbookKeys = array(); while ($addressbook = $adressbooks->fetch()) { $addressbookKeys[] = $addressbook->id; } $alreadyProcessed = array(); $contacts = $this->_getBirthdays($startTime, $endTime, $addressbookKeys); foreach ($contacts as $contact) { if (!in_array($contact->id, $alreadyProcessed)) { $alreadyProcessed[] = $contact->id; $name = \GO\Base\Util\String::format_name($contact->last_name, $contact->first_name, $contact->middle_name); $start_arr = explode('-', $contact->upcoming); $start_unixtime = mktime(0, 0, 0, $start_arr[1], $start_arr[2], $start_arr[0]); $resultCount++; $response['results'][$this->_getIndex($response['results'], strtotime($contact->upcoming . ' 00:00'))] = array('id' => $response['count']++, 'name' => htmlspecialchars(str_replace('{NAME}', $name, \GO::t('birthday_name', 'calendar')), ENT_COMPAT, 'UTF-8'), 'description' => htmlspecialchars(str_replace(array('{NAME}', '{AGE}'), array($name, $contact->upcoming - $contact->birthday), \GO::t('birthday_desc', 'calendar')), ENT_COMPAT, 'UTF-8'), 'time' => date(\GO::user()->time_format, $start_unixtime), 'start_time' => $contact->upcoming . ' 00:00', 'end_time' => $contact->upcoming . ' 23:59', 'model_name' => 'GO\\Adressbook\\Model\\Contact', 'background' => 'EBF1E2', 'calendar_id' => $calendar->id, 'all_day_event' => 1, 'day' => $dayString[date('w', $start_unixtime)] . ' ' . \GO\Base\Util\Date::get_timestamp($start_unixtime, false), 'read_only' => true, 'is_virtual' => true, 'contact_id' => $contact->id); } } // Set the count of the birthdays $response['count_birthdays_only'] = $resultCount; return $response; }