<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
$mails = Utils_RecordBrowserCommon::get_records('rc_mails');
foreach ($mails as $m) {
    Utils_RecordBrowserCommon::update_record('rc_mails', $m['id'], array('message_id' => ltrim(rtrim($m['message_id'], '>'), '<')));
}
foreach ($mails as $m) {
    CRM_RoundcubeCommon::create_thread($m['id']);
}
示例#2
0
 public function update_record($id,$values) {
     Utils_RecordBrowserCommon::update_record($this->tab, $id, $values);
 }
示例#3
0
 private static function copy_company_data_subroutine($values)
 {
     $access = Utils_RecordBrowserCommon::get_access('contact', 'edit', $values);
     if (!$access) {
         return;
     }
     /* First click should generate html code for leightbox and show it.
      * This function is rarely used and we don't want to increase page size.
      * To do this we use REQUEST variable UCD.
      *
      * We use module variable UCD to indicate that form was shown and we
      * must check if it was submitted. If yes - do action. If it wasn't
      * we should come back to initial state - do not print LB.
      */
     if (!(isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0))) {
         if (isset($values['company_name']) && $values['company_name']) {
             Base_ActionBarCommon::add('edit', __('Copy company data'), Module::create_href(array('UCD' => true)));
         }
     }
     if (isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0)) {
         $ucd = Module::static_get_module_variable('CRM/Contacts', 'UCD', 0);
         $ucd++;
         if ($ucd > 1) {
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
         } else {
             Module::static_set_module_variable('CRM/Contacts', 'UCD', $ucd);
         }
         $lid = 'UCDprompt';
         $form = ModuleManager::new_instance('Libs_QuickForm', null, 'QFUCDprompt');
         $form->construct();
         $sel_val = array();
         foreach (array_merge(array($values['company_name']), is_array($values['related_companies']) ? $values['related_companies'] : array()) as $id) {
             $sel_val[$id] = self::company_format_default(self::get_company($id), true);
         }
         $form->addElement('select', 'company', __('Select company:'), $sel_val);
         unset($sel_val);
         $form->addElement('html', __('Select which fields should be copied:'));
         $data = array(array('sid' => 'address_1', 'tid' => 'address_1', 'text' => __('Address 1'), 'checked' => true), array('sid' => 'address_2', 'tid' => 'address_2', 'text' => __('Address 2'), 'checked' => true), array('sid' => 'city', 'tid' => 'city', 'text' => __('City'), 'checked' => true), array('sid' => 'country', 'tid' => 'country', 'text' => __('Country'), 'checked' => true), array('sid' => 'zone', 'tid' => 'zone', 'text' => __('Zone'), 'checked' => true), array('sid' => 'postal_code', 'tid' => 'postal_code', 'text' => __('Postal Code'), 'checked' => true), array('sid' => 'phone', 'tid' => 'work_phone', 'text' => __('Phone as Work Phone'), 'checked' => false), array('sid' => 'fax', 'tid' => 'fax', 'text' => __('Fax'), 'checked' => false));
         foreach ($data as $row) {
             if (is_array($access) && isset($access[$row['tid']]) && $access[$row['tid']]) {
                 $form->addElement('checkbox', $row['sid'], $row['text'], '', $row['checked'] ? array('checked' => 'checked') : array());
             }
         }
         $ok = $form->createElement('submit', 'submit', __('Confirm'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $cancel = $form->createElement('button', 'cancel', __('Cancel'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $form->addGroup(array($ok, $cancel));
         if ($form->validate()) {
             $Uvalues = $form->exportValues();
             $fields = array();
             foreach ($data as $row) {
                 if (array_key_exists($row['sid'], $Uvalues)) {
                     $fields[$row['tid']] = $row['sid'];
                 }
             }
             if (isset($Uvalues['company'])) {
                 $company = CRM_ContactsCommon::get_company($Uvalues['company']);
                 $new_data = array();
                 foreach ($fields as $k => $v) {
                     $new_data[$k] = $company[$v];
                 }
                 Utils_RecordBrowserCommon::update_record('contact', $values['id'], $new_data);
             }
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
             location(array());
         }
         // set default to main company
         if ($mc = self::get_main_company()) {
             $form->setDefaults(array('company' => $mc));
         }
         $html = $form->toHtml();
         Libs_LeightboxCommon::display($lid, $html);
         Base_ActionBarCommon::add('edit', __('Copy company data'), Libs_LeightboxCommon::get_open_href($lid));
         if (isset($_REQUEST['UCD'])) {
             eval_js('leightbox_activate(\'' . $lid . '\')');
         }
         unset($_REQUEST['UCD']);
     }
 }
示例#4
0
 public static function crm_event_update($id, $start, $duration, $timeless)
 {
     if (!Utils_RecordBrowserCommon::get_access('task', 'edit', self::get_task($id))) {
         return false;
     }
     $deadline = $timeless ? date('Y-m-d 12:00:00', $start) : date('Y-m-d H:i:s', $start);
     $values = array('deadline' => $deadline, 'timeless' => $timeless == true);
     Utils_RecordBrowserCommon::update_record('task', $id, $values);
     return true;
 }
示例#5
0
 public function paste($rs, $id)
 {
     if (isset($_SESSION['rc_mails_cp']) && is_array($_SESSION['rc_mails_cp']) && !empty($_SESSION['rc_mails_cp'])) {
         foreach ($_SESSION['rc_mails_cp'] as $mid) {
             $mail = Utils_RecordBrowserCommon::get_record('rc_mails', $mid);
             if (!in_array($rs . '/' . $id, $mail['related'])) {
                 $mail['related'][] = $rs . '/' . $id;
                 Utils_RecordBrowserCommon::update_record('rc_mails', $mid, array('related' => $mail['related']));
             }
         }
         location(array());
     }
 }
示例#6
0
 public static function crm_event_update($id, $start, $duration, $timeless)
 {
     if ($timeless) {
         return false;
     }
     if (!Utils_RecordBrowserCommon::get_access('phonecall', 'edit', self::get_phonecall($id))) {
         return false;
     }
     $values = array('date_and_time' => date('Y-m-d H:i:s', $start));
     Utils_RecordBrowserCommon::update_record('phonecall', $id, $values);
     return true;
 }
示例#7
0
 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);
     }
 }
示例#8
0
 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();
 }
示例#9
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
//addons table
$fields = array(array('name' => _M('Recordset'), 'type' => 'text', 'param' => 64, 'display_callback' => array('CRM_PhoneCallCommon', 'display_recordset'), 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_recordset'), 'required' => true, 'extra' => false, 'visible' => true));
Utils_RecordBrowserCommon::install_new_recordset('phonecall_related', $fields);
Utils_RecordBrowserCommon::set_caption('phonecall_related', _M('Meeting Related Recordsets'));
Utils_RecordBrowserCommon::register_processing_callback('phonecall_related', array('CRM_PhoneCallCommon', 'processing_related'));
Utils_RecordBrowserCommon::add_access('phonecall_related', 'view', 'ACCESS:employee');
Utils_RecordBrowserCommon::add_access('phonecall_related', 'add', 'ADMIN');
Utils_RecordBrowserCommon::add_access('phonecall_related', 'edit', 'SUPERADMIN');
Utils_RecordBrowserCommon::add_access('phonecall_related', 'delete', 'SUPERADMIN');
Utils_RecordBrowserCommon::new_record_field('phonecall', array('name' => _M('Related'), 'type' => 'multiselect', 'param' => '__RECORDSETS__::;CRM_PhoneCallCommon::related_crits', 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_related'), 'extra' => false, 'required' => false, 'visible' => true));
$rel = Utils_RecordBrowserCommon::get_records('phonecall', array('!related_to' => ''));
foreach ($rel as $r) {
    $rr = array();
    foreach ($r['related_to'] as $id) {
        $rr[] = 'contact/' . $id;
    }
    Utils_RecordBrowserCommon::update_record('phonecall', $r['id'], array('related' => $rr));
}
Utils_RecordBrowserCommon::delete_record_field('phonecall', 'Related to');
示例#10
0
文件: grid.php 项目: cretzu89/EPESI
    ob_end_clean();
    print 'alert(\'' . __('This field is not editable') . '\');';
    print 'setTimeout("grid_disable_edit(\'' . $element . '\',\'' . $id . '\');",100);';
    die;
}
$rb->prepare_view_entry_details($record, 'edit', $id, $form, array($element => true), true);
$more_html = ob_get_clean();
if ($mode == 'submit') {
    // && $form->validate()) {
    $form->validate();
    $vals = $form->exportValues();
    if (!isset($vals['__grid_' . $element])) {
        trigger_error(print_r($vals, true));
    }
    $value = $vals['__grid_' . $element];
    Utils_RecordBrowserCommon::update_record($tab, $id, array($element => $value));
    $record[$element] = $value;
    $form = ModuleManager::new_instance('Libs_QuickForm', null, 'grid_form');
    $rb = ModuleManager::new_instance('Utils_RecordBrowser', null, 'grid_rb');
    $form->construct();
    $rb->construct($tab);
    $rb->init();
    $record = Utils_RecordBrowserCommon::get_record($tab, $id);
    $record[$element] = $value;
    $rb->record = $record;
    $rb->view_fields_permission = $rb->get_access('view', $record);
    $rb->prepare_view_entry_details($record, 'view', $id, $form, array($element => true));
    $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty();
    $form->accept($renderer);
    $data = $renderer->toArray();
    $html = $data[$element]['html'];
示例#11
0
    while ($ret = DB::SelectLimit('SELECT * FROM utils_attachment_link ORDER BY id', 1, $links++)) {
        $link = $ret->FetchRow();
        if (!$link) {
            break;
        }
        Patch::set_message('Processing note: ' . $links . '/' . $links_qty);
        $old_checkpoint->require_time(2);
        $notes = DB::GetAll('SELECT * FROM utils_attachment_note WHERE attach_id=%d ORDER BY revision', $link['id']);
        $note = array_shift($notes);
        Acl::set_user($note['created_by']);
        $rid = Utils_RecordBrowserCommon::new_record('utils_attachment', array('title' => $link['title'], 'note' => $note['text'], 'permission' => $link['permission'], 'sticky' => $link['sticky'], 'crypted' => array('crypted' => $link['crypted']), 'func' => $link['func'], 'args' => $link['args'], '__date' => $note['created_on'], 'local' => $link['local']));
        //    DB::Execute('INSERT INTO utils_attachment_local(local,attachment) VALUES(%s,%d)',array($link['local'],$rid));
        $map[$link['id']] = $rid;
        foreach ($notes as $note) {
            Acl::set_user($note['created_by']);
            Utils_RecordBrowserCommon::update_record('utils_attachment', $rid, array('note' => $note['text'], '__date' => $note['created_on']));
        }
        Acl::set_user($us);
        $old_checkpoint->set('links', $links);
        $old_checkpoint->set('map', $map);
    }
}
$old_checkpoint->done();
Patch::set_message('Updating database');
$delete_old_fk_checkpoint = Patch::checkpoint('delete_old_fk');
if (!$delete_old_fk_checkpoint->is_done()) {
    Patch::require_time(5);
    if (DB::is_mysql()) {
        $a = DB::GetRow('SHOW CREATE TABLE utils_attachment_file');
        if (preg_match('/CONSTRAINT (.+) FOREIGN KEY .*attach_id/', $a[1], $m)) {
            DB::Execute('alter table `utils_attachment_file` drop foreign key ' . $m[1]);
示例#12
0
        Utils_RecordBrowserCommon::new_record('rc_related', array('recordset' => $r['recordset']));
        unset($old[$i]);
        $old_checkpoint->set('old', $old);
    }
    $old_checkpoint->done();
}
Patch::set_message('Processing related');
$related_checkpoint = Patch::checkpoint('related');
if (!$related_checkpoint->is_done()) {
    while (1) {
        $related = $related_checkpoint->get('related', array());
        if (empty($related)) {
            $related = Utils_RecordBrowserCommon::get_records('rc_mails_assoc', array(), array(), array(), 10);
            if (empty($related)) {
                break;
            }
        }
        foreach ($related as $i => $r) {
            $related_checkpoint->require_time(5);
            $mail = Utils_RecordBrowserCommon::get_record('rc_mails', $r['mail']);
            $mail['related'][] = $r['recordset'] . '/' . $r['record_id'];
            Utils_RecordBrowserCommon::update_record('rc_mails', $r['mail'], array('related' => $mail['related']));
            Utils_RecordBrowserCommon::delete_record('rc_mails_assoc', $r['id']);
            unset($related[$i]);
            $related_checkpoint->set('related', $related);
        }
    }
    $related_checkpoint->done();
}
Utils_RecordBrowserCommon::uninstall_recordset('rc_mails_assoc');
Utils_RecordBrowserCommon::delete_addon('rc_mails', CRM_Roundcube::module_name(), 'assoc_addon');
示例#13
0
 public static function process_request($data, $mode)
 {
     switch ($mode) {
         case 'adding':
             $data['active'] = true;
             break;
         case 'added':
             Utils_RecordBrowserCommon::update_record('crm_assets', $data['id'], array('asset_id' => self::generate_id($data['id'])), false, null, true);
             break;
         default:
             break;
     }
     return $data;
 }
示例#14
0
 public static function crm_event_update($id, $start, $duration, $timeless)
 {
     $id = explode('_', $id);
     $id = reset($id);
     $r = Utils_RecordBrowserCommon::get_record('crm_meeting', $id);
     if (!Utils_RecordBrowserCommon::get_access('crm_meeting', 'edit', $r)) {
         return false;
     }
     $sp_start = explode(' ', date('Y-m-d H:i:s', $start));
     $values = array();
     $values['date'] = $sp_start[0];
     $values['time'] = '1970-01-01 ' . $sp_start[1];
     if ($timeless) {
         $values['duration'] = -1;
         unset($values['time']);
     } else {
         $values['duration'] = $duration > 0 ? $duration : 3600;
     }
     $r = self::submit_meeting($r, 'editing');
     $values = self::submit_meeting($values, 'editing');
     $values['recurrence_end'] = $r['recurrence_end'];
     $values = Utils_RecordBrowserCommon::update_record('crm_meeting', $id, $values);
     if ($r['recurrence_type'] > 0) {
         print 'Epesi.updateIndicatorText("Updating calendar");Epesi.request("");';
     }
     return true;
 }
示例#15
0
 public static function reload_mails($rs, $id, $email_addresses = null)
 {
     $prefix = ($rs == 'contact' ? 'P' : 'C') . ':';
     if (!$email_addresses) {
         $email_addresses = self::get_email_addresses($rs, $id);
     }
     foreach ($email_addresses as $email) {
         $cc = Utils_RecordBrowserCommon::get_records('rc_mails', array('(~from' => '%' . $email . '%', '|~to' => '%' . $email . '%'));
         foreach ($cc as $mail) {
             if ($rs == 'contact' && $mail['employee'] == $id || in_array($prefix . $id, $mail['contacts'])) {
                 continue;
             }
             if (!preg_match('/(^|[\\s,\\<\\;])' . preg_quote($email, '/') . '($|[\\s,\\>\\&])/i', $mail['from'] . ',' . $mail['to'])) {
                 continue;
             }
             $mail['contacts'][] = $prefix . $id;
             Utils_RecordBrowserCommon::update_record('rc_mails', $mail['id'], array('contacts' => $mail['contacts']));
             CRM_RoundcubeCommon::create_thread($mail['id']);
         }
     }
 }
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
Utils_CommonDataCommon::extend_array('Contacts/Access', array('employee' => _M('Employee')));
$cmp = Variable::get('main_company', null);
if ($cmp) {
    set_time_limit(0);
    $conts = DB::GetAll('SELECT * FROM contact_data_1 WHERE f_company_name=%d OR f_related_companies ' . DB::like() . ' ' . DB::Concat(DB::qstr('\\_\\_'), DB::qstr($cmp), DB::qstr('\\_\\_')), array($cmp));
    foreach ($conts as $k => $v) {
        $v['access'] = Utils_RecordBrowserCommon::decode_multi($v['f_access']);
        $v['access'][] = 'employee';
        Utils_RecordBrowserCommon::update_record('contact', $v['id'], array('access' => $v['access']));
    }
    Variable::delete('main_company', false);
}
$tab = DB::GetAssoc('SELECT tab, tab FROM recordbrowser_table_properties');
foreach ($tab as $t) {
    DB::Execute('UPDATE ' . $t . '_access_clearance SET clearance=%s WHERE clearance=%s', array('ACCESS:employee', 'EMPLOYEE'));
}
示例#17
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
//addons table
$fields = array(array('name' => _M('Recordset'), 'type' => 'text', 'param' => 64, 'display_callback' => array('CRM_PhoneCallCommon', 'display_recordset'), 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_recordset'), 'required' => true, 'extra' => false, 'visible' => true));
Utils_RecordBrowserCommon::install_new_recordset('phonecall_related', $fields);
Utils_RecordBrowserCommon::set_caption('phonecall_related', _M('Meeting Related Recordsets'));
Utils_RecordBrowserCommon::register_processing_callback('phonecall_related', array('CRM_PhoneCallCommon', 'processing_related'));
Utils_RecordBrowserCommon::add_access('phonecall_related', 'view', 'ACCESS:employee');
Utils_RecordBrowserCommon::add_access('phonecall_related', 'add', 'ADMIN');
Utils_RecordBrowserCommon::add_access('phonecall_related', 'edit', 'SUPERADMIN');
Utils_RecordBrowserCommon::add_access('phonecall_related', 'delete', 'SUPERADMIN');
Utils_RecordBrowserCommon::new_record_field('phonecall', array('name' => _M('Related'), 'type' => 'multiselect', 'param' => '__RECORDSETS__::;CRM_PhoneCallCommon::related_crits', 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_related'), 'extra' => false, 'required' => false, 'visible' => true));
$rel = Utils_RecordBrowserCommon::get_records('phonecall', array('!related_to' => ''));
foreach ($rel as $r) {
    $rr = array();
    foreach ($r['related_to'] as $id) {
        $rr[] = 'contact/' . $id;
    }
    Utils_RecordBrowserCommon::update_record('phonecall', $r['id'], array('related' => $rr), false, null, true);
}
Utils_RecordBrowserCommon::delete_record_field('phonecall', 'Related to');
示例#18
0
 public static function crm_event_update($id, $start, $duration, $timeless)
 {
     if (!$timeless) {
         return false;
     }
     if (!Utils_RecordBrowserCommon::get_access('task', 'edit', self::get_task($id))) {
         return false;
     }
     $values = array('deadline' => date('Y-m-d', $start));
     Utils_RecordBrowserCommon::update_record('task', $id, $values);
     return true;
 }
示例#19
0
             $rm_acl[$r['f_patient']] = array();
         }
         $rm_acl[$r['f_patient']][] = $r['id'];
         $field = Utils_RecordBrowserCommon::get_field_id(Utils_CommonDataCommon::get_value('CADES/AccessLevel/' . $r['f_permission_level']));
         $fields = explode('_', $field);
         foreach ($fields as $field) {
             if (!isset($perms[$r['f_patient']][$field])) {
                 $perms[$r['f_patient']][$field] = array();
             }
             $perms[$r['f_patient']][$field][] = $r['f_employee'];
         }
     }
     print 'Patients left: ' . count($perms) . '<br>';
     foreach ($perms as $patient => $v) {
         print 'Patient ' . $patient;
         Utils_RecordBrowserCommon::update_record('contact', $patient, $v);
         print '... cleanup... ';
         DB::StartTrans();
         foreach ($rm_acl[$patient] as $i) {
             DB::Execute('UPDATE cades_access_control_data_1 SET active=0 WHERE id=%d', array($i));
         }
         DB::CompleteTrans();
         print 'done<br>';
     }
 }
 Utils_RecordBrowserCommon::wipe_access('contact');
 Utils_RecordBrowserCommon::add_access('contact', 'view', 'ACCESS:employee', array('(!permission' => 2, '|:Created_by' => 'USER_ID'), array('birth_date', 'ssn', 'home_phone', 'home_address_1', 'home_address_2', 'home_city', 'home_country', 'home_zone', 'home_postal_code', 'view', 'edit', 'add', 'delete'));
 Utils_RecordBrowserCommon::add_access('contact', 'view', 'ALL', array('login' => 'USER_ID'), array('view', 'edit', 'add', 'delete'));
 Utils_RecordBrowserCommon::add_access('contact', 'view', array('ACCESS:employee', 'ACCESS:mrm'), array('(!permission' => 2, '|:Created_by' => 'USER_ID'), array('view', 'edit', 'add', 'delete'));
 Utils_RecordBrowserCommon::add_access('contact', 'add', array('ACCESS:employee', 'ACCESS:manager'));
 Utils_RecordBrowserCommon::add_access('contact', 'edit', 'ACCESS:employee', array('(permission' => 0, '|:Created_by' => 'USER_ID', '!group' => array('patient', 'ex_patient')), array('access', 'login'));
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
Utils_RecordBrowserCommon::register_processing_callback('rc_mails', array('CRM_RoundcubeCommon', 'submit_mail'));
$mails = Utils_RecordBrowserCommon::get_records('rc_mails', array('thread' => null));
foreach ($mails as $m) {
    if (preg_match('/\\nreferences:(.*)\\n/i', $m['headers_data'], $match)) {
        $ref = trim($match[1]);
        Utils_RecordBrowserCommon::update_record('rc_mails', $m['id'], array('references' => $ref));
    }
    if (preg_match('/\\nmessageid:(.*)\\n/i', $m['headers_data'], $match)) {
        $mid = str_replace(array('<', '>'), '', trim($match[1]));
        Utils_RecordBrowserCommon::update_record('rc_mails', $m['id'], array('message_id' => $mid));
    }
}
foreach ($mails as $m) {
    CRM_RoundcubeCommon::create_thread($m['id']);
}
示例#21
0
 public static function create_thread($id)
 {
     $m = Utils_RecordBrowserCommon::get_record('rc_mails', $id);
     $thread = $m['thread'];
     if (!$thread && $m['message_id']) {
         $thread = DB::GetOne('SELECT f_thread FROM rc_mails_data_1 WHERE f_references is not null AND f_references LIKE ' . DB::Concat('\'%%\'', '%s', '\'%%\'') . ' AND active=1', array($m['message_id']));
     }
     if (!$thread && $m['references']) {
         $thread = DB::GetOne('SELECT f_thread FROM rc_mails_data_1 WHERE f_message_id is not null AND %s LIKE ' . DB::Concat('\'%%\'', 'f_message_id', '\'%%\'') . ' AND active=1', array($m['references']));
     }
     if (!$thread) {
         $thread = Utils_RecordBrowserCommon::new_record('rc_mail_threads', array('subject' => $m['subject'], 'contacts' => array_unique(array_merge($m['contacts'], array('P:' . $m['employee']))), 'first_date' => $m['date'], 'last_date' => $m['date']));
     }
     Utils_RecordBrowserCommon::update_record('rc_mails', $id, array('thread' => $thread));
     $t = Utils_RecordBrowserCommon::get_record('rc_mail_threads', $thread);
     Utils_RecordBrowserCommon::update_record('rc_mail_threads', $thread, array('contacts' => array_unique(array_merge($t['contacts'], $m['contacts'], array('P:' . $m['employee']))), 'first_date' => strtotime($m['date']) < strtotime($t['first_date']) ? $m['date'] : $t['first_date'], 'last_date' => strtotime($m['date']) > strtotime($t['last_date']) ? $m['date'] : $t['last_date'], 'subject' => trim($m['references']) == '' || mb_strlen($m['subject']) < mb_strlen($t['subject']) ? $m['subject'] : $t['subject']));
 }