public static function user_suggestbox($str) { $wild = DB::Concat(DB::qstr('%'), DB::qstr($str), DB::qstr('%')); $contacts_raw = CRM_ContactsCommon::get_contacts(array('!login' => '', '(~"first_name' => $wild, '|~"last_name' => $wild)); $contacts = array(); $contacts_login_ids = array(); foreach ($contacts_raw as $c) { $contacts_login_ids[] = $c['login']; $contacts[$c['login']] = $c; } if (!empty($contacts_login_ids)) { $qry_ids = ' OR id IN (' . implode(',', $contacts_login_ids) . ')'; } else { $qry_ids = ''; } $ret = DB::SelectLimit('SELECT id, active FROM user_login WHERE login ' . DB::like() . ' ' . $wild . $qry_ids . ' ORDER BY active DESC', 10); $result = array(); while ($row = $ret->FetchRow()) { $result[$row['id']] = self::user_label($row['id']); if (!$row['active']) { $result[$row['id']] .= ' (' . __('Inactive') . ')'; } } asort($result); return $result; }
public function messanger_addon($arg) { $emp = array(); $ret = CRM_ContactsCommon::get_contacts(array('id' => $arg['employees']), array(), array('last_name' => 'ASC', 'first_name' => 'ASC')); foreach ($ret as $c_id => $data) { if (is_numeric($data['login'])) { $emp[$data['login']] = CRM_ContactsCommon::contact_format_no_company($data); } } $mes = $this->init_module('Utils/Messenger', array('CRM_PhoneCall:' . $arg['id'], array('CRM_PhoneCallCommon', 'get_alarm'), array($arg['id']), strtotime($arg['date_and_time']), $emp)); // $mes->set_inline_display(); $this->display_module($mes); }
public function company_addon($company) { $attachment_groups = array(); $ids = array('C:' . $company['id']); $crits = array('(company_name' => $company['id'], '|related_companies' => array($company['id'])); $cont = CRM_ContactsCommon::get_contacts($crits); foreach ($cont as $k => $v) { $ids[] = 'P:' . $v['id']; $attachment_groups[] = 'contact/' . $v['id']; } if (ModuleManager::is_installed('CRM_Meeting') >= 0) { $records = Utils_RecordBrowserCommon::get_records('crm_meeting', array('customers' => $ids), array()); foreach ($records as $rec) { $attachment_groups[] = 'crm_meeting/' . $rec['id']; } } if (ModuleManager::is_installed('CRM_Tasks') >= 0) { $records = Utils_RecordBrowserCommon::get_records('task', array('customers' => $ids), array()); foreach ($records as $rec) { $attachment_groups[] = 'task/' . $rec['id']; } } if (ModuleManager::is_installed('CRM_PhoneCall') >= 0) { $records = Utils_RecordBrowserCommon::get_records('phonecall', array('customer' => $ids), array()); foreach ($records as $rec) { $attachment_groups[] = 'phonecall/' . $rec['id']; } } if (ModuleManager::is_installed('Premium_SalesOpportunity') >= 0) { $records = Utils_RecordBrowserCommon::get_records('premium_salesopportunity', array('customers' => $ids), array()); foreach ($records as $rec) { $attachment_groups[] = 'premium_salesopportunity/' . $rec['id']; } } if (Base_User_SettingsCommon::get('CRM/Contacts/NotesAggregate', 'show_all_notes')) { $attachment_groups[] = 'company/' . $company['id']; } $a = $this->init_module('Utils/Attachment', array($attachment_groups)); $a->set_multiple_group_mode(); $this->display_module($a); }
public function get_data($user, $pass, $newer_then = 0) { global $namespace; $error = $this->auth($user, $pass); $contacts = array(); $companies = array(); if ($error === '') { $c = CRM_ContactsCommon::get_contacts(array(':Edited_on' => '>' . DB::DBTimeStamp($newer_then))); foreach ($c as $row) { foreach ($row['company_name'] as &$v) { $v = (int) $v; } $contacts[] = new SOAP_Value('item', '{urn:' . $namespace . '}Contact', array('id' => new SOAP_Value("id", "int", (int) $row['id']), 'first' => new SOAP_Value("first", "string", $row['first_name']), 'last' => new SOAP_Value("last", "string", $row['last_name']), 'title' => new SOAP_Value("title", "string", $row['title']), 'work_phone' => new SOAP_Value("work_phone", "string", $row['work_phone']), 'mobile_phone' => new SOAP_Value("mobile_phone", "string", $row['mobile_phone']), 'fax' => new SOAP_Value("fax", "string", $row['fax']), 'mail' => new SOAP_Value("mail", "string", $row['email']), 'web_address' => new SOAP_Value("web_address", "string", $row['web_address']), 'address1' => new SOAP_Value("address1", "string", $row['address_1']), 'address2' => new SOAP_Value("address2", "string", $row['address_2']), 'city' => new SOAP_Value("city", "string", $row['city']), 'country' => new SOAP_Value("country", "string", $row['country']), 'zone' => new SOAP_Value("zone", "string", $row['zone']), 'postal' => new SOAP_Value("postal", "string", $row['postal_code']), 'home_phone' => new SOAP_Value("home_phone", "string", $row['home_phone']), 'home_address1' => new SOAP_Value("home_address1", "string", $row['home_address_1']), 'home_address2' => new SOAP_Value("home_address2", "string", $row['home_address_2']), 'home_city' => new SOAP_Value("home_city", "string", $row['home_city']), 'home_zone' => new SOAP_Value("home_zone", "string", $row['home_zone']), 'home_country' => new SOAP_Value("home_country", "string", $row['home_country']), 'home_postal' => new SOAP_Value("home_postal", "string", $row['home_postal_code']), 'birth' => new SOAP_Value("birth", "string", $row['birth_date']), 'company' => new SOAP_Value("company", '{urn:' . $namespace . '}ArrayOfInt', $row['company_name']))); } $c = CRM_ContactsCommon::get_companies(array(':Edited_on' => '>' . DB::DBTimeStamp($newer_then))); foreach ($c as $row) { $companies[] = new SOAP_Value('item', '{urn:' . $namespace . '}Company', array('id' => new SOAP_Value("id", 'int', (int) $row['id']), 'name' => new SOAP_Value("name", 'string', $row['company_name']), 'short_name' => new SOAP_Value("short_name", 'string', $row['short_name']), 'phone' => new SOAP_Value("phone", 'string', $row['phone']), 'fax' => new SOAP_Value("fax", 'string', $row['fax']), 'web_address' => new SOAP_Value("web_address", 'string', $row['web_address']), 'address1' => new SOAP_Value("address1", 'string', $row['address_1']), 'address2' => new SOAP_Value("address2", 'string', $row['address_2']), 'city' => new SOAP_Value("city", 'string', $row['city']), 'country' => new SOAP_Value("country", 'string', $row['country']), 'zone' => new SOAP_Value("zone", 'string', $row['zone']), 'postal' => new SOAP_Value("postal", 'string', $row['postal_code']))); } } return new SOAP_Value('return', '{urn:' . $namespace . '}GetDataResult', array('companies' => new SOAP_Value('companies', '{urn:' . $namespace . '}ArrayOfCompanies', $companies), 'contacts' => new SOAP_Value('contacts', '{urn:' . $namespace . '}ArrayOfContacts', $contacts), 'error' => new SOAP_Value('error', 'string', $error))); }
public function addon_flat($rs, $id) { $rb = $this->init_module('Utils/RecordBrowser', 'rc_mails', 'rc_mails_flat'); $rb->set_header_properties(array('date' => array('width' => 10), 'employee' => array('name' => __('Archived by'), 'width' => 20), 'contacts' => array('name' => __('Involved contacts'), 'width' => 20), 'subject' => array('name' => __('Message'), 'width' => 40), 'attachments' => array('width' => 5))); $rb->set_additional_actions_method(array($this, 'actions_for_mails')); if ($rs == 'contact') { $this->display_module($rb, array(array('(employee' => $id, '|contacts' => array('P:' . $id), '|related' => $rs . '/' . $id), array(), array('date' => 'DESC')), 'show_data'); } elseif ($rs == 'company') { $form = $this->init_module('Libs/QuickForm'); $form->addElement('checkbox', 'include_related', __('Include related e-mails'), null, array('onchange' => $form->get_submit_form_js())); if ($form->validate()) { $show_related = $form->exportValue('include_related'); $this->set_module_variable('include_related', $show_related); } $show_related = $this->get_module_variable('include_related'); $form->setDefaults(array('include_related' => $show_related)); ob_start(); $form->display_as_row(); $html = ob_get_clean(); $rb->set_button(false, $html); $customers = array('C:' . $id); if ($show_related) { $conts = CRM_ContactsCommon::get_contacts(array('company_name' => $id)); foreach ($conts as $c) { $customers[] = 'P:' . $c['id']; } } $this->display_module($rb, array(array('(contacts' => $customers, '|related' => $rs . '/' . $id), array(), array('date' => 'DESC')), 'show_data'); } else { $this->display_module($rb, array(array('related' => $rs . '/' . $id), array(), array('date' => 'DESC')), 'show_data'); } }
public function body() { if (!Acl::is_user()) { return; } $th = $this->init_module('Base/Theme'); eval_js_once('crm_filters_deactivate = function(){leightbox_deactivate(\'crm_filters\');}'); $th->assign('my', '<a ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), 'my') . ' id="crm_filters_my">' . __('My records') . '</a>'); eval_js('Event.observe(\'crm_filters_my\',\'click\', crm_filters_deactivate)'); /*$th->assign('all','<a '.$this->create_callback_href(array('CRM_FiltersCommon','set_profile'),'all').' id="crm_filters_all">'.__('All records').'</a>'); eval_js('Event.observe(\'crm_filters_all\',\'click\', crm_filters_deactivate)');*/ $th->assign('manage', '<a ' . $this->create_callback_href(array($this, 'manage_filters')) . ' id="crm_filters_manage">' . __('Manage presets') . '</a>'); eval_js('Event.observe(\'crm_filters_manage\',\'click\', crm_filters_deactivate)'); $ret = DB::Execute('SELECT id,name,description FROM crm_filters_group WHERE user_login_id=%d', array(Acl::get_user())); $filters = array(); while ($row = $ret->FetchRow()) { $filters[] = array('title' => $row['name'], 'description' => '', 'open' => '<a ' . Utils_TooltipCommon::open_tag_attrs($row['description'], false) . ' ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), $row['id']) . ' id="crm_filters_' . $row['id'] . '">', 'close' => '</a>'); eval_js('Event.observe(\'crm_filters_' . $row['id'] . '\',\'click\', crm_filters_deactivate)'); } $th->assign('filters', $filters); $qf = $this->init_module('Libs/QuickForm'); $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company'); $recent_crits = array(); if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) { $recent_crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company())); } if (Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')) { $recent_crits['!login'] = ''; } $contacts = CRM_ContactsCommon::get_contacts($recent_crits, array(), array(), 15); $cont = array(); foreach ($contacts as $v) { $cont[$v['id']] = call_user_func($fcallback, $v, true); } asort($cont); $crits = array(); if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) { $crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company())); } $qf->addElement('autoselect', 'crm_filter_contact', __('Records of'), $cont, array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback, false)), $fcallback); if (isset($_SESSION['client']['filter_' . Acl::get_user()]['value'])) { $qf->setDefaults(array('crm_filter_contact' => explode(',', $_SESSION['client']['filter_' . Acl::get_user()]['value']))); } $qf->addElement('submit', 'submit', __('Show'), array('onclick' => 'crm_filters_deactivate()')); if ($qf->validate()) { $c = $qf->exportValue('crm_filter_contact'); CRM_FiltersCommon::set_profile('c' . $c); location(array()); } $th->assign('saved_filters', __('Saved Presets')); $qf->assign_theme('contacts', $th); //$th->assign('contacts',$qf->toHtml()); ob_start(); $th->display(); $profiles_out = ob_get_clean(); Libs_LeightboxCommon::display('crm_filters', $profiles_out, __('Perspective'), true); if (!isset($_SESSION['client']['filter_' . Acl::get_user()]['desc'])) { CRM_FiltersCommon::set_profile('my'); } //Base_ActionBarCommon::add('folder',__('Filters'),'class="lbOn" rel="crm_filters"',$this->get_module_variable('profile_desc',__('My records'))); if (isset($_REQUEST['__location'])) { $in_use = CRM_FiltersCommon::$in_use === $_REQUEST['__location']; } else { $in_use = CRM_FiltersCommon::$in_use; } print '<a class="lbOn' . ($in_use ? '' : ' disabled') . ' button" rel="crm_filters">' . __('Perspective') . ': ' . '<b>' . $_SESSION['client']['filter_' . Acl::get_user()]['desc'] . '</b><div class="filter_icon_img"></div></a>'; }
public function company_activities($me) { $this->theme = $this->pack_module(Base_Theme::module_name()); $this->filters(); $this->theme->display(); $cont = CRM_ContactsCommon::get_contacts(array('(company_name' => $me['id'], '|related_companies' => array($me['id'])), array('id')); $ids = array(); $cus_ids = array(); $rel_ids = array('company/' . $me['id']); $db_string = ''; foreach ($cont as $v) { $ids[] = $v['id']; $cus_ids[] = 'P:' . $v['id']; $rel_ids[] = 'contact/' . $v['id']; } $cus_ids[] = 'C:' . $me['id']; $events = null; $tasks = null; $phonecalls = null; $date_filter = ''; // TODO: recurring events // TODO: check if statsu<2 if fine for closed if ($this->display['events'] && ($ids || $cus_ids)) { if ($this->activities_date == 0) { $events = CRM_MeetingCommon::crm_event_get_all(date('Y-m-d H:i:s'), date('Y-m-d H:i:s', time() + 10 * 365 * 24 * 3600), '(' . implode(',', $ids) . ')', $cus_ids); } elseif ($this->activities_date == 1) { $events = CRM_MeetingCommon::crm_event_get_all(date('Y-m-d H:i:s', 0), date('Y-m-d H:i:s'), '(' . implode(',', $ids) . ')', $cus_ids); } else { $events = CRM_MeetingCommon::crm_event_get_all(date('Y-m-d H:i:s', 0), date('Y-m-d H:i:s', time() + 10 * 365 * 24 * 3600), '(' . implode(',', $ids) . ')', $cus_ids); } } //$events = DB::GetAll('SELECT * FROM crm_calendar_event AS cce WHERE cce.deleted=0 AND '.$date_filter.(!$this->display['closed']?' cce.status<2 AND':'').' (EXISTS (SELECT contact FROM crm_calendar_event_group_emp AS ccegp WHERE ccegp.id=cce.id AND (false'.$db_string.')) OR EXISTS (SELECT contact FROM crm_calendar_event_group_cus AS ccegc WHERE ccegc.id=cce.id AND (false'.$db_string.'))) ORDER BY starts DESC', array_merge($ids, $ids)); $crits = array('(employees' => $ids, '|customers' => $cus_ids, '|related' => $rel_ids); if ($this->activities_date == 0) { $crits['(>=deadline'] = date('Y-m-d'); $crits['|deadline'] = ''; } if ($this->activities_date == 1) { $crits['(<deadline'] = date('Y-m-d'); $crits['|deadline'] = ''; } if (!$this->display['closed']) { $crits['!status'] = array(2, 3); } if ($this->display['tasks']) { $tasks = CRM_TasksCommon::get_tasks($crits, array(), array('deadline' => 'DESC')); } $crits = array('(employees' => $ids, '|customer' => $cus_ids, '|related' => $rel_ids); if ($this->activities_date == 0) { $crits['>=date_and_time'] = date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time(date('Y-m-d 0:00:00'))); } if ($this->activities_date == 1) { $crits['<date_and_time'] = date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time(date('Y-m-d 0:00:00'))); } if (!$this->display['closed']) { $crits['!status'] = array(2, 3); } if ($this->display['phonecalls']) { $phonecalls = CRM_PhoneCallCommon::get_phonecalls($crits, array(), array('date_and_time' => 'DESC')); } $this->display_activities($events, $tasks, $phonecalls); }
public function send($file) { if ($this->is_back()) { return $this->go_back($file); } $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'send_fax'); list($providers, $providers_arr) = self::get_providers($file); if (empty($providers)) { $this->go_back($file); Epesi::alert(__('No fax providers installed or configured for this type of file.')); return; } $qf->addElement('header', null, __('Faxing file: %s', array(basename($file)))); $qf->addElement('select', 'provider', __('Provider'), $providers); $qf->addElement('header', null, __('Contact')); $fav_contact = CRM_ContactsCommon::get_contacts(array(':Fav' => true, '!fax' => '')); $fav_contact2 = array(); foreach ($fav_contact as $v) { $fav_contact2[$v['id']] = CRM_ContactsCommon::contact_format_default($v, true); } $rb_contact = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name()); $this->display_module($rb_contact, array('contact', 'dest_contact', array('CRM_FaxCommon', 'rpicker_contact_format'), array('!fax' => ''), array('fax' => true))); $qf->addElement('multiselect', 'dest_contact', '', $fav_contact2); $qf->addElement('static', null, $rb_contact->create_open_link('Add contact')); $qf->addElement('header', null, __('Company')); $fav_company = CRM_ContactsCommon::get_companies(array(':Fav' => true, '!fax' => ''), array('id', 'company_name')); $fav_company2 = array(); foreach ($fav_company as $v) { $fav_company2[$v['id']] = $v['company_name']; } $rb_company = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name()); $this->display_module($rb_company, array('company', 'dest_company', array('CRM_FaxCommon', 'rpicker_company_format'), array('!fax' => ''), array('fax' => true))); $qf->addElement('multiselect', 'dest_company', '', $fav_company2); $qf->addElement('static', null, $rb_company->create_open_link('Add company')); $qf->addElement('header', null, __('Other')); $qf->addElement('text', 'dest_other', __('Other fax numbers (comma separated)')); $qf->addFormRule(array($this, 'check_numbers')); if ($qf->validate()) { $data = $qf->exportValues(); if (!isset($providers_arr[$data['provider']]['send_func'])) { Epesi::alert(__('Invalid fax provider.')); } else { $fax_func = array($data['provider'] . 'Common', $providers_arr[$data['provider']]['send_func']); $numbers = array(); $contacts = Utils_RecordBrowserCommon::get_records('contact', array('id' => $data['dest_contact']), array('fax')); foreach ($contacts as $row) { $numbers[] = $row['fax']; } $companies = Utils_RecordBrowserCommon::get_records('company', array('id' => $data['dest_company']), array('fax')); foreach ($companies as $row) { $numbers[] = $row['fax']; } $numbers += explode(',', $data['dest_other']); $ret = call_user_func($fax_func, $file, $numbers); if ($ret) { return $this->go_back($file); } } } $qf->display(); Base_ActionBarCommon::add('send', __('Send'), $qf->get_submit_form_href()); Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); }
public function admin() { if ($this->is_back()) { if ($this->parent->get_type() == 'Base_Admin') { $this->parent->reset(); } else { location(array()); } return; } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $user = $this->get_module_variable('filter_user', ''); $form = $this->init_module(Libs_QuickForm::module_name(), null, 'filter'); $form->setDefaults(array('users' => $user)); $count = DB::GetOne('SELECT COUNT(*) FROM user_login'); if ($count > Base_User_SettingsCommon::get('Utils_RecordBrowser', 'enable_autocomplete')) { $f_callback = array('CRM_LoginAuditCommon', 'user_label'); $form->addElement('autoselect', 'users', __('Select user'), array(), array(array('CRM_LoginAuditCommon', 'user_suggestbox'), array($f_callback)), $f_callback, array('onChange' => $form->get_submit_form_js(), 'style' => 'width:200px')); } else { $ret = DB::Execute('SELECT id, active FROM user_login ORDER BY active DESC, login ASC'); $el = $form->addElement('select', 'users', __('Select user'), array(), array('onChange' => $form->get_submit_form_js(), 'style' => 'width:200px')); $el->addOption(__('All'), ''); $contacts_raw = CRM_ContactsCommon::get_contacts(array('!login' => '')); $contacts = array(); foreach ($contacts_raw as $c) { $contacts[$c['login']] = $c; } $active = array(); $inactive = array(); while ($row = $ret->FetchRow()) { $label = '[' . Base_UserCommon::get_user_login($row['id']) . ']'; if (isset($contacts[$row['id']])) { $label = CRM_ContactsCommon::contact_format_no_company($contacts[$row['id']], true) . ' ' . $label; } if ($row['active']) { $active[$row['id']] = $label; } else { $inactive[$row['id']] = $label; } } asort($active); asort($inactive); foreach ($active as $id => $label) { $el->addOption($label, $id); } foreach ($inactive as $id => $label) { $el->addOption($label, $id, array('style' => 'background-color: lightgray;')); } } $user = $form->exportValue('users'); $form->display_as_row(); $this->set_module_variable('filter_user', $user); $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'login_audit'); $gb->set_table_columns(array(array('name' => '<b>' . __('Login') . '</b> ' . __('[uid] -> User Name'), 'order' => 'b.user_login_id', 'width' => 20), array('name' => __('Start'), 'order' => 'b.start_time', 'width' => 15), array('name' => __('End'), 'order' => 'b.end_time', 'width' => 15), array('name' => __('Duration'), 'width' => 10), array('name' => __('IP Address'), 'order' => 'b.ip_address', 'width' => 10), array('name' => __('Host Name'), 'order' => 'b.host_name', 'width' => 30))); $gb->set_default_order(array(__('End') => 'DESC')); if ($user > 0) { $query = 'SELECT b.user_login_id, b.start_time, b.end_time, b.ip_address, b.host_name FROM base_login_audit b WHERE b.user_login_id=' . $user; $query_qty = 'SELECT count(b.id) FROM base_login_audit b WHERE b.user_login_id=' . $user; } else { $query = 'SELECT b.user_login_id, b.start_time, b.end_time, b.ip_address, b.host_name FROM base_login_audit b'; $query_qty = 'SELECT count(b.id) FROM base_login_audit b'; } $ret = $gb->query_order_limit($query, $query_qty); if ($ret) { while ($row = $ret->FetchRow()) { $c = CRM_ContactsCommon::get_contact_by_user_id($row['user_login_id']); $ulogin = Base_UserCommon::get_user_login($row['user_login_id']); $uid = __('Contact not set'); if ($c) { $uid = $c['first_name'] . ' ' . $c['last_name']; } $offset = strtotime("1970-01-01 00:00:00"); $sess_time = date("G:i:s", strtotime($row['end_time']) - strtotime($row['start_time']) + $offset); $gb->add_row('<b>' . $ulogin . ' [' . $row['user_login_id'] . ']</b> -> ' . $uid, $row['start_time'], $row['end_time'], $sess_time, $row['ip_address'], $row['host_name']); } } $this->display_module($gb); if (!DEMO_MODE) { Base_ActionBarCommon::add('settings', __('Maintenance'), $this->create_callback_href(array($this, 'purge_log'))); } return true; }
public function update_contacts_address($company, $fields) { $recs = CRM_ContactsCommon::get_contacts(array('company_name' => $company['id']), array('id')); $new_data = array(); foreach ($fields as $k => $v) { $new_data[$k] = $company[$v]; } foreach ($recs as $contact) { Utils_RecordBrowserCommon::update_record('contact', $contact['id'], $new_data); } }
*/ defined("_VALID_ACCESS") || die('Direct access forbidden'); $ret = ''; $values = $_POST['values']; foreach ($values as $v) { $ret = $v; break; } $params = array(); foreach ($_POST['parameters'] as $k => $v) { $params[$k] = $v; } if ($ret == '') { $contacts = array(); } else { $contacts = CRM_ContactsCommon::get_contacts(array('(company_name' => $ret, '|related_companies' => array($ret)), array(), array('last_name' => 'ASC')); } $res = array(); $callback = explode('::', $params['format']); if (!is_array($_POST['defaults'])) { if ($_POST['defaults'] != '') { $_POST['defaults'] = array($_POST['defaults']); } else { $_POST['defaults'] = array(); } } $ext_rec = array_flip($_POST['defaults']); foreach ($contacts as $k => $v) { $res[$v['id']] = call_user_func($callback, $v, true); if (isset($_POST['defaults'])) { unset($ext_rec[$v['id']]);