public static function contactForm() { $form = new \PHPWS_Form('contact-login'); $form->addHidden('module', 'properties'); $form->addHidden('cop', 'login'); $form->addText('c_username'); $form->setPlaceHolder('c_username', 'Username'); $form->setSize('c_username', 10); $form->setClass('c_username', 'form-control'); $form->addPassword('c_password'); $form->setPlaceHolder('c_password', 'Password'); $form->setSize('c_password', 10); $form->setClass('c_password', 'form-control'); $form->addSubmit('submit', 'Log in to Manager Account'); $form->setClass('submit', 'btn btn-success'); return $form; }
public function createUser() { if (!isset($_SESSION['User'])) { $_SESSION['User'] = new PHPWS_User(); } $form = new PHPWS_Form(); $form->addHidden('step', 5); $form->addText('username', $_SESSION['User']->username); $form->setLabel('username', dgettext('users', 'Username')); $form->addText('email', $_SESSION['User']->email); $form->setLabel('email', dgettext('users', 'Email')); $form->addPassword('pass1'); $form->setLabel('pass1', dgettext('users', 'Password')); $form->addPassword('pass2'); $form->setLabel('pass2', dgettext('users', 'Confirm')); $form->addSubmit(dgettext('core', 'Create my account')); $this->title = dgettext('core', 'Please create your new user account'); $this->content[] = $this->createForm($form, 'new_user.html'); $this->display(); }
public function form() { javascript('jquery'); javascriptMod('properties', 'generate'); \Layout::addStyle('properties', 'forms.css'); $form = new \PHPWS_Form('contact'); $form->addHidden('module', 'properties'); if (!empty($this->id)) { $form->addHidden('cid', $this->id); $form->addSubmit('Update contact'); } else { $form->addSubmit('Add contact'); } if (isset($_SESSION['Contact_User']) && !\Current_User::allow('properties')) { $form->addHidden('cop', 'save_contact'); $form->addHidden('k', $_SESSION['Contact_User']->getKey()); } else { $form->addHidden('aop', 'save_contact'); $form->addText('username', $this->username); $form->setClass('username', 'form-control'); $form->setLabel('username', 'User name'); $form->setSize('username', '20', '20'); $form->setRequired('username'); $form->addButton('make_password', 'Create'); $form->setId('make_password', 'make-password'); $form->setClass('make_password', 'btn btn-default'); $form->addCheck('contact_contact', 1); $form->setLabel('contact_contact', 'Send contact email'); if (!$this->id) { $form->setMatch('contact_contact', 1); } } $form->addPassword('password'); $form->setLabel('password', 'Password'); $form->setClass('password', 'form-control'); $form->addPassword('pw_check'); $form->setLabel('pw_check', 'Retype password below'); $form->setClass('pw_check', 'form-control'); $form->addText('first_name', $this->first_name); $form->setLabel('first_name', 'Contact first name'); $form->setRequired('first_name'); $form->setClass('first_name', 'form-control'); $form->addText('last_name', $this->last_name); $form->setLabel('last_name', 'Contact last name'); $form->setRequired('last_name'); $form->setClass('last_name', 'form-control'); $form->addText('phone', $this->getPhone()); $form->setLabel('phone', 'Phone number'); $form->setRequired('phone'); $form->setClass('phone', 'form-control'); $form->addText('email_address', $this->email_address); $form->setLabel('email_address', 'Email address'); $form->setRequired('email_address'); $form->setSize('email_address', 40); $form->setClass('email_address', 'form-control'); $form->addText('company_name', $this->company_name); $form->setLabel('company_name', 'Company name'); $form->setRequired('company_name'); $form->setSize('company_name', 40); $form->setClass('company_name', 'form-control'); $form->addText('company_url', $this->company_url); $form->setLabel('company_url', 'Company url'); $form->setSize('company_url', 40); $form->setClass('company_url', 'form-control'); $form->addText('company_address', $this->company_address); $form->setLabel('company_address', 'Company (or renter) address'); $form->setClass('company_address', 'form-control'); $form->addTextArea('times_available', $this->times_available); $form->setLabel('times_available', 'Days and hours available for contact'); $form->setRows('times_available', 4); $form->setCols('times_available', 20); $form->setClass('times_available', 'form-control'); $tpl = $form->getTemplate(); if (!empty($this->errors)) { foreach ($this->errors as $key => $message) { $new_key = strtoupper($key) . '_ERROR'; $tpl[$new_key] = $message; } } return \PHPWS_Template::process($tpl, 'properties', 'edit_contact.tpl'); }
function userForm(&$user, $errors = NULL) { PHPWS_Core::initCoreClass('Form.php'); PHPWS_Core::initModClass('users', 'User_Form.php'); $form = new PHPWS_Form(); if (isset($_REQUEST['module'])) { $form->addHidden('module', $_REQUEST['module']); } else { $form->addHidden('step', 3); $form->addHidden('display_name', 'Install'); } $form->addHidden('mod_title', 'users'); $form->addText('username', $user->getUsername()); $form->addText('email', $user->getEmail()); $form->addPassword('password1'); $form->addPassword('password2'); $form->setLabel('username', dgettext('users', 'Username')); $form->setLabel('password1', dgettext('users', 'Password')); $form->setLabel('email', dgettext('users', 'Email')); $form->addSubmit('go', dgettext('users', 'Add User')); $template = $form->getTemplate(); if (!empty($errors)) { foreach ($errors as $tag => $message) { $template[$tag] = $message; } } $result = PHPWS_Template::process($template, 'users', 'forms/userForm.tpl'); $content[] = $result; return implode("\n", $content); }
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'); }
/** * Form to create or edit a branch */ public function edit_db($force = false) { $this->title = dgettext('branch', 'Setup branch database'); $form = new PHPWS_Form('branch-form'); $form->addHidden('module', 'branch'); $form->addHidden('command', 'post_db'); $form->addHidden('force', (int) $force); $form->addCheck('createdb', $this->createdb); $form->setLabel('createdb', dgettext('branch', 'Create new database')); $form->addSelect('dbtype', $this->db_list); $form->setMatch('dbtype', $this->dbtype); $form->setLabel('dbtype', dgettext('branch', 'Database syntax')); $form->addText('dbname', $this->dbname); $form->setLabel('dbname', dgettext('branch', 'Database name')); $form->addText('dbuser', $this->dbuser); $form->setLabel('dbuser', dgettext('branch', 'Permission user')); $form->addPassword('dbpass', $this->dbpass); $form->allowValue('dbpass'); $form->setLabel('dbpass', dgettext('branch', 'User password')); $form->addText('dbprefix', $this->dbprefix); $form->setLabel('dbprefix', dgettext('branch', 'Table prefix')); $form->setSize('dbprefix', 5, 5); $form->addText('dbhost', $this->dbhost); $form->setLabel('dbhost', dgettext('branch', 'Database Host')); $form->setSize('dbhost', 40); $form->addText('dbport', $this->dbport); $form->setLabel('dbport', dgettext('branch', 'Connection Port')); $form->addTplTag('DB_LEGEND', dgettext('branch', 'Database information')); $form->addSubmit('plug', dgettext('branch', 'Use hub values')); $form->addSubmit('submit', dgettext('branch', 'Continue...')); $template = $form->getTemplate(); $this->content = PHPWS_Template::process($template, 'branch', 'edit_db.tpl'); }
public function resetPassword($user_id, $authhash) { $user = new PHPWS_User((int) $user_id); if (!$user->id) { return dgettext('users', 'Sorry there is a problem with your account.'); } if ($user->authorize != 1) { return dgettext('users', 'Sorry but you do not authorize from this site.'); } $form = new PHPWS_Form('reset-password'); $form->addHidden('module', 'users'); $form->addHidden('action', 'user'); $form->addHidden('command', 'reset_pw'); $form->addHidden('user_id', $user->id); $form->addHidden('authhash', $authhash); $form->addPassword('password1'); $form->setLabel('password1', dgettext('users', 'Enter your new password')); $form->addPassword('password2'); $form->setLabel('password2', dgettext('users', 'Repeat it here please')); $form->addSubmit('submit', dgettext('users', 'Update password')); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'users', 'forms/reset_password.tpl'); }