Ejemplo n.º 1
0
 function editSettings()
 {
     $form = new PHPWS_Form('whatsnew_settings');
     $form->addHidden('module', 'whatsnew');
     $form->addHidden('aop', 'post_settings');
     $form->addCheckbox('enable', 1);
     $form->setMatch('enable', PHPWS_Settings::get('whatsnew', 'enable'));
     $form->setLabel('enable', dgettext('whatsnew', 'Enable whatsnew'));
     $form->addCheckbox('homeonly', 1);
     $form->setMatch('homeonly', PHPWS_Settings::get('whatsnew', 'homeonly'));
     $form->setLabel('homeonly', dgettext('whatsnew', 'Show whatsnew sidebox on home page only'));
     $form->addTextField('title', PHPWS_Settings::get('whatsnew', 'title'));
     $form->setLabel('title', dgettext('whatsnew', 'Sidebox title'));
     $form->setSize('title', 30);
     $form->addTextArea('text', PHPWS_Settings::get('whatsnew', 'text'));
     $form->setRows('text', '4');
     $form->setCols('text', '40');
     $form->setLabel('text', dgettext('whatsnew', 'Sidebox text'));
     $form->addTextField('cache_timeout', PHPWS_Settings::get('whatsnew', 'cache_timeout'));
     $form->setLabel('cache_timeout', dgettext('whatsnew', 'Cache duration for whatsnew list (in seconds, 0-7200)'));
     $form->setSize('cache_timeout', 4, 4);
     $form->addTextField('qty_items', PHPWS_Settings::get('whatsnew', 'qty_items'));
     $form->setLabel('qty_items', dgettext('whatsnew', 'Number of recent items to display (0-50)'));
     $form->setSize('qty_items', 4, 4);
     $form->addCheckbox('show_summaries', 1);
     $form->setMatch('show_summaries', PHPWS_Settings::get('whatsnew', 'show_summaries'));
     $form->setLabel('show_summaries', dgettext('whatsnew', 'Show item summaries'));
     $form->addCheckbox('show_dates', 1);
     $form->setMatch('show_dates', PHPWS_Settings::get('whatsnew', 'show_dates'));
     $form->setLabel('show_dates', dgettext('whatsnew', 'Show item update dates'));
     $form->addCheckbox('show_source_modules', 1);
     $form->setMatch('show_source_modules', PHPWS_Settings::get('whatsnew', 'show_source_modules'));
     $form->setLabel('show_source_modules', dgettext('whatsnew', 'Show item source module names'));
     $form->addSubmit('save', dgettext('whatsnew', 'Save settings'));
     $tpl = $form->getTemplate();
     $tpl['SETTINGS_LABEL'] = dgettext('whatsnew', 'General Settings');
     $tpl['FLUSH_LINK'] = PHPWS_Text::secureLink(dgettext('whatsnew', 'Flush cache'), 'whatsnew', array('aop' => 'flush_cache'));
     $tpl['EXCLUDE'] = $this->whatsnew->getKeyMods(unserialize(PHPWS_Settings::get('whatsnew', 'exclude')), 'exclude');
     $tpl['EXCLUDE_LABEL'] = dgettext('whatsnew', 'Select any modules you wish to exclude from your whatsnew box.');
     $this->whatsnew->title = dgettext('whatsnew', 'Settings');
     $this->whatsnew->content = PHPWS_Template::process($tpl, 'whatsnew', 'edit_settings.tpl');
 }
Ejemplo n.º 2
0
 public static function userForm(PHPWS_User $user, $message = NULL)
 {
     require_once PHPWS_SOURCE_DIR . 'core/class/Time.php';
     javascript('jquery');
     $form = new PHPWS_Form();
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'user');
     $form->addHidden('command', 'my_page');
     $form->addHidden('subcommand', 'postUser');
     if (Current_User::allow('users') || $user->display_name == $user->username) {
         $form->addText('display_name', $user->display_name);
         $form->setClass('display_name', 'form-control');
         $form->setLabel('display_name', dgettext('users', 'Display Name'));
     } else {
         $form->addTplTag('DISPLAY_NAME_LABEL', dgettext('users', 'Display Name'));
         $tpl['DISPLAY_NAME'] = javascript('slider', array('link' => $user->display_name, 'id' => 'name-info', 'message' => dgettext('users', 'Once you change your display name, you may not change it again until reset by the site administrator.')));
     }
     if ($user->canChangePassword()) {
         $form->addPassword('password1');
         $form->setAutoComplete('password1');
         $form->setClass('password1', 'form-control');
         $form->addPassword('password2');
         $form->setAutoComplete('password2');
         $form->setClass('password2', 'form-control');
         $form->setTitle('password2', dgettext('users', 'Password confirm'));
         $form->setLabel('password1', dgettext('users', 'Password'));
     } else {
         $tpl['PASSWORD1_LABEL'] = dgettext('users', 'Password');
         $tpl['PASSWORD1'] = javascript('slider', array('link' => dgettext('users', 'Why can\'t I change my password?'), 'id' => 'pw-info', 'message' => dgettext('users', 'Your account is authorized external to this site. You will need to update it at the source.')));
     }
     $form->addText('email', $user->getEmail());
     $form->setSize('email', 40);
     $form->setLabel('email', dgettext('users', 'Email Address'));
     $form->setClass('email', 'form-control');
     if (isset($tpl)) {
         $form->mergeTemplate($tpl);
     }
     $tz_list = PHPWS_Time::getTZList();
     $timezones['server'] = dgettext('users', '-- Use server\'s time zone --');
     foreach ($tz_list as $tz) {
         if (!empty($tz['codes'])) {
             $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['codes'][0]);
         } elseif (!empty($tz['city'])) {
             $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['city'][0]);
         } else {
             $timezones[$tz['id']] = $tz['id'];
         }
     }
     if (isset($_REQUEST['timezone'])) {
         $user_tz = $_REQUEST['timezone'];
     } else {
         $user_tz = PHPWS_Cookie::read('user_tz');
     }
     $form->addSelect('timezone', $timezones);
     $form->setLabel('timezone', dgettext('users', 'Time Zone'));
     $form->setMatch('timezone', $user_tz);
     $form->setClass('timezone', 'form-control');
     if (isset($_REQUEST['dst']) && $_REQUEST['timezone'] != 'server') {
         $dst = $_REQUEST['dst'];
     } else {
         $dst = PHPWS_Cookie::read('user_dst');
     }
     $form->addCheckbox('dst', 1);
     $form->setMatch('dst', $dst);
     $form->setLabel('dst', dgettext('users', 'Use Daylight Savings Time'));
     if (isset($_POST['cp'])) {
         $cp = (int) $_POST['cp'];
     } else {
         $cp = (int) PHPWS_Cookie::read('user_cp');
     }
     if (Current_User::allowRememberMe()) {
         // User must authorize locally
         if ($_SESSION['User']->authorize == 1) {
             $form->addCheckbox('remember_me', 1);
             if (PHPWS_Cookie::read('remember_me')) {
                 $form->setMatch('remember_me', 1);
             }
             $form->setLabel('remember_me', dgettext('users', 'Remember me'));
         }
     }
     $form->addHidden('userId', $user->getId());
     $form->addSubmit('submit', dgettext('users', 'Update my information'));
     $form->setClass('submit', 'btn btn-primary');
     if (!DISABLE_TRANSLATION && !FORCE_DEFAULT_LANGUAGE) {
         $language_file = PHPWS_Core::getConfigFile('users', 'languages.php');
         if ($language_file) {
             include $language_file;
             $form->addSelect('language', $languages);
             $form->setClass('language', 'form-control');
             $form->setLabel('language', dgettext('users', 'Language preference'));
             if (isset($_COOKIE['phpws_default_language'])) {
                 $language = preg_replace('/\\W/', '', $_COOKIE['phpws_default_language']);
                 $form->setMatch('language', $language);
             }
         }
     }
     $template = $form->getTemplate();
     if (isset($message)) {
         foreach ($message as $tag => $error) {
             $template[$tag] = $error;
         }
     }
     $template['ACCT_INFO'] = dgettext('users', 'Account Information');
     $template['LOCAL_INFO'] = dgettext('users', 'Localization');
     $template['PREF'] = dgettext('users', 'Preferences');
     return PHPWS_Template::process($template, 'users', 'my_page/user_setting.tpl');
 }
Ejemplo n.º 3
0
 /**
  * Creates the user interface for editing this form's settings
  *
  * @return string $content The templated string containing the html to display
  *                         a user interface for editing this form's settings.
  * @access public
  */
 function editSettings()
 {
     unset($this->report);
     if ($this->getId()) {
         /* If not a new form get the templated form info */
         $formTags['FORM_INFORMATION'] = $this->getFormInfo();
     }
     $form = new PHPWS_Form('edit_settings');
     /* Setup all editable values and their labels */
     $form->addTextField('PHAT_FormName', $this->getLabel());
     $form->setSize('PHAT_FormName', PHAT_DEFAULT_SIZE);
     $form->setMaxSize('PHAT_FormName', PHAT_DEFAULT_MAXSIZE);
     $form->setLabel('PHAT_FormName', dgettext('phatform', 'Name'));
     $form->addTextField('PHAT_FormPageLimit', $this->_pageLimit);
     $form->setSize('PHAT_FormPageLimit', 3, 3);
     $form->setLabel('PHAT_FormPageLimit', dgettext('phatform', 'Item limit per page'));
     $form->addTextArea('PHAT_FormBlurb0', $this->_blurb0);
     $form->setCols('PHAT_FormBlurb0', PHAT_DEFAULT_COLS);
     $form->setRows('PHAT_FormBlurb0', PHAT_DEFAULT_ROWS);
     $form->setLabel('PHAT_FormBlurb0', dgettext('phatform', 'Instructions'));
     $form->addTextArea('PHAT_FormBlurb1', $this->_blurb1);
     $form->setCols('PHAT_FormBlurb1', PHAT_DEFAULT_COLS);
     $form->setRows('PHAT_FormBlurb1', PHAT_DEFAULT_ROWS);
     $form->setLabel('PHAT_FormBlurb1', dgettext('phatform', 'Submission Message'));
     /* RBW Added a section to hold the post processing code 1/3/04 */
     $form->addTextArea('PHAT_PostProcess', $this->getPostProcessCode());
     $form->setCols('PHAT_FormBlurb1', PHAT_DEFAULT_COLS);
     $form->setRows('PHAT_FormBlurb1', PHAT_DEFAULT_ROWS);
     $form->setLabel('PHAT_PostProcess', dgettext('phatform', 'Post Process Code'));
     //$formTags['POSTPROCESS_HELP']  = PHPWS_Help::show_link('phatform', 'post_process_code');
     $form->addTextArea('PHAT_FormEmails', $this->getAdminEmails());
     $form->setCols('PHAT_FormBlurb1', PHAT_DEFAULT_COLS);
     $form->setRows('PHAT_FormBlurb1', PHAT_DEFAULT_ROWS);
     $form->setLabel('PHAT_FormEmails', dgettext('phatform', 'Admin Email (comma delimited)'));
     $form->addCheckbox('PHAT_FormMultiSubmit', 1);
     $form->setMatch('PHAT_FormMultiSubmit', $this->_multiSubmit);
     $form->setLabel('PHAT_FormMultiSubmit', dgettext('phatform', 'Allow multiple submissions'));
     $form->addCheckbox('PHAT_FormAnonymous', 1);
     $form->setMatch('PHAT_FormAnonymous', $this->_anonymous);
     $form->setLabel('PHAT_FormAnonymous', dgettext('phatform', 'Allow anonymous submissions'));
     $form->addCheckBox('PHAT_FormEditData', 1);
     $form->setMatch('PHAT_FormEditData', $this->_editData);
     $form->setLabel('PHAT_FormEditData', dgettext('phatform', 'Allow users to edit their form data'));
     $form->addCheckBox('PHAT_FormShowElementNumbers', 1);
     $form->setMatch('PHAT_FormShowElementNumbers', $this->_showElementNumbers);
     $form->setLabel('PHAT_FormShowElementNumbers', dgettext('phatform', 'Show numbers for form elements (eg: 1, 2, 3)'));
     $form->addCheckBox('PHAT_FormShowPageNumbers', 1);
     $form->setMatch('PHAT_FormShowPageNumbers', $this->_showPageNumbers);
     $form->setLabel('PHAT_FormShowPageNumbers', dgettext('phatform', 'Show form page numbers (eg: page 1 of 6)'));
     $form->addCheckBox('PHAT_FormHidden', 1);
     $form->setMatch('PHAT_FormHidden', $this->isHidden());
     $form->setLabel('PHAT_FormHidden', dgettext('phatform', 'Hide this form'));
     /* Can't forget the save button */
     $form->addSubmit('PHAT_SaveSettings', dgettext('phatform', 'Save Settings'));
     if ($this->getId()) {
         $form->addSubmit('PHAT_EditElements', dgettext('phatform', 'Edit Elements'));
         $GLOBALS['CNT_phatform']['title'] = $this->getLabel();
     } else {
         $GLOBALS['CNT_phatform']['title'] = PHAT_TITLE;
     }
     /* Add needed hiddens */
     $form->addHidden('module', 'phatform');
     $form->addHidden('PHAT_FORM_OP', 'SaveFormSettings');
     $form->addHidden('PHAT_FormId', $this->getId());
     $template = $form->getTemplate();
     $content = PHPWS_Template::process($template, 'phatform', 'form/settings.tpl');
     return $content;
 }
Ejemplo n.º 4
0
 public function settings()
 {
     $form = new PHPWS_Form('calendar_settings');
     $form->addHidden('module', 'calendar');
     $form->addHidden('aop', 'post_settings');
     $form->addCheckbox('allow_submissions', 1);
     $form->setMatch('allow_submissions', PHPWS_Settings::get('calendar', 'allow_submissions'));
     $form->setLabel('allow_submissions', dgettext('calendar', 'Allow public event submissions'));
     $form->addCheckbox('mini_event_link', 1);
     $form->setMatch('mini_event_link', PHPWS_Settings::get('calendar', 'mini_event_link'));
     $form->setLabel('mini_event_link', dgettext('calendar', 'Only link days with events in mini calendar'));
     $form->addCheckbox('anon_ical', 1);
     $form->setMatch('anon_ical', PHPWS_Settings::get('calendar', 'anon_ical'));
     $form->setLabel('anon_ical', dgettext('calendar', 'Allow anonymous iCal exports of public schedules'));
     $form->addCheckbox('no_follow', 1);
     $form->setMatch('no_follow', PHPWS_Settings::get('calendar', 'no_follow'));
     $form->setLabel('no_follow', dgettext('calendar', 'No follow directives added to navigation links'));
     $start_days = array(0, 1);
     $start_days_label[0] = strftime('%A', mktime(0, 0, 0, 1, 4, 1970));
     $start_days_label[1] = strftime('%A', mktime(0, 0, 0, 1, 5, 1970));
     $form->addRadio('starting_day', $start_days);
     $form->setLabel('starting_day', $start_days_label);
     $form->setMatch('starting_day', PHPWS_Settings::get('calendar', 'starting_day'));
     $form->addRadio('brief_grid', array(0, 1));
     $form->setMatch('brief_grid', PHPWS_Settings::get('calendar', 'brief_grid'));
     $form->setLabel('brief_grid', array(0 => dgettext('calendar', 'Show event titles'), 1 => dgettext('calendar', 'Show number of events')));
     $form->addCheck('personal_schedules', 1);
     $form->setLabel('personal_schedules', dgettext('calendar', 'Allow personal schedules'));
     $form->setMatch('personal_schedules', PHPWS_Settings::get('calendar', 'personal_schedules'));
     $form->addCheck('cache_month_views', 1);
     $form->setLabel('cache_month_views', dgettext('calendar', 'Cache month views (public only)'));
     $form->setMatch('cache_month_views', PHPWS_Settings::get('calendar', 'cache_month_views'));
     $form->addCheck('mini_grid', 1);
     $form->setLabel('mini_grid', dgettext('calendar', 'Show mini grid'));
     $form->setMatch('mini_grid', PHPWS_Settings::get('calendar', 'mini_grid'));
     $form->addRadio('display_mini', array(0, 1, 2));
     $form->setLabel('display_mini', array(dgettext('calendar', 'Don\'t show'), dgettext('calendar', 'Only on front page'), dgettext('calendar', 'On all pages')));
     $form->setMatch('display_mini', PHPWS_Settings::get('calendar', 'display_mini'));
     $views['grid'] = dgettext('calendar', 'Month grid');
     $views['list'] = dgettext('calendar', 'Month list');
     $views['day'] = dgettext('calendar', 'Day view');
     $views['week'] = dgettext('calendar', 'Week view');
     $form->addSelect('default_view', $views);
     $form->setLabel('default_view', dgettext('calendar', 'Default view'));
     $form->setMatch('default_view', PHPWS_Settings::get('calendar', 'default_view'));
     $form->addSubmit(dgettext('calendar', 'Save settings'));
     $tpl = $form->getTemplate();
     $tpl['BRIEF_GRID_LABEL'] = dgettext('calendar', 'Grid event display');
     $tpl['MINI_CALENDAR'] = dgettext('calendar', 'Display mini calendar');
     $tpl['START_LABEL'] = dgettext('calendar', 'Week start day');
     $this->content = PHPWS_Template::process($tpl, 'calendar', 'admin/settings.tpl');
     $this->title = dgettext('calendar', 'Calendar settings');
 }
Ejemplo n.º 5
0
 public static function settings()
 {
     $content = array();
     $form = new PHPWS_Form('user_settings');
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'update_settings');
     $form->addSubmit('submit', dgettext('users', 'Update Settings'));
     $form->addText('site_contact', PHPWS_User::getUserSetting('site_contact'));
     $form->setLabel('site_contact', dgettext('users', 'Site contact email'));
     $form->setSize('site_contact', 40);
     if (Current_User::isDeity()) {
         $signup_modes = array(0, AUTO_SIGNUP, CONFIRM_SIGNUP);
         $signup_labels = array(dgettext('users', 'Not allowed'), dgettext('users', 'Immediate'), dgettext('users', 'Email Verification'));
         $form->addRadio('user_signup', $signup_modes);
         $form->setLabel('user_signup', $signup_labels);
         $form->addTplTag('USER_SIGNUP_LABEL', dgettext('users', 'User Signup Mode'));
         $form->setMatch('user_signup', PHPWS_User::getUserSetting('new_user_method'));
         if (extension_loaded('gd')) {
             $form->addCheckbox('graphic_confirm');
             $form->setLabel('graphic_confirm', dgettext('users', 'New user CAPTCHA confirmation'));
             $form->setMatch('graphic_confirm', PHPWS_User::getUserSetting('graphic_confirm'));
         }
         $included_usermenu = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'mod/users/templates/usermenus/', FALSE, TRUE, FALSE, array('tpl'));
         $theme_usermenu = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . Layout::getThemeDir() . 'templates/users/usermenus/', FALSE, TRUE, FALSE, array('tpl'));
         if ($theme_usermenu) {
             $options = array_unique(array_merge($included_usermenu, $theme_usermenu));
         } else {
             $options = $included_usermenu;
         }
         $menu_options = array_combine($options, $options);
         // Replace below with a directory read
         $menu_options['none'] = dgettext('users', 'None');
         $menu_options['css.tpl'] = 'css.tpl';
         $menu_options['Default.tpl'] = 'Default.tpl';
         $menu_options['top.tpl'] = 'top.tpl';
         $form->addSelect('user_menu', $menu_options);
         $form->setMatch('user_menu', PHPWS_User::getUserSetting('user_menu'));
         $form->setLabel('user_menu', dgettext('users', 'User Menu'));
         $form->addCheckBox('show_login', 1);
         $form->setMatch('show_login', PHPWS_Settings::get('users', 'show_login'));
         $form->setLabel('show_login', dgettext('users', 'Show login box'));
         $form->addTplTag('AFFIRM', dgettext('users', 'Yes'));
         $form->addCheckBox('allow_remember', 1);
         $form->setMatch('allow_remember', PHPWS_Settings::get('users', 'allow_remember'));
         $form->setLabel('allow_remember', dgettext('users', 'Allow Remember Me'));
         $form->addRadioAssoc('allow_new_users', array(1 => 'Yes', 0 => 'No'));
         $form->setMatch('allow_new_users', PHPWS_Settings::get('users', 'allow_new_users'));
         $form->addTplTag('ALLOW_NEW_USERS_LABEL', dgettext('users', 'Allow new user creation?'));
     }
     $form->addTextArea('forbidden_usernames', PHPWS_Settings::get('users', 'forbidden_usernames'));
     $form->setLabel('forbidden_usernames', dgettext('users', 'Forbidden usernames (one per line)'));
     $form->addCheckbox('session_warning', 1);
     $form->setMatch('session_warning', PHPWS_Settings::get('users', 'session_warning'));
     $form->setlabel('session_warning', 'Show session warning');
     $template = $form->getTemplate();
     if (Current_User::isDeity()) {
         $vars['action'] = 'admin';
         $vars['command'] = 'check_permission_tables';
         $template['VERIFY_PERMISSIONS'] = PHPWS_Text::secureLink(dgettext('users', 'Register user permissions'), 'users', $vars);
         $template['VERIFY_EXPLAIN'] = dgettext('users', 'Users module will re-register each module\'s permissions.');
     }
     return PHPWS_Template::process($template, 'users', 'forms/settings.tpl');
 }
Ejemplo n.º 6
0
 private function settingsForm()
 {
     \Layout::addStyle('properties', 'forms.css');
     $form = new \PHPWS_Form();
     $form->addHidden('module', 'properties');
     $form->addHidden('aop', 'post_settings');
     $form->addText('login_link', \PHPWS_Settings::get('properties', 'login_link'));
     $form->setLabel('login_link', 'Alternate authentication link');
     $form->setClass('login_link', 'form-control');
     $form->setSize('login_link', 30);
     $form->addText('email', \PHPWS_Settings::get('properties', 'email'));
     $form->setLabel('email', 'Site email');
     $form->setClass('email', 'form-control');
     $form->addText('approver_email', \PHPWS_Settings::get('properties', 'approver_email'));
     $form->setLabel('approver_email', 'Approver email');
     $form->setClass('approver_email', 'form-control');
     $form->addCheck('roommate_only');
     $form->setMatch('roommate_only', \PHPWS_Settings::get('properties', 'roommate_only'));
     $form->setLabel('roommate_only', 'Only use the roommate functionality');
     $form->addCheckbox('new_user_signup', 1);
     $form->setMatch('new_user_signup', \PHPWS_Settings::get('properties', 'new_user_signup'));
     $form->setLabel('new_user_signup', 'Allow new manager signup');
     $form->addSubmit('Save settings');
     $tpl = $form->getTemplate();
     if (!empty($this->errors)) {
         foreach ($this->errors as $key => $message) {
             $new_key = strtoupper($key) . '_ERROR';
             $tpl[$new_key] = $message;
         }
     }
     $this->title = 'Settings';
     $this->content = \PHPWS_Template::process($tpl, 'properties', 'settings.tpl');
 }