Esempio n. 1
0
 public function install()
 {
     $fields = array('name' => _M('County'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries', 'Country', 'Zone'), 'extra' => false, 'QFfield_callback' => array('CRM_Contacts_CountyCommon', 'QFfield_county'), 'position' => 'Zone');
     Utils_RecordBrowserCommon::new_record_field('company', $fields);
     $fields = array('name' => _M('County'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries', 'Country', 'Zone'), 'extra' => false, 'QFfield_callback' => array('CRM_Contacts_CountyCommon', 'QFfield_county'), 'position' => 'Zone');
     Utils_RecordBrowserCommon::new_record_field('contact', $fields);
     $fields = array('name' => _M('Home County'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries', 'Home Country', 'Home Zone'), 'extra' => false, 'QFfield_callback' => array('CRM_Contacts_CountyCommon', 'QFfield_county'), 'position' => 'Home Zone');
     Utils_RecordBrowserCommon::new_record_field('contact', $fields);
     $hc_pos = DB::GetOne('SELECT position FROM contact_field WHERE field=\'Home City\'');
     $bd_pos = DB::GetOne('SELECT position FROM contact_field WHERE field=\'Birth Date\'');
     if ($hc_pos + 1 < $bd_pos) {
         DB::Execute('UPDATE contact_field SET position = position+1 WHERE position>%d AND position<%d', array($hc_pos, $bd_pos));
         DB::Execute('UPDATE contact_field SET position = %d WHERE field=\'Birth Date\'', array($hc_pos));
     }
     return true;
 }
Esempio n. 2
0
 public function install()
 {
     //addons table
     $fields = array(array('name' => _M('Recordset'), 'type' => 'text', 'param' => 64, 'display_callback' => array($this->get_type() . 'Common', 'display_recordset'), 'QFfield_callback' => array($this->get_type() . 'Common', 'QFfield_recordset'), 'required' => true, 'extra' => false, 'visible' => true));
     Utils_RecordBrowserCommon::install_new_recordset('phonecall_related', $fields);
     Utils_RecordBrowserCommon::set_caption('phonecall_related', _M('Phonecalls 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');
     // ************ phone calls ************** //
     Base_ThemeCommon::install_default_theme(CRM_PhoneCallInstall::module_name());
     $fields = array(array('name' => _M('Subject'), 'type' => 'text', 'required' => true, 'param' => '64', 'extra' => false, 'visible' => true, 'display_callback' => array('CRM_PhoneCallCommon', 'display_subject')), array('name' => _M('Contact Name'), 'type' => 'hidden', 'extra' => false, 'visible' => true, 'display_callback' => array('CRM_PhoneCallCommon', 'display_contact_name')), array('name' => _M('Phone Number'), 'type' => 'hidden', 'extra' => false, 'visible' => true, 'display_callback' => array('CRM_PhoneCallCommon', 'display_phone_number')), array('name' => _M('Customer'), 'type' => 'crm_company_contact', 'param' => array('field_type' => 'select'), 'extra' => false), array('name' => _M('Other Customer'), 'type' => 'checkbox', 'extra' => false, 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_other_contact')), array('name' => _M('Other Customer Name'), 'type' => 'text', 'param' => '64', 'extra' => false), array('name' => _M('Permission'), 'type' => 'commondata', 'required' => true, 'param' => array('order_by_key' => true, 'CRM/Access'), 'extra' => false), array('name' => _M('Employees'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('CRM_PhoneCallCommon', 'employees_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => true, 'extra' => false, 'visible' => true, 'filter' => true), array('name' => _M('Status'), 'type' => 'commondata', 'required' => true, 'filter' => true, 'param' => array('order_by_key' => true, 'CRM/Status'), 'extra' => false, 'visible' => true, 'display_callback' => array('CRM_PhoneCallCommon', 'display_status')), array('name' => _M('Priority'), 'type' => 'commondata', 'required' => true, 'param' => array('order_by_key' => true, 'CRM/Priority'), 'extra' => false), array('name' => _M('Phone'), 'type' => 'integer', 'extra' => false, 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_phone'), 'display_callback' => array('CRM_PhoneCallCommon', 'display_phone')), array('name' => _M('Other Phone'), 'type' => 'checkbox', 'extra' => false, 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_other_phone')), array('name' => _M('Other Phone Number'), 'type' => 'text', 'param' => '64', 'extra' => false), array('name' => _M('Date and Time'), 'type' => 'timestamp', 'required' => true, 'extra' => false, 'visible' => true), array('name' => _M('Description'), 'type' => 'long text', 'required' => false, 'param' => '255', 'extra' => false), array('name' => _M('Related'), 'type' => 'multiselect', 'QFfield_callback' => array('CRM_PhoneCallCommon', 'QFfield_related'), 'param' => '__RECORDSETS__::;CRM_PhoneCallCommon::related_crits', 'extra' => false, 'required' => false, 'visible' => true));
     Utils_RecordBrowserCommon::install_new_recordset('phonecall', $fields);
     Utils_RecordBrowserCommon::set_tpl('phonecall', Base_ThemeCommon::get_template_filename(CRM_PhoneCallInstall::module_name(), 'default'));
     Utils_RecordBrowserCommon::register_processing_callback('phonecall', array('CRM_PhoneCallCommon', 'submit_phonecall'));
     Utils_RecordBrowserCommon::set_icon('phonecall', Base_ThemeCommon::get_template_filename(CRM_PhoneCallInstall::module_name(), 'icon.png'));
     Utils_RecordBrowserCommon::set_recent('phonecall', 5);
     Utils_RecordBrowserCommon::set_caption('phonecall', _M('Phonecalls'));
     Utils_RecordBrowserCommon::enable_watchdog('phonecall', array('CRM_PhoneCallCommon', 'watchdog_label'));
     Utils_RecordBrowserCommon::set_search('phonecall', 2, 0);
     // ************ addons ************** //
     Utils_AttachmentCommon::new_addon('phonecall');
     Utils_RecordBrowserCommon::new_addon('phonecall', CRM_PhoneCallInstall::module_name(), 'messanger_addon', _M('Alerts'));
     CRM_RoundcubeCommon::new_addon('phonecall');
     // ************ other ************** //
     CRM_CalendarCommon::new_event_handler(_M('Phonecalls'), array('CRM_PhoneCallCommon', 'crm_calendar_handler'));
     Utils_BBCodeCommon::new_bbcode('phone', 'CRM_PhoneCallCommon', 'phone_bbcode');
     if (ModuleManager::is_installed('Premium_SalesOpportunity') >= 0) {
         Utils_RecordBrowserCommon::new_record_field('phonecall', _M('Opportunity'), 'select', true, false, 'premium_salesopportunity::Opportunity Name;Premium_SalesOpportunityCommon::crm_opportunity_reference_crits', '', false);
     }
     Utils_RecordBrowserCommon::add_access('phonecall', 'view', 'ACCESS:employee', array('(!permission' => 2, '|employees' => 'USER'));
     Utils_RecordBrowserCommon::add_access('phonecall', 'add', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('phonecall', 'edit', 'ACCESS:employee', array('(permission' => 0, '|employees' => 'USER', '|customer' => 'USER'));
     Utils_RecordBrowserCommon::add_access('phonecall', 'delete', 'ACCESS:employee', array(':Created_by' => 'USER_ID'));
     Utils_RecordBrowserCommon::add_access('phonecall', 'delete', array('ACCESS:employee', 'ACCESS:manager'));
     return true;
 }
Esempio n. 3
0
    public function view_field($action = 'add', $field = null) {
        if (!$action) $action = 'add';
        if ($this->is_back()) return false;
        if ($this->check_for_jump()) return;
        $data_type = array(
            'autonumber'=>__('Autonumber'),
            'currency'=>__('Currency'),
            'checkbox'=>__('Checkbox'),
            'date'=>__('Date'),
            'time' => __('Time'),
            'timestamp' => __('Timestamp'),
            'integer'=>__('Integer'),
            'float'=>__('Float'),
            'text'=>__('Text'),
            'long text'=>__('Long text'),
			'select'=>__('Select field')
        );
        natcasesort($data_type);
		
		load_js('modules/Utils/RecordBrowser/js/field_admin.js');
        $form = $this->init_module('Libs/QuickForm');

        switch ($action) {
            case 'add': $form->addElement('header', null, __('Add new field'));
                        break;
            case 'edit': $form->addElement('header', null, __('Edit field properties'));
                        break;
        }
        $form->addElement('text', 'field', __('Field'), array('maxlength'=>32));
        $form->registerRule('check_if_column_exists', 'callback', 'check_if_column_exists', $this);
        $this->current_field = $field;
        $form->registerRule('check_if_no_id', 'callback', 'check_if_no_id', $this);
        $form->addRule('field', __('Field required'), 'required');
        $form->addRule('field', __('Field with this name already exists.'), 'check_if_column_exists');
        $form->addRule('field', __('Field length cannot be over 32 characters.'), 'maxlength', 32);
        $form->addRule('field', __('Invalid field name.'), 'regex', '/^[a-zA-Z][a-zA-Z \(\)\%0-9]*$/');
        $form->addRule('field', __('Invalid field name.'), 'check_if_no_id');

        $form->addElement('text', 'caption', __('Caption'), array('maxlength'=>255, 'placeholder' => __('Leave empty to use default label')));

        if ($action=='edit') {
            $row = DB::GetRow('SELECT field, caption, type, visible, required, param, filter, export, tooltip, extra, position FROM '.$this->tab.'_field WHERE field=%s',array($field));
			switch ($row['type']) {
				case 'select':
					$row['select_data_type'] = 'select';
					$row['select_type'] = 'select';
					$row['data_source'] = 'rset';
					$ref = explode(';', $row['param']);
					$refe = explode('::',$ref[0]);
					$row['rset'] = array_filter(explode(',',$refe[0]));
					$row['label_field'] = isset($refe[1]) ? str_replace('|', ',', $refe[1]) : '';
					break;
				case 'multiselect':
					$row['select_data_type'] = 'select';
					$row['select_type'] = 'multiselect';
					$ref = explode(';', $row['param']);
					$refe = explode('::',$ref[0]);
					$tab = $refe[0];
					if ($tab=='__COMMON__') {
						$row['data_source'] = 'commondata';
						$order = isset($refe[2])?$refe[2]:'value';
						$row['order_by'] = ($order=='key'?'key':'value');
						$row['commondata_table'] = $refe[1];
					} else {
						$row['label_field'] = '';
                        if (isset($refe[1]))
                            $row['label_field'] = str_replace('|', ',', $refe[1]);
						$row['data_source'] = 'rset';
						$row['rset'] = array_filter(explode(',',$tab));
					}
					break;
				case 'commondata':
					$row['select_data_type'] = 'select';
					$row['select_type'] = 'select';
					$row['data_source'] = 'commondata';
					$param = Utils_RecordBrowserCommon::decode_commondata_param($row['param']);
					$form->setDefaults(array('order_by'=>$param['order_by_key']?'key':'value', 'commondata_table'=>$param['array_id']));
					break;
                case 'autonumber':
                    $row['select_data_type'] = 'autonumber';
                    Utils_RecordBrowserCommon::decode_autonumber_param($row['param'], $autonumber_prefix, $autonumber_pad_length, $autonumber_pad_mask);
                    $row['autonumber_prefix'] = $autonumber_prefix;
                    $row['autonumber_pad_length'] = $autonumber_pad_length;
                    $row['autonumber_pad_mask'] = $autonumber_pad_mask;
                    break;
				case 'text':
                    $row['select_data_type'] = $row['type'];
					$row['text_length'] = $row['param'];
                    break;
                case 'time':
                case 'timestamp':
                    $row['select_data_type'] = $row['type'];
                    $row['minute_increment'] = $row['param'];
                    break;
				default:
					$row['select_data_type'] = $row['type'];
					if (!isset($data_type[$row['type']]))
						$data_type[$row['type']] = _V(ucfirst($row['type'])); // ****** - field type
			}
			if (!isset($row['rset'])) $row['rset'] = array('contact');
			if (!isset($row['data_source'])) $row['data_source'] = 'commondata';
            $form->setDefaults($row);
            $selected_data = $row['type'];
			$this->admin_field_type = $row['select_data_type'];
			$this->admin_field = $row;
        } else {
            $selected_data = $form->exportValue('select_data_type');
            $form->setDefaults(array('visible'=>1,
                'autonumber_prefix'=>'#',
                'autonumber_pad_length'=>'6',
                'autonumber_pad_mask'=>'0'));
        }
		$this->admin_field_mode = $action;
		$this->admin_field_name = $field;
		
		$form->addElement('select', 'select_data_type', __('Data Type'), $data_type, array('id'=>'select_data_type', 'onchange'=>'RB_hide_form_fields()'));

		$form->addElement('text', 'text_length', __('Maximum Length'), array('id'=>'length'));
        $minute_increment_values = array(1=>1,2=>2,5=>5,10=>10,15=>15,20=>20,30=>30,60=>__('Full hours'));
		$form->addElement('select', 'minute_increment', __('Minutes Interval'), $minute_increment_values, array('id'=>'minute_increment'));

		$form->addElement('select', 'data_source', __('Source of Data'), array('rset'=>__('Recordset'), 'commondata'=>__('CommonData')), array('id'=>'data_source', 'onchange'=>'RB_hide_form_fields()'));
		$form->addElement('select', 'select_type', __('Type'), array('select'=>__('Single value selection'), 'multiselect'=>__('Multiple values selection')), array('id'=>'select_type'));
		$form->addElement('select', 'order_by', __('Order by'), array('key'=>__('Key'), 'value'=>__('Value')), array('id'=>'order_by'));
		$form->addElement('text', 'commondata_table', __('CommonData table'), array('id'=>'commondata_table'));

		$tables = Utils_RecordBrowserCommon::list_installed_recordsets();
		asort($tables);
		$form->addElement('multiselect', 'rset', '<span id="rset_label">'.__('Recordset').'</span>', $tables, array('id'=>'rset'));
		$form->addElement('text', 'label_field', __('Related field(s)'), array('id'=>'label_field'));

		$form->addFormRule(array($this, 'check_field_definitions'));

		$form->addElement('checkbox', 'visible', __('Table view'));
		$form->addElement('checkbox', 'tooltip', __('Tooltip view'));
		$form->addElement('checkbox', 'required', __('Required'), null, array('id'=>'required'));
		$form->addElement('checkbox', 'filter', __('Filter enabled'), null, array('id' => 'filter'));
		$form->addElement('checkbox', 'export', __('Export'));
        
        $form->addElement('text', 'autonumber_prefix', __('Prefix string'), array('id' => 'autonumber_prefix'));
        $form->addRule('autonumber_prefix', __('Double underscore is not allowed'), 'callback', array('Utils_RecordBrowser', 'qf_rule_without_double_underscore'));
        $form->addElement('text', 'autonumber_pad_length', __('Pad length'), array('id' => 'autonumber_pad_length'));
        $form->addRule('autonumber_pad_length', __('Only integer numbers are allowed.'), 'regex', '/^[0-9]*$/');
        $form->addElement('text', 'autonumber_pad_mask', __('Pad character'), array('id' => 'autonumber_pad_mask'));
        $form->addRule('autonumber_pad_mask', __('Double underscore is not allowed'), 'callback', array('Utils_RecordBrowser', 'qf_rule_without_double_underscore'));

		$form->addElement('checkbox', 'advanced', __('Edit advanced properties'), null, array('onchange'=>'RB_advanced_settings()', 'id'=>'advanced'));
		$form->addElement('text', 'display_callback', __('Value display function'), array('maxlength'=>255, 'style'=>'width:300px', 'id'=>'display_callback'));
		$form->addElement('text', 'QFfield_callback', __('Field generator function'), array('maxlength'=>255, 'style'=>'width:300px', 'id'=>'QFfield_callback'));
		
        if ($action=='edit') {
			$form->freeze('field');
			$form->freeze('select_data_type');
			$form->freeze('data_source');
			$form->freeze('rset');
		}
		
		if ($action=='edit') {
			$display_callbacback = DB::GetOne('SELECT callback FROM '.$this->tab.'_callback WHERE freezed=1 AND field=%s', array($field));
			$QFfield_callbacback = DB::GetOne('SELECT callback FROM '.$this->tab.'_callback WHERE freezed=0 AND field=%s', array($field));
			$form->setDefaults(array('display_callback'=>$display_callbacback));
			$form->setDefaults(array('QFfield_callback'=>$QFfield_callbacback));
		}

        if ($form->validate()) {
            $data = $form->exportValues();
            $data['caption'] = trim($data['caption']);
            $data['field'] = trim($data['field']);
			$type = DB::GetOne('SELECT type FROM '.$this->tab.'_field WHERE field=%s', array($field));
			if (!isset($data['select_data_type'])) $data['select_data_type'] = $type;
            if ($action=='add')
                $field = $data['field'];
            $id = preg_replace('/[^a-z0-9]/','_',strtolower($field));
            $new_id = preg_replace('/[^a-z0-9]/','_',strtolower($data['field']));
            if (preg_match('/^[a-z0-9_]*$/',$id)==0) trigger_error('Invalid column name: '.$field);
            if (preg_match('/^[a-z0-9_]*$/',$new_id)==0) trigger_error('Invalid new column name: '.$data['field']);
			$param = '';
			switch ($data['select_data_type']) {
                case 'autonumber':
                    $data['required'] = false;
                    $data['filter'] = false;
                    $param = Utils_RecordBrowserCommon::encode_autonumber_param(
                            $data['autonumber_prefix'],
                            $data['autonumber_pad_length'],
                            $data['autonumber_pad_mask']);
                    // delete field and add again later to generate values
                    if ($action != 'add') {
                        Utils_RecordBrowserCommon::delete_record_field($this->tab, $field);
                        $action = 'add';
                        $field = $data['field'];
                    }
                    break;
				case 'checkbox': 
							$data['required'] = false;
							break;
				case 'text': if ($action=='add') $param = $data['text_length'];
							else {
								if ($data['text_length']<$row['param']) trigger_error('Invalid field length', E_USER_ERROR);
								$param = $data['text_length'];
								if ($data['text_length']!=$row['param']) {
									if(DB::is_postgresql())
										DB::Execute('ALTER TABLE '.$this->tab.'_data_1 ALTER COLUMN f_'.$id.' TYPE VARCHAR('.$param.')');
									else
										DB::Execute('ALTER TABLE '.$this->tab.'_data_1 MODIFY f_'.$id.' VARCHAR('.$param.')');
								}
							}
							break;
				case 'select':
							if ($data['data_source']=='commondata') {
								if ($data['select_type']=='select') {
									$param = Utils_RecordBrowserCommon::encode_commondata_param(array('order_by_key'=>$data['order_by']=='key', 'array_id'=>$data['commondata_table']));
									$data['select_data_type'] = 'commondata';
								} else {
									$param = '__COMMON__::'.$data['commondata_table'].'::'.$data['order_by'];
									$data['select_data_type'] = 'multiselect';
								}
							} else {
								$data['select_data_type'] = $data['select_type'];
								if (!isset($row) || !isset($row['param'])) $row['param'] = ';::';
								$props = explode(';', $row['param']);
                                $change_param = false;
								if($data['rset']) {
								    $fs = explode(',', $data['label_field']);
								    if($data['label_field']) foreach($data['rset'] as $rset) {
        								$ret = $this->detranslate_field_names($rset, $fs);
	        							if (!empty($ret)) trigger_error('Invalid fields: '.implode(',',$fs));
	        						    }
	        						    $data['rset'] = implode(',',$data['rset']);
	        						    $data['label_field'] = implode('|',$fs);
                                    $change_param = true;
								} else if ($action == 'add') {
								    $data['rset'] = '__RECORDSETS__';
								    $data['label_field'] = '';
                                    $change_param = true;
								}
                                if ($change_param) {
                                    $props[0] = $data['rset'].'::'.$data['label_field'];
                                    $param = implode(';', $props);
                                } else {
                                    $param = $row['param'];
                                }
							}
							if (isset($row) && isset($row['type']) && $row['type']=='multiselect' && $data['select_type']=='select') {
								$ret = DB::Execute('SELECT id, f_'.$id.' AS v FROM '.$this->tab.'_data_1 WHERE f_'.$id.' IS NOT NULL');
								while ($rr = $ret->FetchRow()) {
									$v = Utils_RecordBrowserCommon::decode_multi($rr['v']);
									$v = array_pop($v);
									DB::Execute('UPDATE '.$this->tab.'_data_1 SET f_'.$id.'=%s WHERE id=%d', array($v, $rr['id']));
								}
							}
							if (isset($row) && isset($row['type'])  && $row['type']!='multiselect' && $data['select_type']=='multiselect') {
								if(DB::is_postgresql())
									DB::Execute('ALTER TABLE '.$this->tab.'_data_1 ALTER COLUMN f_'.$id.' TYPE TEXT');
								else
									DB::Execute('ALTER TABLE '.$this->tab.'_data_1 MODIFY f_'.$id.' TEXT');
								$ret = DB::Execute('SELECT id, f_'.$id.' AS v FROM '.$this->tab.'_data_1 WHERE f_'.$id.' IS NOT NULL');
								while ($rr = $ret->FetchRow()) {
									$v = Utils_RecordBrowserCommon::encode_multi($rr['v']);
									DB::Execute('UPDATE '.$this->tab.'_data_1 SET f_'.$id.'=%s WHERE id=%d', array($v, $rr['id']));
								}
							}
							break;
                case 'time':
                case 'timestamp':
                    $param = $data['minute_increment'];
                    break;
				default:	if (isset($row) && isset($row['param']))
								$param = $row['param'];
							break;
			}
            if ($action=='add') {
                $id = $new_id;
                if (in_array($data['select_data_type'], array('time','timestamp','currency','integer')))
                    $style = $data['select_data_type'];
                else
                    $style = '';
                $new_field_data = array('name' => $data['field'], 'type' => $data['select_data_type'], 'param' => $param, 'style' => $style);
                if (isset($this->admin_field['position']) && $this->admin_field['position']) {
                    $new_field_data['position'] = (int) $this->admin_field['position'];
                }
                Utils_RecordBrowserCommon::new_record_field($this->tab, $new_field_data);
            }
            if(!isset($data['visible']) || $data['visible'] == '') $data['visible'] = 0;
            if(!isset($data['required']) || $data['required'] == '') $data['required'] = 0;
            if(!isset($data['filter']) || $data['filter'] == '') $data['filter'] = 0;
            if(!isset($data['export']) || $data['export'] == '') $data['export'] = 0;
            if(!isset($data['tooltip']) || $data['tooltip'] == '') $data['tooltip'] = 0;

            foreach($data as $key=>$val)
                if (is_string($val)) $data[$key] = htmlspecialchars($val);

/*            DB::StartTrans();
            if ($id!=$new_id) {
                Utils_RecordBrowserCommon::check_table_name($this->tab);
                if(DB::is_postgresql())
                    DB::Execute('ALTER TABLE '.$this->tab.'_data_1 RENAME COLUMN f_'.$id.' TO f_'.$new_id);
                else {
                    $old_param = DB::GetOne('SELECT param FROM '.$this->tab.'_field WHERE field=%s', array($field));
                    DB::RenameColumn($this->tab.'_data_1', 'f_'.$id, 'f_'.$new_id, Utils_RecordBrowserCommon::actual_db_type($type, $old_param));
                }
            }*/
            DB::Execute('UPDATE '.$this->tab.'_field SET caption=%s, param=%s, type=%s, field=%s, visible=%d, required=%d, filter=%d, export=%d, tooltip=%d WHERE field=%s',
                        array($data['caption'], $param, $data['select_data_type'], $data['field'], $data['visible'], $data['required'], $data['filter'], $data['export'], $data['tooltip'], $field));
/*            DB::Execute('UPDATE '.$this->tab.'_edit_history_data SET field=%s WHERE field=%s',
                        array($new_id, $id));
            DB::CompleteTrans();*/
			
			DB::Execute('DELETE FROM '.$this->tab.'_callback WHERE freezed=1 AND field=%s', array($field));
			if ($data['display_callback'])
				DB::Execute('INSERT INTO '.$this->tab.'_callback (callback,freezed,field) VALUES (%s,1,%s)', array($data['display_callback'], $data['field']));
				
			DB::Execute('DELETE FROM '.$this->tab.'_callback WHERE freezed=0 AND field=%s', array($field));
			if ($data['QFfield_callback'])
				DB::Execute('INSERT INTO '.$this->tab.'_callback (callback,freezed,field) VALUES (%s,0,%s)', array($data['QFfield_callback'], $data['field']));
			
            $this->init(true, true);
            return false;
        }
        $form->display_as_column();

		eval_js('RB_hide_form_fields();');
		eval_js('RB_advanced_confirmation = "'.Epesi::escapeJS(__('Changing these settings may often cause system unstability. Are you sure you want to see advanced settings?')).'";');
		eval_js('RB_advanced_settings();');

		Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
		Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
		
        return true;
    }
Esempio n. 4
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_TasksCommon', 'display_recordset'), 'QFfield_callback' => array('CRM_TasksCommon', 'QFfield_recordset'), 'required' => true, 'extra' => false, 'visible' => true));
Utils_RecordBrowserCommon::install_new_recordset('task_related', $fields);
Utils_RecordBrowserCommon::set_caption('task_related', _M('Meeting Related Recordsets'));
Utils_RecordBrowserCommon::register_processing_callback('task_related', array('CRM_TasksCommon', 'processing_related'));
Utils_RecordBrowserCommon::add_access('task_related', 'view', 'ACCESS:employee');
Utils_RecordBrowserCommon::add_access('task_related', 'add', 'ADMIN');
Utils_RecordBrowserCommon::add_access('task_related', 'edit', 'SUPERADMIN');
Utils_RecordBrowserCommon::add_access('task_related', 'delete', 'SUPERADMIN');
Utils_RecordBrowserCommon::new_record_field('task', array('name' => _M('Related'), 'type' => 'multiselect', 'param' => '__RECORDSETS__::;CRM_TasksCommon::related_crits', 'QFfield_callback' => array('CRM_TasksCommon', 'QFfield_related'), 'extra' => false, 'required' => false, 'visible' => true));
Esempio n. 5
0
 public function install()
 {
     Utils_RecordBrowserCommon::new_record_field('company', array('name' => _M('Parent Company'), 'type' => 'crm_company', 'param' => array('field_type' => 'select', 'crits' => array('CRM_Contacts_ParentCompanyCommon', 'parent_company_crits')), 'required' => false, 'extra' => false, 'visible' => true, 'filter' => true, 'position' => 'Phone'));
     Utils_RecordBrowserCommon::new_addon('company', 'CRM_Contacts_ParentCompany', 'parent_company_addon', _M('Child Companies'));
     return true;
 }
Esempio n. 6
0
 /**
  * Add new field to RecordSet.
  * @param array|RBO_FieldDefinition $definition Field definition
  */
 public function new_record_field($definition)
 {
     if ($definition instanceof RBO_FieldDefinition) {
         $definition = $definition->get_definition();
     }
     Utils_RecordBrowserCommon::new_record_field($this->tab, $definition);
 }
Esempio n. 7
0
 public function install()
 {
     Utils_RecordBrowserCommon::new_record_field('company', array('name' => _M('Account Manager'), 'type' => 'crm_contact', 'param' => array('field_type' => 'select', 'crits' => array('CRM_Contacts_AccountManagerCommon', 'crits_accountmanager'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => false, 'filter' => true, 'visible' => true));
     Utils_RecordBrowserCommon::new_browse_mode_details_callback('company', 'CRM/Contacts/AccountManager', 'browse_mode_details');
     return true;
 }
Esempio n. 8
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
$deadline_field_is_not_timestamp = !DB::GetOne('SELECT 1 FROM task_field WHERE field=%s AND type=%s', array('Deadline', 'timestamp'));
if ($deadline_field_is_not_timestamp) {
    PatchUtil::db_alter_column('task_data_1', 'f_deadline', 'T');
    DB::Execute('UPDATE task_field SET type=%s WHERE field=%s', array('timestamp', 'Deadline'));
}
$tab = 'task';
$field = array('name' => _M('Timeless'), 'type' => 'checkbox', 'required' => false, 'extra' => false, 'position' => 'Deadline', 'QFfield_callback' => 'CRM_TasksCommon::QFfield_timeless');
Utils_RecordBrowserCommon::new_record_field($tab, $field);
$deadline_time_field_exists = DB::GetOne('SELECT 1 FROM task_field WHERE field=%s', array('Deadline Time'));
$sql = false;
if ($deadline_time_field_exists) {
    if (DB::is_mysql()) {
        $sql = 'UPDATE task_data_1 SET f_deadline = TIMESTAMP(f_deadline, TIME(f_deadline_time)), f_timeless = (f_deadline_time IS NULL)';
    } else {
        $sql = 'UPDATE task_data_1 SET f_deadline = f_deadline + CAST(f_deadline_time as time), f_timeless = (f_deadline_time IS NULL)::int';
    }
} elseif ($deadline_field_is_not_timestamp) {
    if (DB::is_mysql()) {
        $sql = 'UPDATE task_data_1 SET f_deadline = TIMESTAMP(f_deadline, \'12:00:00\'), f_timeless = 1';
    } else {
        $sql = 'UPDATE task_data_1 SET f_deadline = f_deadline + CAST(\'12:00:00\' as time), f_timeless = 1';
    }
}
if ($sql) {
    DB::Execute($sql);
}
if ($deadline_time_field_exists) {
    Utils_RecordBrowserCommon::delete_record_field('task', 'Deadline Time');
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
Utils_RecordBrowserCommon::new_record_field('rc_accounts', array('name' => _M('Use EPESI Archive directories'), 'type' => 'checkbox', 'extra' => true, 'visible' => false));
DB::Execute('UPDATE rc_accounts_data_1 SET f_use_epesi_archive_directories=1');
Esempio n. 10
0
         $r2 = DB::Execute('SELECT * FROM contact_data_1 WHERE f_login=%d', array($row['id']));
         while ($r = $r2->FetchRow()) {
             if (!$r['f_access']) {
                 $gr = '__mrm__';
             } else {
                 $gr = $r['f_access'] . 'mrm__';
             }
             DB::Execute('UPDATE contact_data_1 SET f_access=%s WHERE id=%d', array($gr, $r['id']));
         }
     }
 }
 Acl::del_group('Medical Record Manager');
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('View'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('Edit'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('Add'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('Delete'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 // migrate data
 if (Utils_RecordBrowserCommon::check_table_name('cades_access_control', false, false)) {
     $recs = DB::Execute('SELECT * FROM cades_access_control_data_1 WHERE active=1');
     $perms = array();
     $rm_acl = array();
     $count = 0;
     $done = 0;
     while ($r = $recs->FetchRow()) {
         if (!isset($rm_acl[$r['f_patient']])) {
             $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) {
Esempio n. 11
0
<?php

$rs_checkpoint = Patch::checkpoint('recordset');
if (!$rs_checkpoint->is_done()) {
    Patch::require_time(5);
    //addons table
    $fields = array(array('name' => _M('Recordset'), 'type' => 'text', 'param' => 64, 'display_callback' => array('CRM_RoundcubeCommon', 'display_recordset'), 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_recordset'), 'required' => true, 'extra' => false, 'visible' => true));
    Utils_RecordBrowserCommon::install_new_recordset('rc_related', $fields);
    Utils_RecordBrowserCommon::set_caption('rc_related', _M('Mail Related Recordsets'));
    Utils_RecordBrowserCommon::register_processing_callback('rc_related', array('CRM_RoundcubeCommon', 'processing_related'));
    Utils_RecordBrowserCommon::add_access('rc_related', 'view', 'ACCESS:employee');
    Utils_RecordBrowserCommon::add_access('rc_related', 'add', 'ADMIN');
    Utils_RecordBrowserCommon::add_access('rc_related', 'edit', 'SUPERADMIN');
    Utils_RecordBrowserCommon::add_access('rc_related', 'delete', 'SUPERADMIN');
    Utils_RecordBrowserCommon::new_record_field('rc_mails', array('name' => _M('Related'), 'type' => 'multiselect', 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_related'), 'param' => '__RECORDSETS__::;CRM_RoundcubeCommon::related_crits', 'extra' => false, 'required' => false, 'visible' => true, 'position' => 'Employee'));
    Utils_RecordBrowserCommon::new_record('rc_related', array('recordset' => 'company'));
    Utils_RecordBrowserCommon::new_record('rc_related', array('recordset' => 'contact'));
    Utils_RecordBrowserCommon::add_access('rc_mails', 'edit', 'ACCESS:employee', array(), array('subject', 'employee', 'date', 'headers_data', 'body', 'from', 'to', 'thread', 'message_id', 'references'));
    $rs_checkpoint->done();
}
Patch::set_message('Processing addons');
$old_checkpoint = Patch::checkpoint('old');
if (!$old_checkpoint->is_done()) {
    $old = $old_checkpoint->get('old', array());
    if (empty($old) && ModuleManager::is_installed('Premium/RoundcubeCustomAddons') >= 0) {
        $old = Utils_RecordBrowserCommon::get_records('premium_roundcube_custom_addon');
        ModuleManager::uninstall('Premium/RoundcubeCustomAddons');
    }
    foreach ($old as $i => $r) {
        if ($r['recordset'] == 'company' || $r['recordset'] == 'contact') {
            continue;
Esempio n. 12
0
<?php

Utils_RecordBrowserCommon::new_record_field('task', array('name' => _M('Deadline Time'), 'type' => 'time', 'required' => false, 'extra' => false, 'visible' => true, 'position' => 'Deadline'));
Utils_RecordBrowserCommon::set_display_callback('task', 'Deadline', array('CRM_TasksCommon', 'display_deadline'));
Esempio n. 13
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
Utils_RecordBrowserCommon::new_record_field('utils_attachment', array('name' => _M('Attached to'), 'type' => 'calculated', 'extra' => false, 'display_callback' => array('Utils_AttachmentCommon', 'display_attached_to')));
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
if (DB::GetOne('SELECT 1 FROM utils_attachment_field WHERE field=%s', array('Date'))) {
    Utils_RecordBrowserCommon::new_record_field('utils_attachment', array('name' => _M('Edited on'), 'type' => 'timestamp', 'extra' => false, 'visible' => true, 'required' => false, 'display_callback' => array('Utils_AttachmentCommon', 'display_date'), 'QFfield_callback' => array('Utils_AttachmentCommon', 'QFfield_date'), 'position' => 'Date'));
    DB::Execute('UPDATE utils_attachment_data_1 SET f_edited_on=f_date');
    Utils_RecordBrowserCommon::delete_record_field('utils_attachment', 'Date');
    Utils_RecordBrowserCommon::wipe_access('utils_attachment');
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'view', 'ACCESS:employee', array('(!permission' => 2, '|:Created_by' => 'USER_ID'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'delete', 'ACCESS:employee', array(':Created_by' => 'USER_ID'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'delete', array('ACCESS:employee', 'ACCESS:manager'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'add', 'ACCESS:employee', array(), array('edited_on'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'edit', 'ACCESS:employee', array('(permission' => 0, '|:Created_by' => 'USER_ID'), array('edited_on'));
}
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
Utils_RecordBrowserCommon::new_record_field('rc_mails', array('name' => _M('Message ID'), 'type' => 'text', 'param' => 128, 'extra' => false, 'visible' => false, 'required' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_hidden')));
Utils_RecordBrowserCommon::new_record_field('rc_mails', array('name' => _M('References'), 'type' => 'text', 'param' => 128, 'extra' => false, 'visible' => false, 'required' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_hidden')));
Esempio n. 16
0
 public static function install_new_recordset($tab, $fields = array())
 {
     if (!preg_match('/^[a-zA-Z_0-9]+$/', $tab)) {
         trigger_error('Invalid table name (' . $tab . ') given to install_new_recordset.', E_USER_ERROR);
     }
     if (strlen($tab) > 39) {
         trigger_error('Invalid table name (' . $tab . ') given to install_new_recordset, max length is 39 characters.', E_USER_ERROR);
     }
     if (!DB::GetOne('SELECT 1 FROM recordbrowser_table_properties WHERE tab=%s', array($tab))) {
         DB::Execute('INSERT INTO recordbrowser_table_properties (tab) VALUES (%s)', array($tab));
     }
     @DB::DropTable($tab . '_callback');
     @DB::DropTable($tab . '_recent');
     @DB::DropTable($tab . '_favorite');
     @DB::DropTable($tab . '_edit_history_data');
     @DB::DropTable($tab . '_edit_history');
     @DB::DropTable($tab . '_field');
     @DB::DropTable($tab . '_data_1');
     @DB::DropTable($tab . '_access_clearance');
     @DB::DropTable($tab . '_access_fields');
     @DB::DropTable($tab . '_access');
     self::check_table_name(null, true);
     DB::CreateTable($tab . '_field', 'id I2 AUTO KEY NOTNULL,' . 'field C(32) UNIQUE NOTNULL,' . 'caption C(255),' . 'type C(32),' . 'extra I1 DEFAULT 1,' . 'visible I1 DEFAULT 1,' . 'tooltip I1 DEFAULT 1,' . 'required I1 DEFAULT 1,' . 'export I1 DEFAULT 1,' . 'active I1 DEFAULT 1,' . 'position I2,' . 'processing_order I2 NOTNULL,' . 'filter I1 DEFAULT 0,' . 'param C(255),' . 'style C(64)', array('constraints' => ''));
     DB::CreateTable($tab . '_callback', 'field C(32),' . 'callback C(255),' . 'freezed I1', array('constraints' => ''));
     DB::Execute('INSERT INTO ' . $tab . '_field(field, type, extra, visible, position, processing_order) VALUES(\'id\', \'foreign index\', 0, 0, 1, 1)');
     DB::Execute('INSERT INTO ' . $tab . '_field(field, type, extra, position, processing_order) VALUES(\'General\', \'page_split\', 0, 2, 2)');
     $fields_sql = '';
     foreach ($fields as $v) {
         $fields_sql .= Utils_RecordBrowserCommon::new_record_field($tab, $v, false, false);
     }
     DB::CreateTable($tab . '_data_1', 'id I AUTO KEY,' . 'created_on T NOT NULL,' . 'created_by I NOT NULL,' . 'indexed I1 NOT NULL DEFAULT 0,' . 'active I1 NOT NULL DEFAULT 1' . $fields_sql, array('constraints' => ''));
     DB::CreateIndex($tab . '_idxed', $tab . '_data_1', 'indexed,active');
     DB::CreateIndex($tab . '_act', $tab . '_data_1', 'active');
     DB::CreateTable($tab . '_edit_history', 'id I AUTO KEY,' . $tab . '_id I NOT NULL,' . 'edited_on T NOT NULL,' . 'edited_by I NOT NULL', array('constraints' => ', FOREIGN KEY (edited_by) REFERENCES user_login(id), FOREIGN KEY (' . $tab . '_id) REFERENCES ' . $tab . '_data_1(id)'));
     DB::CreateTable($tab . '_edit_history_data', 'edit_id I,' . 'field C(32),' . 'old_value X', array('constraints' => ', FOREIGN KEY (edit_id) REFERENCES ' . $tab . '_edit_history(id)'));
     DB::CreateTable($tab . '_favorite', 'fav_id I AUTO KEY,' . $tab . '_id I,' . 'user_id I', array('constraints' => ', FOREIGN KEY (user_id) REFERENCES user_login(id), FOREIGN KEY (' . $tab . '_id) REFERENCES ' . $tab . '_data_1(id)'));
     DB::CreateTable($tab . '_recent', 'recent_id I AUTO KEY,' . $tab . '_id I,' . 'user_id I,' . 'visited_on T', array('constraints' => ', FOREIGN KEY (user_id) REFERENCES user_login(id), FOREIGN KEY (' . $tab . '_id) REFERENCES ' . $tab . '_data_1(id)'));
     DB::CreateTable($tab . '_access', 'id I AUTO KEY,' . 'action C(16),' . 'crits X', array('constraints' => ''));
     DB::CreateTable($tab . '_access_fields', 'rule_id I,' . 'block_field C(32)', array('constraints' => ', FOREIGN KEY (rule_id) REFERENCES ' . $tab . '_access(id)'));
     DB::CreateTable($tab . '_access_clearance', 'rule_id I,' . 'clearance C(32)', array('constraints' => ', FOREIGN KEY (rule_id) REFERENCES ' . $tab . '_access(id)'));
     self::check_table_name($tab, true);
     self::add_access($tab, 'print', 'SUPERADMIN');
     self::add_access($tab, 'export', 'SUPERADMIN');
     return true;
 }
Esempio n. 17
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
$fields = array(array('name' => _M('Subject'), 'type' => 'text', 'param' => '256', 'extra' => false, 'visible' => true, 'required' => false, 'display_callback' => array('CRM_RoundcubeCommon', 'display_subject')), array('name' => _M('Count'), 'type' => 'calculated', 'extra' => false, 'visible' => true, 'required' => false, 'display_callback' => array('CRM_RoundcubeCommon', 'display_thread_count'), 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_thread_count')), array('name' => _M('Contacts'), 'type' => 'crm_company_contact', 'param' => array('field_type' => 'multiselect'), 'required' => false, 'extra' => false, 'visible' => true), array('name' => _M('First Date'), 'type' => 'timestamp', 'extra' => false, 'visible' => true, 'required' => false), array('name' => _M('Last Date'), 'type' => 'timestamp', 'extra' => false, 'visible' => true, 'required' => false), array('name' => _M('Attachments'), 'type' => 'calculated', 'extra' => false, 'visible' => true, 'display_callback' => array('CRM_RoundcubeCommon', 'display_thread_attachments'), 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_thread_attachments')));
Utils_RecordBrowserCommon::install_new_recordset('rc_mail_threads', $fields);
Utils_RecordBrowserCommon::set_caption('rc_mail_threads', _M('Mail Thread'));
Utils_RecordBrowserCommon::new_record_field('rc_mails', array('name' => _M('Thread'), 'type' => 'select', 'param' => 'rc_mail_threads::Count', 'extra' => false, 'visible' => false, 'required' => false));
Utils_RecordBrowserCommon::add_access('rc_mail_threads', 'view', 'ACCESS:employee');
Utils_RecordBrowserCommon::add_access('rc_mail_threads', 'delete', 'ACCESS:employee');