Ejemplo n.º 1
0
 /**
  * Starts new wizard step.
  * This method returns QuickForm object which you should use 
  * to create wizard step.
  * 
  * @param string alias for the page
  * @return object QuickForm object
  */
 public function begin_page($name = null, $always_return_valid_form = true)
 {
     if (isset($this->form[$this->counter])) {
         $this->next_page();
     }
     if (isset($name)) {
         $this->r_aliases[$name] = $this->counter;
         $this->aliases[$this->counter] = $name;
         if (is_string($this->curr_page) && $this->curr_page == $name) {
             $this->curr_page = $this->counter;
         }
     }
     if ($always_return_valid_form || $this->curr_page === $this->counter) {
         $args = func_get_args();
         array_shift($args);
         array_shift($args);
         $this->form[$this->counter] = $this->init_module(Libs_QuickForm::module_name(), $args, isset($name) ? $name : $this->counter);
         if (isset($this->data[$this->counter]) && is_array($this->data[$this->counter])) {
             $this->form[$this->counter]->setDefaults($this->data[$this->counter]);
         }
     } else {
         $this->form[$this->counter] = false;
     }
     ob_start();
     return $this->form[$this->counter];
 }
Ejemplo n.º 2
0
 public function body()
 {
     $f = $this->init_module(Libs_QuickForm::module_name());
     $f->addElement('automulti', 'automul', 'Automulti test', array($this->get_type() . 'Common', 'automulti_search'), array('ble'), array($this->get_type() . 'Common', 'automulti_format'));
     $f->setDefaults(array('automul' => array(2, 3)));
     $f->addElement('autoselect', 'autosel', 'Autoselect test', array(1 => 1, 3 => 3, 8 => 8), array($this->get_type() . 'Common', 'autoselect_search'));
     $f->addElement('text', 'frozen', 'Frozen test');
     $f->addRule('frozen', 'required', 'required');
     $x = $f->addElement('timestamp', 'xxxyss', 'Date picker');
     print 'get(here is what was submited): ' . $x->getValue() . '<br>';
     print 'export: ' . $f->exportValue('xxxyss') . '<br>';
     $f->addRule('xxxyss', 'required rule not passed', 'required');
     $f->addElement('autocomplete', 'auto_test', 'Autocomplete', array($this->get_type() . 'Common', 'autocomplete'));
     $f->addElement('currency', 'cur', 'Currency');
     //		$f->setDefaults(array('xxxyss'=>time()));
     //		$f->freeze(array('xxxyss'));
     //		$f->setDefaults(array('cur'=>'1252341.22'));
     //		$f->addElement('commondata_group','xxx2','commondata_group', 'Countries',array('depth'=>2,'separator'=>'<br>','empty_option'=>true));
     $f->addElement('commondata', 'cd_country', 'commondata Country', 'Countries', array('empty_option' => true), array('id' => 'dddd1'));
     $f->addElement('commondata', 'cd_state', 'commondata State', array('Countries', 'cd_country'), array('empty_option' => true));
     $f->addElement('commondata', 'cd_city', 'commondata City', array('Countries', 'cd_country', 'cd_state'), array('id' => 'dddd3'));
     $f->addElement('commondata', 'cd_street', 'commondata street', array('Countries', 'cd_country', 'cd_state', 'cd_city'));
     $f->setDefaults(array('cd_country' => 'US'));
     //		$f->addRule('cd_city','required','required');
     //		print($x->getValue().'<br>');
     //		$f->freeze();
     $f->addElement('select', 'sel1', 'sel1', array('x' => 'x', 'y' => 'y'), array('id' => 'sel1'));
     $f->addElement('select', 'sel2', 'sel2', array(), array('id' => 'sel2'));
     $f->addElement('select', 'sel3', 'sel3', array(), array('id' => 'sel3'));
     $f->setDefaults(array('sel2' => 'y'));
     print 'freezing<hr>';
     $f->freeze(array('frozen'));
     Utils_ChainedSelectCommon::create('sel2', array('sel1'), 'modules/Tests/QuickForm/update_sel.php', null, $f->exportValue('sel2'));
     Utils_ChainedSelectCommon::create('sel3', array('sel1', 'sel2'), 'modules/Tests/QuickForm/update_sel.php', array('test' => 'finito '), $f->exportValue('sel3'));
     $select1[0] = 'Pop';
     $select1[1] = 'Classical';
     $select1[2] = 'Funeral doom';
     $f->addElement('select', 'sel11', 'sel11', $select1, array('id' => 'sel11'));
     $f->addElement('select', 'sel22', 'sel22', array(), array('id' => 'sel22'));
     $f->addElement('select', 'sel33', 'sel33', array(), array('id' => 'sel33'));
     Utils_ChainedSelectCommon::create('sel22', array('sel11'), 'modules/Tests/QuickForm/update_sel2.php', null, $f->exportValue('sel22'));
     Utils_ChainedSelectCommon::create('sel33', array('sel11', 'sel22'), 'modules/Tests/QuickForm/update_sel2.php', null, $f->exportValue('sel33'));
     $c1 = $f->createElement('checkbox', 'c1', 'c1_l', 'c1_t');
     $c2 = $f->createElement('checkbox', 'c2', 'c2_l', 'c2_t');
     $c3 = $f->createElement('checkbox', 'c3', 'c3_l', 'c3_t');
     $f->addGroup(array($c1, $c2, $c3), 'g', 'g_l');
     $f->add_array(array(array('type' => 'group', 'elems' => array(array('type' => 'checkbox', 'label' => 'c1_l', 'name' => 'c1', 'values' => 'c1_t', 'default' => 0), array('type' => 'checkbox', 'label' => 'c2_l', 'name' => 'c2', 'values' => 'c2_t', 'default' => 0)), 'label' => 'radio')));
     $f->addElement('submit', null, 'ok');
     if ($f->validate()) {
         print_r($f->exportValues());
     }
     $f->display();
     //------------------------------ print out src
     print '<hr><b>Install</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/QuickForm/QuickFormInstall.php');
     print '<hr><b>Main</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/QuickForm/QuickForm_0.php');
     print '<hr><b>Common</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/QuickForm/QuickFormCommon_0.php');
 }
Ejemplo n.º 3
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), 'Changing template');
     $themes = Base_Theme::list_themes();
     $form->addElement('header', 'install_module_header', __('Themes Administration'));
     $form->addElement('select', 'theme', __('Choose template'), $themes);
     $form->addElement('static', null, '', '<br /><br />');
     $form->addElement('header', 'upload_theme_header', __('Upload template'));
     $form->setDefaults(array('theme' => Variable::get('default_theme')));
     if ($form->validate()) {
         $form->process(array(&$this, 'submit_admin'));
     } else {
         $form->display();
         if (class_exists('ZipArchive')) {
             $this->pack_module(Utils_FileUpload::module_name(), array(array($this, 'upload_template'), __('Upload template')));
             //				Base_ActionBarCommon::add('edit',__('Manage templates'),$this->create_callback_href(array($this,'download_template')));
         }
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
 }
Ejemplo n.º 4
0
 public function applet()
 {
     $f = $this->init_module(Libs_QuickForm::module_name());
     $t = $f->createElement('text', 't');
     $ok = $f->createElement('submit', 'ok', __('OK'));
     $f->addGroup(array($t, $ok), 'w');
     $f->display();
     $msg =& $this->get_module_variable('msg');
     if ($f->validate()) {
         $w = $f->exportValues();
         $w = $w['w']['t'];
         if (ip2long($w) === false) {
             $ip = gethostbynamel($w);
             if ($ip) {
                 $msg = '';
                 foreach ($ip as $i) {
                     $msg .= $i . '<br>';
                 }
             } else {
                 $msg = __('No such domain');
             }
         } else {
             $domain = gethostbyaddr($w);
             if ($domain != $w) {
                 $msg = $domain;
             } else {
                 $msg = __('No such ip entry');
             }
         }
     }
     print $msg;
 }
Ejemplo n.º 5
0
 public function construct()
 {
     $_SESSION['client']['utils_planner'] = array();
     $_SESSION['client']['utils_planner']['resources'] = array();
     $this->form = $this->init_module(Libs_QuickForm::module_name());
     $this->form->addElement('hidden', 'grid_selected_frames', '', array('id' => 'grid_selected_frames'));
 }
Ejemplo n.º 6
0
 /**
  * For internal use only.
  */
 public function edit($parent, $key = null)
 {
     if ($this->is_back()) {
         return false;
     }
     $id = Utils_CommonDataCommon::get_id($parent);
     if (!$id) {
         print __('No such array');
         return false;
     }
     $f = $this->init_module(Libs_QuickForm::module_name(), null, 'edit');
     $f->addElement('header', null, $key === null ? __('New node') : __('Edit node'));
     $f->add_table('utils_commondata_tree', array(array('name' => 'akey', 'label' => __('Key'), 'rule' => array(array('type' => 'callback', 'param' => array($parent, $key), 'func' => array($this, 'check_key'), 'message' => __('Specified key already exists')), array('type' => 'callback', 'param' => array($parent, $key), 'func' => array($this, 'check_key2'), 'message' => __('Specified contains invalid character "/"')))), array('name' => 'value', 'label' => __('Value'))));
     if ($key !== null) {
         $value = Utils_CommonDataCommon::get_value($parent . '/' . $key);
         $f->setDefaults(array('akey' => $key, 'value' => $value));
     }
     if ($f->validate()) {
         $submited = $f->exportValues();
         if ($key !== null) {
             Utils_CommonDataCommon::rename_key($parent, $key, $submited['akey']);
         }
         Utils_CommonDataCommon::set_value($parent . '/' . $submited['akey'], $submited['value']);
         return false;
     }
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
     $f->display();
     return true;
 }
Ejemplo n.º 7
0
 public function edit_rset($id = null)
 {
     if ($this->is_back()) {
         return false;
     }
     $form = $this->init_module(Libs_QuickForm::module_name());
     $menu_deep = 3;
     $form->addElement('header', null, $id ? __('Edit RecordSet properties') : __('Create new RecordSet'));
     $form->addElement('text', 'tab', __('Table name'));
     $form->addElement('text', 'caption', __('Caption'));
     $m = array();
     for ($i = 0; $i < $menu_deep; $i++) {
         $m[] = $form->createElement('text', 'menu_' . $i, __('Menu'), array('placeholder' => __('Enter Menu or Submenu label')));
     }
     $form->addGroup($m, 'menu', __('Menu'));
     $form->addElement('checkbox', 'recent', __('Enable Recent'));
     $form->addElement('checkbox', 'favs', __('Enable Favorites'));
     $form->addRule('tab', __('Field required'), 'required');
     $form->addRule('caption', __('Field required'), 'required');
     $form->addFormRule(array($this, 'check_form'));
     if ($id !== null) {
         $tab = DB::GetOne('SELECT tab FROM recordbrowser_custom_recordsets WHERE id=%d', array($id));
         $menu = DB::GetOne('SELECT menu FROM recordbrowser_custom_recordsets WHERE id=%d', array($id));
         $p = DB::getRow('SELECT * FROM recordbrowser_table_properties WHERE tab=%s', array($tab));
         $form->setDefaults(array('tab' => $tab, 'caption' => $p['caption'], 'recent' => $p['recent'], 'favs' => $p['favorites']));
         $menu = explode(Utils_RecordBrowser_CustomRecordsetsCommon::$sep, $menu);
         foreach ($menu as $k => $v) {
             $form->setDefaults(array('menu[menu_' . $k . ']' => $v));
         }
         $form->freeze('tab');
     }
     if ($form->validate()) {
         $vals = $form->exportValues();
         $menu = array();
         for ($i = 0; $i < $menu_deep; $i++) {
             if ($vals['menu']['menu_' . $i]) {
                 $menu[] = $vals['menu']['menu_' . $i];
             }
         }
         if ($id === null) {
             $vals['tab'] = strtolower($vals['tab']);
             Utils_RecordBrowserCommon::install_new_recordset($vals['tab']);
             Utils_RecordBrowserCommon::add_default_access($vals['tab']);
             DB::Execute('INSERT INTO recordbrowser_custom_recordsets (active, tab, menu) VALUES (1, %s, %s)', array($vals['tab'], implode(Utils_RecordBrowser_CustomRecordsetsCommon::$sep, $menu)));
             $tab = $vals['tab'];
         } else {
             DB::Execute('UPDATE recordbrowser_custom_recordsets SET menu=%s WHERE id=%d', array(implode(Utils_RecordBrowser_CustomRecordsetsCommon::$sep, $menu), $id));
         }
         Utils_RecordBrowserCommon::set_caption($tab, $vals['caption']);
         Utils_RecordBrowserCommon::set_recent($tab, isset($vals['recent']) ? 15 : 0);
         Utils_RecordBrowserCommon::set_favorites($tab, isset($vals['favs']) ? true : false);
         return false;
     }
     $form->display_as_column();
     Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Module constructor.
  */
 public function construct($req = true)
 {
     $this->added_upload_elem = false;
     $this->upload_button_caption = __('Upload');
     $this->form = $this->init_module(Libs_QuickForm::module_name(), array(__('Uploading file...'), 'modules/Utils/FileUpload/upload.php', 'upload_iframe', ''), 'file_chooser');
     $this->form->addElement('static', 'upload_iframe', null, '<iframe frameborder="0" id="upload_iframe" name="upload_iframe" src="" style="display:none"></iframe>');
     $this->form->addElement('hidden', 'required', $req ? '1' : '0');
     $this->form->addElement('hidden', 'cid', CID);
 }
Ejemplo n.º 9
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();
 }
Ejemplo n.º 10
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     $form = $this->init_module(Libs_QuickForm::module_name());
     $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::module_name(), 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::module_name(), 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());
 }
Ejemplo n.º 11
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), '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();
     }
 }
Ejemplo n.º 12
0
 public function body()
 {
     $qf = $this->init_module(Libs_QuickForm::module_name());
     $x = $qf->addElement('codepress', 'cd', 'CD');
     $x->setRows(15);
     $x->setCols(100);
     $x->setLineNumbers(false);
     //$x->setLang('php'); //default
     //$x->setAutocomplete(true); //default
     $qf->setDefaults(array('cd' => file_get_contents($this->get_module_dir() . 'Codepress_0.php')));
     //$qf->freeze(array('cd'));
     $qf->addElement('submit', null, 'ok');
     //		$qf->addElement('button',null,'toggle','onClick="CodePress.update()"');
     if ($qf->validate()) {
         print '<div align="left"><pre>' . htmlspecialchars($qf->exportValue('cd')) . '</pre></div>';
     } else {
         $qf->display();
     }
 }
Ejemplo n.º 13
0
 public function add($def_date, $timeless = false)
 {
     if ($this->is_back()) {
         $this->back_to_calendar();
     }
     $qf = $this->init_module(Libs_QuickForm::module_name(), 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());
     }
 }
Ejemplo n.º 14
0
    public function body()
    {
        $form = $this->init_module(Libs_QuickForm::module_name(), null, 'RBpicker_test');
        $form->addElement('multiselect', 'test', 'Test', array(1 => 0, 4 => 1, 7 => 2, 8 => 3));
        $form->addElement('submit', 'submit', 'Submit');
        $form->display();
        if ($form->validate()) {
            print_r($form->exportValues());
        }
        $rb1 = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
        $this->display_module($rb1, array('contact', 'test', array('Tests_LeightboxCommon', 'TEST'), array('company_name' => 1), array('country' => true)));
        print $rb1->create_open_link('Click here!');
        Libs_LeightboxCommon::display('leightbox1', '<h1>Leightbox</h1>' . 'ble ble ble', 'Test header');
        print '<hr><a ' . Libs_LeightboxCommon::get_open_href('leightbox1') . '>leightbox container</a>
			</div>';
        //------------------------------ print out src
        print '<hr><b>Install</b><br>';
        $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Leightbox/LeightboxInstall.php');
        print '<hr><b>Main</b><br>';
        $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Leightbox/Leightbox_0.php');
        print '<hr><b>Common</b><br>';
        $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Leightbox/LeightboxCommon_0.php');
    }
Ejemplo n.º 15
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::module_name());
     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);
     }
 }
Ejemplo n.º 16
0
 public function send($file)
 {
     if ($this->is_back()) {
         return $this->go_back($file);
     }
     $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'send_fax');
     list($providers, $providers_arr) = self::get_providers($file);
     if (empty($providers)) {
         $this->go_back($file);
         Epesi::alert(__('No fax providers installed or configured for this type of file.'));
         return;
     }
     $qf->addElement('header', null, __('Faxing file: %s', array(basename($file))));
     $qf->addElement('select', 'provider', __('Provider'), $providers);
     $qf->addElement('header', null, __('Contact'));
     $fav_contact = CRM_ContactsCommon::get_contacts(array(':Fav' => true, '!fax' => ''));
     $fav_contact2 = array();
     foreach ($fav_contact as $v) {
         $fav_contact2[$v['id']] = CRM_ContactsCommon::contact_format_default($v, true);
     }
     $rb_contact = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_contact, array('contact', 'dest_contact', array('CRM_FaxCommon', 'rpicker_contact_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_contact', '', $fav_contact2);
     $qf->addElement('static', null, $rb_contact->create_open_link('Add contact'));
     $qf->addElement('header', null, __('Company'));
     $fav_company = CRM_ContactsCommon::get_companies(array(':Fav' => true, '!fax' => ''), array('id', 'company_name'));
     $fav_company2 = array();
     foreach ($fav_company as $v) {
         $fav_company2[$v['id']] = $v['company_name'];
     }
     $rb_company = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_company, array('company', 'dest_company', array('CRM_FaxCommon', 'rpicker_company_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_company', '', $fav_company2);
     $qf->addElement('static', null, $rb_company->create_open_link('Add company'));
     $qf->addElement('header', null, __('Other'));
     $qf->addElement('text', 'dest_other', __('Other fax numbers (comma separated)'));
     $qf->addFormRule(array($this, 'check_numbers'));
     if ($qf->validate()) {
         $data = $qf->exportValues();
         if (!isset($providers_arr[$data['provider']]['send_func'])) {
             Epesi::alert(__('Invalid fax provider.'));
         } else {
             $fax_func = array($data['provider'] . 'Common', $providers_arr[$data['provider']]['send_func']);
             $numbers = array();
             $contacts = Utils_RecordBrowserCommon::get_records('contact', array('id' => $data['dest_contact']), array('fax'));
             foreach ($contacts as $row) {
                 $numbers[] = $row['fax'];
             }
             $companies = Utils_RecordBrowserCommon::get_records('company', array('id' => $data['dest_company']), array('fax'));
             foreach ($companies as $row) {
                 $numbers[] = $row['fax'];
             }
             $numbers += explode(',', $data['dest_other']);
             $ret = call_user_func($fax_func, $file, $numbers);
             if ($ret) {
                 return $this->go_back($file);
             }
         }
     }
     $qf->display();
     Base_ActionBarCommon::add('send', __('Send'), $qf->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
 }
Ejemplo n.º 17
0
 public function purge_log()
 {
     # Return to main body
     if ($this->is_back()) {
         return false;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), null, 'purge_date');
     $form->addElement('header', null, __('Audit Log Maintenance'));
     $form->addElement('html', '<tr><td colspan=2><br />' . __('Purge log with records older than specified number of days:') . '</td></tr>');
     $form->addElement('select', 'purge_date', __('Select number of days'), array(30 => 30, 90 => 90, 365 => 365, 1 => 'All'));
     $purge_date = $form->exportValue('purge_date');
     $form->display();
     if (!$purge_date == null) {
         $del_date = strtotime("-" . $purge_date . " days", time());
         $sql_date = date('Y-m-d H:i:s', $del_date);
         # print ('<br/> date: '.$sql_date.'<br />');
         if ($purge_date == 1) {
             $sql_query = 'Delete FROM base_login_audit';
             $ret = DB::Execute($sql_query);
             print __('Entire log was purged!');
         } else {
             $sql_query = 'Delete FROM base_login_audit where start_time < \'' . $sql_date . '\'';
             $ret = DB::Execute($sql_query);
             print __('Records older than %s days (%s) were purged.', array($purge_date, date('Y-m-d', $del_date)));
         }
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('delete', __('Purge Log File'), 'href="javascript:void(0)" onClick="if(confirm(\'' . Epesi::escapeJS(__('Log will be purged!')) . '\')){' . $form->get_submit_form_js() . '}"');
     return true;
 }
Ejemplo n.º 18
0
 public function filters()
 {
     $form = $this->init_module(Libs_QuickForm::module_name());
     $form->addElement('header', 'display', __('Show'));
     if (CRM_MeetingInstall::is_installed()) {
         $form->addElement('checkbox', 'events', __('Meetings'), null, array('onchange' => $form->get_submit_form_js()));
     }
     if (CRM_TasksInstall::is_installed()) {
         $form->addElement('checkbox', 'tasks', __('Tasks'), null, array('onchange' => $form->get_submit_form_js()));
     }
     if (CRM_PhoneCallInstall::is_installed()) {
         $form->addElement('checkbox', 'phonecalls', __('Phonecalls'), null, array('onchange' => $form->get_submit_form_js()));
     }
     $form->addElement('select', 'activities_date', str_replace(' ', '&nbsp;', __('Activities date')), array(0 => __('Future'), 1 => __('Past'), 2 => __('All time')), array('onchange' => $form->get_submit_form_js()));
     $form->addElement('checkbox', 'closed', __('Closed'), null, array('onchange' => $form->get_submit_form_js()));
     $old_display = $this->get_module_variable('display_options', array('events' => CRM_MeetingInstall::is_installed(), 'tasks' => CRM_TasksInstall::is_installed(), 'phonecalls' => CRM_PhoneCallInstall::is_installed(), 'closed' => 1, 'activities_date' => 2));
     $form->setDefaults($old_display);
     $form->assign_theme('form', $this->theme);
     if ($form->validate()) {
         $this->display = $form->exportValues();
         foreach (array('events', 'tasks', 'phonecalls', 'closed', 'activities_date') as $v) {
             if (!isset($this->display[$v])) {
                 $this->display[$v] = false;
             }
         }
     } else {
         $this->display = $old_display;
     }
     $this->activities_date = isset($this->display['activities_date']) ? $this->display['activities_date'] : 0;
     $this->set_module_variable('display_options', $this->display);
 }
Ejemplo n.º 19
0
 public function license_key_form()
 {
     if ($this->is_back()) {
         return false;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $f = $this->init_module(Libs_QuickForm::module_name());
     $f->addElement('text', 'license_key', __('License Key'), array('maxlength' => 64, 'size' => 64, 'style' => 'width:395px;'));
     if ($f->validate()) {
         $x = $f->exportValues();
         Base_EssClientCommon::set_license_key($x['license_key']);
         return false;
     }
     $f->setDefaults(array('license_key' => Base_EssClientCommon::get_license_key()));
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     print '<span class="important_notice"><center>';
     print __('On this screen you can manually set your License Key for this installation. This feature should only be used in case of system recovery or migration. If you are uncertain how to use this feature, it\'s best to leave this screen immediately.') . '<br><br>';
     $f->display_as_column();
     print '</center></span>';
     return true;
 }
Ejemplo n.º 20
0
 public function display_date_picker($datepicker_defaults = array(), $form = null, $show_dates = true)
 {
     if ($form === null) {
         $form = $this->init_module(Libs_QuickForm::module_name());
     }
     $theme = $this->init_module(Base_Theme::module_name());
     $minyear = date('Y', strtotime('-5 years'));
     $maxyear = date('Y', strtotime('+5 years'));
     if ($show_dates) {
         $display_stuff_js = 'document.getElementById(\'day_elements\').style.display=\'none\';document.getElementById(\'month_elements\').style.display=\'none\';document.getElementById(\'week_elements\').style.display=\'none\';document.getElementById(\'year_elements\').style.display=\'none\';document.getElementById(this.value+\'_elements\').style.display=\'block\';';
         $form->addElement('select', 'date_range_type', __('Display report'), array('day' => __('Days'), 'week' => __('Weeks'), 'month' => __('Months'), 'year' => __('Years')), array('onChange' => $display_stuff_js, 'onKeyUp' => $display_stuff_js));
         $form->addElement('datepicker', 'from_day', __('From Date'));
         $form->addElement('datepicker', 'to_day', __('To Date'));
         $form->addElement('date', 'from_week', __('From week'), array('format' => 'Y W', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'to_week', __('To week'), array('format' => 'Y W', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'from_month', __('From month'), array('format' => 'Y m', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'to_month', __('To month'), array('format' => 'Y m', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'from_year', __('From year'), array('format' => 'Y', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'to_year', __('To year'), array('format' => 'Y', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->registerRule('check_dates', 'callback', 'check_dates', $this);
         $form->addRule(array('date_range_type', 'from_day', 'to_day', 'from_week', 'to_week', 'from_month', 'to_month', 'from_year', 'to_year'), __('\'From\' date must be earlier than \'To\' date'), 'check_dates');
     }
     if ($this->isset_module_variable('vals')) {
         $vals = $this->get_module_variable('vals');
         unset($vals['submited']);
         $form->setDefaults($vals);
     } else {
         foreach (array('week' => 3, 'day' => 13, 'month' => 5, 'year' => 5) as $v => $k) {
             $form->setDefaults(array('from_' . $v => date('Y-m-d H:i:s', strtotime('-' . $k . ' ' . $v))));
             $form->setDefaults(array('to_' . $v => date('Y-m-d H:i:s')));
         }
         $form->setDefaults(array('date_range_type' => 'month'));
         $form->setDefaults($datepicker_defaults);
     }
     $form->addElement('submit', 'submit', __('Show'));
     //		$failed = false;
     $other = $vals = $form->exportValues();
     $this->set_module_variable('vals', $vals);
     //		if ($vals['submited'] && !$form->validate()) {
     //			$this->date_range = 'error';
     //			$failed = true;
     //		}
     $theme->assign('show_dates', $show_dates);
     $form->assign_theme('form', $theme);
     $theme->display('date_picker');
     if ($show_dates) {
         $type = $vals['date_range_type'];
         foreach (array('week', 'day', 'year', 'month') as $v) {
             if ($v != $type) {
                 eval_js('document.getElementById(\'' . $v . '_elements\').style.display=\'none\';');
             }
         }
         //		if ($failed) {
         //			return array('type'=>'day', 'dates'=>array());
         //		}
         $this->date_range = array();
         foreach (array('date_range_type', 'from_' . $type, 'to_' . $type) as $v) {
             $this->date_range[$v] = $vals[$v];
         }
         $header = array();
         $start_p = $start = $this->get_date($type, $this->date_range['from_' . $type]);
         $end_p = $end = $this->get_date($type, $this->date_range['to_' . $type]);
         $header[] = $start;
         while (true) {
             switch ($type) {
                 case 'day':
                     $start = strtotime(date('Y-m-d 12:00:00', $start + 86400));
                     $start_format = 'Y-m-d';
                     $end_format = 'Y-m-d';
                     break;
                 case 'week':
                     $start = strtotime(date('Y-m-d 12:00:00', $start + 604800));
                     $start_format = 'Y-m-d';
                     $end_format = 'Y-m-d';
                     $fdow = Utils_PopupCalendarCommon::get_first_day_of_week();
                     $start_p -= (4 - $fdow) * 24 * 60 * 60;
                     $end_p += (2 + $fdow) * 24 * 60 * 60;
                     break;
                 case 'month':
                     $start = strtotime(date('Y-m-15 12:00:00', $start + 2592000));
                     $start_format = 'Y-m-01';
                     $end_format = 'Y-m-t';
                     break;
                 case 'year':
                     $start = strtotime(date('Y-06-15 12:00:00', $start + 2592000 * 12));
                     $start_format = 'Y-01-01';
                     $end_format = 'Y-12-31';
                     break;
             }
             if ($start > $end) {
                 break;
             }
             $header[] = $start;
         }
         return array('type' => $type, 'dates' => $header, 'start' => date($start_format, $start_p), 'end' => date($end_format, $end), 'other' => $other);
     } else {
         return array('other' => $other);
     }
 }
Ejemplo n.º 21
0
 public function edit_group($id = null)
 {
     if ($this->is_back()) {
         return false;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), 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;
 }
Ejemplo n.º 22
0
 /**
  * Displays and processes post replying form.
  */
 public function post_reply()
 {
     if ($this->is_back()) {
         $this->unset_module_variable('action');
         $this->unset_module_variable('answer');
         location(array());
     }
     $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_or_unique_href_variable('answer', -1);
         $this->set_module_variable('answer', $answer);
     } else {
         $answer = -1;
     }
     $form->addElement('hidden', 'comment_content', 'none');
     if ($answer != -1) {
         $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', __('Reply to %s\'s comment given at %s', array($comment_info['login'], date('G:i, d M Y', strtotime($comment_info['created_on'])))));
     }
     $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->addRule('comment_page_reply', __('Field required'), 'required');
     $form->addElement('submit', 'submit_comment', __('Submit'));
     $form->addElement('button', 'cancel_comment', __('Cancel'), $this->create_back_href());
     if ($form->validate() && $this->reply) {
         $this->add_post($form->exportValue('comment_page_reply'), $answer);
         $this->unset_module_variable('answer');
         $this->unset_module_variable('action');
         $answer = -1;
         location(array());
     } else {
         $form->assign_theme('form', $theme);
         $theme->assign('required', '<span align=top size=4 style="color:#FF0000">*</span>');
         $theme->assign('required_description', __('Indicates required fields.'));
         $theme->display('Reply');
     }
 }
Ejemplo n.º 23
0
 public function mini()
 {
     if (!Base_AclCommon::check_permission('Search')) {
         return '';
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), __('Searching'));
     $form->addElement('text', 'quick_search', __('Quick Search'), array('x-webkit-speech' => 'x-webkit-speech', 'lang' => Base_LangCommon::get_lang_code(), 'onwebkitspeechchange' => $form->get_submit_form_js()));
     $form->addElement('submit', 'quick_search_submit', __('Search'), array('class' => 'mini_submit'));
     $theme = $this->pack_module(Base_Theme::module_name());
     $theme->assign('submit_href', $form->get_submit_form_href());
     $theme->assign('submit_label', __('Search'));
     $form->assign_theme('form', $theme);
     $theme->assign('form_mini', 'yes');
     $theme->display('Search');
     if ($form->validate()) {
         $search = $form->exportValues();
         Base_BoxCommon::location('Base_Search', null, null, null, array('quick_search' => $search['quick_search']));
     }
 }
Ejemplo n.º 24
0
 /**
  * private function
  */
 private function edit($path)
 {
     if ($this->is_back()) {
         $this->unset_module_variable('edit');
         location(array());
         return;
     }
     $f = $this->init_module(Libs_QuickForm::module_name());
     if ($path) {
         $f->setDefaults(array('path' => $path));
     }
     $f->addElement('text', 'path', __('Menu entry path'), array('maxlength' => 255));
     $f->addRule('path', __('This field is required'), 'required');
     $f->addRule('path', __('Field too long, max 255 chars'), 'maxlength', 255);
     $f->registerRule('check_path', 'callback', 'check_path', $this);
     $f->addRule('path', __('Specified path already exists'), 'check_path');
     $save_b =& HTML_QuickForm::createElement('submit', null, __('OK'));
     $back_b =& HTML_QuickForm::createElement('button', null, __('Cancel'), $this->create_back_href());
     $f->addGroup(array($save_b, $back_b), 'submit_button');
     if ($f->validate()) {
         $ret = $f->exportValue('path');
         $data = $this->get_module_variable('data');
         if ($path) {
             foreach ($data as &$row) {
                 if ($row == $path) {
                     $row = $ret;
                 }
             }
         } else {
             $data[] = $ret;
         }
         $this->set_module_variable('data', $data);
         $this->unset_module_variable('edit');
         location(array());
         return;
     }
     $f->display();
 }
Ejemplo n.º 25
0
 public function configure_applet($id, $mod, &$ok = null)
 {
     $default_dash = $this->get_module_variable('default');
     if (!$default_dash && !Base_DashboardCommon::has_permission_to_manage_applets()) {
         return;
     }
     if ($this->is_back()) {
         $ok = false;
         return false;
     }
     $sett_fn = array($mod . 'Common', 'applet_settings');
     $is_conf = is_callable($sett_fn);
     $fc = $this->get_module_variable('first_conf');
     if (!$is_conf && $fc) {
         $ok = true;
         return false;
     }
     $f = $this->init_module(Libs_QuickForm::module_name(), __('Saving settings'), 'settings');
     $caption = call_user_func(array($mod . 'Common', 'applet_caption'));
     if ($is_conf) {
         $f->addElement('header', null, __('%s settings', array($caption)));
         $menu = call_user_func($sett_fn);
         if (is_array($menu)) {
             $this->add_module_settings_to_form($menu, $f, $id, $mod);
         } else {
             trigger_error('Invalid applet settings function: ' . $mod, E_USER_ERROR);
         }
     }
     $f->addElement('header', null, $caption . ' ' . __('display settings'));
     $color = Base_DashboardCommon::get_available_colors();
     $color[0] = __('Default') . ': ' . $color[0]['label'];
     for ($k = 1; $k < count($color); $k++) {
         $color[$k] = '&bull; ' . $color[$k]['label'];
     }
     $f->addElement('select', '__color', __('Color'), $color, array('style' => 'width: 100%;'));
     $table_tabs = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'tabs';
     $table_applets = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'applets';
     $tabs = DB::GetAssoc('SELECT id,name FROM ' . $table_tabs . ($default_dash ? '' : ' WHERE user_login_id=' . Base_AclCommon::get_user()));
     $f->addElement('select', '__tab', __('Tab'), $tabs);
     $dfs = DB::GetRow('SELECT tab,color FROM ' . $table_applets . ' WHERE id=%d', array($id));
     $f->setDefaults(array('__tab' => $dfs['tab'], '__color' => $dfs['color']));
     if ($f->validate()) {
         //$f->process(array(& $this, 'submit_settings'));
         $submited = $f->exportValues();
         DB::Execute('UPDATE ' . $table_applets . ' SET tab=%d WHERE id=%d', array($submited['__tab'], $id));
         DB::Execute('UPDATE ' . $table_applets . ' SET color=%d WHERE id=%d', array($submited['__color'], $id));
         $defaults = $this->get_default_values($mod);
         $old = $this->get_values($id, $mod);
         foreach ($defaults as $name => $def_value) {
             if (!isset($submited[$name])) {
                 $submited[$name] = 0;
             }
             if ($submited[$name] != $old[$name]) {
                 if ($this->get_module_variable('default')) {
                     if ($submited[$name] == $def_value) {
                         DB::Execute('DELETE FROM base_dashboard_default_settings WHERE applet_id=%d AND name=%s', array($id, $name));
                     } else {
                         DB::Replace('base_dashboard_default_settings', array('applet_id' => $id, 'name' => $name, 'value' => $submited[$name]), array('applet_id', 'name'), true);
                     }
                 } else {
                     if ($submited[$name] == $def_value) {
                         DB::Execute('DELETE FROM base_dashboard_settings WHERE applet_id=%d AND name=%s', array($id, $name));
                     } else {
                         DB::Replace('base_dashboard_settings', array('applet_id' => $id, 'name' => $name, 'value' => $submited[$name]), array('applet_id', 'name'), true);
                     }
                 }
             }
         }
         $ok = true;
         self::$settings_cache = null;
         return false;
     }
     $ok = null;
     $f->display();
     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'), 'onClick="' . $this->set_default_js . '" href="javascript:void(0)"');
     return true;
 }
Ejemplo n.º 26
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::module_name());
         $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__']);
 }
Ejemplo n.º 27
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::module_name(), __('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;
 }
Ejemplo n.º 28
0
 public function search_by_id_form($label)
 {
     $message = '';
     $form = $this->init_module(Libs_QuickForm::module_name());
     $theme = $this->init_module(Base_Theme::module_name());
     $form->addElement('text', 'record_id', $label);
     $form->addRule('record_id', __('Must be a number'), 'numeric');
     $form->addRule('record_id', __('Field required'), 'required');
     $ret = false;
     if ($form->isSubmitted()) {
         $ret = true;
     }
     if ($form->validate()) {
         $id = $form->exportValue('record_id');
         if (!is_numeric($id)) {
             trigger_error('Invalid id', E_USER_ERROR);
         }
         $r = Utils_RecordBrowserCommon::get_record($this->tab, $id);
         if (!$r || empty($r)) {
             $message = __('There is no such record') . '<br>';
         } else {
             if (!$r[':active']) {
                 $message = __('This record was deleted from the system') . '<br>';
             } else {
                 $x = ModuleManager::get_instance('/Base_Box|0');
                 if (!$x) {
                     trigger_error('There is no base box module instance', E_USER_ERROR);
                 }
                 $x->push_main(Utils_RecordBrowser::module_name(), 'view_entry', array('view', $id), array($this->tab));
                 return;
             }
         }
     }
     $form->assign_theme('form', $theme);
     $theme->assign('message', $message);
     $theme->display('search_by_id');
     return $ret;
 }
Ejemplo n.º 29
0
 public function body($header = '', $params = array(), $add_disp = '', $big = true)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     if (isset($_REQUEST['__location']) && $this->last_location != $_REQUEST['__location']) {
         $this->last_location = $_REQUEST['__location'];
         $this->leightbox_ready = false;
     }
     if (!$this->leightbox_ready) {
         if (!empty($params)) {
             $this->params = $params;
             $js = 'f' . $this->group . '_set_params = function(arg' . implode(',arg', array_keys($params)) . '){';
             foreach ($params as $k => $v) {
                 $js .= 'els=document.getElementsByName(\'' . $this->group . '_' . $v . '\');';
                 $js .= 'i=0;while(i<els.length){els[i].value=arg' . $k . ';i++;}';
             }
             $js .= '}';
             eval_js($js);
         }
         $this->leightbox_ready = true;
         eval_js_once('f' . $this->group . '_prompt_deactivate = function(){leightbox_deactivate(\'' . $this->group . '_prompt_leightbox\');}');
         eval_js_once('f' . $this->group . '_show_form = function(arg){$(arg+\'_' . $this->group . '_form_section\').style.display=\'block\';$(\'' . $this->group . '_buttons_section\').style.display=\'none\';}');
         eval_js('$(\'' . $this->group . '_buttons_section\').style.display=\'' . (count($this->options) == 1 ? 'none' : 'block') . '\';');
         $buttons = array();
         $sections = array();
         foreach ($this->options as $k => $v) {
             $next_button = array('icon' => $v['icon'], 'label' => $v['label']);
             if ($v['form'] !== null) {
                 $form = $v['form'];
             } else {
                 $form = $this->options[$k]['form'] = $this->init_module(Libs_QuickForm::module_name());
             }
             if (!empty($params)) {
                 foreach ($params as $w) {
                     $form->addElement('hidden', $this->group . '_' . $w, 'none', array('id' => $this->group . '_' . $w));
                 }
             }
             if ($v['form'] !== null) {
                 $v['form']->addElement('button', 'cancel', __('Cancel'), array('id' => $this->group . '_lp_cancel', 'onclick' => count($this->options) == 1 ? 'f' . $this->group . '_prompt_deactivate();' : '$(\'' . $this->group . '_buttons_section\').style.display=\'block\';$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'none\';'));
                 $v['form']->addElement('submit', 'submit', __('OK'), array('id' => $this->group . '_lp_submit', 'onclick' => 'f' . $this->group . '_prompt_deactivate();'));
                 ob_start();
                 $th = $this->init_module(Base_Theme::module_name());
                 $v['form']->assign_theme('form', $th);
                 $th->assign('id', $this->get_instance_id());
                 $th->display('form');
                 $form_contents = ob_get_clean();
                 $next_button['open'] = '<a href="javascript:void(0);" onclick="f' . $this->group . '_show_form(\'' . $k . '\');">';
                 $sections[] = '<div id="' . $k . '_' . $this->group . '_form_section" style="display:none;">' . $form_contents . '</div>';
                 eval_js('$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'' . (count($this->options) != 1 ? 'none' : 'block') . '\';');
                 if ($v['form']->exportValue('submited') && !$v['form']->validate()) {
                     // open this selection
                     eval_js('f' . $this->get_group_key() . "_show_form('{$k}')");
                 }
             } else {
                 //                  $next_button['open'] = '<a '.$this->create_callback_href(array($this,'option_chosen'), array($k)).' onmouseup="f'.$this->group.'_prompt_deactivate();">';
                 $next_button['open'] = '<a href="javascript:void(0);" onmouseup="f' . $this->group . '_prompt_deactivate();' . $form->get_submit_form_js() . ';">';
                 $form->display();
             }
             $next_button['close'] = '</a>';
             $buttons[] = $next_button;
         }
         $theme = $this->init_module(Base_Theme::module_name());
         $theme->assign('open_buttons_section', '<div id="' . $this->group . '_buttons_section">');
         $theme->assign('buttons', $buttons);
         $theme->assign('sections', $sections);
         $theme->assign('additional_info', $add_disp);
         $theme->assign('close_buttons_section', '</div>');
         ob_start();
         $theme->display('leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($this->group . '_prompt_leightbox', $profiles_out, $header, $big);
     }
 }
Ejemplo n.º 30
0
 public function chat($big = false, $uid = null)
 {
     $to =& $this->get_module_variable('to', "all");
     eval_js('shoutbox_uid="' . $to . '"');
     if (Base_AclCommon::is_user()) {
         //initialize HTML_QuickForm
         $qf = $this->init_module(Libs_QuickForm::module_name());
         /*            $myid = Base_AclCommon::get_user();
                 	if(Base_User_SettingsCommon::get('Apps_Shoutbox','enable_im')) {
                 	    $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox','enable_im');
                 	    if(ModuleManager::is_installed('CRM_Contacts')>=0) {
                     	    $emps = DB::GetAssoc('SELECT l.id,IF(cd.f_last_name!=\'\',CONCAT(cd.f_last_name,\' \',cd.f_first_name,\' (\',l.login,\')\'),l.login) as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY name',array($myid,serialize(1)));			    
         		        } else
             		        $emps = DB::GetAssoc('SELECT l.id,l.login FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY l.login',array($myid,serialize(1)));
             		} else $emps = array();
             		if(ModuleManager::is_installed('Tools_WhoIsOnline')>=0) {
             		    $online = Tools_WhoIsOnlineCommon::get_ids();
             		    foreach($online as $id) {
             		        if(isset($emps[$id])) 
             		            $emps[$id] = '* '.$emps[$id] ;
             		    }
             		}
                		$qf->addElement('select','to',__('To'),array('all'=>'['.__('All').']')+$emps,array('id'=>'shoutbox_to'.($big?'_big':''),'onChange'=>'shoutbox_uid=this.value;shoutbox_refresh'.($big?'_big':'').'()'));*/
         $myid = Base_AclCommon::get_user();
         if (Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im') && ModuleManager::is_installed('Tools_WhoIsOnline') >= 0) {
             $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox', 'enable_im');
             $online = Tools_WhoIsOnlineCommon::get_ids();
             if ($online) {
                 if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
                     $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name', DB::qstr(' ('), 'l.login', DB::qstr(')')), 'l.login')) . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY name', array($myid, serialize(1)));
                 } else {
                     $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), 'l.login') . ' FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY l.login', array($myid, serialize(1)));
                 }
             } else {
                 $emps = array();
             }
         } else {
             $emps = array();
         }
         $e = $qf->addElement('autoselect', 'shoutbox_to', __('To'), array('all' => '[' . __('All') . ']') + $emps, array(array($this->get_type() . 'Common', 'user_search'), array()), array($this->get_type() . 'Common', 'user_format'));
         $e->setAttribute('id', 'shoutbox_to' . ($big ? '_big' : ''));
         $e->setAttribute('onChange', 'shoutbox_uid=this.value;shoutbox_refresh' . ($big ? '_big' : '') . '()');
         if (!Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im')) {
             $qf->freeze(array('shoutbox_to'));
         }
         //create text box
         $qf->addElement($big ? 'textarea' : 'textarea', 'post', __('Message'), 'class="border_radius_6px" id="shoutbox_text' . ($big ? '_big' : '') . '"');
         $qf->addRule('post', __('Field required'), 'required');
         //create submit button
         $qf->addElement('submit', 'submit_button', __('Send'), 'id="shoutbox_button' . ($big ? '_big' : '') . '"');
         //add it
         $qf->setRequiredNote(null);
         $qf->setDefaults(array('shoutbox_to' => $to));
         $theme = $this->init_module(Base_Theme::module_name());
         $qf->assign_theme('form', $theme);
         //confirm when sending messages to all
         eval_js("jq('#shoutbox_button, #shoutbox_button_big').click(function() {\n      \t\t\t\t\tvar submit = true;\n\t\t    \t\t\tif (jq('#shoutbox_to').val() == 'all' && !confirm('" . __('Send message to all?') . "')) {\n         \t\t\t\t\tsubmit = false;\n      \t\t\t\t\t}\n\t\t    \n\t\t    \t\t\treturn submit;\t\t    \t\t\t\n\t\t\t\t\t});");
         //if submited
         if ($qf->validate()) {
             //get post group
             $msg = $qf->exportValue('post');
             $to = $qf->exportValue('shoutbox_to');
             //get msg from post group
             $msg = Utils_BBCodeCommon::optimize($msg);
             //get logged user id
             $user_id = Base_AclCommon::get_user();
             //clear text box and focus it
             eval_js('$(\'shoutbox_text' . ($big ? '_big' : '') . '\').value=\'\';focus_by_id(\'shoutbox_text' . ($big ? '_big' : '') . '\');shoutbox_uid="' . $to . '"');
             //insert to db
             DB::Execute('INSERT INTO apps_shoutbox_messages(message,base_user_login_id,to_user_login_id) VALUES(%s,%d,%d)', array(htmlspecialchars($msg, ENT_QUOTES, 'UTF-8'), $user_id, is_numeric($to) ? $to : null));
         }
     } else {
         print __('Please log in to post message') . '<br>';
         return;
     }
     $theme->assign('board', '<div id=\'shoutbox_board' . ($big ? '_big' : '') . '\'></div>');
     $theme->assign('header', __('Shoutbox'));
     $theme->display('chat_form' . ($big ? '_big' : ''));
     //if shoutbox is diplayed, call myFunctions->refresh from refresh.php file every 5s
     eval_js_once('shoutbox_refresh' . ($big ? '_big' : '') . ' = function(){if(!$(\'shoutbox_board' . ($big ? '_big' : '') . '\')) return;' . 'new Ajax.Updater(\'shoutbox_board' . ($big ? '_big' : '') . '\',\'modules/Apps/Shoutbox/refresh.php\',{method:\'get\', parameters: { uid: shoutbox_uid }});' . '};setInterval(\'shoutbox_refresh' . ($big ? '_big' : '') . '()\',' . ($big ? '10000' : '30000') . ')');
     eval_js('shoutbox_refresh' . ($big ? '_big' : '') . '()');
 }