示例#1
0
 public static function login_check_exit()
 {
     $after = Base_AclCommon::is_user();
     if ($after !== self::$logged) {
         if ($after) {
             Base_HomePageCommon::load();
         } else {
             Base_BoxCommon::location(Base_BoxCommon::get_main_module_name());
         }
     }
 }
示例#2
0
 public function body()
 {
     if (!Base_AclCommon::i_am_user()) {
         print __('First log in to the system.');
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), __('Saving settings'));
     //pass
     $form->addElement('header', null, __('Change password'));
     $form->addElement('html', '<tr><td colspan=2>' . __('Leave password boxes empty if you prefer your current password') . '</td></tr>');
     $form->addElement('password', 'new_pass', __('New password'));
     $form->addElement('password', 'new_pass_c', __('Confirm new password'));
     $form->addRule(array('new_pass', 'new_pass_c'), __('Your passwords don\'t match'), 'compare');
     $form->addRule('new_pass', __('Your password must be longer then 5 chars'), 'minlength', 6);
     //mail
     $form->addElement('header', null, __('Change e-mail'));
     $form->addElement('text', 'mail', __('New e-mail address'));
     $form->addRule('mail', __('Field required'), 'required');
     $form->addRule('mail', __('Invalid e-mail address'), 'email');
     //autologin
     $ret = DB::GetAll('SELECT autologin_id,description,last_log FROM user_autologin WHERE user_login_id=%d', array(Acl::get_user()));
     if ($ret) {
         $form->addElement('header', null, __('Delete autologin'));
     }
     foreach ($ret as $row) {
         $form->addElement('checkbox', 'delete_autologin[' . $row['autologin_id'] . ']', $row['description'], Base_RegionalSettingsCommon::time2reg($row['last_log']));
     }
     //confirmation
     $form->addElement('header', null, __('Confirmation'));
     $form->addElement('password', 'old_pass', __('Old password'));
     $form->registerRule('check_old_pass', 'callback', 'check_old_pass', $this);
     $form->addRule('old_pass', __('Old password incorrect'), 'check_old_pass');
     $form->addRule('old_pass', __('Field required'), 'required');
     if (Base_AclCommon::check_permission('Advanced User Settings')) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     #$form->addElement('submit', 'submit_button', __('OK'));
     if ($form->validate_with_message('Setting saved', __('Problem encountered'))) {
         if ($form->process(array(&$this, 'submit_user_preferences'))) {
             if (Base_AclCommon::check_permission('Advanced User Settings')) {
                 Base_BoxCommon::location('Base_User_Settings');
             }
         }
     } else {
         //defaults
         $ret = DB::Execute('SELECT p.mail FROM user_password p  WHERE p.user_login_id=%d', Acl::get_user());
         if ($row = $ret->FetchRow()) {
             $form->setDefaults(array('mail' => $row[0]));
         }
         $form->display();
     }
 }
示例#3
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']));
     }
 }
示例#4
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;
 }