function view_contact($contact_id = '', $contact_type = '', $referer = '') { $contact_id = empty($contact_id) ? phpgw::get_var('ab_id') : $contact_id; $contact_type = $contact_type ? $contact_type : $this->bo->search_contact_type_id($this->bo->get_type_contact($contact_id)); $referer = $referer == '' ? phpgw::get_var('referer') : $referer; $referer = urldecode($referer); if ($contact_type == $this->tab_main_persons) { $type = 'person'; $contacts = $this->bo->get_principal_persons_data($contact_id); $userformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; if ($userformat != $this->bo->bday_internformat) { $contacts['org_name'] = '<a href="' . $contacts['org_link'] . '">' . htmlentities($contacts['org_name'], ENT_QUOTES, 'UTF-8') . '</a>'; unset($contacts['org_link']); $cat_link_url = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.index', 'section' => 'Persons', 'nonavbar' => $this->nonavbar)); $contacts['per_birthday'] = phpgwapi_datetime::convertDate($contacts['per_birthday'], $this->bo->bday_internformat, $userformat); } } else { if ($contact_type == $this->tab_main_organizations) { $cat_link_url = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.index', 'section' => 'Organizations', 'nonavbar' => $this->nonavbar)); $type = 'org'; $contacts = $this->bo->get_principal_organizations_data($contact_id); } } if (isset($contacts['tab_extra']) && is_array($contacts['tab_extra'])) { foreach ($contacts['tab_extra'] as $key => $value) { $contacts[$key] = $value; } } $owner = $contacts['owner']; $cats = $contacts['tab_cats']['my_cats']; $access = $contacts['access']; unset($contacts['tab_cats']); unset($contacts['tab_extra']); if (!$this->bo->check_read($contact_id, $owner)) { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.index', 'section' => $contact_type, 'nonavbar' => $this->nonavbar)); } $tmp_cats = array(); foreach ($cats as $key => $cat_id) { if ($cat_id) { $catinfo = $this->cat->return_single(intval($cat_id)); $tmp_cats[] = '<a href="' . $cat_link_url . '&fcat_id=' . $cat_id . '">' . $catinfo[0]['name'] . '</a>'; } } $catname = implode(', ', $tmp_cats); unset($tmp_cats); unset($contacts['contact_id']); unset($contacts['cat_id']); unset($contacts['access']); unset($contacts['owner']); unset($contacts['email']); unset($contacts['wphone']); unset($contacts['load']); unset($contacts['my_cats']); $comms = $this->bo->get_comm_contact_data($contact_id); if (isset($comms[$contact_id]) && is_array($comms[$contact_id])) { $contacts = $contacts + $comms[$contact_id]; $comms_media[] = array_keys($comms[$contact_id]); } else { $comms_media[0] = array(); } $addr = $this->bo->get_addr_contact_data($contact_id, array('addr_pref_val' => 'Y')); if (isset($addr) && isset($addr[0]) && is_array($addr[0])) { unset($addr[0]['contact_id']); unset($addr[0]['key_addr_id']); unset($addr[0]['addr_type']); unset($addr[0]['addr_preferred']); unset($addr[0]['addr_description']); unset($addr[0]['addr_contact_id']); $contacts = array_merge($contacts, $addr[0]); } $others = $this->bo->get_others_contact_data($contact_id); if (is_array($others)) { foreach ($others as $key => $other_data) { $contacts[$other_data['other_name']] = $other_data['other_value']; } } $this->template->set_root(PHPGW_APP_TPL); $this->template->set_file(array('view_t' => 'view.tpl')); $this->template->set_block('view_t', 'view_header', 'view_header'); $this->template->set_block('view_t', 'view_row', 'view_row'); $this->template->set_block('view_t', 'view_footer', 'view_footer'); $this->template->set_block('view_t', 'view_buttons', 'view_buttons'); $GLOBALS['phpgw']->common->phpgw_header(true); $this->template->set_var('lang_viewpref', lang('Address book - view')); $tr_class = ''; $row_cnt = 0; foreach ($contacts as $field => $data) { if ($field != 'org_name') { $data = htmlentities($data, ENT_QUOTES, 'UTF-8'); } $ref = ''; if (!is_numeric($field) && $data != '') { if (in_array($field, $comms_media[0])) { $this->template->set_var('display_col', lang($field)); if (strpos($field, 'email')) { if (isset($GLOBALS['phpgw_info']['user']['apps']['email']) && $GLOBALS['phpgw_info']['user']['apps']['email']) { $ref = '<a href="' . $GLOBALS['phpgw']->link('/email/compose.php', array('to' => urlencode($data))) . '" target="_new">'; } else { $ref = '<a href="mailto:' . $data . '">'; } $data .= '</a>'; } if ($field == 'website') { if (!empty($data) && substr($data, 0, 7) != 'http://') { $data = 'http://' . $data; } $ref = '<a href="' . $data . '" target="_new">'; $data .= '</a>'; } } else { $this->template->set_var('display_col', $this->bo->display_name($field)); } $tr_class = $row_cnt % 2 ? 'row_off' : 'row_on'; $this->template->set_var('tr_class', $tr_class); ++$row_cnt; $this->template->set_var('ref_data', $ref . $data); $this->template->parse('cols', 'view_row', True); } } if ($contact_type == $this->tab_main_organizations) { $persons = $this->bo->get_person_orgs_data($contact_id); if ($persons && is_array($persons)) { $per_link = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.view_person', 'nonavbar' => $this->nonavbar)); $ppl = array(); foreach ($persons as $per) { if ($per['per_first_name'] || $per['per_last_name']) { $ppl[] = '<a href="' . $per_link . '&ab_id=' . $per['my_person_id'] . '">' . $per['per_first_name'] . ' ' . $per['per_last_name'] . '</a>'; } } $tr_class = $row_cnt % 2 ? 'row_off' : 'row_on'; $this->template->set_var('tr_class', $tr_class); ++$row_cnt; $this->template->set_var('display_col', lang('contacts')); $this->template->set_var('ref_data', implode('<br />', $ppl)); $this->template->parse('cols', 'view_row', True); } } /* Following cleans up view_row, since we were only using it to fill {cols} */ $this->template->set_var('view_row', ''); /* These are in the footer */ if ($row_cnt % 2) { $this->template->set_var(array('access_class' => 'row_on', 'cat_class' => 'row_off', 'owner_class' => 'row_off')); } else { $this->template->set_var(array('access_class' => 'row_off', 'cat_class' => 'row_on', 'owner_class' => 'row_on')); } unset($row_cnt); $this->template->set_var('lang_owner', lang('Record owner')); if (isset($GLOBALS['phpgw_info']['server']['addressmaster']) && $owner == $GLOBALS['phpgw_info']['server']['addressmaster']) { $this->template->set_var('owner', 'addressmaster'); } else { $this->template->set_var('owner', $GLOBALS['phpgw']->common->grab_owner_name($owner)); } $this->template->set_var('lang_access', lang('Record access')); $this->template->set_var('access', $access); $this->template->set_var('lang_category', lang('Category')); $this->template->set_var('catname', $catname); if ($this->bo->check_edit($contact_id)) { $this->template->set_var('edit_button', $this->html_1button_form('edit', 'Edit', $GLOBALS['phpgw']->link('/index.php', array('menuaction' => "addressbook.uiaddressbook.edit_{$type}", 'ab_id' => $contact_id, 'nonavbar' => $this->nonavbar)))); } else { $this->template->set_var('edit_button', ''); } $this->template->set_var('copy_button', $this->html_1button_form('submit', 'copy', $GLOBALS['phpgw']->link('/index.php', array('menuaction' => "addressbook.uiaddressbook.copy_{$type}", 'ab_id' => $contact_id, 'nonavbar' => $this->nonavbar)))); if ($contacts['per_first_name'] && $contacts['per_last_name']) { $this->template->set_var('vcard_button', $this->html_1button_form('VCardForm', 'VCard', $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'addressbook.uivcard.out', 'ab_id' => $contact_id, 'nonavbar' => $this->nonavbar)))); } else { $this->template->set_var('vcard_button', lang('no vcard')); } $this->template->set_var('done_button', $this->html_1button_form('DoneForm', 'Done', isset($referer) && $referer ? $referer : $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.index', 'action' => $contact_type, 'nonavbar' => $this->nonavbar)))); $this->template->pparse('out', 'view_t'); if ($contact_type == $this->tab_main_persons) { $GLOBALS['phpgw']->hooks->process(array('location' => 'addressbook_view', 'ab_id' => $contact_id)); } }
/** * Find recurring events for a period defined by the event * * @return array schedule */ public function event_schedule_data() { $id = phpgw::get_var('id', 'int'); $event = $this->so->read_single($id); $criteria = array('start_date' => $event['start_date'], 'end_date' => $event['end_date'], 'location_id' => $event['location_id'], 'location_item_id' => $event['location_item_id']); $this->find_scedules($criteria); $schedules = $this->cached_events; $total_records = 0; $lang_exception = lang('exception'); $values = array(); $i = 1; foreach ($schedules as $_date => $set) { $__date = substr($_date, 0, 4) . '-' . substr($_date, 4, 2) . '-' . substr($_date, 6, 2); $date = phpgwapi_datetime::convertDate($__date, 'Y-m-d', $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); foreach ($set as $entry) { $values[] = array('time' => $i, 'date' => array('exception' => $entry['exception'], 'lang_exception' => $lang_exception, 'type' => 'event', 'name' => $date, 'link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'booking.uievent.show', 'location_id' => $entry['location_id'], 'location_item_id' => $entry['location_item_id'])))); $i++; } } $data = array('ResultSet' => array("totalResultsAvailable" => $total_records, "Result" => $values)); return $data; }
public function add_listener($name, $date = '', $title = '') { $this->fields[] = $name; $date2 = ''; if ($date) { $date2 = phpgwapi_datetime::convertDate($date, $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 'Y-m-d'); } $title = $title ? $title : $name; $img = $GLOBALS['phpgw']->common->image('phpgwapi', 'cal'); $alt = lang('date selector trigger'); $lang_close = lang('close'); $lang_clear = lang('clear'); $html .= <<<HTML \t\t\t\t<input type="text" name="{$name}" id="{$name}" size="10" value="{$date}" readonly="true" /> \t\t\t<!--\t<img src="{$img}" alt="{$alt}" id="{$name}_img" title="{$name}"> --> \t\t\t\t<input type="hidden" name="{$name}_hidden" id="{$name}_hidden" value="{$date2}"/> \t\t\t\t<div id="calendar{$name}"> \t\t\t\t\t<div id="calendar{$name}_body"></div> \t\t\t\t\t<div class="calheader"> \t\t\t\t-\t\t<button id="calendar{$name}CloseButton">{$lang_close}</button> \t\t\t\t\t\t<button id="calendar{$name}ClearButton">{$lang_clear}</button> \t\t\t\t\t</div> \t\t\t\t</div> HTML; return $html; }