public static function applet_info_format($r) { // Build array representing 2-column tooltip // Format: array (Label,value) $access = Utils_CommonDataCommon::get_translated_array('CRM/Access'); $priority = Utils_CommonDataCommon::get_translated_array('CRM/Priority'); $status = Utils_CommonDataCommon::get_translated_array('CRM/Status'); $args = array(__('Meeting') => '<b>' . $r['title'] . '</b>', __('Description') => $r['description'], __('Assigned to') => Utils_RecordBrowserCommon::get_val('crm_meeting', 'Employees', $r, true), __('Customers') => Utils_RecordBrowserCommon::get_val('crm_meeting', 'Customers', $r, true), __('Status') => $status[$r['status']], __('Date') => $r['duration'] >= 0 ? Base_RegionalSettingsCommon::time2reg($r['date'] . ' ' . date('H:i:s', strtotime($r['time']))) : Base_RegionalSettingsCommon::time2reg($r['date'], false), __('Duration') => $r['duration'] >= 0 ? Base_RegionalSettingsCommon::seconds_to_words($r['duration']) : '---', __('Permission') => $access[$r['permission']], __('Priority') => $priority[$r['priority']]); $bg_color = ''; switch ($r['priority']) { case 0: $bg_color = '#FFFFFF'; break; // low priority // low priority case 1: $bg_color = '#FFFFD5'; break; // medium // medium case 2: $bg_color = '#FFD5D5'; break; // high } // Pass 1 argument: array containing pairs: label/value //return Utils_TooltipCommon::format_info_tooltip($args); $ret = array('notes' => Utils_TooltipCommon::format_info_tooltip($args)); if ($bg_color) { $ret['row_attrs'] = 'style="background:' . $bg_color . ';"'; } return $ret; }
public static function mobile_rb_edit($tab, $id) { if ($id === false) { $rec = array(); } else { $rec = self::get_record($tab, $id); } $cols = Utils_RecordBrowserCommon::init($tab); $defaults = array(); if ($id === false) { $mode = 'add'; $access = array(); $defaults = self::record_processing($tab, $defaults, 'adding'); } else { $mode = 'edit'; $access = Utils_RecordBrowserCommon::get_access($tab, 'view', $rec); if (is_array($access)) { foreach ($access as $k => $v) { if (!$v) { unset($rec[$k]); } } } $defaults = $rec = self::record_processing($tab, $rec, 'editing'); } $QFfield_callback_table = array(); $ret = DB::Execute('SELECT * FROM ' . $tab . '_callback WHERE freezed=0'); while ($row = $ret->FetchRow()) { $QFfield_callback_table[$row['field']] = $row['callback']; } $defaults = array_merge($defaults, $_SESSION['rb_' . $tab . '_defaults']); $qf = new HTML_QuickForm('rb_edit', 'post', 'mobile.php?' . http_build_query($_GET)); foreach ($cols as $field => $args) { if (isset($access[$args['id']]) && !$access[$args['id']]) { continue; } if (isset($rec[$args['id']])) { $val = $rec[$args['id']]; } elseif (isset($defaults[$args['id']])) { $val = $defaults[$args['id']]; } else { $val = null; } $label = _V($args['name']); // TRSL if (isset($QFfield_callback_table[$field])) { $mobile_rb = new Utils_RecordBrowserMobile($tab, $rec); self::call_QFfield_callback($QFfield_callback_table[$field], $qf, $args['id'], $label, $mode, $val, $args, $mobile_rb, null); if ($mode == 'edit') { unset($defaults[$args['id']]); } continue; } switch ($args['type']) { case 'calculated': $qf->addElement('static', $args['id'], $label); if (!is_array($rec)) { $values = $defaults; } else { $values = $rec; if (is_array($defaults)) { $values = $values + $defaults; } } if (!isset($values[$args['id']])) { $values[$args['id']] = ''; } $val = Utils_RecordBrowserCommon::get_val($tab, $field, $values, true, $args); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'integer': case 'float': $qf->addElement('text', $args['id'], $label); if ($args['type'] == 'integer') { $qf->addRule($args['id'], __('Only integer numbers are allowed.'), 'regex', '/^[0-9]*$/'); } else { $qf->addRule($args['id'], __('Only numbers are allowed.'), 'numeric'); } if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'checkbox': $qf->addElement('checkbox', $args['id'], $label, ''); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'currency': $qf->addElement('currency', $args['id'], $label); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'text': $qf->addElement('text', $args['id'], $label, array('maxlength' => $args['param'])); $qf->addRule($args['id'], __('Maximum length for this field is %s characters.', array($args['param'])), 'maxlength', $args['param']); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'long text': $qf->addElement('textarea', $args['id'], $label, array('maxlength' => 200)); $qf->addRule($args['id'], __('Maximum length for this field in mobile edition is 200 chars.'), 'maxlengt', 200); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'commondata': $param = explode('::', $args['param']['array_id']); foreach ($param as $k => $v) { if ($k != 0) { $param[$k] = self::get_field_id($v); } } if (count($param) == 1) { $qf->addElement($args['type'], $args['id'], $label, $param, array('empty_option' => true, 'id' => $args['id'], 'order_by_key' => $args['param']['order_by_key'])); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } } break; case 'select': $comp = array(); $ref = explode(';', $args['param']); if (isset($ref[1])) { $crits_callback = $ref[1]; } else { $crits_callback = null; } if (isset($ref[2])) { $multi_adv_params = call_user_func(explode('::', $ref[2])); } else { $multi_adv_params = null; } if (!isset($multi_adv_params) || !is_array($multi_adv_params)) { $multi_adv_params = array(); } if (!isset($multi_adv_params['order'])) { $multi_adv_params['order'] = array(); } if (!isset($multi_adv_params['cols'])) { $multi_adv_params['cols'] = array(); } if (!isset($multi_adv_params['format_callback'])) { $multi_adv_params['format_callback'] = array(); } $ref = $ref[0]; @(list($tab2, $col) = explode('::', $ref)); if (!isset($col)) { trigger_error($field); } if ($tab2 == '__RECORDSETS__') { continue; } //skip multi recordsets chained selector if ($tab2 == '__COMMON__') { $data = Utils_CommonDataCommon::get_translated_tree($col); if (!is_array($data)) { $data = array(); } $comp = $comp + $data; } else { if (isset($crits_callback)) { $crit_callback = explode('::', $crits_callback); if (is_callable($crit_callback)) { $crits = call_user_func($crit_callback, false, $rec); $adv_crits = call_user_func($crit_callback, true, $rec); } else { $crits = $adv_crits = array(); } if ($adv_crits === $crits) { $adv_crits = null; } if ($adv_crits !== null) { continue; //skip record picker } } else { $crits = array(); } $col = explode('|', $col); $col_id = array(); foreach ($col as $c) { $col_id[] = self::get_field_id($c); } $records = Utils_RecordBrowserCommon::get_records($tab2, $crits, empty($multi_adv_params['format_callback']) ? $col_id : array(), !empty($multi_adv_params['order']) ? $multi_adv_params['order'] : array()); $ext_rec = array(); if (isset($rec[$args['id']])) { if (!is_array($rec[$args['id']])) { if ($rec[$args['id']] != '') { $rec[$args['id']] = array($rec[$args['id']] => $rec[$args['id']]); } else { $rec[$args['id']] = array(); } } } if (isset($defaults[$args['id']])) { if (!is_array($defaults[$args['id']])) { $rec[$args['id']][$defaults[$args['id']]] = $defaults[$args['id']]; } else { foreach ($defaults[$args['id']] as $v) { $rec[$args['id']][$v] = $v; } } } $single_column = count($col_id) == 1; if (isset($rec[$args['id']])) { $ext_rec = array_flip($rec[$args['id']]); foreach ($ext_rec as $k => $v) { $c = Utils_RecordBrowserCommon::get_record($tab2, $k); if (!empty($multi_adv_params['format_callback'])) { $n = call_user_func($multi_adv_params['format_callback'], $c); } else { if ($single_column) { $n = $c[$col_id[0]]; } else { $n = array(); foreach ($col_id as $cid) { $n[] = $c[$cid]; } $n = implode(' ', $n); } } $comp[$k] = $n; } } if (!empty($multi_adv_params['order'])) { natcasesort($comp); } foreach ($records as $k => $v) { if (!empty($multi_adv_params['format_callback'])) { $n = call_user_func($multi_adv_params['format_callback'], $v); } else { // $n = $v[$col_id]; if ($single_column) { $n = $v[$col_id[0]]; } else { $n = array(); foreach ($col_id as $cid) { $n[] = $v[$cid]; } $n = implode(' ', $n); } } $comp[$k] = $n; unset($ext_rec[$v['id']]); } if (empty($multi_adv_params['order'])) { natcasesort($comp); } } if ($args['type'] === 'select') { $comp = array('' => '---') + $comp; } $qf->addElement($args['type'], $args['id'], $label, $comp, array('id' => $args['id'])); if ($id !== false) { $qf->setDefaults(array($args['id'] => $rec[$args['id']])); } break; case 'date': $qf->addElement('date', $args['id'], $label, array('format' => 'd M Y', 'minYear' => date('Y') - 95, 'maxYear' => date('Y') + 5, 'addEmptyOption' => true, 'emptyOptionText' => '--')); if ($val) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'timestamp': $qf->addElement('date', $args['id'], $label, array('format' => 'd M Y H:i', 'minYear' => date('Y') - 95, 'maxYear' => date('Y') + 5, 'addEmptyOption' => true, 'emptyOptionText' => '--')); if ($val) { $default = Base_RegionalSettingsCommon::time2reg($val, true, true, true, false); $qf->setDefaults(array($args['id'] => $default)); } break; case 'time': $qf->addElement('date', $args['id'], $label, array('format' => 'H:i', 'addEmptyOption' => true, 'emptyOptionText' => '--')); if ($val) { $default = Base_RegionalSettingsCommon::time2reg($val, true, true, true, false); $qf->setDefaults(array($args['id'] => $default)); } break; case 'multiselect': //ignore if ($id === false) { continue; } $val = Utils_RecordBrowserCommon::get_val($tab, $field, $rec, true, $args); if ($val === '') { continue; } $qf->addElement('static', $args['id'], $label); $qf->setDefaults(array($args['id'] => $val)); unset($defaults[$args['id']]); break; } if ($args['required']) { $qf->addRule($args['id'], __('Field required'), 'required'); } } $qf->addElement('submit', 'submit_button', __('Save'), IPHONE ? 'class="button white"' : ''); if ($qf->validate()) { $values = $qf->exportValues(); foreach ($cols as $v) { if ($v['type'] == 'checkbox' && !isset($values[$v['id']])) { $values[$v['id']] = 0; } elseif ($v['type'] == 'date') { if (is_array($values[$v['id']]) && $values[$v['id']]['Y'] !== '' && $values[$v['id']]['M'] !== '' && $values[$v['id']]['d'] !== '') { $values[$v['id']] = sprintf("%d-%02d-%02d", $values[$v['id']]['Y'], $values[$v['id']]['M'], $values[$v['id']]['d']); } else { $values[$v['id']] = ''; } } elseif ($v['type'] == 'timestamp') { if ($values[$v['id']]['Y'] !== '' && $values[$v['id']]['M'] !== '' && $values[$v['id']]['d'] !== '' && $values[$v['id']]['H'] !== '' && $values[$v['id']]['i'] !== '') { $timestamp = $values[$v['id']]['Y'] . '-' . $values[$v['id']]['M'] . '-' . $values[$v['id']]['d'] . ' ' . $values[$v['id']]['H'] . ':' . $values[$v['id']]['i']; $values[$v['id']] = Base_RegionalSettingsCommon::reg2time($timestamp, true); } else { $values[$v['id']] = ''; } } elseif ($v['type'] == 'time') { if ($values[$v['id']]['H'] !== '' && $values[$v['id']]['i'] !== '') { $time = recalculate_time(date('Y-m-d'), $values[$v['id']]); $timestamp = Base_RegionalSettingsCommon::reg2time(date('1970-01-01 H:i:s', $time), true); $values[$v['id']] = date('1970-01-01 H:i:s', $timestamp); } else { $values[$v['id']] = ''; } } } foreach ($defaults as $k => $v) { if (!isset($values[$k])) { $values[$k] = $v; } } if ($id !== false) { $values['id'] = $id; Utils_RecordBrowserCommon::update_record($tab, $id, $values); } else { $id = Utils_RecordBrowserCommon::new_record($tab, $values); } return false; } $renderer =& $qf->defaultRenderer(); $qf->accept($renderer); print $renderer->toHtml(); }
/** * Get field string representation - display callback gets called. * @param string $field Field id, e.g. 'first_name' * @param array|RBO_Record $record Records array or object * @param bool $nolink Do not create link * @return string String representation of field value */ public function get_val($field, $record, $nolink = false) { if (is_object($record) && $record instanceof RBO_Record) { $record = $record->to_array(); } return Utils_RecordBrowserCommon::get_val($this->tab, $field, $record, $nolink); }
public function view_entry($mode='view', $id = null, $defaults = array(), $show_actions=true) { Base_HelpCommon::screen_name('rb_'.$mode.'_'.$this->tab); if (isset($_SESSION['client']['recordbrowser']['admin_access'])) Utils_RecordBrowserCommon::$admin_access = true; self::$mode = $mode; if ($this->navigation_executed) { $this->navigation_executed = false; return true; } if ($this->check_for_jump()) return; $theme = $this->init_module('Base/Theme'); if ($this->isset_module_variable('id')) { $id = $this->get_module_variable('id'); $this->unset_module_variable('id'); } self::$browsed_records = null; Utils_RecordBrowserCommon::$cols_order = array(); $js = ($mode!='view'); $time = microtime(true); if ($this->is_back()) { self::$clone_result = 'canceled'; return $this->back(); } $this->init(); if (is_numeric($id)) { $id = intVal($id); self::$last_record = $this->record = Utils_RecordBrowserCommon::get_record($this->tab, $id, $mode!=='edit'); } else { self::$last_record = $this->record = $id; $id = intVal($this->record['id']); } if ($id===0) $id = null; if ($id!==null && is_numeric($id)) Utils_WatchdogCommon::notified($this->tab,$id); if($mode=='add') { foreach ($defaults as $k=>$v) $this->custom_defaults[$k] = $v; foreach($this->table_rows as $field => $args) if (!isset($this->custom_defaults[$args['id']])) $this->custom_defaults[$args['id']] = $args['type'] == 'multiselect' ? array() : ''; $this->custom_defaults['created_by'] = Acl::get_user(); } $access = $this->get_access($mode=='history'?'view':$mode, isset($this->record)?$this->record:$this->custom_defaults); if ($mode=='edit' || $mode=='add') $this->view_fields_permission = $this->get_access('view', isset($this->record)?$this->record:$this->custom_defaults); else $this->view_fields_permission = $access; if ($mode!='add' && (!$access || $this->record==null)) { if (Base_AclCommon::i_am_admin()) { Utils_RecordBrowserCommon::$admin_access = true; $access = $this->get_access($mode, isset($this->record)?$this->record:$this->custom_defaults); if ($mode=='edit' || $mode=='add') $this->view_fields_permission = $this->get_access('view', isset($this->record)?$this->record:$this->custom_defaults); else $this->view_fields_permission = $access; } else { print(__('You don\'t have permission to view this record.')); if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) { Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}'); } return true; } } if ($mode=='add' && !$access) { print(__('You don\'t have permission to perform this action.')); if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) { Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}'); } return true; } if($mode == 'add' || $mode == 'edit') { $theme -> assign('click2fill', '<div id="c2fBox"></div>'); load_js('modules/Utils/RecordBrowser/click2fill.js'); eval_js('initc2f("'.__('Scan/Edit').'","'.__('Paste data here with Ctrl-v, click button below, then click on separated words in specific order and click in text field where you want put those words. They will replace text in that field.').'")'); Base_ActionBarCommon::add('clone', __('Click 2 Fill'), 'href="javascript:void(0)" onclick="c2f()"'); } // if ($mode!='add' && !$this->record[':active'] && !Base_AclCommon::i_am_admin()) return $this->back(); $tb = $this->init_module('Utils/TabbedBrowser', null, 'recordbrowser_addons'); if ($mode=='history') $tb->set_inline_display(); self::$tab_param = $tb->get_path(); $form = $this->init_module('Libs/QuickForm',null, $mode); if(Base_User_SettingsCommon::get($this->get_type(), 'confirm_leave') && ($mode == 'add' || $mode == 'edit')) $form->set_confirm_leave_page(); $this->form = $form; if($mode!='add') Utils_RecordBrowserCommon::add_recent_entry($this->tab, Acl::get_user(),$id); $dp = Utils_RecordBrowserCommon::record_processing($this->tab, $mode!='add'?$this->record:$this->custom_defaults, ($mode=='view' || $mode=='history')?'view':$mode.'ing'); if($dp===false) return false; if (is_array($dp)) $defaults = $this->custom_defaults = self::$last_record = $this->record = $dp; if (self::$last_record===null) self::$last_record = $defaults; if($mode=='add') $form->setDefaults($defaults); switch ($mode) { case 'add': $this->action = _M('New record'); break; case 'edit': $this->action = _M('Edit record'); break; case 'view': $this->action = _M('View record'); break; case 'history': $this->action = _M('Record history view'); break; } $this->prepare_view_entry_details($this->record, $mode=='history'?'view':$mode, $id, $form); if ($mode==='edit' || $mode==='add') foreach($this->table_rows as $field => $args) { if (!$access[$args['id']]) $form->freeze($args['id']); } if ($form->exportValue('submited') && $form->validate()) { $values = $form->exportValues(); foreach ($defaults as $k=>$v) { if (!isset($values[$k]) && isset($this->view_fields_permission[$k]) && !$this->view_fields_permission[$k]) $values[$k] = $v; if (isset($access[$k]) && !$access[$k]) $values[$k] = $v; } foreach ($this->table_rows as $v) { if ($v['type']=='checkbox' && !isset($values[$v['id']])) $values[$v['id']]=0; } $values['id'] = $id; foreach ($this->custom_defaults as $k=>$v) if (!isset($values[$k])) $values[$k] = $v; if ($mode=='add') { $id = Utils_RecordBrowserCommon::new_record($this->tab, $values); self::$clone_result = $id; self::$clone_tab = $this->tab; return $this->back(); } $time_from = date('Y-m-d H:i:s', $this->get_module_variable('edit_start_time')); $ret = DB::Execute('SELECT * FROM '.$this->tab.'_edit_history WHERE edited_on>=%T AND edited_on<=%T AND '.$this->tab.'_id=%d',array($time_from, date('Y-m-d H:i:s'), $id)); if ($ret->EOF) { $this->update_record($id,$values); return $this->back(); } $this->dirty_read_changes($id, $time_from); } $form->add_error_closing_buttons(); if (($mode=='edit' || $mode=='add') && $show_actions!==false) { Utils_ShortcutCommon::add(array('Ctrl','S'), 'function(){'.$form->get_submit_form_js().'}'); } if ($mode=='edit') { $this->set_module_variable('edit_start_time',$time); } if ($show_actions!==false) { if ($mode=='view') { if ($this->get_access('edit',$this->record)) { Base_ActionBarCommon::add('edit', __('Edit'), $this->create_callback_href(array($this,'navigate'), array('view_entry','edit',$id))); Utils_ShortcutCommon::add(array('Ctrl','E'), 'function(){'.$this->create_callback_href_js(array($this,'navigate'), array('view_entry','edit',$id)).'}'); } if ($this->get_access('delete',$this->record)) { Base_ActionBarCommon::add('delete', __('Delete'), $this->create_confirm_callback_href(__('Are you sure you want to delete this record?'),array($this,'delete_record'),array($id))); } if ($this->get_access('add',$this->record)) { Base_ActionBarCommon::add('clone',__('Clone'), $this->create_confirm_callback_href(__('You are about to create a copy of this record. Do you want to continue?'),array($this,'clone_record'),array($id))); } /** @var Base_Print_Printer $printer */ $printer = Utils_RecordBrowserCommon::get_printer($this->tab); if ($printer) { Base_ActionBarCommon::add('print', __('Print'), $printer->get_href(array('tab' => $this->tab, 'record_id' => $this->record['id']))); } if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); } elseif($mode!='history') { Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href()); Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href()); } //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}'); } if ($mode!='add') { $theme -> assign('info_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(Utils_RecordBrowserCommon::get_html_record_info($this->tab, $id)).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','info.png').'" /></a>'); $row_data= array(); if ($mode!='history') { if ($this->favorites) $theme -> assign('fav_tooltip', Utils_RecordBrowserCommon::get_fav_button($this->tab, $id)); if ($this->watchdog) $theme -> assign('subscription_tooltip', Utils_WatchdogCommon::get_change_subscription_icon($this->tab, $id)); if ($this->full_history) { $info = Utils_RecordBrowserCommon::get_record_info($this->tab, $id); if ($info['edited_on']===null) $theme -> assign('history_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('This record was never edited')).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','history_inactive.png').'" /></a>'); else $theme -> assign('history_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('Click to view edit history of currently displayed record')).' '.$this->create_callback_href(array($this,'navigate'), array('view_edit_history', $id)).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','history.png').'" /></a>'); } if ($this->clipboard_pattern) { $theme -> assign('clipboard_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('Click to export values to copy')).' '.Libs_LeightboxCommon::get_open_href('clipboard').'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','clipboard.png').'" /></a>'); $text = $this->clipboard_pattern; $record = Utils_RecordBrowserCommon::get_record($this->tab, $id); /* for every field name store its value */ $data = array(); foreach($this->table_rows as $val) { $fval = Utils_RecordBrowserCommon::get_val($this->tab, $val['id'], $record, true); if(strlen($fval)) $data[$val['id']] = $fval; } /* some complicate preg match to find every occurence * of %{ .. {f_name} .. } pattern */ if (preg_match_all('/%\{(([^%\}\{]*?\{[^%\}\{]+?\}[^%\}\{]*?)+?)\}/', $text, $match)) { // match for all patterns %{...{..}...} foreach ($match[0] as $k => $matched_string) { $text_replace = $match[1][$k]; $changed = false; while(preg_match('/\{(.+?)\}/', $text_replace, $second_match)) { // match for keys in braces {key} $replace_value = ''; if(array_key_exists($second_match[1], $data)) { $replace_value = $data[$second_match[1]]; $changed = true; } $text_replace = str_replace($second_match[0], $replace_value, $text_replace); } if(! $changed ) $text_replace = ''; $text = str_replace($matched_string, $text_replace, $text); } } load_js("modules/Utils/RecordBrowser/selecttext.js"); /* remove all php new lines, replace <br>|<br/> to new lines and quote all special chars */ $ftext = htmlspecialchars(preg_replace('#<[bB][rR]/?>#', "\n", str_replace("\n", '', $text))); $flash_copy = '<object width="60" height="20">'. '<param name="FlashVars" value="txtToCopy='.$ftext.'">'. '<param name="movie" value="'.$this->get_module_dir().'copyButton.swf">'. '<embed src="'.$this->get_module_dir().'copyButton.swf" flashvars="txtToCopy='.$ftext.'" width="60" height="20">'. '</embed>'. '</object>'; $text = '<h3>'.__('Click Copy under the box or move mouse over box below to select text and hit Ctrl-c to copy it.').'</h3><div onmouseover="fnSelect(this)" style="border: 1px solid gray; margin: 15px; padding: 20px;">'.$text.'</div>'.$flash_copy; Libs_LeightboxCommon::display('clipboard',$text,__('Copy')); } } } if ($mode=='view') { $dp = Utils_RecordBrowserCommon::record_processing($this->tab, $this->record, 'display'); if ($dp && is_array($dp)) foreach ($dp as $k=>$v) $theme->assign($k, $v); } if ($mode=='view' || $mode=='history') $form->freeze(); $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty(); $form->accept($renderer); $data = $renderer->toArray(); print($data['javascript'].'<form '.$data['attributes'].'>'.$data['hidden']."\n"); $last_page = DB::GetOne('SELECT MIN(position) FROM '.$this->tab.'_field WHERE type = \'page_split\' AND field != \'General\''); if (!$last_page) $last_page = DB::GetOne('SELECT MAX(position) FROM '.$this->tab.'_field')+1; $label = DB::GetRow('SELECT field, param FROM '.$this->tab.'_field WHERE position=%s', array($last_page)); if ($label) { $cols = $label['param']; $label = $label['field']; } else $cols = false; $this->view_entry_details(1, $last_page, $data, $theme, true); $ret = DB::Execute('SELECT position, field, param FROM '.$this->tab.'_field WHERE type = \'page_split\' AND position > %d ORDER BY position', array($last_page)); $row = true; if ($mode=='view') print("</form>\n"); $tab_counter=-1; $additional_tabs = 0; $default_tab = null; while ($row) { $row = $ret->FetchRow(); if ($row) $pos = $row['position']; else $pos = DB::GetOne('SELECT MAX(position) FROM '.$this->tab.'_field WHERE active=1')+1; $valid_page = false; $hide_page = ($mode=='view' && Base_User_SettingsCommon::get('Utils/RecordBrowser','hide_empty')); foreach($this->table_rows as $field => $args) { if (!isset($data[$args['id']]) || $data[$args['id']]['type']=='hidden') continue; if ($args['position'] >= $last_page && ($pos+1 == -1 || $args['position'] < $pos+1)) { $valid_page = true; if ($hide_page && !$this->field_is_empty($this->record, $args['id'])) $hide_page = false; break; } } if ($valid_page && $pos - $last_page>1 && !isset($this->hide_tab[$label])) { $tb->set_tab(_V($label),array($this,'view_entry_details'), array($last_page, $pos+1, $data, null, false, $cols, _V($label)), $js); // TRSL if ($hide_page) { eval_js('$("'.$tb->get_tab_id(_V($label)).'").style.display="none";'); if ($default_tab===($tab_counter+1) || $tb->get_tab()==($tab_counter+1)) $default_tab = $tab_counter+2; } else $additional_tabs++; } $cols = $row['param']; $last_page = $pos; if ($row) $label = $row['field']; $tab_counter++; } if ($default_tab!==null) $tb->set_default_tab($default_tab); if ($mode!='history') { $ret = DB::Execute('SELECT * FROM recordbrowser_addon WHERE tab=%s AND enabled=1 ORDER BY pos', array($this->tab)); $addons_mod = array(); while ($row = $ret->FetchRow()) { if (ModuleManager::is_installed($row['module'])==-1) continue; if (is_callable(explode('::',$row['label']))) { $result = call_user_func(explode('::',$row['label']), $this->record, $this); if (!isset($result['show'])) $result['show']=true; if (($mode=='add' || $mode=='edit') && (!isset($result['show_in_edit']) || !$result['show_in_edit'])) continue; if ($result['show']==false) continue; if (!isset($result['label'])) $result['label']=''; $row['label'] = $result['label']; } else { if ($mode=='add' || $mode=='edit') continue; $labels = explode('#',$row['label']); foreach($labels as $i=>$label) $labels[$i] = _V($label); // translate labels from database $row['label'] = implode('#',$labels); } $mod_id = md5(serialize($row)); if (method_exists($row['module'].'Common',$row['func'].'_access') && !call_user_func(array($row['module'].'Common',$row['func'].'_access'), $this->record, $this)) continue; $addons_mod[$mod_id] = $this->init_module($row['module']); if (!method_exists($addons_mod[$mod_id],$row['func'])) $tb->set_tab($row['label'],array($this, 'broken_addon'), array(), $js); else $tb->set_tab($row['label'],array($this, 'display_module'), array(& $addons_mod[$mod_id], array($this->record, $this), $row['func']), $js); } } if ($additional_tabs==0 && ($mode=='add' || $mode=='edit' || $mode=='history')) print("</form>\n"); $this->display_module($tb); $tb->tag(); foreach ($this->fields_in_tabs as $label=>$fields) { $highlight = false; foreach ($fields as $f) { $err = $form->getElementError($f); if ($err) { $highlight = true; break; } } if ($highlight) $tb->tab_icon($label, Base_ThemeCommon::get_template_file('Utils_RecordBrowser','notify_error.png')); } if ($this->switch_to_addon) { $this->set_module_variable('switch_to_addon',false); if($tab_counter<0) $tab_counter=0; $ret = DB::Execute('SELECT * FROM recordbrowser_addon WHERE tab=%s AND enabled=1 ORDER BY pos', array($this->tab)); while ($row = $ret->FetchRow()) { if (ModuleManager::is_installed($row['module'])==-1) continue; if (is_callable(explode('::',$row['label']))) { $result = call_user_func(explode('::',$row['label']), $this->record,$this); if (isset($result['show']) && $result['show']==false) continue; $row['label'] = $result['label']; } if ($row['label']==$this->switch_to_addon) $this->switch_to_addon = $tab_counter; $tab_counter++; } $tb->switch_tab($this->switch_to_addon); location(array()); } if ($additional_tabs!=0 && ($mode=='add' || $mode=='edit' || $mode=='history')) print("</form>\n"); return true; } //view_entry
define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); if (!Acl::is_user()) { die('Not logged in'); } $rec = Utils_RecordBrowserCommon::get_record('rc_mails', $_GET['id']); if (!$rec) { die('Invalid e-mail id.'); } $access_fields = Utils_RecordBrowserCommon::get_access('rc_mails', 'view', $rec); if (!isset($access_fields['body']) || !$access_fields['body']) { die('Access forbidden'); } if (isset($_GET['field']) && $_GET['field'] == 'headers') { $html = Utils_RecordBrowserCommon::get_val('rc_mails', 'headers_data', $rec, false, null); } else { $html = $rec['body']; } if (!$html) { die('Invalid e-mail id.'); } $images = DB::GetAssoc('SELECT mime_id,name FROM rc_mails_attachments WHERE mail_id=%d AND attachment=1 AND type ' . DB::like() . ' %s', array($_GET['id'], 'image/%')); foreach ($images as $k => &$n) { $n = '<img src="get.php?' . http_build_query(array('mime_id' => $k, 'mail_id' => $_GET['id'])) . '" onload="fix_height();"/><br />'; } $html = str_ireplace('<img ', '<img onload="fix_height();" ', $html); $html = str_replace('__MAIL_ID__', $_GET['id'], $html); $html = preg_replace("/<a([^>]*)>(.*)<\\/a>/i", '<a$1 target="_blank">$2</a>', $html); $html = '<html>' . '<head><meta http-equiv=Content-Type content="text/html; charset=utf-8" />' . '<script type="text/javascript">function fix_height(){parent.$("rc_mail_body").height = Math.max(document.body.offsetHeight,document.body.scrollHeight)+30;}</script>' . '</head><body>' . $html . ($images ? '<hr />' . implode('<br />', $images) : '') . '<script type="text/javascript">fix_height();</script>' . '</body>' . '</html>'; print $html;
} $rec = array($r['id']); $details = Utils_RecordBrowserCommon::get_record_info($tab, $r['id']); $rec[] = $details['created_on']; $rec[] = Base_UserCommon::get_user_label($details['created_by'], true); $rec[] = $details['edited_on']; $rec[] = $details['edited_by'] ? Base_UserCommon::get_user_label($details['edited_by'], true) : ''; foreach ($tab_info as $field_name => $v) { if (!$v['export']) { continue; } ob_start(); if (!isset($has_access[$v['id']]) || !$has_access[$v['id']]) { $val = ''; } else { $val = Utils_RecordBrowserCommon::get_val($tab, $field_name, $r, true, $v); } ob_end_clean(); $val = str_replace(' ', ' ', htmlspecialchars_decode(strip_tags(preg_replace('/\\<[Bb][Rr]\\/?\\>/', "\n", $val)))); if ($v['style'] == 'currency') { $val = str_replace(' ', '_', $val); $val = explode(';', $val); if (isset($val[1])) { $final = array(); foreach ($val as $v) { $v = explode('_', $v); if (isset($v[1])) { $final[] = rb_csv_export_format_currency_value($v[0], $v[1]) . ' ' . $currency_codes[$v[1]]; } } $rec[] = implode('; ', $final);
public static function note_title_with_attached_to($row, $nolink = false) { $note = self::description_callback($row, $nolink); $of = Utils_RecordBrowserCommon::get_val('utils_attachment', 'attached_to', $row, $nolink); $of = " [ $of ]"; return $note . $of; }
public static function watchdog_label($rid = null, $events = array(), $details = true) { if ($rid !== null && !self::get_access($rid)) { return null; } $ret = Utils_RecordBrowserCommon::watchdog_label('utils_attachment', __('Note'), $rid, $events, null, $details); if ($rid && $ret) { $r = Utils_RecordBrowserCommon::get_record('utils_attachment', $rid); $of = Utils_RecordBrowserCommon::get_val('utils_attachment', 'attached_to', $r); $ret['title'] .= " [ {$of} ]"; } return $ret; }
$letter_col = current($cols_out); $letter_col = $letter_col['record']['id']; print '<ul>'; } else { $data_out = array(); } foreach ($data as $v) { if (IPHONE) { $row_sort = ''; $row_info = ''; } else { $row = array(); } foreach ($cols_out as $col) { $i = array_key_exists($col['record']['id'], $info); $val = Utils_RecordBrowserCommon::get_val($table, $col['key'], $v, IPHONE, $col['record']); if (IPHONE) { if ($val === '') { continue; } if ($type != 'recent' && $col['record']['id'] == $letter_col && $letter !== $val[0]) { $letter = $val[0]; print '</ul><h4>' . $letter . '</h4><ul>'; } if ($i) { $row_info .= ($info[$col['record']['id']] ? $col['name'] . ': ' : '') . $val . '<br>'; } else { $row_sort .= $val . ' '; } } else { $row[] = $val;
continue; } $changed[$row2['field']] = $row2['old_value']; $last_row = $row2; } foreach ($changed as $k => $v) { if ($k != 'id') { if (!isset($field_hash[$k])) { continue; } if (!isset($table_rows[$field_hash[$k]])) { continue; } if ($table_rows[$field_hash[$k]]['type'] == 'multiselect') { $v = Utils_RecordBrowserCommon::decode_multi($v); } $created[$k] = $v; } } } foreach ($table_rows as $field => $args) { ob_start(); $val = @Utils_RecordBrowserCommon::get_val($tab, $field, $created, false, $args); if (!$val) { $val = Utils_RecordBrowserCommon::get_val($tab, $field, $created, true, $args); } ob_end_clean(); print 'if($("_' . $args['id'] . '__data"))$("_' . $args['id'] . '__data").innerHTML = "' . Epesi::escapeJS($val) . '";'; // if (!$access[$args['id']]) continue; // if ($created[$args['id']] !== '') $created[$args['id']] = $val; // TRSL }
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); }