public static function user_label($id) { $label = Base_UserCommon::get_user_login($id); $c = Utils_RecordBrowserCommon::get_id('contact', 'login', $id); if ($c) { $label = CRM_ContactsCommon::contact_format_no_company($c, true) . ' [' . $label . ']'; } return $label; }
public function make_event_PDF($pdf, $id, $no_details = false, $type = 'Event') { $custom_event = false; if (!is_array($id)) { $check = explode('#', $id); if (isset($check[1])) { $callback = DB::GetOne('SELECT handler_callback FROM crm_calendar_custom_events_handlers WHERE id=%d', $check[0]); $callback = explode('::', $callback); $ev = call_user_func($callback, 'get', $check[1]); $no_details = true; $custom_event = true; } else { trigger_error('Invalid event id: ' . $id, E_USER_ERROR); } } else { $ev = $id; $id = $ev['id']; $id = explode('_', $id); $id = $id[0]; /* $ev_details = DB::GetRow('SELECT *, starts AS start, ends AS end FROM crm_calendar_event WHERE id=%d', array($id)); foreach ($ev_details as $k=>$v) if (!isset($ev[$k])) $ev[$k] = $v;*/ $ev['title'] = strip_tags($ev['title']); $check = explode('#', $id); if (isset($check[1])) { $no_details = true; $custom_event = true; } } $pdf_theme = $this->pack_module('Base/Theme'); $pdf_theme->assign('description', array('label' => __('Description'), 'value' => str_replace("\n", '<br/>', htmlspecialchars($ev['description'])))); if (!$no_details) { $ev['status'] = Utils_CommonDataCommon::get_value('CRM/Status/' . $ev['status'], true); $ev['access'] = self::$access[$ev['access']]; $ev['priority'] = self::$priority[$ev['priority']]; foreach (array('access' => __('Access'), 'priority' => __('Priority'), 'status' => __('Status')) as $v => $label) { $pdf_theme->assign($v, array('label' => $label, 'value' => $ev[$v])); } $created_by = CRM_ContactsCommon::get_contact_by_user_id($ev['created_by']); if ($created_by !== null) { $created_by = $created_by['last_name'] . ' ' . $created_by['first_name']; } else { $created_by = Base_UserCommon::get_user_login($ev['created_by']); } $created_on = Base_RegionalSettingsCommon::time2reg($ev['created_on'], false); $pdf_theme->assign('created_on', array('label' => __('Created on'), 'value' => $created_on)); $pdf_theme->assign('created_by', array('label' => __('Created by'), 'value' => $created_by)); if ($ev['edited_by'] != null) { $edited_by = CRM_ContactsCommon::get_contact_by_user_id($ev['edited_by']); if ($edited_by !== null) { $edited_by = $edited_by['last_name'] . ' ' . $edited_by['first_name']; } else { $edited_by = Base_UserCommon::get_user_login($ev['edited_by']); } $edited_on = Base_RegionalSettingsCommon::time2reg($ev['edited_on'], false); } else { $edited_by = '--'; $edited_on = '--'; } $pdf_theme->assign('edited_on', array('label' => __('Edited on'), 'value' => $edited_on)); $pdf_theme->assign('edited_by', array('label' => __('Edited by'), 'value' => $edited_by)); $pdf_theme->assign('printed_on', array('label' => __('Printed on'), 'value' => Base_RegionalSettingsCommon::time2reg(time()))); } $emps = array(); $cuss = array(); $cus_cmps = array(); if (isset($ev['employees']) && !empty($ev['employees'])) { foreach ($ev['employees'] as $v) { $c = CRM_ContactsCommon::get_contact($v); $emps[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone']); } } if (isset($ev['customers']) && !empty($ev['customers'])) { foreach ($ev['customers'] as $v) { $det = explode(':', $v); if (isset($det[1])) { $v = $det[1]; } else { $v = $det[0]; $det[0] = 'P'; } if ($det[0] == 'P') { $c = CRM_ContactsCommon::get_contact($v); $company_name = isset($c['company_name']) && is_numeric($c['company_name']) ? array(Utils_RecordBrowserCommon::get_value('company', $c['company_name'], 'Company Name')) : '---'; $cuss[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone'], 'company_name' => $company_name); } if ($det[0] == 'C') { $c = array('company_name' => array($v)); } if (is_array($c['company_name'])) { foreach ($c['company_name'] as $v2) { if (!isset($cus_cmps[$v2])) { $cus_cmps[$v2] = CRM_ContactsCommon::get_company($v2); } } } } } $pdf_theme->assign('employees', array('main_label' => __('Employees'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'lp_label' => __('Lp'), 'data' => $emps)); $pdf_theme->assign('customers', array('main_label' => __('Customers'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'company_name' => __('Company Name'), 'lp_label' => __('Lp'), 'data' => $cuss)); $pdf_theme->assign('customers_companies', array('main_label' => __('Customers Companies'), 'name_label' => __('Company Name'), 'phone_label' => __('Phone'), 'fax_label' => __('Fax'), 'address_label' => __('Address'), 'city_label' => __('City'), 'lp_label' => __('Lp'), 'data' => $cus_cmps)); $pdf_theme->assign('title', array('label' => __('Title'), 'value' => $ev['title'])); $start = Base_RegionalSettingsCommon::time2reg($ev['start'], false); $pdf_theme->assign('start_date', array('label' => __('Start Date'), 'value' => $start, 'details' => array('weekday' => __date('l', strtotime($start))))); if (!isset($ev['timeless'])) { $pdf_theme->assign('start_time', array('label' => __('Start Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['start'], true, false))); if (!isset($ev['end'])) { trigger_error(print_r($ev, true)); } $pdf_theme->assign('end_time', array('label' => __('End Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], true, false))); $hours = floor(($ev['end'] - $ev['start']) / 3600); $format = __('%d hours', array($hours)); $minutes = ($ev['end'] - $ev['start']) % 3600; if ($minutes != 0) { if ($hours == 0) { $format = ''; } else { $format .= ', '; } $format .= __('%d minutes', array($minutes / 60)); } $pdf_theme->assign('duration', array('label' => __('Duration'), 'value' => $format)); if (date('Y-m-d', $ev['start']) != date('Y-m-d', $ev['end'])) { $pdf_theme->assign('end_date', array('label' => __('End Date'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], false))); } } else { $pdf_theme->assign('timeless', array('label' => __('Timeless'), 'value' => __('Yes'))); } $pdf_theme->assign('type', $type); ob_start(); $pdf_theme->display('pdf_version'); $cont = ob_get_clean(); $pdf->writeHTML($cont); }
public static function get_html_record_info($created_by, $created_on, $edited_by = null, $edited_on = null, $id = null) { if ($created_by !== null) { $contact = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact_by_user_id($created_by), true); if ($contact != '') { $created_by = $contact; } else { $created_by = Base_UserCommon::get_user_login($created_by); } } else { $created_by = ''; } // If the record was edited get user contact info if ($edited_by != null) { if ($edited_by != $created_by) { $contact = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact_by_user_id($edited_by), true); } if ($contact != '') { $edited_by = $contact; } else { $edited_by = Base_UserCommon::get_user_login($edited_by); } } $htmlinfo = array(); if ($id) { $htmlinfo[__('Record ID') . ':'] = $id; } $htmlinfo[__('Created by') . ':'] = $created_by; $htmlinfo[__('Created on') . ':'] = Base_RegionalSettingsCommon::time2reg($created_on); if ($edited_by != null) { $htmlinfo = $htmlinfo + array(__('Edited by') . ':' => $edited_by, __('Edited on') . ':' => Base_RegionalSettingsCommon::time2reg($edited_on)); } return Utils_TooltipCommon::format_info_tooltip($htmlinfo); }
public static function get_change_subscription_icon_tags($category_name, $id) { $category_id = self::get_category_id($category_name); if (!$category_id) { return; } $last_seen = self::check_if_notified($category_name, $id); load_js('modules/Utils/Watchdog/subscribe.js'); $tag_id = 'watchdog_sub_button_' . $category_name . '_' . $id; $href = ' onclick="utils_watchdog_set_subscribe(' . ($last_seen === null ? 1 : 0) . ',\'' . $category_name . '\',' . $id . ',\'' . $tag_id . '\')" href="javascript:void(0);"'; if ($last_seen === null) { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png'); $tooltip = __('Click to watch this record for changes.'); } else { if ($last_seen === true) { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png'); $tooltip = __('You are watching this record, click to stop watching this record for changes.'); } else { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png'); $ev = self::display_events($category_id, $last_seen, $id); $tooltip = __('You are watching this record, click to stop watching this record for changes.') . ($ev ? '<br>' . __('The following changes were made since the last time you were viewing this record:') . '<br><br>' . $ev['events'] : ''); } } $subscribers = self::get_subscribers($category_name, $id); $my_user = Base_AclCommon::get_user(); if ($subscribers) { $icon_on = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"'; $icon_off = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"'; $other_subscribers = array(); foreach ($subscribers as $subscriber) { if ($subscriber == $my_user) { continue; } if (class_exists('CRM_ContactsCommon')) { $contact = CRM_ContactsCommon::get_user_label($subscriber, true); } else { $contact = Base_UserCommon::get_user_login($subscriber); } $notified = self::user_check_if_notified($subscriber, $category_name, $id); $icon2 = $notified === true ? $icon_on : $icon_off; $other_subscribers[] = '<img style="margin-right:4px;" ' . $icon2 . ' /><a>' . Utils_RecordBrowserCommon::no_wrap($contact) . '</a>'; } if ($other_subscribers) { $tooltip .= '<hr />' . implode('<br>', $other_subscribers); } } $tooltip = Utils_TooltipCommon::open_tag_attrs($tooltip); return '<a ' . $href . ' ' . $tooltip . '><img border="0" src="' . $icon . '"></a>'; }
<?php if (!isset($_GET['hash'])) { die(''); } header("Content-Type: text/html; charset=UTF-8"); define('READ_ONLY_SESSION', true); define('CID', false); require_once '../../../../include.php'; ModuleManager::load_modules(); DB::Execute('DELETE FROM user_reset_pass WHERE created_on<%T', array(time() - 3600 * 2)); $user_id = DB::GetOne('SELECT user_login_id FROM user_reset_pass WHERE hash_id=%s', array($_GET['hash'])); if ($user_id == false) { die(__('Request failed. Authentication link is valid for 2 hours since sending request.')); } $pass = generate_password(); $pass_hash = function_exists('password_hash') ? password_hash($pass, PASSWORD_DEFAULT) : md5($pass); if (!DB::Execute('UPDATE user_password SET password=%s WHERE user_login_id=%d', array($pass_hash, $user_id))) { die(__('Unable to update password. Please contact system administrator.')); } if (!Base_User_LoginCommon::send_mail_with_password(Base_UserCommon::get_user_login($user_id), $pass, Base_User_LoginCommon::get_mail($user_id), true)) { die(__('Unable to send e-mail with password. Mail module configuration invalid. Please contact system administrator.')); } DB::Execute('DELETE FROM user_reset_pass WHERE hash_id =%s', array($_GET['hash'])); header('Location: ' . get_epesi_url() . '?' . http_build_query(array('password_recovered' => 1)));
public function body() { $gb = $this->init_module('Utils/GenericBrowser',null,'messages'); $gb->set_table_columns(array( array('name'=>__('Alert on'), 'width'=>20), array('name'=>__('Message'), 'width'=>50), array('name'=>__('Users'), 'width'=>30) )); $data = DB::GetAll('SELECT * FROM utils_messenger_message WHERE page_id=\''.$this->mid.'\''); foreach($data as & $row) { $row['users'] = DB::GetCol('SELECT user_login_id FROM utils_messenger_users WHERE message_id=\''.$row['id'].'\''); $r = & $gb->get_new_row(); if(is_array($this->users)) { $us = ''; foreach($row['users'] as $rr) if(isset($this->users[$rr])) $us .= $this->users[$rr].'<br>'; } else $us = Base_UserCommon::get_user_login($this->users); $r->add_data(Base_RegionalSettingsCommon::time2reg($row['alert_on']),$row['message'],$us); $r->add_action($this->create_callback_href(array($this,'push_box0'),array('edit',array($row),array($this->real_id,$this->callback_method,$this->callback_args,$this->def_date,$this->users))),'Edit'); $r->add_action($this->create_confirm_callback_href(__('Are you sure?'),array($this,'delete_entry'),$row['id']),'Delete'); } $this->display_module($gb); Base_ActionBarCommon::add('add',__('New alert'),$this->create_callback_href(array($this,'push_box0'),array('edit',array(false),array($this->real_id,$this->callback_method,$this->callback_args,$this->def_date,$this->users)))); }
public static function crits_to_words($tab, $crits, $inline_joints=true) { $ret = array(); $or_started = false; foreach($crits as $k=>$v){ self::init($tab, false); $next = ''; $negative = $noquotes = $or_start = $or = false; $operator = '='; while (($k[0]<'a' || $k[0]>'z') && ($k[0]<'A' || $k[0]>'Z') && $k[0]!=':') { if ($k[0]=='!') $negative = true; if ($k[0]=='"') $noquotes = true; if ($k[0]=='(') $or_start = true; if ($k[0]=='|') $or = true; if ($k[0]=='<') $operator = '<'; if ($k[0]=='>') $operator = '>'; if ($k[0]=='~') $operator = DB::like(); if ($k[1]=='=' && $operator!=DB::like()) { $operator .= '='; $k = substr($k, 2); } else $k = substr($k, 1); if (!isset($k[0])) trigger_error('Invalid criteria in build query: missing word. Crits:'.print_r($crits,true), E_USER_ERROR); } $or |= $or_start; if (!isset($r[$k]) && $k[strlen($k)-1]==']') { list($ref, $sub_field) = explode('[', trim($k, ']')); $args = self::$table_rows[self::$hash[$ref]]; $commondata = $args['commondata']; if (!$commondata) { if (!isset($args['ref_table'])) trigger_error('Invalid crits, field '.$ref.' is not a reference; crits: '.print_r($crits,true),E_USER_ERROR); $is_multiselect = ($args['type']=='multiselect'); $tab2 = $tab; $col2 = $k; $tab = $args['ref_table']; $k = $sub_field; $f_dis = self::$table_rows[self::$hash[$ref]]['name']; self::init($tab); $next .= '<b>'._V($f_dis).'</b> '.' is set to record with '; } } if ($k[0]!=':' && $k!=='id' && !isset(self::$table_rows[$k]) && (!isset(self::$hash[$k]) || !isset(self::$table_rows[self::$hash[$k]]))) continue; //failsafe if (!empty($ret)) { if ($or_start) $joint = 'and'; elseif ($or) $joint = 'or'; else $joint = 'and'; if ($inline_joints) $next .= _V($joint).' '; else $ret[] = $joint; } if ($k[0]==':') { switch ($k) { case ':Fav' : $next .= (!$v || ($negative && $v))?__('is not on %sfavorites%s', array('<b>','</b>')):__('is on %sfavorites%s', array('<b>','</b>')); $ret[] = $next; continue 2; case ':Recent' : $next .= (!$v || ($negative && $v))?__('wasn\'t %srecently%s viewed', array('<b>','</b>')):__('was %srecently%s viewed', array('<b>','</b>')); $ret[] = $next; continue 2; case ':Sub' : $next .= (!$v || ($negative && $v))?__('is not %swatched%s', array('<b>','</b>')):__('is %swatched%s', array('<b>','</b>')); $ret[] = $next; continue 2; case ':Created_on' : $next .= '<b>'.__('Created on').'</b> '; break; case ':Created_by' : $next .= '<b>'.__('Created by').'</b> '; break; case ':Edited_on' : $next .= '<b>'.__('Edited on').'</b> '; break; } } else { if ($k=='id') $next .= '<b>'.__('ID').'</b> '; else $next .= '<b>'._V(self::$table_rows[self::$hash[$k]]['name']).'</b> '; } $operand = ''; if (!isset($tab2)) { if ($negative) $operand .= '<i>'.__('is not').'</i> '; else $operand .= __('is').' '; } if ($v==='') { $next .= $operand.__('empty'); } else { switch ($operator) { case '<': $operand .= __('smaller than'); break; case '<=': $operand .= __('smaller or equal to'); break; case '>': $operand .= __('greater than'); break; case '>=': $operand .= __('greater or equal to'); break; case DB::like(): $operand = $negative?__('does not contain'):__('contains'); $v = str_replace(array('||', "'%'"), '', $v); // FIXME doesn't differentiate between "begins with", "contains" or "ends with" break; default: $operand .= __('equal to'); } $operand = $operand.' '; $next .= $operand; switch ($k) { case 'id': if (!is_array($v)) $v = array($v); break; case ':Created_by': $v = array(is_numeric($v)?Base_UserCommon::get_user_login($v):$v); break; case ':Created_on': case ':Edited_on': if (isset(self::$date_values[$v])) $v = array(self::$date_values[$v]); else $v = array(Base_RegionalSettingsCommon::time2reg($v)); break; default: if (!is_array($v) && isset(self::$date_values[$v])) { $v = array(self::$date_values[$v]); break; } if (!is_array($v)) $v = array($v); $args = self::$table_rows[self::$hash[$k]]; if($args['type']=='checkbox' && count($v)==2 && !$v[0] && !$v[1]) unset($v[1]); foreach ($v as $kk=>$vv) { if (!is_numeric($vv) && !$args['commondata'] && isset($args['ref_table'])) { continue; } $v[$kk] = self::get_val($tab, $k, array($k=>$vv), true); } } foreach ($v as $kk=>$vv) $v[$kk] = '<b>'.$vv.'</b>'; $next .= implode(' or ', $v); } $ret[] = $next; if (isset($tab2)) { $tab = $tab2; unset($tab2); } } // $ret[] = print_r($crits,true); return $ret; }
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 static function display_epesi_user($record, $nolink, $desc) { return Base_UserCommon::get_user_login($record['epesi_user']); }
public static function telegram() { $tokens = DB::GetAssoc('SELECT token,single_cache_uid FROM base_notify WHERE telegram=1 AND single_cache_uid is not null'); if (!$tokens) { return; } $ret = array(); $map = array(); $refresh_time = time(); $notified_cache = array(); foreach ($tokens as $token => $uid) { $msgs = array(); if (Base_NotifyCommon::is_refresh_due_telegram($token)) { Base_AclCommon::set_user($uid); $notified_cache[$token] = array(); $notifications = Base_NotifyCommon::get_notifications($token); foreach ($notifications as $module => $module_new_notifications) { foreach ($module_new_notifications as $id => $message) { $notified_cache[$token][$module][] = $id; $title = EPESI . ' ' . Base_NotifyCommon::strip_html($message['title']); $body = Base_NotifyCommon::strip_html($message['body']); //$icon = Base_NotifyCommon::get_icon($module, $message); $msgs[] = array('title' => $title, 'body' => $body); } } } $remote_token = md5($uid . '#' . Base_UserCommon::get_user_login($uid) . '#' . $token); $ret[$remote_token] = $msgs ? $msgs : '0'; $map[$remote_token] = $token; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://telegram.epesicrm.com/"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($ret)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $status = curl_exec($ch); curl_close($ch); $status = @json_decode($status); if (is_array($status)) { foreach ($status as $remove) { if (isset($map[$remove])) { DB::Execute('UPDATE base_notify SET telegram=0 WHERE token=%s', array($map[$remove])); unset($notified_cache[$map[$remove]]); } } foreach ($notified_cache as $token => $nc) { Base_NotifyCommon::set_notified_cache($nc, $token, $refresh_time); } } }
public static function prepare_header(& $tcpdf, $title='', $subject='', $printed_by=true, $logo_filename=null, $l = array()) { if ($title!==null) { if ($logo_filename===null) $logo_filename = Libs_TCPDFCommon::get_logo_filename(); if ($logo_filename!==false && !file_exists($logo_filename)) { $logo_filename = Base_ThemeCommon::get_template_file('Libs/TCPDF','logo-small.png'); } $margins = $tcpdf->getMargins(); if($logo_filename) { $logo_size = getimagesize($logo_filename); $logo_height = $logo_size[1] * PDF_HEADER_LOGO_WIDTH / $logo_size[0]; } else { $logo_height = 0; } $tcpdf->SetHeaderMargin(10); $tcpdf->SetTopMargin($logo_height + $margins['top']); $tcpdf->SetHeaderData($logo_filename, $logo_filename?PDF_HEADER_LOGO_WIDTH:0, $title, $subject); } else { $tcpdf->setPrintHeader(false); } //set some language-dependent strings $l['a_meta_charset'] = "UTF-8"; $l['a_meta_dir'] = "ltr"; $l['a_meta_language'] = "pl"; $who = null; if (ModuleManager::is_installed('CRM/Contacts') >= 0) { $who = CRM_ContactsCommon::get_contact_by_user_id(Acl::get_user()); } if ($who!==null) $who = $who['last_name'].' '.$who['first_name']; else $who= Base_UserCommon::get_user_login(Acl::get_user()); $when = date('Y-m-d H:i:s'); if (!isset($l['w_page'])) { $l['w_page'] = ''; if ($printed_by) $l['w_page'] .= __('Printed with %s by %s, on %s, ',array('EPESI (http://epe.si)',$who,$when)); $l['w_page'] .= __('Page'); } $tcpdf->setLanguageArray($l); self::SetFont($tcpdf, self::$default_font, '', 9); }
die('alert(\'Invalid request\')'); } define('JS_OUTPUT', 1); define('CID', $_POST['cid']); define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); if (!Base_AclCommon::is_user()) { die; } $id = $_POST['id']; $tab = $_POST['tab']; $now = $_POST['date']; $created = Utils_RecordBrowserCommon::get_record($tab, $id, true); $access = Utils_RecordBrowserCommon::get_access($tab, 'view', $created); $created['created_by_login'] = Base_UserCommon::get_user_login($created['created_by']); $field_hash = array(); $edited = DB::GetRow('SELECT ul.login, c.edited_on FROM ' . $tab . '_edit_history AS c LEFT JOIN user_login AS ul ON ul.id=c.edited_by WHERE c.' . $tab . '_id=%d ORDER BY edited_on DESC', array($id)); Utils_RecordBrowserCommon::init($tab); $table_rows = Utils_RecordBrowserCommon::$table_rows; foreach ($table_rows as $field => $args) { $field_hash[$args['id']] = $field; } $ret = DB::Execute('SELECT ul.login, c.id, c.edited_on, c.edited_by FROM ' . $tab . '_edit_history AS c LEFT JOIN user_login AS ul ON ul.id=c.edited_by WHERE c.' . $tab . '_id=%d AND edited_on>%T ORDER BY edited_on DESC, id DESC', array($id, $now)); while ($row = $ret->FetchRow()) { $changed = array(); $ret2 = DB::Execute('SELECT * FROM ' . $tab . '_edit_history_data WHERE edit_id=%d', array($row['id'])); while ($row2 = $ret2->FetchRow()) { if ($row2['field'] != 'id' && (!isset($access[$row2['field']]) || !$access[$row2['field']])) { continue; }
protected function build_single_crit_to_words(Utils_RecordBrowser_CritsSingle $crits) { $value = $crits->get_value(); $operator = $crits->get_operator(); list($field, $subfield) = Utils_RecordBrowser_CritsSingle::parse_subfield($crits->get_field()); $negation = $crits->get_negation(); $field_definition = $this->get_field_definition($field); $subquery_generated = false; if ($subfield) { $tab2 = isset($field_definition['ref_table']) ? $field_definition['ref_table'] : false; $single_tab = !($tab2 == '__RECORDSETS__' || count(explode(',', $tab2)) > 1); if ($tab2 && $single_tab) { $cb = new self($tab2); $cb->enable_html_decoration($this->html_decoration); $value = $cb->to_words(new Utils_RecordBrowser_CritsSingle($subfield, $operator, $value, $negation, $crits->get_raw_sql_value())); $subquery_generated = true; } } if (!is_array($value)) { $value = array($value); } foreach ($value as $k => $v) { if (is_bool($v)) { $value[$k] = $v ? __('true') : __('false'); } elseif ($v === '' || $v === null) { $value[$k] = __('empty'); } else { if ($field == ':Created_on' || $field == ':Edited_on') { if (isset(Utils_RecordBrowserCommon::$date_values[$v])) { $value[$k] = Utils_RecordBrowserCommon::$date_values[$v]; } else { $value[$k] = Base_RegionalSettingsCommon::time2reg($v); } } elseif ($field == ':Created_by') { if (is_numeric($v)) { $value[$k] = Base_UserCommon::get_user_login($v); } } elseif ($field_definition) { $vv = explode('::', $v, 2); if (!(isset($vv[1]) && is_callable($vv)) && (is_numeric($v) || $field_definition['commondata'] || !isset($field_definition['ref_table']))) { $new_val = Utils_RecordBrowserCommon::get_val($this->tab, $field, array($field => $v), true); if ($new_val) { $value[$k] = $new_val; } } } } if ($this->html_decoration) { if (!$subquery_generated) { $value[$k] = '<strong>' . $value[$k] . '</strong>'; } } } if ($operator == '!=') { $negation ^= $operator == '!='; $operator = '='; } switch ($field) { case ':Fav': $field = __('Favorite status'); break; case ':Recent': $field = __('Recently viewed'); break; case ':Sub': $field = __('Subscription status'); break; case ':Created_by': $field = __('Created by'); break; case ':Created_on': $field = __('Created on'); break; case ':Edited_on': $field = __('Edited on'); break; case 'id': $field = __('ID'); break; default: if ($field_definition) { $field = _V($field_definition['name']); } } if ($this->html_decoration) { $field = "<strong>{$field}</strong>"; } if ($subquery_generated) { $operand = __('is set to record where'); } else { switch ($operator) { case '<': $operand = $negation ? __('is not smaller than') : __('is smaller than'); break; case '<=': $operand = $negation ? __('is not smaller or equal to') : __('is smaller or equal to'); break; case '>': $operand = $negation ? __('is not greater than') : __('is greater than'); break; case '>=': $operand = $negation ? __('is not greater than') : __('is greater or equal to'); break; case 'LIKE': $operand = $negation ? __('is not like') : __('is like'); break; case 'NOT LIKE': $operand = $negation ? __('is like') : __('is not like'); break; default: $operand = $negation ? __('is not equal to') : __('is equal to'); } } $value_str = implode(' ' . __('or') . ' ', $value); if (count($value) > 1) { $value_str = "({$value_str})"; } $ret = "{$field} {$operand} {$value_str}"; if (!$this->html_decoration) { $ret = html_entity_decode($ret); } return array('str' => $ret, 'multiple' => false); }