Exemplo n.º 1
0
	public function show($tab, $crits=array(), $cols=array(), $order=array(), $filters=array(),$path=null) {
		$rb = $this->init_module('Utils/RecordBrowser', $tab, $tab.'_picker');
//		$rb->adv_search = true;
		$rb->disable_actions();

		$this->display_module($rb, array($crits, $cols, $order, $filters, $path), 'recordpicker_fs');
	        Base_ActionBarCommon::add('save', __('Commit Selection'), $this->create_callback_href(array($this,'back')));
	        Base_ActionBarCommon::add('back', __('Cancel'), $this->create_callback_href(array($this,'cancel')));
	}
Exemplo n.º 2
0
 /**
  * For internal use only.
  */
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name());
     //defaults
     $defaults = array();
     $defaults['mail_method'] = Variable::get('mail_method');
     $defaults['mail_use_replyto'] = Variable::get('mail_use_replyto');
     $defaults['mail_user'] = Variable::get('mail_user');
     $defaults['mail_from_addr'] = Variable::get('mail_from_addr');
     $defaults['mail_from_name'] = Variable::get('mail_from_name');
     $defaults['mail_host'] = Variable::get('mail_host');
     $defaults['mail_security'] = Variable::get('mail_security', false);
     $defaults['mail_auth'] = Variable::get('mail_auth');
     $defaults['mail_password'] = Variable::get('mail_password');
     $form->setDefaults($defaults);
     //form
     $form->addElement('header', null, __('Mail settings'));
     $form->addElement('select', 'mail_method', __('Choose method'), array('smtp' => __('remote smtp server'), 'mail' => __('local php.ini settings')), 'onChange="' . $form->get_submit_form_js(false) . '"');
     $form->addElement('text', 'mail_from_addr', __('Administrator e-mail address'));
     $form->addRule('mail_from_addr', __('Invalid e-mail address'), 'email');
     $form->addRule('mail_from_addr', __('Field required'), 'required');
     $form->addElement('text', 'mail_from_name', __('Send e-mails from name'));
     $form->addElement('text', 'mail_use_replyto', __('Set "Reply-To" email address'));
     $form->addRule('mail_use_replyto', __('Invalid e-mail address'), 'email');
     $method = $form->getElement('mail_method')->getSelected();
     if ($method[0] == 'smtp') {
         $form->addElement('text', 'mail_host', __('SMTP host address'));
         $form->addRule('mail_host', __('Field required'), 'required');
         $form->addElement('select', 'mail_security', __('Security'), array('' => __('None'), 'ssl' => 'SSL', 'ssl_ssc' => 'SSL (self signed certificate)', 'tls' => 'TLS', 'tls_ssc' => 'TLS (self signed certificate)'));
         $form->addElement('checkbox', 'mail_auth', __('SMTP authorization'), '', 'onChange="' . $form->get_submit_form_js(false) . '"');
         $auth = $form->getElement('mail_auth')->getValue();
         if ($auth) {
             $form->addElement('text', 'mail_user', __('Login'));
             $form->addElement('password', 'mail_password', __('Password'));
         }
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
         $me = CRM_ContactsCommon::get_my_record();
         $email = $me['email'];
         Base_ActionBarCommon::add('search', __('Test'), $this->create_callback_href(array($this, 'test_mail_config'), array($email)), __('E-mail will be sent to %s to test the configuration', array('<b>' . $email . '</b>')));
     }
     if ($form->getSubmitValue('submited') && $form->validate() && $form->process(array(&$this, 'submit_admin'))) {
         Base_StatusBarCommon::message(__('Settings saved'));
     }
     $form->display();
 }
Exemplo n.º 3
0
 public static function user_settings($settings_edit = false)
 {
     if ($settings_edit) {
         Base_ActionBarCommon::add(Base_ThemeCommon::get_template_file('Base_Notify', 'icon.png'), __('Browser Settings'), 'onClick="Base_Notify__notify (\'Notification\', {body: \'enabled\', icon: \'' . self::get_icon('Base_Notify') . '\'}, true);"', __('Click to set browser settings for tray notifications'));
     }
     $ret = array(array('name' => null, 'label' => __('General'), 'type' => 'header'), array('name' => 'general_timeout', 'reload' => 1, 'label' => __('Close Message Timeout'), 'type' => 'select', 'values' => Utils_CommonDataCommon::get_translated_array('Base_Notify/Timeout', true), 'default' => 0), array('name' => 'general_group', 'label' => __('Group Similar Notifications'), 'type' => 'checkbox', 'default' => 1), array('name' => null, 'label' => __('Module Specific Timeout'), 'type' => 'header'));
     $modules = ModuleManager::check_common_methods('tray_notification');
     foreach ($modules as $module) {
         $label = self::get_module_caption($module);
         $ret = array_merge($ret, array(array('name' => $module . '_timeout', 'label' => $label, 'type' => 'select', 'values' => array(-2 => _M('Use general setting')) + Utils_CommonDataCommon::get_translated_array('Base_Notify/Timeout', true), 'default' => -2)));
     }
     return array(__('Notify') => $ret);
 }
Exemplo n.º 4
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $this->pack_module(Utils_CommonData::module_name(), 'Countries', 'admin_array');
 }
Exemplo n.º 5
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $this->rb = $this->init_module(Utils_RecordBrowser::module_name(), 'data_tax_rates', 'data_tax_rates_module');
     $this->display_module($this->rb);
 }
Exemplo n.º 6
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $this->rb = $this->init_module('Utils/RecordBrowser', 'quick_search', 'quick_searach');
     $this->display_module($this->rb);
     return true;
 }
Exemplo n.º 7
0
 public function download_template()
 {
     $ld = $this->get_data_dir() . 'list/';
     if (!file_exists($ld)) {
         return $this->download_templates_list();
     }
     if ($this->is_back()) {
         return false;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('search', __('Update templates list'), $this->create_callback_href(array($this, 'download_templates_list')));
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'new_templates');
     $m->set_table_columns(array(array('name' => 'Name', 'search' => 1), array('name' => 'Version'), array('name' => 'Screenshot'), array('name' => 'Author', 'search' => 1), array('name' => 'Info', 'search' => 1), array('name' => 'Compatible')));
     $content = scandir($ld);
     foreach ($content as $template_name) {
         if ($template_name == '.' || $template_name == '..') {
             continue;
         }
         $ini = parse_ini_file($ld . $template_name . '/info.ini');
         $compatible = version_compare($ini['epesi_version'], EPESI_VERSION) <= 0;
         $installed = is_dir(DATA_DIR . '/Base_Theme/templates/' . $template_name);
         if ($installed) {
             $installed_ini = @parse_ini_file(DATA_DIR . '/Base_Theme/templates/' . $template_name . '/info.ini');
             if (!$installed_ini) {
                 $installed_ini = array('version' => 0);
             }
         }
         if (isset($ini['screenshot'])) {
             $th_big = Utils_ImageCommon::create_thumb($ld . $template_name . '/' . $ini['screenshot'], 640, 480);
             $thumb = '<a href="' . $th_big['thumb'] . '" rel="lyteshow">' . Utils_ImageCommon::get_thumb_html($ld . $template_name . '/' . $ini['screenshot'], 120, 120) . '</a>';
         } else {
             $thumb = '';
         }
         $r = $m->get_new_row();
         $r->add_data($template_name, $ini['version'], $thumb, $ini['author'], $ini['info'], $compatible ? '<font color="green">yes</font>' : '<font color="red">NO</font> epesi ' . $ini['epesi_version'] . ' required');
         if ($compatible && !$installed) {
             $r->add_action($this->create_callback_href(array($this, 'install_template'), $template_name), 'Install');
         }
         if ($installed) {
             $r->add_action($this->create_callback_href(array($this, 'delete_template'), $template_name), 'Delete');
             if ($ini['version'] > $installed_ini['version']) {
                 $r->add_action($this->create_callback_href(array($this, 'update_template'), $template_name), 'Update');
             }
         }
     }
     $this->display_module($m, array(true), 'automatic_display');
     return true;
 }
Exemplo n.º 8
0
 /**
  * Displays menu editor.
  */
 public function body()
 {
     $edit = $this->get_module_variable_or_unique_href_variable('edit');
     if (isset($edit)) {
         return $this->edit($edit);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'custommenu');
     $data = $this->get_module_variable('data');
     $gb->set_table_columns(array(array('name' => __('Menu entry path'), 'width' => 70)));
     foreach ($data as $row) {
         $r =& $gb->get_new_row();
         $r->add_data($row);
         $r->add_action($this->create_unique_href(array('edit' => $row)), 'Edit');
         $r->add_action($this->create_confirm_callback_href(__('Are you sure?'), array($this, 'delete_entry'), $row), 'Delete');
     }
     $this->display_module($gb);
     Base_ActionBarCommon::add('add', __('New menu entry'), $this->create_unique_href(array('edit' => false)));
 }
Exemplo n.º 9
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     $form = $this->init_module('Libs/QuickForm', 'Errors to mail');
     $form->addElement('text', 'mail', __('Send bugs to'));
     $form->addRule('mail', __('Invalid e-mail address'), 'email');
     $form->addElement('static', '', '', __('Leave empty to disable bug reports.'));
     Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     $form->setDefaults(array('mail' => Variable::get('error_mail')));
     if ($form->validate()) {
         Variable::set('error_mail', $form->exportValue('mail'));
         $this->parent->reset();
     } else {
         $form->display();
     }
 }
Exemplo n.º 10
0
 public function body($record)
 {
     $form = $this->init_module('Utils/FileUpload', array(false));
     $form->addElement('header', 'upload', __('Upload new photo') . ': ' . $record['last_name'] . ' ' . $record['first_name']);
     $form->set_upload_button_caption(__('Save'));
     $form->add_upload_element();
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     if (CRM_Contacts_PhotoCommon::get_photo($record['id'])) {
         Base_ActionBarCommon::add('delete', __('Clear'), $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'clear_photo'), array($record['id'])));
     }
     $this->display_module($form, array(array($this, 'submit_attach'), $record));
     if ($this->is_back() || $this->submitted) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         return $x->pop_main();
     }
 }
Exemplo n.º 11
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $theme = $this->init_module(Base_Theme::module_name());
     $new_token_href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'new_token'));
     $theme->assign('new_token_href', $new_token_href);
     $theme->assign('wiki_url', 'http://www.epesi.org/Cron');
     $theme->assign('cron_url', Base_CronCommon::get_cron_url());
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'cron');
     $m->set_table_columns(array(array('name' => 'Description', 'width' => 65), array('name' => 'Last Run', 'width' => 20), array('name' => 'Running', 'width' => 15)));
     $ret = DB::Execute('SELECT description,last,running FROM cron ORDER BY last DESC');
     while ($row = $ret->FetchRow()) {
         $m->add_row($row['description'] ? $row['description'] : '???', $row['last'] ? Base_RegionalSettingsCommon::time2reg($row['last']) : '---', $row['running'] ? '<span style="color:red">' . __('Yes') . '</span>' : '<span style="color:green">' . __('No') . '</span>');
     }
     $html = $this->get_html_of_module($m);
     $theme->assign('history', $html);
     $theme->display();
 }
Exemplo n.º 12
0
 public function body()
 {
     /* Do not delete anything - all messages are kept in history
     		// to allow delete by admin uncomment below lines
     		// if i am admin add "clear shoutbox" actionbar button
     		if(Base_AclCommon::i_am_admin())
     			Base_ActionBarCommon::add('delete',__('Clear shoutbox'),$this->create_callback_href(array($this,'delete_all')));
     		*/
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     if ($this->is_back()) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         $x->pop_main();
         return;
     }
     $tb = $this->init_module(Utils_TabbedBrowser::module_name());
     $tb->set_tab(__('Chat'), array($this, 'chat'), true, null);
     $tb->set_tab(__('History'), array($this, 'history'), null);
     $this->display_module($tb);
 }
Exemplo n.º 13
0
	public function add($def_date,$timeless=false) {
		if($this->is_back()) $this->back_to_calendar();

		$qf = $this->init_module('Libs/QuickForm',null,'addf');
		$qf->addElement('datepicker','start','Start Date');
		$qf->addElement('datepicker','end','End Date');
//		$qf->addElement('checkbox','timeless','Timeless'); //always
		$qf->addElement('text','title','Title');
		$qf->addElement('textarea','description','Description');
		$qf->addElement('select','color','Color',array('blue'=>'&bull; Blue', 'red'=>'&bull; Red', 'yellow'=>'&bull; Yellow', 'green'=>'&bull; Green', 'gray' => '&bull; Gray', 'cyan' => '&bull; Cyan', 'magenta' => '&bull; Magenta'));
		$qf->setDefaults(array('start'=>$def_date,'end'=>$def_date));
		if($qf->validate()) {
			$d = $qf->exportValues();
			DB::Execute('INSERT INTO tests_calendar_event(start,duration,timeless,title,description,created_on,created_by,color) VALUES(%d,%d,%b,%s,%s,%T,%d,%s)',
				array(strtotime($d['start']),strtotime($d['end'])-strtotime($d['start'])+86400,true,$d['title'],$d['description'],time(),Acl::get_user(),$d['color']));
			$this->back_to_calendar();
		} else {
			$qf->display();
			Base_ActionBarCommon::add('back',__('Cancel'),$this->create_back_href());
			Base_ActionBarCommon::add('save',__('Save'),$qf->get_submit_form_href());
		}
	}
Exemplo n.º 14
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $form = $this->init_module('Libs/QuickForm');
     foreach (Base_PrintCommon::get_registered_printers_translated() as $class_name => $printer_name) {
         $printer = Base_PrintCommon::printer_instance($class_name);
         $form->addElement('header', $printer_name, $printer_name);
         foreach ($printer->default_templates() as $tpl_name => $tpl) {
             $field_id = "{$class_name}::{$tpl_name}";
             $field_id = preg_replace('/[^A-Za-z0-9_:]/', '_', $field_id);
             $form->addElement('checkbox', $field_id, _V($tpl_name));
             $state = !Base_PrintCommon::is_template_disabled($class_name, $tpl_name);
             $form->setDefaults(array($field_id => $state));
         }
     }
     if ($form->validate()) {
         $values = $form->exportValues();
         foreach (Base_PrintCommon::get_registered_printers_translated() as $class_name => $printer_name) {
             $printer = Base_PrintCommon::printer_instance($class_name);
             foreach ($printer->default_templates() as $tpl_name => $tpl) {
                 $field_id = "{$class_name}::{$tpl_name}";
                 $field_id = preg_replace('/[^A-Za-z0-9_:]/', '_', $field_id);
                 $active = isset($values[$field_id]) ? $values[$field_id] : false;
                 Base_PrintCommon::set_template_disabled($class_name, $tpl_name, $active);
             }
         }
         $this->parent->reset();
     } else {
         Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
         $this->display_module($form);
     }
 }
Exemplo n.º 15
0
 public function account_manager($pushed_on_top = false)
 {
     if ($pushed_on_top) {
         if ($this->is_back()) {
             Base_BoxCommon::pop_main();
             return;
         }
         Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     } else {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     $this->rb = $this->init_module('Utils/RecordBrowser', 'rc_accounts', 'rc_accounts');
     $this->rb->set_defaults(array('epesi_user' => Acl::get_user()));
     $order = array(array('login' => 'DESC'), array('epesi_user' => Acl::get_user()), array('epesi_user' => false));
     $this->display_module($this->rb, $order);
     // other settings
     $qf = $this->init_module('Libs/QuickForm');
     $qf->addElement('advcheckbox', 'standard_mailto', __("Use standard mailto links"), null, array('onchange' => $qf->get_submit_form_js()));
     $use_standard_mailto = CRM_RoundcubeCommon::use_standard_mailto();
     $qf->setDefaults(array('standard_mailto' => $use_standard_mailto));
     if ($qf->validate()) {
         CRM_RoundcubeCommon::set_standard_mailto($qf->exportValue('standard_mailto'));
     }
     $qf->display_as_row();
 }
Exemplo n.º 16
0
 public function edit_group($id = null)
 {
     if ($this->is_back()) {
         return false;
     }
     $form = $this->init_module('Libs/QuickForm', null, 'edit_group');
     if (isset($id)) {
         $name = DB::GetOne('SELECT name FROM crm_filters_group WHERE id=%d', array($id));
         $description = DB::GetOne('SELECT description FROM crm_filters_group WHERE id=%d', array($id));
         $form->addElement('header', null, __('Edit group "%s"', array($name)));
         $contacts_def = DB::GetCol('SELECT contact_id FROM crm_filters_contacts WHERE group_id=%d', array($id));
         $form->setDefaults(array('name' => $name, 'contacts' => $contacts_def, 'description' => $description));
     } else {
         $form->addElement('header', null, __('New preset'));
     }
     $form->addElement('text', 'name', __('Name'));
     $form->addElement('text', 'description', __('Description'));
     $form->addRule('name', __('Max length of field exceeded'), 'maxlength', 128);
     $form->addRule('description', __('Max length of field exceeded'), 'maxlength', 256);
     $form->addRule('name', __('Field required'), 'required');
     $form->registerRule('unique', 'callback', 'check_group_name_exists', 'CRM_Filters');
     $form->addRule('name', __('Group with this name already exists'), 'unique', $id);
     $form->addFormRule(array($this, 'check_amount_of_records'));
     $form->addElement('automulti', 'contacts', __('Records of'), array('CRM_ContactsCommon', 'automulti_contact_suggestbox'), array(array(), array('CRM_ContactsCommon', 'contact_format_no_company')), array('CRM_ContactsCommon', 'contact_format_no_company'));
     if ($form->validate()) {
         $v = $form->exportValues();
         if (isset($id)) {
             DB::Execute('UPDATE crm_filters_group SET name=%s,description=%s WHERE id=%d', array($v['name'], $v['description'], $id));
             DB::Execute('DELETE FROM crm_filters_contacts WHERE group_id=%d', array($id));
         } else {
             DB::Execute('INSERT INTO crm_filters_group(name,description,user_login_id) VALUES(%s,%s,%d)', array($v['name'], $v['description'], Acl::get_user()));
             $id = DB::Insert_ID('crm_filters_group', 'id');
         }
         foreach ($v['contacts'] as $p) {
             DB::Execute('INSERT INTO crm_filters_contacts(group_id,contact_id) VALUES(%d,%d)', array($id, $p));
         }
         return false;
     } else {
         Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
         Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
         $form->display_as_column();
     }
     return true;
 }
Exemplo n.º 17
0
 /**
  * For internal use only.
  */
 public function browse($name = '', $root = true)
 {
     if ($this->is_back()) {
         return false;
     }
     if (isset($_REQUEST['node_position'])) {
         list($node_id, $position) = $_REQUEST['node_position'];
         Utils_CommonDataCommon::change_node_position($node_id, $position);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'browse' . md5($name));
     $gb->set_table_columns(array(array('name' => __('Position'), 'width' => 5, 'order' => 'position'), array('name' => __('Key'), 'width' => 20, 'order' => 'akey', 'search' => 1, 'quickjump' => 'akey'), array('name' => __('Value'), 'width' => 20, 'order' => 'value', 'search' => 1)));
     print '<h2>' . $name . '</h2><br>';
     $ret = Utils_CommonDataCommon::get_translated_array($name, true, true);
     foreach ($ret as $k => $v) {
         $gb_row = $gb->get_new_row();
         $gb_row->add_data($v['position'], $k, $v['value']);
         // ****** CommonData value translation
         $gb_row->add_action($this->create_callback_href(array($this, 'browse'), array($name . '/' . $k, false)), 'View');
         if (!$v['readonly']) {
             $gb_row->add_action($this->create_callback_href(array($this, 'edit'), array($name, $k)), 'Edit');
             $gb_row->add_action($this->create_confirm_callback_href(__('Delete array') . ' \'' . Epesi::escapeJS($name . '/' . $k, false) . '\'?', array('Utils_CommonData', 'remove_array'), array($name . '/' . $k)), 'Delete');
         }
         $node_id = $v['id'];
         $gb_row->add_action('class="move-handle"', 'Move', __('Drag to change node order'), 'move-up-down');
         $gb_row->set_attrs("node=\"{$node_id}\" class=\"sortable\"");
     }
     $gb->set_default_order(array(__('Position') => 'ASC'));
     //$this->display_module($gb);
     $this->display_module($gb, array(true), 'automatic_display');
     // sorting
     load_js($this->get_module_dir() . 'sort_nodes.js');
     $table_md5 = md5($gb->get_path());
     eval_js("utils_commondata_sort_nodes_init(\"{$table_md5}\")");
     Base_ActionBarCommon::add('settings', __('Reset Order By Key'), $this->create_callback_href(array('Utils_CommonDataCommon', 'reset_array_positions'), $name));
     Base_ActionBarCommon::add('add', __('Add array'), $this->create_callback_href(array($this, 'edit'), $name));
     if (!$root) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     }
     return true;
 }
Exemplo n.º 18
0
 public function no_ssl_settings()
 {
     $f = $this->init_module("Libs/QuickForm");
     $f->addElement('checkbox', 'allow', 'Allow unsecure connection');
     Base_ActionBarCommon::add('back', __('Back'), Base_BoxCommon::pop_main_href());
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     if ($f->validate()) {
         $x = $f->exportValues();
         $allow = false;
         if (isset($x['allow']) && $x['allow']) {
             $allow = true;
         }
         Base_EssClientCommon::set_no_ssl_allow($allow);
         Base_BoxCommon::pop_main();
         return;
     }
     $f->setDefaults(array('allow' => Base_EssClientCommon::is_no_ssl_allowed()));
     print '<div class="important_notice">';
     print __('Allowing unsecure connection will cause all the data to be transferred without encryption. This creates opportunity for third parties to capture the data being transmitted, including your License Key. Please note that License Key should be kept confidential and that using the same License Key on several EPESI installations is a direct violation of Terms of Service and will result in termination of the License Key.');
     print '<center>';
     $f->display();
     print '</center>';
     print '</div>';
 }
Exemplo n.º 19
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
         return;
     }
     $rb = $this->init_module('Utils/RecordBrowser', 'phonecall_related', 'phonecall_related');
     $this->display_module($rb);
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
 }
Exemplo n.º 20
0
 public function body($pdf = false, $charts = false)
 {
     if ($this->is_back()) {
         return false;
     }
     if ($this->date_range == 'error') {
         return;
     }
     Base_ThemeCommon::load_css('Utils/RecordBrowser/Reports');
     $this->pdf = $pdf || isset($_REQUEST['rb_reports_enable_pdf']);
     $this->csv = isset($_REQUEST['rb_reports_enable_csv']);
     unset($_REQUEST['rb_reports_enable_pdf']);
     $this->charts = $charts;
     if ($this->pdf) {
         $this->pdf_ob = $this->init_module(Libs_TCPDF::module_name(), 'L');
         $this->pdf_ob->set_title($this->pdf_title);
         $this->pdf_ob->set_subject($this->pdf_subject);
         $this->pdf_ob->prepare_header();
         $this->pdf_ob->AddPage();
     } elseif (!$this->charts && !$this->csv) {
         Base_ActionBarCommon::add('report', __('Charts'), $this->create_callback_href(array($this, 'body'), array(false, true)));
     }
     if ($this->charts) {
         $this->make_charts();
     } else {
         $this->make_table();
     }
     if ($this->csv) {
         $this->set_module_variable('csv', $this->csv_ob);
     }
     if ($charts) {
         Base_ActionBarCommon::add('report', __('Table'), $this->create_back_href());
         return true;
     } else {
         if (!$this->csv) {
             if ($this->pdf) {
                 Base_ActionBarCommon::add('save', __('Download PDF'), 'target="_blank" href="' . $this->pdf_ob->get_href($this->pdf_filename) . '"');
                 self::$pdf_ready = 1;
             } elseif ($this->pdf_title != '' && self::$pdf_ready == 0) {
                 if (count($this->gb_captions) < 20) {
                     Base_ActionBarCommon::add('print', __('Create PDF'), $this->create_href(array('rb_reports_enable_pdf' => 1)));
                 } else {
                     Base_ActionBarCommon::add('print', __('Create PDF'), '', __('Too many columns to prepare printable version - please limit number of columns'));
                 }
             }
         }
         if ($this->pdf_filename && !$this->pdf) {
             if ($this->csv) {
                 Base_ActionBarCommon::add('save', __('Download CSV'), 'target="_blank" href="' . $this->get_module_dir() . '/csv.php?' . http_build_query(array('p' => $this->get_path(), 'id' => CID, 'filename' => $this->pdf_filename)) . '"');
             } else {
                 Base_ActionBarCommon::add('print', __('Create CSV'), $this->create_href(array('rb_reports_enable_csv' => 1)));
             }
         }
     }
     return false;
 }
Exemplo n.º 21
0
 /**
  * Displays Comments.
  */
 public function body()
 {
     if (!Base_AclCommon::i_am_user()) {
         $this->reply = false;
     }
     $action = $this->get_module_variable_or_unique_href_variable('action');
     if ($action) {
         $this->{$action}();
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), __('Posting reply'));
     $theme = $this->init_module(Base_Theme::module_name());
     if ($this->tree_structure) {
         $answer = $this->get_module_variable('answer', -1);
         $change_answer = $this->get_unique_href_variable('answer');
         if ($change_answer) {
             $answer = $change_answer;
         }
         $this->set_module_variable('answer', $answer);
     } else {
         $answer = -1;
     }
     $report = $this->get_unique_href_variable('report');
     if ($report) {
         DB::Execute('INSERT INTO comment_report (id, user_login_id) VALUES (%d, %d)', array($report, Acl::get_user()));
     }
     if ($this->reply) {
         if ($this->reply_on_comment_page) {
             $form->addElement('hidden', 'comment_content', 'none');
             if ($answer == -1) {
                 $form->addElement('header', 'reply', __('Post in this thread'));
             } else {
                 $comment_info = DB::Execute('SELECT c.id, c.text, ul.login, c.created_on FROM comment AS c LEFT JOIN user_login AS ul ON (c.user_login_id = ul.id) WHERE c.id = %d ORDER BY created_on', array($answer))->FetchRow();
                 $form->addElement('header', 'reply', sprintf(__('Reply to %s\'s comment given at %s'), $comment_info['login'], date('G:i, d M Y', strtotime($comment_info['created_on']))));
                 $form->addElement('static', 'whole', '', '<a ' . $this->create_unique_href(array('answer' => -1)) . '>' . __('Comment whole thread') . '</a>');
             }
             $form->addElement('textarea', 'comment_page_reply', __('Message'), array('rows' => 4, 'cols' => 40));
             //,'onBlur'=>'document.getElementsByName(\'comment_content\')[0].value = document.getElementsByName(\'comment_page_reply\')[0].value.replace(/\n/g,\'<br>\');'));
             $form->addElement('submit', 'submit_comment', __('Submit'));
             if ($form->validate() && $this->reply) {
                 $this->add_post($form->exportValue('comment_page_reply'), $answer);
                 $this->unset_module_variable('answer');
                 $answer = -1;
             }
             $form->assign_theme('form', $theme);
         } else {
             Base_ActionBarCommon::add('add', __('Reply'), $this->create_unique_href(array('action' => 'post_reply')));
         }
     }
     $recordSet = DB::Execute('SELECT COUNT(*) FROM comment WHERE topic=%s AND parent <= -1', array($this->key))->FetchRow();
     if (!$this->per_page) {
         $this->per_page = 10;
     }
     $this->qty = $recordSet[0];
     $this->offset = intval($this->get_module_variable_or_unique_href_variable('offset'));
     if ($this->get_unique_href_variable('next') == '1') {
         $this->offset += $this->per_page;
     } elseif ($this->get_unique_href_variable('prev') == '1') {
         $this->offset -= $this->per_page;
         if ($this->offset < 0) {
             $this->offset = 0;
         }
     } elseif ($this->get_unique_href_variable('first') == '1') {
         $this->offset = 0;
     } elseif ($this->get_unique_href_variable('last') == '1') {
         $this->offset = floor(($this->qty - 1) / $this->per_page) * $this->per_page;
     } elseif (($goto = $this->get_unique_href_variable('goto', null)) !== null) {
         $this->offset = $goto * $this->per_page;
     }
     $this->set_module_variable('offset', $this->offset);
     $comments = $this->fetch_posts();
     $pages = ceil($this->qty / $this->per_page);
     $curr_page = $this->offset / $this->per_page + 1;
     $i = 1;
     $before_dots = false;
     $after_dots = false;
     $pages_links = array(__('Pages'));
     while ($i <= $pages) {
         if ($i == $curr_page) {
             $pages_links[] = '<a>' . $i . '</a>';
         } else {
             if ($i <= 3 || abs($i - $curr_page) <= 1 || $pages - $i < 2) {
                 $pages_links[] = '<a ' . $this->create_unique_href(array('goto' => $i - 1)) . '>' . $i . '</a>';
             } else {
                 if ($i < $curr_page) {
                     if (!$before_dots) {
                         $before_dots = true;
                         $pages_links[] = '...';
                     }
                 } else {
                     if (!$after_dots) {
                         $after_dots = true;
                         $pages_links[] = '...';
                     }
                 }
             }
         }
         $i++;
     }
     if (!empty($comments)) {
         $theme->assign('comments', $comments);
         $theme->assign('first', $pages != $curr_page ? $this->first() : null);
         $theme->assign('prev', $pages != $curr_page ? $this->prev() : null);
         $theme->assign('next', $pages != $curr_page ? $this->next() : null);
         $theme->assign('last', $pages != $curr_page ? $this->last() : null);
         $theme->assign('pages', $pages != $curr_page ? $pages_links : null);
         $theme->assign('no_comments', false);
     } else {
         $theme->assign('no_comments', 'No comments yet.');
     }
     $theme->display('Comment');
 }
Exemplo n.º 22
0
 public static function handle_module_action($module, $action, $response_callback = null)
 {
     if (Base_BoxCommon::main_module_instance()->is_back()) {
         return false;
     }
     $return = null;
     switch ($action) {
         case self::ACTION_BUY:
             $modules = array_merge(array($module['id']), $module['needed_modules']);
             $response = Base_EssClientCommon::server()->order_submit($modules);
             $return = isset($response['order_id']) ? $response['order_id'] !== null : false;
             if ($return !== true) {
                 break;
             }
             $needs_payment = isset($response['needs_payment']) ? $response['needs_payment'] : false;
             if (!$needs_payment) {
                 break;
             }
             $return = self::_display_payments_for_order($response['order_id']);
             if ($return === true) {
                 Base_ActionBarCommon::add('back', __('Back'), Base_BoxCommon::main_module_instance()->create_back_href());
                 return true;
             }
             break;
         case self::ACTION_DOWNLOAD:
         case self::ACTION_UPDATE:
             $mi = self::_active_module_license_for_module($module['id']);
             if ($mi !== false) {
                 $return = self::download_module($mi);
             } else {
                 $return = false;
             }
             break;
         case self::ACTION_INSTALL:
             break;
         case self::ACTION_RESTORE:
             $modules = self::get_downloaded_modules();
             $download_info =& $modules[$module['id']];
             $return = false;
             if (isset($download_info)) {
                 try {
                     self::extract_module_file($download_info['file']);
                     $return = true;
                 } catch (ErrorException $ex) {
                     $return = $ex->getMessage();
                 }
             }
             break;
     }
     if (is_callable($response_callback)) {
         call_user_func($response_callback, $action, $return);
         return;
     }
     return $return;
 }
Exemplo n.º 23
0
 public function admin()
 {
     if (!Base_AclCommon::i_am_sa() || $this->is_back()) {
         $this->parent->reset();
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $cmr = ModuleManager::call_common_methods('admin_caption');
     foreach ($cmr as $name => $caption) {
         if (!ModuleManager::check_access($name, 'admin') || $name == 'Base_Admin') {
             continue;
         }
         if (!isset($caption)) {
             continue;
         }
         if (!is_array($caption)) {
             $caption = array('label' => $caption);
         }
         if (!isset($caption['section'])) {
             $caption['section'] = __('Misc');
         }
         $mod_ok[$name] = $caption;
     }
     uksort($mod_ok, 'strcasecmp');
     $form = $this->init_module('Libs_QuickForm');
     $buttons = array();
     load_js('modules/Base/Admin/js/main.js');
     foreach ($mod_ok as $name => $caption) {
         if (method_exists($name . 'Common', 'admin_icon')) {
             $icon = call_user_func(array($name . 'Common', 'admin_icon'));
         } else {
             $icon = Base_ThemeCommon::get_template_file($name, 'icon.png');
             if (!file_exists($icon)) {
                 $icon = Base_ThemeCommon::get_template_file('Base_Admin', 'icon.png');
             }
         }
         $button_id = $name . '__button';
         $enable_field = $name . '_enable';
         $sections = array();
         $sections_id = $name . '__sections';
         $enable_default = Base_AdminCommon::get_access($name, '', true);
         $form->addElement('checkbox', $enable_field, $enable_default === null ? __('Access blocked') : __('Allow access'), null, array('onchange' => 'admin_switch_button("' . $button_id . '",this.checked, "' . $sections_id . '");', 'id' => $enable_field, 'style' => $enable_default === null ? 'display:none;' : ''));
         $form->setDefaults(array($enable_field => $enable_default));
         eval_js('admin_switch_button("' . $button_id . '",$("' . $enable_field . '").checked, "' . $sections_id . '", 1);');
         if (class_exists($name . 'Common') && is_callable(array($name . 'Common', 'admin_access_levels'))) {
             $raws = call_user_func(array($name . 'Common', 'admin_access_levels'));
             if (is_array($raws)) {
                 foreach ($raws as $s => $v) {
                     $type = isset($v['values']) ? 'select' : 'checkbox';
                     $vals = isset($v['values']) ? $v['values'] : null;
                     $s_field = $name . '__' . $s . '__switch';
                     $form->addElement($type, $s_field, $v['label'], $vals);
                     $form->setDefaults(array($s_field => Base_AdminCommon::get_access($name, $s, true)));
                     $sections[$s] = $s_field;
                 }
             }
         }
         $buttons[$caption['section']][$name] = array('label' => $caption['label'], 'icon' => $icon, 'id' => $button_id, 'enable_switch' => $enable_field, 'sections_id' => $sections_id, 'sections' => $sections);
     }
     if ($form->validate()) {
         $vals = $form->exportValues();
         DB::Execute('DELETE FROM base_admin_access');
         foreach ($buttons as $section => $bs) {
             foreach ($bs as $name => $b) {
                 DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, '', isset($vals[$b['enable_switch']]) && $vals[$b['enable_switch']] ? 1 : 0));
                 foreach ($b['sections'] as $s => $f) {
                     DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, $s, isset($vals[$f]) ? $vals[$f] : 0));
                 }
             }
         }
         $this->parent->reset();
         return;
     }
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     $sections = array();
     foreach ($buttons as $section => $b) {
         $sections[$section] = array('header' => $section, 'buttons' => $b);
     }
     $sections = $this->sort_sections($sections);
     $theme = $this->pack_module('Base/Theme');
     $form->assign_theme('form', $theme);
     $theme->assign('header', __('Admin Panel Access'));
     $theme->assign('sections', $sections);
     $theme->display('access_panel');
 }
Exemplo n.º 24
0
 /**
  * Displays action bar.
  */
 public function body()
 {
     $this->help('ActionBar basics', 'main');
     $icons = Base_ActionBarCommon::get();
     //sort
     usort($icons, array($this, 'compare'));
     //translate
     foreach ($icons as &$i) {
         $description = $i['description'];
         if ($i['description']) {
             $t = Utils_TooltipCommon::open_tag_attrs($description);
         } else {
             $t = '';
         }
         $i['open'] = '<a ' . $i['action'] . ' ' . $t . '>';
         $i['close'] = '</a>';
         $i['helpID'] = 'ActionBar_' . $i['icon'];
         if (strpos($i['icon'], '/') !== false && file_exists($i['icon'])) {
             $i['icon_url'] = $i['icon'];
             unset($i['icon']);
         }
         //if (isset(Base_ActionBarCommon::$available_icons[$i['icon']]))
         //	$i['icon'] = Base_ThemeCommon::get_template_file('Base_ActionBar','icons/'.$i['icon'].'.png');
     }
     $launcher = array();
     if (Base_AclCommon::is_user()) {
         $opts = Base_Menu_QuickAccessCommon::get_options();
         if (!empty($opts)) {
             self::$launchpad = array();
             foreach ($opts as $k => $v) {
                 if (Base_ActionBarCommon::$quick_access_shortcuts && Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_d')) {
                     $ii = array();
                     $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
                     $ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
                     $ii['description'] = $v['label'];
                     $arr = $v['link'];
                     if (isset($arr['__url__'])) {
                         $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank">';
                     } else {
                         $ii['open'] = '<a ' . Base_MenuCommon::create_href($this, $arr) . '>';
                     }
                     $ii['close'] = '</a>';
                     if (isset($v['link']['__icon__'])) {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
                     } else {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
                     }
                     if (!$icon) {
                         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png');
                     }
                     $ii['icon'] = $icon;
                     $launcher[] = $ii;
                 }
                 if (Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_l')) {
                     $ii = array();
                     $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
                     $ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
                     $ii['description'] = $v['label'];
                     $arr = $v['link'];
                     if (isset($arr['__url__'])) {
                         $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank" onClick="actionbar_launchpad_deactivate()">';
                     } else {
                         $ii['open'] = '<a onClick="actionbar_launchpad_deactivate();' . Base_MenuCommon::create_href_js($this, $arr) . '" href="javascript:void(0)">';
                     }
                     $ii['close'] = '</a>';
                     if (isset($v['link']['__icon__'])) {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
                     } else {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
                     }
                     if (!$icon) {
                         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png');
                     }
                     $ii['icon'] = $icon;
                     self::$launchpad[] = $ii;
                 }
             }
         }
     }
     //display
     $th = $this->pack_module(Base_Theme::module_name());
     $th->assign('icons', $icons);
     $th->assign('launcher', array_reverse($launcher));
     $th->display();
 }
Exemplo n.º 25
0
 public function new_lang_pack()
 {
     if ($this->is_back()) {
         return false;
     }
     $url = 'http://forum.epesibim.com/';
     $forum_link = "<a target=\"_blank\" href=\"{$url}\">{$url}</a>";
     $info_msg = __('If you wish to add other language or dialect of existing language, then please contact us via forum: %s', array($forum_link));
     print "<div class=\"important_notice\">{$info_msg}</div>";
     $form = $this->init_module('Libs/QuickForm', __('Creating new langpack...'), 'new_langpack');
     $form->addElement('header', null, __('Create new langpack'));
     $form->addElement('select', 'code', __('Language'), Base_Lang_AdministratorCommon::available_new_languages());
     $form->registerRule('check_if_langpack_exists', 'callback', 'check_if_langpack_exists', $this);
     $form->addRule('code', __('Specified langpack already exists'), 'check_if_langpack_exists');
     $form->addRule('code', __('Field required'), 'required');
     if ($form->validate()) {
         Base_LangCommon::new_langpack($form->exportValue('code'));
         $this->unset_module_variable('action');
         return false;
     }
     Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     $form->display();
     return true;
 }
Exemplo n.º 26
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     $form = $this->init_module('Libs/QuickForm');
     $form->addElement('header', 'settings', __('Title'));
     $form->setDefaults(array('title' => Variable::get('base_page_title'), 'show_caption_in_title' => Variable::get('show_caption_in_title'), 'show_module_indicator' => Variable::get('show_module_indicator')));
     $form->addElement('text', 'title', __('Base page title'));
     $form->addElement('checkbox', 'show_caption_in_title', __('Display module captions inside page title'));
     $form->addElement('checkbox', 'show_module_indicator', __('Display module captions inside module'));
     $form->addElement('submit', 'button', __('Save'), $form->get_submit_form_href());
     $form->addElement('static', '', '<div style="width:200px"></div>', '<div style="width:600px"></div>');
     if ($form->validate()) {
         $form->process(array($this, 'submit_config'));
     } else {
         $this->display_module($form);
     }
     $form = $this->init_module('Utils/FileUpload', array(false));
     $form->addElement('header', 'upload', __('Small Logo'));
     $form->addElement('static', 'logo_size', '', __('Logo image should be 193px by 83px in JPG/JPEG, GIF, PNG or BMP format'));
     $logo = Variable::get('logo_file');
     if ($logo && file_exists($logo)) {
         $form->addElement('static', 'logo', '', '<img src="' . $logo . '?' . filemtime($logo) . '" />');
     }
     $form->addElement('hidden', 'type', '');
     $form->add_upload_element();
     $form->addElement('static', '', '<div style="width:200px"></div>', '<div style="width:600px"></div>');
     //$form->addElement('submit', 'button', __('Upload'), $form->get_submit_form_href());
     $this->display_module($form, array(array($this, 'submit_logo')));
     $form = $this->init_module('Utils/FileUpload', array(false));
     $form->addElement('header', 'upload', __('Login Logo'));
     $form->addElement('static', 'logo_size', '', __('Logo image should be 550px by 200px in JPG/JPEG, GIF, PNG or BMP format'));
     $logo = Variable::get('login_logo_file');
     if ($logo && file_exists($logo)) {
         $form->addElement('static', 'logo', '', '<img src="' . $logo . '?' . filemtime($logo) . '" />');
     }
     $form->addElement('hidden', 'type', 'login_');
     $form->add_upload_element();
     $form->addElement('static', '', '<div style="width:200px"></div>', '<div style="width:600px"></div>');
     //$form->addElement('submit', 'button', __('Upload'), $form->get_submit_form_href());
     $this->display_module($form, array(array($this, 'submit_logo')));
     Base_ActionBarCommon::add('delete', __('Delete logo'), $this->create_callback_href(array($this, 'delete_logo')));
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
 }
Exemplo n.º 27
0
 public function file_history($attachment)
 {
     if ($this->is_back()) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         return $x->pop_main();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $id = $attachment['id'];
     $tb =& $this->init_module(Utils_TabbedBrowser::module_name());
     $tb->start_tab('File history');
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hua' . $id);
     $gb->set_inline_display();
     $gb->set_table_columns(array(array('name' => __('Deleted'), 'order' => 'deleted', 'width' => 10), array('name' => __('Date'), 'order' => 'upload_on', 'width' => 25), array('name' => __('Who'), 'order' => 'upload_by', 'width' => 25), array('name' => __('Attachment'), 'order' => 'uaf.original')));
     $gb->set_default_order(array(__('Date') => 'DESC'));
     $ret = $gb->query_order_limit('SELECT uaf.id,uaf.deleted,uaf.filestorage_id,uaf.created_on as upload_on,uaf.created_by as upload_by,uaf.original FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id, 'SELECT count(*) FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id);
     while ($row = $ret->FetchRow()) {
         $r = $gb->get_new_row();
         if ($row['deleted']) {
             $r->add_action($this->create_confirm_callback_href(__('Are you sure you want to restore attached file?'), array($this, 'restore_file'), array($row['id'])), 'restore', __('Restore'));
         }
         $view_link = '';
         $lb = array();
         $lb['aid'] = $id;
         $lb['crypted'] = $attachment['crypted'];
         $lb['original'] = $row['original'];
         $lb['id'] = $row['id'];
         $lb['filestorage_id'] = $row['filestorage_id'];
         $file = '<a ' . Utils_AttachmentCommon::get_file_leightbox($lb, $view_link) . '>' . $row['original'] . '</a>';
         $r->add_data($row['deleted'] ? __('Yes') : __('No'), Base_RegionalSettingsCommon::time2reg($row['upload_on']), Base_UserCommon::get_user_label($row['upload_by']), $file);
     }
     $this->display_module($gb);
     $tb->end_tab();
     $tb->start_tab('File access history');
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hda' . $id);
     $gb->set_inline_display();
     $gb->set_table_columns(array(array('name' => __('Create date'), 'order' => 'created_on', 'width' => 15), array('name' => __('Download date'), 'order' => 'download_on', 'width' => 15), array('name' => __('Who'), 'order' => 'created_by', 'width' => 15), array('name' => __('IP Address'), 'order' => 'ip_address', 'width' => 15), array('name' => __('Host Name'), 'order' => 'host_name', 'width' => 15), array('name' => __('Method description'), 'order' => 'description', 'width' => 20), array('name' => __('Remote'), 'order' => 'remote', 'width' => 10)));
     $gb->set_default_order(array(__('Create date') => 'DESC'));
     $query = 'SELECT uad.created_on,uad.download_on,(SELECT l.login FROM user_login l WHERE uad.created_by=l.id) as created_by,uad.remote,uad.ip_address,uad.host_name,uad.description FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id;
     $query_qty = 'SELECT count(*) FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id;
     if (Base_AclCommon::check_permission('Attachments - view full download history')) {
         $ret = $gb->query_order_limit($query, $query_qty);
     } else {
         print 'You are allowed to see your own downloads only';
         $who = ' AND uad.created_by=' . Acl::get_user();
         $ret = $gb->query_order_limit($query . $who, $query_qty . $who);
     }
     while ($row = $ret->FetchRow()) {
         $r = $gb->get_new_row();
         $r->add_data(Base_RegionalSettingsCommon::time2reg($row['created_on']), $row['remote'] != 1 ? Base_RegionalSettingsCommon::time2reg($row['download_on']) : '', $row['created_by'], $row['ip_address'], $row['host_name'], $row['description'], $row['remote'] == 0 ? 'no' : 'yes');
     }
     $this->display_module($gb);
     $tb->end_tab();
     $this->display_module($tb);
     $this->caption = 'Note history';
     return true;
 }
Exemplo n.º 28
0
	public function edit_permissions_rule($id = null, $clone = false) {
		if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions')!=2) return false;
        if ($this->is_back()) {
            return false;
		}
		load_js('modules/Utils/RecordBrowser/edit_permissions.js');
		$all_clearances = array(''=>'---')+array_flip(Base_AclCommon::get_clearance(true));
		$all_fields = array();
		$this->init();
		foreach ($this->table_rows as $k=>$v)
			$all_fields[$v['id']] = $k;
		$js = '';
		$operators = array(
			'='=>__('equal'), 
			'!'=>__('not equal'), 
			'>'=>'>',
			'>='=>'>=',
			'<'=>'<',
			'<='=>'<='
		);

		$form = $this->init_module('Libs_QuickForm');
		$theme = $this->init_module('Base_Theme');
		
		$counts = array(
			'clearance'=>5,
			'ands'=>5,
			'ors'=>10
		);
		
		$actions = $this->get_permission_actions();
		$form->addElement('select', 'action', __('Action'), $actions);
		
		$fields_permissions = $all_fields;

		foreach ($all_fields as $k=>$v) {
			if ($this->table_rows[$v]['type']=='calculated' || $this->table_rows[$v]['type']=='hidden') unset($all_fields[$k]);
			else $this->manage_permissions_set_field_values($k);
		}

		$all_fields = array(
			':Created_by'=>__('Created by'),
			':Created_on'=>__('Created on'),
			':Edited_on'=>__('Edited on')
		) + $all_fields;
		if ($this->tab=='contact' || $this->tab=='company')
			$all_fields = array('id'=>__('ID')) + $all_fields;
		
		$this->manage_permissions_set_field_values(':Created_by', array('USER_ID'=>__('User Login')));
		$this->manage_permissions_set_field_values(':Created_on', Utils_RecordBrowserCommon::$date_values);
		$this->manage_permissions_set_field_values(':Edited_on', Utils_RecordBrowserCommon::$date_values);
		if ($this->tab=='contact')
			$this->manage_permissions_set_field_values('id', array('USER'=>__('User Contact')));
		if ($this->tab=='company')
			$this->manage_permissions_set_field_values('id', array('USER_COMPANY'=>__('User Company')));
		
		for ($i=0; $i<$counts['clearance']; $i++)
			$form->addElement('select', 'clearance_'.$i, __('Clearance'), $all_clearances);
		$current_or = array();
		$current_and = 0;
		
		foreach ($all_fields as $k=>$v) {
			if (isset($this->table_rows[$v])) {
				$v = $this->table_rows[$v]['name'];
			}
			$all_fields[$k] = _V($v);
		}
		
		for ($i=0; $i<$counts['ands']; $i++) {
			$current_or[$i] = 0;
			for ($j=0; $j<$counts['ors']; $j++) {
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_field', __('Crits'), array(''=>'---')+$all_fields, array('onchange'=>'utils_recordbrowser__update_field_values('.$i.', '.$j.');', 'id'=>'crits_'.$i.'_'.$j.'_field'));
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_op', __('Operator'), array(''=>'---')+$operators);
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_value', __('Value'), array(), array('id'=>'crits_'.$i.'_'.$j.'_value', 'onchange'=>'utils_recordbrowser__update_field_sub_values('.$i.', '.$j.');'));
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_sub_value', __('Subrecord Value'), array(), array('id'=>'crits_'.$i.'_'.$j.'_sub_value', 'style'=>'display:none;'));
				$js .= 'utils_recordbrowser__update_field_values('.$i.', '.$j.');';
			}
		}
		$defaults = array();
		foreach ($fields_permissions as $k=>$v) {
			$defaults['field_'.$k] = 1;
			$form->addElement('checkbox', 'field_'.$k, _V($this->table_rows[$v]['name']));
		}
		$theme->assign('labels', array(
			'and' => '<span class="joint">'.__('and').'</span>',
			'or' => '<span class="joint">'.__('or').'</span>',
			'caption' => $id?__('Edit permission rule'):__('Add permission rule'),
			'clearance' => __('Clearance requried'),
			'fields' => __('Fields allowed'),
			'crits' => __('Criteria required'),
			'add_clearance' => __('Add clearance'),
			'add_or' => __('Add criteria (or)'),
			'add_and' => __('Add criteria (and)')
 		));
		$current_clearance = 0;
		$sub_values = array();
		if ($id!==null && $this->tab!='__RECORDSETS__' && !preg_match('/,/',$this->tab)) {
			$row = DB::GetRow('SELECT * FROM '.$this->tab.'_access AS acs WHERE id=%d', array($id));
			
			$defaults['action'] = $row['action'];
			$crits = unserialize($row['crits']);
			$i = 0;
			$j = 0;
			$or = false;
			$first = true;
			foreach ($crits as $k=>$v) {
				$operator = '=';
				while (($k[0]<'a' || $k[0]>'z') && ($k[0]<'A' || $k[0]>'Z') && $k[0]!=':') {
					if ($k[0]=='!') $operator = '!';
					if ($k[0]=='(' && $or) $or = false;
					if ($k[0]=='|') $or = true;
					if ($k[0]=='<') $operator = '<';
					if ($k[0]=='>') $operator = '>';
					if ($k[0]=='~') $operator = DB::like();
					if ($k[1]=='=' && $operator!=DB::like()) {
						$operator .= '=';
						$k = substr($k, 2);
					} else $k = substr($k, 1);
				}
				if (!$first) {
					if ($or) $j++;
					else {
						$current_or[$i] += $j;
						$j = 0;
						$i++;
					}
				} else {
					$first = false;
				}
				$sub_value = null;
				if (!isset($r[$k]) && $k[strlen($k)-1]==']') {
					$sub_value = $v;
					list($k, $v) = explode('[', trim($k, ']'));
				}
				$defaults['crits_'.$i.'_'.$j.'_field'] = $k;
				$defaults['crits_'.$i.'_'.$j.'_op'] = $operator;
				$js .= '$("crits_'.$i.'_'.$j.'_value").value = "'.$v.'";';
				if ($sub_value!==null) $sub_values['crits_'.$i.'_'.$j.'_sub_value'] = $sub_value;
			}
			$current_or[$i] += $j;
			$current_and += $i;
			
			$i = 0;
			$tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_clearance AS acs WHERE rule_id=%d', array($id));
			foreach ($tmp as $t) {
				$defaults['clearance_'.$i] = $t['clearance'];
				$i++;
			}
			$current_clearance += $i-1;
			
			$tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_fields AS acs WHERE rule_id=%d', array($id));
			foreach ($tmp as $t) {
				unset($defaults['field_'.$t['block_field']]);
			}
		}
		for ($i=0; $i<$counts['ands']; $i++)
			for ($j=0; $j<$counts['ors']; $j++)
				$js .= 'utils_recordbrowser__update_field_sub_values('.$i.', '.$j.');';
		foreach ($sub_values as $k=>$v)
			$js .= '$("'.$k.'").value = "'.$v.'";';

		$form->setDefaults($defaults);
		
		if ($form->validate()) {
			$vals = $form->exportValues();
			$action = $vals['action'];

			$clearance = array();
			for ($i=0; $i<$counts['clearance']; $i++)
				if ($vals['clearance_'.$i]) $clearance[] = $vals['clearance_'.$i];
			
			$crits = array();
			for ($i=0; $i<$counts['ands']; $i++) {
				$or = '(';
				for ($j=0; $j<$counts['ors']; $j++) {
					if ($vals['crits_'.$i.'_'.$j.'_field'] && $vals['crits_'.$i.'_'.$j.'_op']) {
						if (!isset($operators[$vals['crits_'.$i.'_'.$j.'_op']])) trigger_error('Fatal error',E_USER_ERROR);
						if (!isset($all_fields[$vals['crits_'.$i.'_'.$j.'_field']])) trigger_error('Fatal error',E_USER_ERROR);
						$op = $vals['crits_'.$i.'_'.$j.'_op'];
						if ($op=='=') $op = '';
						if (isset($vals['crits_'.$i.'_'.$j.'_sub_value'])) {
							$vals['crits_'.$i.'_'.$j.'_field'] = $vals['crits_'.$i.'_'.$j.'_field'].'['.$vals['crits_'.$i.'_'.$j.'_value'].']';
							$vals['crits_'.$i.'_'.$j.'_value'] = $vals['crits_'.$i.'_'.$j.'_sub_value'];
						}
						$next = array($or.$op.$vals['crits_'.$i.'_'.$j.'_field'] => $vals['crits_'.$i.'_'.$j.'_value']);
						$crits = Utils_RecordBrowserCommon::merge_crits($crits, $next);
					}
					$or = '|';
				}
			}

			$blocked_fields = array();
			foreach ($fields_permissions as $k=>$v) {
				if (isset($vals['field_'.$k])) continue;
				$blocked_fields[] = $k;
			}
			
			if ($id===null || $clone)
				Utils_RecordBrowserCommon::add_access($this->tab, $action, $clearance, $crits, $blocked_fields);
			else
				Utils_RecordBrowserCommon::update_access($this->tab, $id, $action, $clearance, $crits, $blocked_fields);
			return false;
		}
		
		eval_js($js);

		eval_js('utils_recordbrowser__init_clearance('.$current_clearance.', '.$counts['clearance'].')');
		eval_js('utils_recordbrowser__init_crits_and('.$current_and.', '.$counts['ands'].')');
		for ($i=0; $i<$counts['ands']; $i++)
				eval_js('utils_recordbrowser__init_crits_or('.$i.', '.$current_or[$i].', '.$counts['ors'].')');
		eval_js('utils_recordbrowser__crits_initialized = true;');
		
		$form->assign_theme('form', $theme);
		$theme->assign('fields', $fields_permissions);
		$theme->assign('counts', $counts);
		
		$theme->display('edit_permissions');
		Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
		Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href());
		return true;
	}
Exemplo n.º 29
0
	public function set_filters($rb, $display_tray_select = true, $filter_defaults = array()) {
		if(!Base_AclCommon::check_permission('Dashboard')) return;
		if($this->is_back()) {
			$x = ModuleManager::get_instance('/Base_Box|0');
			if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR);
			return $x->push_main('Utils_Tray');
		}

		if (isset($_REQUEST['tray_slot'])) {
			Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
			$this->set_module_variable('tray_slot', $_REQUEST['tray_slot']);
		}

		$tray_func = $this->parent->get_type().'Common::tray';
		if (!is_callable($tray_func)) return;

		$settings = call_user_func($tray_func);

		if (!isset($settings[$rb->tab])) return;

		$slot_defs = Utils_TrayCommon::get_slots($rb->tab, $settings[$rb->tab]);
		Utils_TrayCommon::sort_trays($slot_defs);

		if ($display_tray_select) {
			$tray_slot_select_options = array('__NULL__'=>'---');
			foreach ($slot_defs as $slot_id=>$slot_def) {
				$tray_slot_select_options[$slot_id] = _V($slot_def['__name__']);
			}

			$form = $this->init_module('Libs/QuickForm');
			$form->addElement('select', 'tray_slot_select', __('Tray'), $tray_slot_select_options, array('style'=>'width: 130px','onchange'=>$form->get_submit_form_js()));
			if ($form->validate()) {
				$tray_slot = $form->exportValue('tray_slot_select');
				$this->set_module_variable('tray_slot',$tray_slot);
				
				$rb->unset_module_variable('def_filter');
			}
		}

		$tray_slot = $this->get_module_variable('tray_slot');
		
		if (isset($slot_defs[$tray_slot]['__filters__'])) {
			$filters_changed = Utils_TrayCommon::are_filters_changed($slot_defs[$tray_slot]['__filters__']);
		}
		else {
			$filters_changed = true;
		}

		if (!isset($_REQUEST['__location']) && ($tray_slot!='__NULL__') && isset($tray_slot) && !$filters_changed){
			$rb->set_additional_caption(_V($slot_defs[$tray_slot]['__name__']));
		}
		else {
			$this->unset_module_variable('tray_slot');
			$tray_slot='__NULL__';
		}

		if ($display_tray_select) {
			$form->setDefaults(array('tray_slot_select'=>$tray_slot));

			ob_start();
			$form->display_as_row();
			$html = ob_get_clean();
			print('<div style="position: absolute;right:120px;">'.$html.'</div>');
		}
		
		if (is_null($tray_slot) || $tray_slot=='__NULL__') {
			$rb->set_filters_defaults($filter_defaults);
			return;
		}
		
		$rb->disable_browse_mode_switch();

		$rb->set_filters_defaults($slot_defs[$tray_slot]['__filters__']);
	}
Exemplo n.º 30
0
 public function body($branch = null, $admin_settings = false)
 {
     $branch = $this->get_module_variable_or_unique_href_variable('settings_branch', $branch);
     if ($branch !== null && $this->is_back()) {
         $branch = null;
     }
     if ($branch === null) {
         if ($this->is_back()) {
             if ($this->parent->get_type() == 'Base_Admin') {
                 $this->parent->reset();
             } else {
                 location(array());
             }
             return;
         }
         if ($this->parent->get_type() == 'Base_Admin') {
             Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
         }
     }
     $this->set_module_variable('settings_branch', $branch);
     $this->get_module_variable('admin_settings', $admin_settings);
     if (!$branch) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         $mains = $x->get_module_variable('main');
         if (count($mains) > 1) {
             $x->pop_main();
         } else {
             $this->main_page();
         }
         return;
     }
     $f = $this->init_module('Libs/QuickForm', __('Saving settings'), 'settings');
     $f->addElement('header', null, $branch);
     $this->indicator = ': ' . $branch;
     $this->settings_fields = array();
     $this->set_default_js = '';
     $us = ModuleManager::call_common_methods('user_settings');
     foreach ($us as $name => $menu) {
         if (!is_array($menu)) {
             continue;
         }
         foreach ($menu as $k => $v) {
             if ($k == $branch) {
                 if (is_string($v)) {
                     Base_BoxCommon::location($name, $v);
                 } else {
                     $this->add_module_settings_to_form($v, $f, $name);
                 }
             }
         }
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     Base_ActionBarCommon::add('settings', __('Restore Defaults'), 'href="javascript:void(0)" onClick="' . $this->set_default_js . '"');
     if ($f->validate()) {
         $this->submit_settings($f->exportValues());
         $this->set_back_location();
     } else {
         $f->display();
     }
     return;
 }