Esempio n. 1
0
	public function install() {
		$this->create_data_dir();
		
		Base_ThemeCommon::install_default_theme('Utils/RecordBrowser');
		DB::CreateTable('recordbrowser_table_properties',
						'id I2 AUTO KEY,'.
						'tab C(64),'.
						'quickjump C(64) DEFAULT \'\','.
						'tpl C(255) DEFAULT \'\','.
						'favorites I1 DEFAULT 0,'.
						'recent I2 DEFAULT 0,'.
						'full_history I1 DEFAULT 1,'.
						'caption C(32) DEFAULT \'\','.
						'icon C(255) DEFAULT \'\','.
						'access_callback C(128) DEFAULT \'\','.
						'description_callback C(128) DEFAULT \'\','.
                        'jump_to_id I1 DEFAULT 1,'.
                        'search_include I1 DEFAULT 0,'.
                        'search_priority I1 DEFAULT 0,'.
                        'printer C(255) DEFAULT \'\'',
						array('constraints'=>', UNIQUE(tab)'));
		DB::CreateTable('recordbrowser_datatype',
						'type C(32) KEY,'.
						'module C(64),'.
						'func C(128)',
						array('constraints'=>''));
		DB::CreateTable('recordbrowser_addon',
					'tab C(64),'.
					'module C(128),'.
					'func C(128),'.
					'pos I,'.
					'enabled I1,'.
					'label C(128)',
					array('constraints'=>', PRIMARY KEY(tab, module, func)'));
		DB::CreateTable('recordbrowser_browse_mode_definitions',
					'tab C(64),'.
					'module C(128),'.
					'func C(128)',
					array('constraints'=>', PRIMARY KEY(tab, module, func)'));
		DB::CreateTable('recordbrowser_processing_methods',
					'tab C(64),'.
					'func C(255)',
					array('constraints'=>', PRIMARY KEY(tab, func)'));
		DB::CreateTable('recordbrowser_clipboard_pattern', 'tab C(64) KEY, pattern X, enabled I4');

		DB::CreateTable('recordbrowser_words_index', 'id I AUTO KEY,word C(3)',
					array('constraints'=>', UNIQUE(word)'));
		DB::CreateTable('recordbrowser_words_map', 'word_id I, tab_id I2, record_id I, field_id I2, position I',
					array('constraints'=>', FOREIGN KEY (word_id) REFERENCES recordbrowser_words_index(id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (tab_id) REFERENCES recordbrowser_table_properties(id) ON DELETE CASCADE ON UPDATE CASCADE'));
		DB::CreateIndex('recordbrowser_words_map__idx','recordbrowser_words_map','tab_id,record_id');
        Base_PrintCommon::register_printer(new Utils_RecordBrowser_RecordPrinter());
		return true;
	}
Esempio n. 2
0
 public function install()
 {
     Base_ThemeCommon::install_default_theme(CRM_ContactsInstall::module_name());
     Utils_RecordBrowserCommon::register_datatype('crm_company', 'CRM_ContactsCommon', 'crm_company_datatype');
     Utils_RecordBrowserCommon::register_datatype('crm_contact', 'CRM_ContactsCommon', 'crm_contact_datatype');
     Utils_RecordBrowserCommon::register_datatype('crm_company_contact', 'CRM_ContactsCommon', 'crm_company_contact_datatype');
     Utils_RecordBrowserCommon::register_datatype('email', 'CRM_ContactsCommon', 'email_datatype');
     ModuleManager::include_common('CRM_Contacts', 0);
     // ************ companies ************** //
     $fields = array(array('name' => _M('Company Name'), 'type' => 'text', 'required' => true, 'param' => '128', 'extra' => false, 'visible' => true, 'display_callback' => array('Utils_RecordBrowserCommon', 'display_linked_field_label'), 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_cname')), array('name' => _M('Short Name'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'visible' => false), array('name' => _M('Phone'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'visible' => true, 'display_callback' => array('CRM_ContactsCommon', 'display_phone')), array('name' => _M('Fax'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true), array('name' => _M('Email'), 'type' => 'email', 'required' => false, 'param' => array('unique' => true), 'extra' => true, 'visible' => false), array('name' => _M('Web address'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'display_webaddress'), 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_webaddress')), array('name' => _M('Group'), 'type' => 'multiselect', 'required' => false, 'visible' => true, 'param' => Utils_RecordBrowserCommon::multiselect_from_common('Companies_Groups'), 'extra' => false, 'filter' => true), array('name' => _M('Permission'), 'type' => 'commondata', 'required' => true, 'param' => array('order_by_key' => true, 'CRM/Access'), 'extra' => true), array('name' => _M('Address 1'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'maplink')), array('name' => _M('Address 2'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'maplink')), array('name' => _M('City'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'visible' => true, 'display_callback' => array('CRM_ContactsCommon', 'maplink')), array('name' => _M('Country'), 'type' => 'commondata', 'required' => true, 'param' => array('Countries'), 'extra' => true, 'QFfield_callback' => array('Data_CountriesCommon', 'QFfield_country')), array('name' => _M('Zone'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries', 'Country'), 'extra' => true, 'visible' => true, 'QFfield_callback' => array('Data_CountriesCommon', 'QFfield_zone')), array('name' => _M('Postal Code'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true), array('name' => _M('Tax ID'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_tax_id')));
     Utils_RecordBrowserCommon::install_new_recordset('company', $fields);
     // ************ contacts ************** //
     $fields = array(array('name' => _M('Last Name'), 'type' => 'text', 'required' => true, 'param' => '64', 'extra' => false, 'visible' => true, 'display_callback' => array('Utils_RecordBrowserCommon', 'display_linked_field_label')), array('name' => _M('First Name'), 'type' => 'text', 'required' => true, 'param' => '64', 'extra' => false, 'visible' => true, 'display_callback' => array('Utils_RecordBrowserCommon', 'display_linked_field_label')), array('name' => _M('Company Name'), 'type' => 'crm_company', 'param' => array('field_type' => 'select'), 'required' => false, 'extra' => false, 'visible' => true, 'filter' => true), array('name' => _M('Related Companies'), 'type' => 'crm_company', 'param' => array('field_type' => 'multiselect'), 'required' => false, 'extra' => true, 'visible' => false, 'filter' => true), array('name' => _M('Group'), 'type' => 'multiselect', 'required' => false, 'param' => Utils_RecordBrowserCommon::multiselect_from_common('Contacts_Groups'), 'extra' => true, 'filter' => true), array('name' => _M('Title'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true), array('name' => _M('Work Phone'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'visible' => true, 'display_callback' => array('CRM_ContactsCommon', 'display_phone')), array('name' => _M('Mobile Phone'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'visible' => true, 'display_callback' => array('CRM_ContactsCommon', 'display_phone')), array('name' => _M('Fax'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true), array('name' => _M('Email'), 'type' => 'email', 'required' => false, 'param' => array('unique' => true), 'extra' => false, 'visible' => false), array('name' => _M('Web address'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'display_webaddress'), 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_webaddress')), array('name' => _M('Address 1'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'maplink')), array('name' => _M('Address 2'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'maplink')), array('name' => _M('City'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'visible' => true, 'display_callback' => array('CRM_ContactsCommon', 'maplink')), array('name' => _M('Country'), 'type' => 'commondata', 'required' => true, 'param' => array('Countries'), 'extra' => true, 'visible' => false, 'QFfield_callback' => array('Data_CountriesCommon', 'QFfield_country')), array('name' => _M('Zone'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries', 'Country'), 'extra' => true, 'visible' => true, 'QFfield_callback' => array('Data_CountriesCommon', 'QFfield_zone')), array('name' => _M('Postal Code'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true), array('name' => _M('Permission'), 'type' => 'commondata', 'required' => true, 'param' => array('order_by_key' => true, 'CRM/Access'), 'extra' => true), array('name' => _M('Details'), 'type' => 'page_split'), array('name' => _M('Home Phone'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'display_phone')), array('name' => _M('Home Address 1'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'home_maplink')), array('name' => _M('Home Address 2'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'home_maplink')), array('name' => _M('Home City'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true, 'display_callback' => array('CRM_ContactsCommon', 'home_maplink')), array('name' => _M('Home Country'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries'), 'extra' => true, 'QFfield_callback' => array('Data_CountriesCommon', 'QFfield_country')), array('name' => _M('Home Zone'), 'type' => 'commondata', 'required' => false, 'param' => array('Countries', 'Home Country'), 'extra' => true, 'QFfield_callback' => array('Data_CountriesCommon', 'QFfield_zone')), array('name' => _M('Home Postal Code'), 'type' => 'text', 'required' => false, 'param' => '64', 'extra' => true), array('name' => _M('Birth Date'), 'type' => 'date', 'required' => false, 'param' => 64, 'extra' => true), array('name' => _M('Login Panel'), 'type' => 'page_split', 'param' => 1), array('name' => _M('Login'), 'type' => 'integer', 'required' => false, 'param' => '64', 'extra' => false, 'display_callback' => array('CRM_ContactsCommon', 'display_login'), 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_login'), 'style' => ''), array('name' => _M('Username'), 'type' => 'calculated', 'required' => false, 'extra' => false, 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_username')), array('name' => _M('Set Password'), 'type' => 'calculated', 'required' => false, 'extra' => false, 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_password')), array('name' => _M('Confirm Password'), 'type' => 'calculated', 'required' => false, 'extra' => false, 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_repassword')), array('name' => _M('Admin'), 'type' => 'calculated', 'required' => false, 'extra' => false, 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_admin'), 'display_callback' => array('CRM_ContactsCommon', 'display_admin')), array('name' => _M('Access'), 'type' => 'multiselect', 'required' => false, 'param' => Utils_RecordBrowserCommon::multiselect_from_common('Contacts/Access'), 'extra' => false, 'QFfield_callback' => array('CRM_ContactsCommon', 'QFfield_access')));
     Utils_RecordBrowserCommon::install_new_recordset('contact', $fields);
     DB::CreateIndex('contact_data_1__f_login_idx', 'contact_data_1', 'f_login,active');
     // ************ company settings ************** //
     Utils_RecordBrowserCommon::register_processing_callback('company', array('CRM_ContactsCommon', 'submit_company'));
     Utils_RecordBrowserCommon::set_quickjump('company', 'Company Name');
     Utils_RecordBrowserCommon::set_favorites('company', true);
     Utils_RecordBrowserCommon::set_recent('company', 15);
     Utils_RecordBrowserCommon::set_caption('company', _M('Companies'));
     Utils_RecordBrowserCommon::set_icon('company', Base_ThemeCommon::get_template_filename(CRM_ContactsInstall::module_name(), 'companies.png'));
     Utils_RecordBrowserCommon::set_description_callback('company', array('CRM_ContactsCommon', 'company_format_default'));
     Utils_RecordBrowserCommon::enable_watchdog('company', array('CRM_ContactsCommon', 'company_watchdog_label'));
     Utils_RecordBrowserCommon::set_clipboard_pattern('company', "%{{company_name}<BR>}\n%{{address_1}<BR>}\n%{{address_2}<BR>}\n%{%{{city} }%{{zone} }{postal_code}<BR>}\n%{{country}<BR>}\n%{tel. {phone}<BR>}\n%{fax. {fax}<BR>}\n%{{web_address}<BR>}");
     // ************ contacts settings ************** //
     Utils_RecordBrowserCommon::set_tpl('contact', Base_ThemeCommon::get_template_filename(CRM_ContactsInstall::module_name(), 'Contact'));
     Utils_RecordBrowserCommon::register_processing_callback('contact', array('CRM_ContactsCommon', 'submit_contact'));
     Utils_RecordBrowserCommon::set_quickjump('contact', 'Last Name');
     Utils_RecordBrowserCommon::set_favorites('contact', true);
     Utils_RecordBrowserCommon::set_recent('contact', 15);
     Utils_RecordBrowserCommon::set_caption('contact', _M('Contacts'));
     Utils_RecordBrowserCommon::set_icon('contact', Base_ThemeCommon::get_template_filename(CRM_ContactsInstall::module_name(), 'icon.png'));
     Utils_RecordBrowserCommon::set_description_callback('contact', array('CRM_ContactsCommon', 'contact_format_default'));
     Utils_RecordBrowserCommon::enable_watchdog('contact', array('CRM_ContactsCommon', 'contact_watchdog_label'));
     Utils_RecordBrowserCommon::set_clipboard_pattern('contact', "%{{first_name} {last_name}<BR>}\n%{{title}<BR>}\n%{{company_name}<BR>}\n%{{address_1}<BR>}\n%{{address_2}<BR>}\n%{%{{city} }%{{zone} }{postal_code}<BR>}\n%{{country}<BR>}\n%{tel. {work_phone}<BR>}\n%{{email}<BR>}");
     // ************ addons ************** //
     Utils_RecordBrowserCommon::new_addon('company', CRM_ContactsInstall::module_name(), 'company_addon', _M('Contacts'));
     Utils_AttachmentCommon::new_addon('company');
     Utils_AttachmentCommon::new_addon('contact');
     // ************ other ************** //
     Utils_CommonDataCommon::new_array('Companies_Groups', array('customer' => _M('Customer'), 'vendor' => _M('Vendor'), 'other' => _M('Other'), 'manager' => _M('Manager')), true, true);
     Utils_CommonDataCommon::new_array('Contacts_Groups', array('office' => _M('Office Staff'), 'field' => _M('Field Staff'), 'custm' => _M('Customer')), true, true);
     Utils_CommonDataCommon::new_array('Contacts/Access', array('manager' => _M('Manager')), true, true);
     Utils_BBCodeCommon::new_bbcode('contact', 'CRM_ContactsCommon', 'contact_bbcode');
     Utils_BBCodeCommon::new_bbcode('company', 'CRM_ContactsCommon', 'company_bbcode');
     Utils_RecordBrowserCommon::set_search('company', 1, 2);
     Utils_RecordBrowserCommon::set_search('contact', 1, 2);
     Base_AclCommon::add_clearance_callback(array('CRM_ContactsCommon', 'crm_clearance'));
     Utils_CommonDataCommon::extend_array('Contacts/Access', array('employee' => _M('Employee')));
     self::install_permissions();
     return true;
 }
Esempio n. 3
0
	public function install() {
		Base_ThemeCommon::install_default_theme($this->get_type());
		$ret = true;
		$ret &= DB::CreateTable('utils_watchdog_category',
					'id I AUTO KEY,'.
					'name C(32),'.
					'callback C(128)',
			array('constraints'=>''));
		if(!$ret){
			print('Unable to create table utils_watchdog_category.<br>');
			return false;
		}
		$ret &= DB::CreateTable('utils_watchdog_event',
					'id I AUTO KEY,'.
					'category_id I,'.
					'internal_id I,'.
					'message C(64),'.
					'event_time T',
			array('constraints'=>', FOREIGN KEY (category_id) REFERENCES utils_watchdog_category(id)'));
		if(!$ret){
			print('Unable to create table utils_watchdog_event.<br>');
			return false;
		}
		$ret &= DB::CreateTable('utils_watchdog_subscription',
					'category_id I,'.
					'internal_id I,'.
					'last_seen_event I,'.
					'user_id I',
			array('constraints'=>', FOREIGN KEY (user_id) REFERENCES user_login(id)'));
		if(!$ret){
			print('Unable to create table utils_watchdog_subscription.<br>');
			return false;
		}
		$ret &= DB::CreateTable('utils_watchdog_category_subscription',
					'category_id I,'.
					'user_id I',
			array('constraints'=>', FOREIGN KEY (user_id) REFERENCES user_login(id), FOREIGN KEY (category_id) REFERENCES utils_watchdog_category(id)'));
		if(!$ret){
			print('Unable to create table utils_watchdog_category_subscription.<br>');
			return false;
		}

		DB::CreateIndex('utils_watchdog_event__internal_id__idx', 'utils_watchdog_event', 'internal_id');
		DB::CreateIndex('utils_watchdog_event__cat_int__idx', 'utils_watchdog_event', array('category_id','internal_id'));
		DB::CreateIndex('utils_watchdog_subscription__cat_int__idx', 'utils_watchdog_subscription', array('category_id','internal_id'));
		DB::CreateIndex('utils_watchdog_subscription__user__idx', 'utils_watchdog_subscription', 'user_id');
		Base_AclCommon::add_permission(_M('Watchdog - subscribe to categories'),array('ACCESS:employee','ACCESS:manager'));
		return $ret;
	}
Esempio n. 4
0
	public function install() {
		$ret = true;
        Utils_RecordBrowserCommon::uninstall_recordset('utils_attachment');
        $fields = array(
            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')
            ),
            array(
                'name' => _M('Title'),
                'type' => 'text',
                'param' => 255,
                'required' => false, 'extra' => false, 'visible' => false
            ),
            array('name' => _M('Note'),
                'type' => 'long text',
                'required' => false,
                'extra' => false,
                'visible'=>true,
                'display_callback'=>array('Utils_AttachmentCommon','display_note'),
                'QFfield_callback'=>array('Utils_AttachmentCommon','QFfield_note'),
            ),
            array('name' => _M('Permission'),
                'type' => 'commondata',
                'required' => true,
                'param' => array('order_by_key' => true, 'CRM/Access'),
                'extra' => false),
            array('name' => _M('Sticky'),
                'type' => 'checkbox',
                'visible' => true,
                'extra' => false),
            array('name' => _M('Crypted'),
                'type' => 'checkbox',
                'extra' => false,
                'QFfield_callback'=>array('Utils_AttachmentCommon','QFfield_crypted')),
            array('name' => _M('Attached to'),
                'type' => 'calculated',
                'extra' => false,
                'display_callback'=>array('Utils_AttachmentCommon','display_attached_to')),
        );
        Utils_RecordBrowserCommon::install_new_recordset('utils_attachment',$fields);
        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'));
        Utils_RecordBrowserCommon::register_processing_callback('utils_attachment',array('Utils_AttachmentCommon','submit_attachment'));
        Utils_RecordBrowserCommon::set_tpl('utils_attachment', Base_ThemeCommon::get_template_filename('Utils/Attachment', 'View_entry'));
        Utils_RecordBrowserCommon::enable_watchdog('utils_attachment', array('Utils_AttachmentCommon','watchdog_label'));
        Utils_RecordBrowserCommon::set_caption('utils_attachment', _M('Note'));
        Utils_RecordBrowserCommon::set_description_callback('utils_attachment', array('Utils_AttachmentCommon','description_callback'));
        Utils_RecordBrowserCommon::set_jump_to_id('utils_attachment', false);
        Utils_RecordBrowserCommon::set_search('utils_attachment',1,0);

        $ret &= DB::CreateTable('utils_attachment_local','
			local C(255) NOTNULL,
			attachment I4 NOTNULL,
			func C(255),
			args C(255)',
            array('constraints'=>', FOREIGN KEY (attachment) REFERENCES utils_attachment_data_1(ID)'));
        if(!$ret){
            print('Unable to create table utils_attachment_local.<br>');
            return false;
        }
        DB::CreateIndex('utils_attachment_local__idx', 'utils_attachment_local', 'local');

		$ret &= DB::CreateTable('utils_attachment_file','
			id I4 AUTO KEY NOTNULL,
			attach_id I4 NOTNULL,
			original C(255) NOTNULL,
			created_by I4,
			created_on T DEFTIMESTAMP,
			deleted I1 NOTNULL DEFAULT 0',
			array('constraints'=>', FOREIGN KEY (created_by) REFERENCES user_login(ID), FOREIGN KEY (attach_id) REFERENCES utils_attachment_data_1(id)'));
		if(!$ret){
			print('Unable to create table utils_attachment_file.<br>');
			return false;
		}
        DB::CreateIndex('attach_id_idx','utils_attachment_file','attach_id');
		$ret &= DB::CreateTable('utils_attachment_download','
			id I4 AUTO KEY NOTNULL,
			attach_file_id I4 NOTNULL,
			created_by I4,
			created_on T,
			expires_on T,
			remote I1 DEFAULT 0,
			download_on T DEFTIMESTAMP,
			ip_address C(32),
			host_name C(64),
			description C(128),
			token C(32)',
			array('constraints'=>', FOREIGN KEY (created_by) REFERENCES user_login(ID), FOREIGN KEY (attach_file_id) REFERENCES utils_attachment_file(id)'));
		if(!$ret){
			print('Unable to create table utils_attachment_download.<br>');
			return false;
		}
		$ret &= DB::CreateTable('utils_attachment_clipboard','
			id I4 AUTO KEY NOTNULL,
			filename C(255),
			created_by I4,
			created_on T DEFTIMESTAMP',
			array('constraints'=>''));

		$this->create_data_dir();
		file_put_contents($this->get_data_dir().'.htaccess','deny from all');
		Base_ThemeCommon::install_default_theme($this->get_type());
		
		DB::CreateTable('utils_attachment_googledocs','
			id I4 AUTO KEY NOTNULL,
			note_id I4 NOTNULL,
			view_link C(255),
			doc_id C(128)',
			array('constraints'=>''));
		
		Base_AclCommon::add_permission(_M('Attachments - view full download history'), array('ACCESS:employee'));

		Variable::set('utils_attachments_google_user', '');
		Variable::set('utils_attachments_google_pass', '');
		return $ret;
	}
Esempio n. 5
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. 6
0
        if (DB::is_postgresql()) {
            DB::Execute('ALTER TABLE recordbrowser_table_properties DROP CONSTRAINT recordbrowser_table_properties_pkey');
            DB::Execute('ALTER TABLE recordbrowser_table_properties ADD COLUMN id SERIAL PRIMARY KEY');
        } else {
            DB::Execute('ALTER TABLE recordbrowser_table_properties DROP PRIMARY KEY');
            DB::Execute('ALTER TABLE recordbrowser_table_properties ADD id SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY');
        }
        DB::CreateIndex('recordbrowser_table_properties_tab', 'recordbrowser_table_properties', 'tab', array('UNIQUE' => 1));
        $tab_ids_checkpoint->done();
    }
}
$field_ids_checkpoint = Patch::checkpoint('field_ids');
if (!$field_ids_checkpoint->is_done()) {
    Patch::require_time(20);
    $recordsets = Utils_RecordBrowserCommon::list_installed_recordsets();
    foreach ($recordsets as $tab => $caption) {
        $tab_f = $tab . "_field";
        $columns = DB::MetaColumnNames($tab_f);
        if (!isset($columns['ID'])) {
            if (DB::is_postgresql()) {
                @DB::Execute('ALTER TABLE ' . $tab_f . ' DROP CONSTRAINT ' . $tab_f . '_pkey');
                DB::Execute('ALTER TABLE ' . $tab_f . ' ADD COLUMN id SERIAL PRIMARY KEY');
            } else {
                @DB::Execute('ALTER TABLE ' . $tab_f . ' DROP PRIMARY KEY');
                DB::Execute('ALTER TABLE ' . $tab_f . ' ADD id SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY');
            }
            DB::CreateIndex($tab_f . '_field', $tab_f, 'field', array('UNIQUE' => 1));
        }
    }
    $field_ids_checkpoint->done();
}
Esempio n. 7
0
function install_base()
{
    require_once 'include/config.php';
    require_once 'include/database.php';
    @DB::Execute('ALTER DATABASE `' . DATABASE_NAME . '` CHARACTER SET utf8 COLLATE utf8_unicode_ci');
    $ret = DB::CreateTable('modules', "name C(128) KEY,version I NOTNULL, priority I NOTNULL DEFAULT 0, state I NOTNULL DEFAULT 0");
    if ($ret === false) {
        die('Invalid SQL query - Setup module (modules table)');
    }
    $ret = DB::CreateTable('cron', "func C(32) KEY,last I NOTNULL, running I1 NOTNULL DEFAULT 0, description C(255)");
    if ($ret === false) {
        die('Invalid SQL query - Setup cron (cron table)');
    }
    $ret = DB::CreateTable('session', "name C(128) NOTNULL," . "expires I NOTNULL DEFAULT 0, data B", array('constraints' => ', PRIMARY KEY(name)'));
    if ($ret === false) {
        die('Invalid SQL query - Database module (session table)');
    }
    $ret = DB::CreateTable('session_client', "session_name C(128) NOTNULL, client_id I2," . "data B", array('constraints' => ', FOREIGN KEY(session_name) REFERENCES session(name), PRIMARY KEY(client_id,session_name)'));
    if ($ret === false) {
        die('Invalid SQL query - Database module (session_client table)');
    }
    $ret = DB::CreateTable('history', "session_name C(128) NOTNULL, page_id I, client_id I2," . "data B", array('constraints' => ', FOREIGN KEY(session_name) REFERENCES session(name), PRIMARY KEY(client_id,session_name,page_id)'));
    if ($ret === false) {
        die('Invalid SQL query - Database module (history table)');
    }
    DB::CreateIndex('history__session_name__client_id__idx', 'history', 'session_name, client_id');
    $ret = DB::CreateTable('variables', "name C(32) KEY,value X");
    if ($ret === false) {
        die('Invalid SQL query - Database module (variables table)');
    }
    $ret = DB::Execute("insert into variables values('default_module',%s)", array(serialize('FirstRun')));
    if ($ret === false) {
        die('Invalid SQL query - Setup module (populating variables)');
    }
    $ret = DB::Execute("insert into variables values('version',%s)", array(serialize(EPESI_VERSION)));
    if ($ret === false) {
        die('Invalid SQL query - Setup module (populating variables)');
    }
}
Esempio n. 8
0
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'add', array('ACCESS:employee', 'ACCESS:mrm'));
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'delete', array('ACCESS:employee', 'ACCESS:mrm'));
    $field = 'person';
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'view', 'ALL', array($field . '[view]' => 'USER', '(employees' => 'USER', '|employees' => ''));
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'view', 'ALL', array($field . '[view]' => 'USER'), array('employees', 'notes', 'description', 'witness', 'notified_party', 'action_taken'));
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'edit', 'ALL', array($field . '[edit]' => 'USER'), array($field));
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'add', 'ALL', array('(' . $field => '', '|' . $field . '[add]' => 'USER'));
    Utils_RecordBrowserCommon::add_access('cades_incidents', 'delete', 'ALL', array($field . '[delete]' => 'USER'));
    Utils_RecordBrowserCommon::add_default_access('cades_billing_authorization');
    Utils_RecordBrowserCommon::add_default_access('cades_billing_auth_used');
    Utils_RecordBrowserCommon::add_default_access('premium_schoolregister_att_except');
    Utils_RecordBrowserCommon::add_default_access('cades_billing_auth_rejected');
    Utils_RecordBrowserCommon::add_default_access('cades_billing_auth_bill');
    DB::CreateIndex('prem_school_reg__idx_1', 'premium_schoolregister_lesson_data_1', 'f_date');
    DB::CreateIndex('prem_school_reg__idx_2', 'premium_schoolregister_lesson_data_1', 'f_course');
    DB::CreateIndex('prem_school_reg__idx_3', 'premium_schoolregister_lesson_data_1', 'f_custom_course');
    DB::Execute('UPDATE contact_data_1 SET f_company_name=1, f_related_companies=NULL WHERE f_related_companies=%s AND f_company_name IS NULL', array('__1__'));
}
if (ModuleManager::is_installed('Premium_Warehouse_eCommerce') >= 0) {
    DB::Execute('UPDATE premium_ecommerce_products_field SET type=%s WHERE field=%s OR field=%s', array(Variable::get('ecommerce_item_descriptions') ? 'calculated' : 'hidden', 'Product Name', 'Description'));
    foreach (array('premium_ecommerce_products', 'premium_ecommerce_parameters', 'premium_ecommerce_parameter_groups', 'premium_ecommerce_pages', 'premium_ecommerce_polls', 'premium_ecommerce_boxes', 'premium_ecommerce_3rdp_info') as $t) {
        DB::Execute('UPDATE ' . $t . '_field SET type=%s WHERE field=%s', array('hidden', 'Position'));
    }
}
if (ModuleManager::is_installed('Premium_Warehouse_Items') >= 0) {
    DB::Execute('UPDATE premium_warehouse_items_categories_field SET type=%s WHERE field=%s', array('hidden', 'Position'));
}
if (ModuleManager::is_installed('Premium_Warehouse_Items_Orders') >= 0) {
    Utils_RecordBrowserCommon::field_deny_access('premium_warehouse_items', 'Quantity on Hand', 'edit');
}
Utils_RecordBrowserCommon::add_access('premium_warehouse_items_orders', 'view', 'ACCESS:employee');
Esempio n. 9
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
@DB::CreateIndex('attach_id_idx', 'utils_attachment_file', 'attach_id');
Esempio n. 10
0
 public function install()
 {
     $this->create_data_dir();
     // create htaccess to prevent logs to be available on the internet
     $htaccess = $this->get_data_dir() . '.htaccess';
     $f = fopen($htaccess, 'w');
     if ($f === false) {
         print "Cannot create .htaccess file ({$htaccess}). " . "Your Roundcube logs may be available on the internet!";
     } else {
         fwrite($f, "deny from all\n");
         fclose($f);
     }
     Base_ThemeCommon::install_default_theme($this->get_type());
     $this->drop_all_rc_tables();
     if (DB::is_mysql()) {
         $f = file_get_contents('modules/CRM/Roundcube/RC/SQL/mysql.initial.sql');
     } else {
         $f = file_get_contents('modules/CRM/Roundcube/RC/SQL/postgres.initial.sql');
     }
     foreach (explode(';', $f) as $q) {
         $q = trim($q);
         if (!$q) {
             continue;
         }
         DB::Execute($q);
     }
     Utils_CommonDataCommon::new_array('CRM/Roundcube/Security', array('tls' => _M('TLS'), 'ssl' => _M('SSL')), true, true);
     //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('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('rc_related', array('recordset' => 'company'));
     Utils_RecordBrowserCommon::new_record('rc_related', array('recordset' => 'contact'));
     //accounts table
     $fields = array(array('name' => _M('EPESI User'), 'type' => 'integer', 'extra' => false, 'visible' => true, 'required' => true, 'display_callback' => array('CRM_RoundcubeCommon', 'display_epesi_user'), 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_epesi_user')), array('name' => _M('Email'), 'type' => 'text', 'extra' => false, 'visible' => true, 'required' => true, 'param' => 128), array('name' => _M('Account Name'), 'type' => 'text', 'extra' => false, 'visible' => true, 'required' => true, 'param' => 32, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_account_name')), array('name' => _M('Server'), 'type' => 'text', 'extra' => false, 'visible' => true, 'param' => '255', 'required' => true), array('name' => _M('Login'), 'type' => 'text', 'required' => true, 'param' => '255', 'extra' => false, 'visible' => true), array('name' => _M('Password'), 'type' => 'text', 'required' => true, 'extra' => false, 'param' => '255', 'visible' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_password'), 'display_callback' => array('CRM_RoundcubeCommon', 'display_password')), array('name' => _M('Security'), 'type' => 'commondata', 'param' => array('CRM/Roundcube/Security'), 'extra' => false, 'visible' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_security')), array('name' => _M('SMTP Server'), 'type' => 'text', 'extra' => false, 'visible' => false, 'param' => '255', 'required' => true), array('name' => _M('SMTP Auth'), 'type' => 'checkbox', 'extra' => false, 'visible' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_smtp_auth')), array('name' => _M('SMTP Login'), 'type' => 'text', 'required' => false, 'param' => '255', 'extra' => false, 'visible' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_smtp_login')), array('name' => _M('SMTP Password'), 'type' => 'text', 'extra' => false, 'param' => '255', 'visible' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_smtp_password'), 'display_callback' => array('CRM_RoundcubeCommon', 'display_password')), array('name' => _M('SMTP Security'), 'type' => 'commondata', 'param' => array('CRM/Roundcube/Security'), 'extra' => false, 'visible' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_smtp_security')), array('name' => _M('Default Account'), 'type' => 'checkbox', 'extra' => false, 'visible' => true, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_default_account')), array('name' => _M('Advanced'), 'type' => 'page_split'), array('name' => _M('Archive on sending'), 'type' => 'checkbox', 'extra' => true, 'visible' => false), array('name' => _M('Use EPESI Archive directories'), 'type' => 'checkbox', 'extra' => true, 'visible' => false), array('name' => _M('IMAP Root'), 'type' => 'text', 'param' => 32, 'extra' => true, 'visible' => false), array('name' => _M('IMAP Delimiter'), 'type' => 'text', 'param' => 8, 'extra' => true, 'visible' => false));
     Utils_RecordBrowserCommon::install_new_recordset('rc_accounts', $fields);
     Utils_RecordBrowserCommon::set_caption('rc_accounts', _M('Mail accounts'));
     Utils_RecordBrowserCommon::register_processing_callback('rc_accounts', array('CRM_RoundcubeCommon', 'submit_account'));
     $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_addon('rc_mail_threads', 'CRM/Roundcube', 'thread_addon', _M('E-mails'));
     Utils_RecordBrowserCommon::set_search('rc_mail_threads', 2, -1);
     $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('Contacts'), 'type' => 'crm_company_contact', 'param' => array('field_type' => 'multiselect'), 'required' => false, 'extra' => false, 'visible' => true), array('name' => _M('Employee'), 'type' => 'crm_contact', 'param' => array('field_type' => 'select'), 'extra' => false, 'visible' => true, 'required' => false), 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), array('name' => _M('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_attachments'), 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_attachments')), array('name' => _M('Headers Data'), 'type' => 'long text', 'extra' => false, 'visible' => false, 'required' => false), array('name' => _M('Body'), 'type' => 'long text', 'extra' => false, 'visible' => false, 'required' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_body')), array('name' => _M('From'), 'type' => 'text', 'param' => 128, 'extra' => false, 'visible' => false, 'required' => false), array('name' => _M('To'), 'type' => 'text', 'param' => 4096, 'extra' => false, 'visible' => false, 'required' => false), array('name' => _M('Thread'), 'type' => 'select', 'param' => 'rc_mail_threads::Count', 'extra' => false, 'visible' => false, 'required' => false, 'display_callback' => array('CRM_RoundcubeCommon', 'display_mail_thread'), 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_mail_thread')), array('name' => _M('Message ID'), 'type' => 'text', 'param' => 128, 'extra' => false, 'visible' => false, 'required' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_hidden')), array('name' => _M('References'), 'type' => 'text', 'param' => 4096 * 4, 'extra' => false, 'visible' => false, 'required' => false, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_hidden')));
     Utils_RecordBrowserCommon::install_new_recordset('rc_mails', $fields);
     Utils_RecordBrowserCommon::set_caption('rc_mails', _M('Mails'));
     Utils_RecordBrowserCommon::set_tpl('rc_mails', Base_ThemeCommon::get_template_filename('CRM/Roundcube', 'mails'));
     Utils_RecordBrowserCommon::register_processing_callback('rc_mails', array('CRM_RoundcubeCommon', 'submit_mail'));
     Utils_RecordBrowserCommon::set_search('rc_mails', 2, -1);
     DB::CreateIndex('rc_mails_thread_idx', 'rc_mails_data_1', 'f_thread');
     DB::CreateIndex('rc_mails_msgid_idx', 'rc_mails_data_1', 'f_message_id');
     Utils_RecordBrowserCommon::new_addon('rc_mails', 'CRM/Roundcube', 'mail_body_addon', _M('Body'));
     Utils_RecordBrowserCommon::new_addon('rc_mails', 'CRM/Roundcube', 'attachments_addon', _M('Attachments'));
     Utils_RecordBrowserCommon::new_addon('rc_mails', 'CRM/Roundcube', 'mail_headers_addon', _M('Headers'));
     @DB::DropTable('rc_mails_attachments');
     DB::CreateTable('rc_mails_attachments', '
         mail_id I4 NOTNULL,
         type C(32),
         name C(255),
         mime_id C(32),
         attachment I1 DEFAULT 1', array('constraints' => ', FOREIGN KEY (mail_id) REFERENCES rc_mails_data_1(ID)'));
     DB::CreateTable('rc_mails_attachments_download', '
         mail_id I4 NOTNULL,
         hash C(32),
         created_on T DEFTIMESTAMP', array('constraints' => ', FOREIGN KEY (mail_id) REFERENCES rc_mails_data_1(ID)'));
     Utils_RecordBrowserCommon::new_addon('contact', 'CRM/Roundcube', 'addon', _M('E-mails'));
     Utils_RecordBrowserCommon::new_addon('company', 'CRM/Roundcube', 'addon', _M('E-mails'));
     $fields = array(array('name' => _M('Record Type'), 'type' => 'hidden', 'param' => Utils_RecordBrowserCommon::actual_db_type('text', 64), 'required' => false, 'visible' => false, 'filter' => true, 'extra' => false), array('name' => _M('Record ID'), 'type' => 'hidden', 'param' => Utils_RecordBrowserCommon::actual_db_type('integer'), 'filter' => false, 'required' => false, 'extra' => false, 'visible' => false), array('name' => _M('Nickname'), 'type' => 'text', 'required' => true, 'param' => '64', 'extra' => false, 'visible' => true, 'QFfield_callback' => array('CRM_RoundcubeCommon', 'QFfield_nickname')), array('name' => _M('Email'), 'type' => 'email', 'required' => true, 'param' => array('unique' => true), 'extra' => false, 'visible' => true));
     Utils_RecordBrowserCommon::install_new_recordset('rc_multiple_emails', $fields);
     Utils_RecordBrowserCommon::set_favorites('rc_multiple_emails', true);
     Utils_RecordBrowserCommon::set_caption('rc_multiple_emails', _M('Mail addresses'));
     Utils_RecordBrowserCommon::set_icon('rc_multiple_emails', Base_ThemeCommon::get_template_filename('CRM/Roundcube', 'icon.png'));
     Utils_RecordBrowserCommon::set_search('rc_multiple_emails', 2, 0);
     Utils_RecordBrowserCommon::new_addon('contact', 'CRM/Roundcube', 'mail_addresses_addon', _M('E-mail addresses'));
     Utils_RecordBrowserCommon::new_addon('company', 'CRM/Roundcube', 'mail_addresses_addon', _M('E-mail addresses'));
     Variable::set('crm_roundcube_global_signature', "Message sent with EPESI - managing business your way!<br /><a href=\"http://epe.si\">http://epe.si</a>");
     Utils_RecordBrowserCommon::add_access('rc_accounts', 'view', 'ACCESS:employee', array('epesi_user' => 'USER_ID'));
     Utils_RecordBrowserCommon::add_access('rc_accounts', 'add', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_accounts', 'edit', 'ACCESS:employee', array(), array('epesi_user'));
     Utils_RecordBrowserCommon::add_access('rc_accounts', 'delete', 'ACCESS:employee', array('epesi_user' => 'USER_ID'));
     Utils_RecordBrowserCommon::add_access('rc_mails', 'view', 'ACCESS:employee', array(), array('headers_data'));
     Utils_RecordBrowserCommon::add_access('rc_mails', 'delete', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_mails', 'edit', 'ACCESS:employee', array(), array('subject', 'employee', 'date', 'headers_data', 'body', 'from', 'to', 'thread', 'message_id', 'references'));
     Utils_RecordBrowserCommon::add_access('rc_mail_threads', 'view', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_mail_threads', 'delete', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_multiple_emails', 'view', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_multiple_emails', 'add', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_multiple_emails', 'edit', 'ACCESS:employee');
     Utils_RecordBrowserCommon::add_access('rc_multiple_emails', 'delete', 'ACCESS:employee');
     return true;
 }
        JOIN information_schema.constraint_column_usage AS ccu
          ON ccu.constraint_name = tc.constraint_name
        WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name='recordbrowser_words_map' AND kcu.column_name='word_id';");
        if($a) {
            DB::Execute('alter table recordbrowser_words_map drop CONSTRAINT "'.$a.'"');
        }
    }
    DB::CreateIndex('recordbrowser_words_map__idx','recordbrowser_words_map','word_id,tab,record_id,field_name',array('DROP'=>1));
    DB::CreateIndex('recordbrowser_words_map__idx2','recordbrowser_words_map','tab,record_id',array('DROP'=>1));
    
    DB::Execute('TRUNCATE TABLE recordbrowser_words_index');
    
    $remove_idx_checkpoint->done();
}

$finalize_checkpoint = Patch::checkpoint('finalize');
if(!$finalize_checkpoint->is_done()) {
    Patch::require_time(20);

    PatchUtil::db_drop_column('recordbrowser_words_map', 'tab');
    PatchUtil::db_drop_column('recordbrowser_words_map', 'field_name');

    if(DB::is_postgresql()) {
        DB::Execute('ALTER TABLE recordbrowser_words_map ADD CONSTRAINT word_id_fk FOREIGN KEY (word_id) REFERENCES recordbrowser_words_index');
    } else {
        DB::Execute('ALTER TABLE recordbrowser_words_map ADD FOREIGN KEY (word_id) REFERENCES recordbrowser_words_index(id)');
    }
    DB::CreateIndex('recordbrowser_words_map__idx','recordbrowser_words_map','word_id,tab_id');
    $finalize_checkpoint->done();
}
Esempio n. 12
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
$checkpoint = Patch::checkpoint('indexes');
if (!$checkpoint->is_done()) {
    $done = $checkpoint->get('recordsets', array());
    $recordsets = Utils_RecordBrowserCommon::list_installed_recordsets();
    foreach ($recordsets as $tab => $caption) {
        Patch::require_time(1);
        if (!isset($done[$tab])) {
            @DB::CreateIndex($tab . '_act', $tab . '_data_1', 'active');
            @DB::CreateIndex($tab . '_idxed', $tab . '_data_1', 'indexed,active');
            $done[$tab] = true;
            $checkpoint->set('recordsets', $done);
        }
    }
    $checkpoint->done();
}
Esempio n. 13
0
    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');
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'edit', 'ACCESS:employee', array('(permission' => 0, '|employees' => 'USER', '|customer' => 'USER'), array('edited_on'));
    Utils_RecordBrowserCommon::register_processing_callback('utils_attachment', array('Utils_AttachmentCommon', 'submit_attachment'));
    Utils_RecordBrowserCommon::set_tpl('utils_attachment', Base_ThemeCommon::get_template_filename(Utils_Attachment::module_name(), 'View_entry'));
    $ret = DB::CreateTable('utils_attachment_local', '
			local C(255) NOTNULL,
			attachment I4 NOTNULL,
			func C(255),
			args C(255)', array('constraints' => ', FOREIGN KEY (attachment) REFERENCES utils_attachment_data_1(ID)'));
    if (!$ret) {
        print 'Unable to create table utils_attachment_link.<br>';
        return false;
    }
    DB::CreateIndex('utils_attachment_local__idx', 'utils_attachment_local', 'local');
    $rs_checkpoint->done();
}
//parse old notes
Patch::set_message('Processing notes');
$old_checkpoint = Patch::checkpoint('old');
$map = $old_checkpoint->get('map', array());
if (!$old_checkpoint->is_done()) {
    $us = Acl::get_user();
    if ($old_checkpoint->has('links')) {
        $links = $old_checkpoint->get('links');
    } else {
        $links = 0;
    }
    if ($old_checkpoint->has('links_qty')) {
        $links_qty = $old_checkpoint->get('links_qty');
Esempio n. 14
0
<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');
PatchUtil::db_alter_column('rc_mails_data_1', 'f_references', 'C(16384)');
PatchUtil::db_alter_column('rc_mails_data_1', 'f_to', 'C(4096)');
DB::Execute('UPDATE rc_mails_data_1 SET f_thread=null');
DB::Execute('DELETE FROM rc_mail_threads_edit_history_data');
DB::Execute('DELETE FROM rc_mail_threads_edit_history');
DB::Execute('DELETE FROM rc_mail_threads_data_1');
DB::Execute("UPDATE rc_mails_data_1 SET f_message_id=REPLACE (f_message_id, '&lt;','')");
DB::Execute("UPDATE rc_mails_data_1 SET f_message_id=REPLACE (f_message_id, '&gt;','')");
// create index to optimize counting completed field
@DB::CreateIndex('rc_mails_thread_idx', 'rc_mails_data_1', 'f_thread');
@DB::CreateIndex('rc_mails_msgid_idx', 'rc_mails_data_1', 'f_message_id');
$mails = Utils_RecordBrowserCommon::get_records('rc_mails');
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 (!$m['message_id'] && 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']);
}