Ejemplo n.º 1
0
 public function show()
 {
     $form = new PHPWS_Form('room_change_request');
     /* Cell phone */
     $form->addText('cell_num');
     $form->setLabel('cell_num', 'Cell phone Number');
     $form->addCssClass('cell_num', 'form-control');
     $form->addCheck('cell_opt_out');
     /* Preferences */
     $halls = array(0 => 'Choose from below...');
     $halls = $halls + HMS_Residence_Hall::get_halls_array(Term::getSelectedTerm());
     $form->addRadioAssoc('type', array('switch' => 'I want to change to an open bed.', 'swap' => 'I want to swap beds with someone I know.'));
     /* Swap */
     $form->addText('swap_with');
     $form->setLabel('swap_with', 'ASU Email Address');
     $form->addCssClass('swap_with', 'form-control');
     /* Switch */
     $form->addDropBox('first_choice', $halls);
     $form->setLabel('first_choice', 'First Choice');
     $form->addCssClass('first_choice', 'form-control');
     $form->addDropBox('second_choice', $halls);
     $form->setLabel('second_choice', 'Second Choice');
     $form->addCssClass('second_choice', 'form-control');
     /* Reason */
     $form->addTextArea('reason');
     $form->setLabel('reason', 'Reason');
     $form->addCssClass('reason', 'form-control');
     $form->setRows('reason', 5);
     /* POST location */
     $cmd = CommandFactory::getCommand('SubmitRoomChangeRequest');
     $cmd->initForm($form);
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'student/roomChangeRequestForm.tpl');
 }
Ejemplo n.º 2
0
 public function show()
 {
     $username = UserStatus::getUsername();
     $currentTerm = Term::getCurrentTerm();
     $student = StudentFactory::getStudentByUsername($username, $currentTerm);
     $applicationTerm = $student->getApplicationTerm();
     $tpl = array();
     $tpl['TITLE'] = 'Contact Form';
     $form = new PHPWS_Form();
     $form->addText('name');
     $form->setLabel('name', 'Name');
     $form->addText('email');
     $form->setLabel('email', 'Email Address');
     $form->addText('phone');
     $form->setLabel('phone', 'Phone number');
     $form->addDropBox('stype', array('F' => 'New Freshmen', 'T' => 'Transfer', 'C' => 'Returning'));
     $form->setLabel('stype', 'Classification');
     $form->addTextArea('comments');
     $form->setLabel('comments', 'Question, Comments, or Description of the Problem');
     $form->addSubmit('Submit');
     $form->mergeTemplate($tpl);
     $cmd = CommandFactory::getCommand('SubmitContactForm');
     $cmd->setUsername($username);
     $cmd->setApplicationTerm($applicationTerm);
     $cmd->setStudentType($student->getType());
     $cmd->initForm($form);
     $tpl = $form->getTemplate();
     //var_dump($tpl);exit;
     return PHPWS_Template::process($tpl, 'hms', 'student/contact_page.tpl');
 }
Ejemplo n.º 3
0
 public function addForm(PHPWS_Form &$form)
 {
     $form->addText('piwik_url', $this->getPiwikUrl());
     $form->setLabel('piwik_url', dgettext('analytics', 'Base URL of Piwik (DO NOT specify protocol (http:// or https://), as this is autodetected by the script)'));
     $form->setRequired('piwik_url');
     $form->addText('piwik_id', $this->getPiwikId());
     $form->setLabel('piwik_id', dgettext('analytics', 'Piwik Site ID'));
     $form->setRequired('piwik_id');
 }
Ejemplo n.º 4
0
 public function checkinForm()
 {
     $form = new PHPWS_Form('checkin');
     $form->turnOffAutoComplete();
     $form->setProtected(false);
     $form->addHidden('module', 'checkin');
     $form->addHidden('uop', 'post_checkin');
     $form->addText('first_name', isset($_POST['first_name']) ? trim($_POST['first_name']) : null);
     $form->setLabel('first_name', dgettext('checkin', 'First name'));
     $form->setRequired('first_name');
     $form->addText('last_name', isset($_POST['last_name']) ? trim($_POST['last_name']) : null);
     $form->setLabel('last_name', dgettext('checkin', 'Last name'));
     $form->setRequired('last_name');
     if (PHPWS_Settings::get('checkin', 'email')) {
         $form->addText('email', isset($_POST['email']) ? trim($_POST['email']) : null);
         $form->setLabel('email', dgettext('checkin', 'Email address'));
         $form->setRequired('email');
     }
     // If gender is requested
     if (PHPWS_Settings::get('checkin', 'gender')) {
         $sex = array('male' => 'Male', 'female' => 'Female');
         $form->addRadioAssoc('gender', $sex);
         $form->addTplTag('GENDER_LABEL', dgettext('checkin', 'Gender'));
     }
     // If birthdate is requested
     if (PHPWS_Settings::get('checkin', 'birthdate')) {
         /*
          * Minimum representable date is 12-13-1901, and instead of doing 
          * lots of math to ensure that all selected dates in 1901 are after
          * 12-13-1901, just make the minimum year always be 1902
          */
         $yearsPrior = date('Y', time()) - 1902;
         // current year - minimum full year (1902)
         $form->dateSelect('birthdate', 0, '%B', $yearsPrior, 0);
         $form->addTplTag('BIRTHDATE_LABEL', dgettext('checkin', 'Date of birth'));
     }
     $reasons = $this->getReasons();
     if (!empty($reasons)) {
         $reasons = array_reverse($reasons, true);
         $reasons[0] = dgettext('checkin', '-- Please choose a reason from the list below --');
         $reasons = array_reverse($reasons, true);
         $form->addSelect('reason_id', $reasons);
         $form->setLabel('reason_id', dgettext('checkin', 'Reason for visit'));
     }
     $form->addSubmit(dgettext('checkin', 'Check in'));
     $tpl = $form->getTemplate();
     $this->title = dgettext('checkin', 'Please check in using the form below');
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'signin.tpl');
     if (!Current_User::isLogged() && PHPWS_Settings::get('checkin', 'collapse_signin')) {
         Layout::collapse();
     }
 }
Ejemplo n.º 5
0
 public function display()
 {
     // permissions...
     if (!\Current_User::isDeity()) {
         \NQ::simple('intern', NotifyUI::ERROR, 'You cannot edit administrators.');
         return false;
     }
     // set up some stuff for the page template
     $tpl = array();
     // create the list of admins
     $adminList = Admin::getAdminPager();
     // get the list of departments
     $depts = Department::getDepartmentsAssoc();
     // make the form for adding a new admin
     $form = new \PHPWS_Form('add_admin');
     $form->addSelect('department_id', $depts);
     $form->setLabel('department_id', 'Department');
     $form->addText('username');
     $form->setLabel('username', 'Username');
     $form->addCheck('all');
     $form->setLabel('all', 'All Departments');
     $form->addSubmit('submit', 'Create Admin');
     $form->setAction('index.php?module=intern&action=edit_admins');
     $form->addHidden('add', 1);
     // TODO: Add Javascript autocomplete for usernames.
     javascript('jquery');
     javascript('jquery_ui');
     javascriptMod('intern', 'admin');
     $tpl['PAGER'] = $adminList;
     $form->mergeTemplate($tpl);
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_admin.tpl');
 }
Ejemplo n.º 6
0
 public function addForm(PHPWS_Form &$form)
 {
     $form->addText('owa_url', $this->getOwaUrl());
     $form->setLabel('owa_url', dgettext('analytics', 'Base URL of Open Web Analytics (DO specify protocol (http:// or https://)'));
     $form->setRequired('owa_url');
     $form->addText('owa_site_id', $this->getOwaSiteId());
     $form->setLabel('owa_site_id', dgettext('analytics', 'Open Web Analytics Site ID'));
     $form->setRequired('owa_site_id');
     $form->addCheck('owa_track_page_view', 1);
     $form->setMatch('owa_track_page_view', $this->getTrackPageView());
     $form->setLabel('owa_track_page_view', dgettext('analytics', 'Track Page Views (see OWA documentation)'));
     $form->addCheck('owa_track_clicks', 1);
     $form->setMatch('owa_track_clicks', $this->getTrackClicks());
     $form->setLabel('owa_track_clicks', dgettext('analytics', 'Track Clicks (see OWA documentation)'));
     $form->addCheck('owa_track_domstream', 1);
     $form->setMatch('owa_track_domstream', $this->getTrackDomStream());
     $form->setLabel('owa_track_domstream', dgettext('analytics', 'Track DOM Stream (see OWA documentation)'));
 }
Ejemplo n.º 7
0
 public function show()
 {
     // Setup form
     $form = new PHPWS_Form('likebox_settings');
     $form->setMethod('POST');
     // Hidden fields for directing this request after submission
     $form->addHidden('module', 'likebox');
     $form->addHidden('action', 'SaveSettings');
     // Enabled Checkbox
     $form->addCheck('enabled', 'enabled');
     $form->setLabel('enabled', 'Enabled');
     // URL
     $form->addText('fb_url', $this->settings->get('fb_url'));
     $form->setLabel('fb_url', 'Facebook Page URL:');
     // Width
     $form->addText('width', $this->settings->get('width'));
     $form->setLabel('width', 'Width');
     // Height
     $form->addText('height', $this->settings->get('height'));
     $form->setLabel('height', 'Height');
     // Show header bar i.e. "Find us on Facebook"
     $form->addCheck('small_header', 'small_header');
     $form->setLabel('small_header', 'Use Small header');
     // Show border
     $form->addCheck('hide_cover', 'hide_cover');
     $form->setLabel('hide_cover', 'Hide Cover Photo');
     // Show stream
     $form->addCheck('show_posts', 'show_posts');
     $form->setLabel('show_posts', 'Show Page Posts');
     // Show faces
     $form->addCheck('show_faces', 'show_faces');
     $form->setLabel('show_faces', 'Show Friend\'s faces');
     // Submit button
     $form->addSubmit('submit', 'Submit');
     $checkBoxes = array('enabled', 'small_header', 'hide_cover', 'show_posts', 'show_faces');
     foreach ($checkBoxes as $key) {
         $value = $this->settings->get($key);
         if (isset($value) && $value == 1) {
             $form->setMatch($key, $key);
         }
     }
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'likebox', 'settings.tpl');
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 public function display()
 {
     /* Permission check */
     if (!\Current_User::allow('intern', Department::getEditPermission())) {
         \NQ::simple('intern', NotifyUI::ERROR, "You do not have permission to edit departments.");
         return;
     }
     javascript('/jquery/');
     javascriptMod('intern', 'editMajor', array('EDIT_ACTION' => Department::getEditAction()));
     // Form for adding new department
     $form = new \PHPWS_Form('add_department');
     $form->addText('name');
     $form->setLabel('name', 'Department Name');
     $form->addSubmit('submit', 'Add Department');
     $form->setAction('index.php?module=intern&action=edit_dept');
     $form->addHidden('add', TRUE);
     $tpl['PAGER'] = DepartmentUI::doPager();
     $form->mergeTemplate($tpl);
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_department.tpl');
 }
Ejemplo n.º 10
0
 public function display()
 {
     /* Check if user can add/edit/hide/delete majors. */
     if (!\Current_User::allow('intern', 'edit_major') && !\Current_User::allow('intern', 'delete_major')) {
         \NQ::simple('intern', NotifyUI::WARNING, 'You do not have permission to edit undergraduate majors.');
         return false;
     }
     $tpl['PAGER'] = MajorUI::doPager();
     javascript('/jquery/');
     javascriptMod('intern', 'editMajor', array('EDIT_ACTION' => Major::getEditAction()));
     /* Form for adding new major */
     $form = new \PHPWS_Form('add_major');
     $form->addText('name');
     $form->setLabel('name', 'Major Title');
     $form->addSubmit('submit', 'Add Major');
     $form->setAction('index.php?module=intern&action=edit_major');
     $form->addHidden('add', TRUE);
     $form->mergeTemplate($tpl);
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_major.tpl');
 }
Ejemplo n.º 11
0
 public static function display()
 {
     /* Permission check */
     if (!Current_User::allow('intern', Department::getEditPermission())) {
         NQ::simple('intern', INTERN_ERROR, "Uh Uh Uh! You didn't say the magic word!");
         return;
     }
     javascript('/jquery/');
     javascriptMod('intern', 'editMajor', array('EDIT_ACTION' => Department::getEditAction()));
     // Form for adding new department
     $form = new PHPWS_Form('add_department');
     $form->addText('name');
     $form->setLabel('name', 'Department Name');
     $form->addSubmit('submit', 'Add Department');
     $form->setAction('index.php?module=intern&action=' . DEPT_EDIT);
     $form->addHidden('add', TRUE);
     $tpl['PAGER'] = DepartmentUI::doPager();
     $form->mergeTemplate($tpl);
     return PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_department.tpl');
 }
 public static function display()
 {
     /* Check if user can add/edit/hide/delete grad programs. */
     if (!Current_User::allow('intern', 'edit_grad_prog') && !Current_User::allow('intern', 'delete_grad_prog')) {
         NQ::simple('intern', INTERN_WARNING, 'You do not have permission to edit graduate programs.');
         return false;
     }
     $tpl['PAGER'] = self::doPager();
     javascript('/jquery/');
     javascriptMod('intern', 'editMajor', array('EDIT_ACTION' => GradProgram::getEditAction()));
     /* Form for adding new grad program */
     $form = new PHPWS_Form('add_prog');
     $form->addText('name');
     $form->setLabel('name', 'Graduate Program Title');
     $form->addSubmit('submit', 'Add Graduate Program');
     $form->setAction('index.php?module=intern&action=edit_grad');
     $form->addHidden('add', TRUE);
     $form->mergeTemplate($tpl);
     return PHPWS_Template::process($form->getTemplate(), 'intern', 'edit_grad.tpl');
 }
Ejemplo n.º 13
0
 public static function editFeed(RSS_Feed $feed)
 {
     $form = new PHPWS_Form();
     if ($feed->id) {
         $form->addHidden('feed_id', $feed->id);
     }
     $form->addHidden('module', 'rss');
     $form->addHidden('command', 'save_feed');
     $form->addText('address', $feed->address);
     $form->setLabel('address', dgettext('rss', 'Address'));
     $form->setSize('address', '30');
     $form->addText('title', $feed->title);
     $form->setLabel('title', dgettext('rss', 'Title'));
     $form->setSize('title', '30');
     $form->addSubmit('submit', dgettext('rss', 'Save'));
     $form->addButton('cancel', dgettext('rss', 'Cancel'));
     $form->setExtra('cancel', 'onclick="window.close()"');
     $form->addText('item_limit', $feed->item_limit);
     $form->setSize('item_limit', 2);
     $form->setLabel('item_limit', dgettext('rss', 'Item limit'));
     $form->addText('refresh_time', $feed->refresh_time);
     $form->setSize('refresh_time', 5);
     $form->setLabel('refresh_time', dgettext('rss', 'Refresh time'));
     $template = $form->getTemplate();
     $template['TITLE_WARNING'] = dgettext('rss', 'Feed title will be used if left empty');
     $template['REFRESH_WARNING'] = dgettext('rss', 'In seconds');
     $content = PHPWS_Template::process($template, 'rss', 'add_feed.tpl');
     $tpl['TITLE'] = dgettext('rss', 'Add Feed');
     $tpl['CONTENT'] = $content;
     return $tpl;
 }
Ejemplo n.º 14
0
 public static function settings()
 {
     $form = new PHPWS_Form('block-form');
     $form->addHidden('module', 'block');
     $form->addHidden('action', 'post_settings');
     $form->addText('max_image_width', PHPWS_Settings::get('block', 'max_image_width'));
     $form->setLabel('max_image_width', dgettext('block', 'Max image width (50 - 1024)'));
     $form->setSize('max_image_width', 4, 4);
     $form->addText('max_image_height', PHPWS_Settings::get('block', 'max_image_height'));
     $form->setLabel('max_image_height', dgettext('block', 'Max image height (50 - 3000)'));
     $form->setSize('max_image_height', 4, 4);
     $form->addSubmit(dgettext('block', 'Save settings'));
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'block', 'settings.tpl');
 }
Ejemplo n.º 15
0
 /**
  * Allows users with sufficient privileges to change the settings associated
  * with the faxmaster module.
  */
 private function changeSettings()
 {
     // Check user's permissions
     if (!Current_User::allow('faxmaster', 'settings')) {
         PHPWS_Core::initModClass('faxmaster', 'exception/PermissionException.php');
         throw new PermissionException('Permission denied');
     }
     $content = array();
     $form = new PHPWS_Form('faxmaster_settings');
     // If $_REQUEST data has been given, set the paths
     if (isset($_REQUEST['fax_path']) && !is_null($_REQUEST['fax_path']) && isset($_REQUEST['archive_path']) && !is_null($_REQUEST['archive_path'])) {
         clearstatcache(true);
         // is_readable and is_writable cache results, so you need to clear the cache
         $faxRead = is_readable($_REQUEST['fax_path']);
         $faxWrite = is_writable($_REQUEST['fax_path']);
         $archiveRead = is_readable($_REQUEST['archive_path']);
         $archiveWrite = is_writable($_REQUEST['archive_path']);
         if (!$faxRead || !$faxWrite || !$archiveRead || !$archiveWrite) {
             // Show warnings for invalid paths
             PHPWS_Core::initModClass('faxmaster', 'FaxmasterNotificationView.php');
             if (!$faxRead) {
                 NQ::simple('faxmaster', FAX_NOTIFICATION_ERROR, "The fax directory you specified is not readable or does not exist.");
             }
             if (!$faxWrite) {
                 NQ::simple('faxmaster', FAX_NOTIFICATION_ERROR, "The fax directory you specified is not writable or does not exist.");
             }
             if (!$archiveRead) {
                 NQ::simple('faxmaster', FAX_NOTIFICATION_ERROR, "The archive directory you specified is not readable or does not exist.");
             }
             if (!$archiveWrite) {
                 NQ::simple('faxmaster', FAX_NOTIFICATION_ERROR, "The archive directory you specified is not writable or does not exist.");
             }
             $nv = new FaxmasterNotificationView();
             $nv->popNotifications();
             Layout::add($nv->show());
             // Show supplied paths
             $form->setAction('index.php?module=faxmaster&op=settings');
             $form->addTplTag('FAX_PATH', $_REQUEST['fax_path']);
             $form->addTplTag('ARCHIVE_PATH', $_REQUEST['archive_path']);
             $form->addSubmit('Try Again');
             $tpl = $form->getTemplate();
             Layout::add(PHPWS_Template::process($tpl, 'faxmaster', 'settings.tpl'));
         } else {
             // new paths were valid, so update settings
             PHPWS_Settings::set('faxmaster', 'fax_path', $_REQUEST['fax_path']);
             PHPWS_Settings::set('faxmaster', 'archive_path', $_REQUEST['archive_path']);
             PHPWS_Settings::save('faxmaster');
             // Show new paths
             $form->setAction('index.php?module=faxmaster&op=go_home');
             $form->addTplTag('SAVED', 'New Settings Saved!');
             $form->addTplTag('FAX_PATH', PHPWS_Settings::get('faxmaster', 'fax_path'));
             $form->addTplTag('ARCHIVE_PATH', PHPWS_Settings::get('faxmaster', 'archive_path'));
             $form->addSubmit('Return to Fax List');
             $tpl = $form->getTemplate();
             Layout::add(PHPWS_Template::process($tpl, 'faxmaster', 'settings.tpl'));
         }
     } else {
         // Show initial form to change paths
         $form->setAction('index.php?module=faxmaster&op=settings');
         $form->addTplTag('WARNING', '<strong>WARNING: </strong> Changing paths does not move files. Files must be moved manually.<br /><br \\>');
         $form->addText('fax_path', PHPWS_Settings::get('faxmaster', 'fax_path'));
         $form->setSize('fax_path', 45);
         $form->addText('archive_path', PHPWS_Settings::get('faxmaster', 'archive_path'));
         $form->setSize('archive_path', 45);
         $form->addSubmit('Save Settings');
         $tpl = $form->getTemplate();
         Layout::add(PHPWS_Template::process($tpl, 'faxmaster', 'settings.tpl'));
     }
     $this->addNavLinks();
 }
Ejemplo n.º 16
0
 public function userSignup()
 {
     if (!$this->signup->sheet->id) {
         PHPWS_Core::errorPage('404');
     }
     $sheet = $this->signup->sheet;
     $peep = $this->signup->peep;
     if (Current_User::isLogged() && empty($peep->email)) {
         $peep->email = Current_User::getEmail();
     }
     if ($sheet->end_time < time()) {
         $this->signup->title = dgettext('signup', 'Sorry');
         $this->signup->content = dgettext('signup', 'We are no longer accepting applications.');
         return;
     }
     $slots = $sheet->getAllSlots();
     $slots_filled = $sheet->totalSlotsFilled();
     if (empty($slots)) {
         $this->signup->title = dgettext('signup', 'Sorry');
         $this->signup->content = dgettext('signup', 'There is a problem with this signup sheet. Please check back later.');
         return;
     }
     $this->signup->title =& $sheet->title;
     foreach ($slots as $slot) {
         // if the slots are filled, don't offer it
         if ($slots_filled && isset($slots_filled[$slot->id])) {
             $filled =& $slots_filled[$slot->id];
             if ($filled >= $slot->openings) {
                 continue;
             } else {
                 $openings_left = $slot->openings - $filled;
             }
         } else {
             $openings_left =& $slot->openings;
         }
         $options[$slot->id] = sprintf(dngettext('signup', '%s (%s opening)', '%s (%s openings)', $openings_left), $slot->title, $openings_left);
     }
     if (!isset($options)) {
         $this->signup->content = dgettext('signup', 'Sorry, but all available slots are full. Please check back later for possible cancellations.');
         return;
     } else {
         $form = new PHPWS_Form('slots');
         $form->useFieldset();
         $form->setLegend(dgettext('signup', 'Signup form'));
         $form->addHidden('module', 'signup');
         $form->addHidden('uop', 'slot_signup');
         $form->addHidden('sheet_id', $this->signup->sheet->id);
         $form->addSelect('slot_id', $options);
         $form->setLabel('slot_id', dgettext('signup', 'Available slots'));
         $form->setMatch('slot_id', $peep->slot_id);
         $form->addText('first_name', $peep->first_name);
         $form->setLabel('first_name', dgettext('signup', 'First name'));
         $form->addText('last_name', $peep->last_name);
         $form->setLabel('last_name', dgettext('signup', 'Last name'));
         $form->addText('email', $peep->email);
         $form->setSize('email', 30);
         $form->setLabel('email', dgettext('signup', 'Email address'));
         $form->addText('phone', $peep->getPhone());
         $form->setSize('phone', 15);
         $form->setLabel('phone', dgettext('signup', 'Phone number'));
         if (!empty($this->signup->sheet->extra1)) {
             $form->addText('extra1', $peep->extra1);
             $form->setLabel('extra1', $this->signup->sheet->extra1);
         }
         if (!empty($this->signup->sheet->extra2)) {
             $form->addText('extra2', $peep->extra2);
             $form->setLabel('extra2', $this->signup->sheet->extra2);
         }
         if (!empty($this->signup->sheet->extra3)) {
             $form->addText('extra3', $peep->extra3);
             $form->setLabel('extra3', $this->signup->sheet->extra3);
         }
         $form->addSubmit(dgettext('signup', 'Submit'));
         $tpl = $form->getTemplate();
     }
     $tpl['DESCRIPTION'] = $sheet->getDescription();
     $this->signup->content = PHPWS_Template::process($tpl, 'signup', 'signup_form.tpl');
     $this->signup->sheet->flag();
 }
Ejemplo n.º 17
0
 /**
  * Form for meta tags. Used for site mata tags and individual key
  * meta tags.
  */
 public static function metaForm($key_id = 0)
 {
     $meta_description = $meta_keywords = $page_title = null;
     $meta_robots = '11';
     if (!$key_id) {
         $vars = $_SESSION['Layout_Settings']->getMetaTags();
     } else {
         $vars = $_SESSION['Layout_Settings']->getPageMetaTags($key_id);
         if (empty($vars)) {
             $vars = $_SESSION['Layout_Settings']->getMetaTags();
             $key = new Key($key_id);
             $vars['page_title'] = $key->title;
         }
     }
     if (is_array($vars)) {
         extract($vars);
     }
     $index = substr($meta_robots, 0, 1);
     $follow = substr($meta_robots, 1, 1);
     $form = new PHPWS_Form('metatags');
     if ($key_id) {
         $form->addHidden('key_id', $key_id);
         $form->addSubmit('reset', dgettext('layout', 'Restore to default'));
     }
     $form->addHidden('module', 'layout');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'postMeta');
     $form->addText('page_title', $page_title);
     $form->setClass('page_title', 'form-control');
     $form->setLabel('page_title', dgettext('layout', 'Site Name'));
     $form->addTextArea('meta_keywords', $meta_keywords);
     $form->setLabel('meta_keywords', dgettext('layout', 'Keywords'));
     $form->setClass('meta_keywords', 'form-control');
     $form->addTextArea('meta_description', $meta_description);
     $form->setLabel('meta_description', dgettext('layout', 'Description'));
     $form->setClass('meta_description', 'form-control');
     $form->addCheckBox('index', 1);
     $form->setMatch('index', $index);
     $form->setLabel('index', dgettext('layout', 'Allow indexing'));
     $form->addCheckBox('follow', 1);
     $form->setMatch('follow', $follow);
     $form->setLabel('follow', dgettext('layout', 'Allow link following'));
     $form->addCheckBox('use_key_summaries', 1);
     $form->setMatch('use_key_summaries', PHPWS_Settings::get('layout', 'use_key_summaries'));
     $form->setLabel('use_key_summaries', dgettext('layout', 'Use Key summaries for meta description'));
     $form->addSubmit('submit', dgettext('layout', 'Update'));
     $template = $form->getTemplate();
     $template['ROBOT_LABEL'] = dgettext('layout', 'Default Robot Settings');
     return PHPWS_Template::process($template, 'layout', 'metatags.tpl');
 }
Ejemplo n.º 18
0
 /**
  */
 public function editRTMP()
 {
     $form = new PHPWS_Form();
     $form->setFormId('file-form');
     $form->addHidden('multimedia_id', $this->multimedia->id);
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('mop', 'post_rtmp');
     $form->addHidden('folder_id', $this->multimedia->folder_id);
     $form->addText('title', $this->multimedia->getTitle());
     $form->setLabel('title', 'Stream title');
     $form->setClass('title', 'form-control');
     $form->addText('rtmp_server', $this->multimedia->file_directory);
     $form->setLabel('rtmp_server', 'RTMP server');
     $form->setClass('rtmp_server', 'form-control');
     $form->addText('rtmp_file', $this->multimedia->file_name);
     $form->setLabel('rtmp_file', 'Stream/File name');
     $form->setClass('rtmp_file', 'form-control');
     $form->addText('width', $this->multimedia->width);
     $form->setLabel('width', 'Width');
     $form->setClass('width', 'form-control');
     $form->addText('height', $this->multimedia->height);
     $form->setLabel('height', 'Height');
     $form->setClass('height', 'form-control');
     $tpl = $form->getTemplate();
     $this->title = dgettext('filecabinet', 'Create/Update RTMP Stream');
     $this->content = PHPWS_Template::process($tpl, 'filecabinet', 'Forms/rtmp_edit.tpl');
 }
Ejemplo n.º 19
0
 public static function editFeed($feed = null, $add_submit = false)
 {
     if (empty($feed)) {
         $feed = new RSS_Feed();
     }
     $form = new PHPWS_Form();
     $form->addHidden('feed_id', $feed->id);
     $form->addHidden('module', 'rss');
     $form->addHidden('command', 'save_feed');
     $form->addTextArea('address', $feed->address);
     $form->setClass('address', 'form-control');
     $form->setLabel('address', dgettext('rss', 'Address'));
     $form->addText('title', $feed->title);
     $form->setClass('title', 'form-control');
     $form->setLabel('title', dgettext('rss', 'Title'));
     $form->addText('item_limit', $feed->item_limit);
     $form->setClass('item_limit', 'form-control');
     $form->setSize('item_limit', 2);
     $form->setLabel('item_limit', dgettext('rss', 'Item limit'));
     $form->addText('refresh_time', $feed->refresh_time);
     $form->setClass('refresh_time', 'form-control');
     $form->setSize('refresh_time', 5);
     $form->setLabel('refresh_time', dgettext('rss', 'Refresh time'));
     if ($add_submit) {
         $form->addSubmit('submit', dgettext('rss', 'Save'));
         $form->setClass('submit', 'btn btn-primary');
     }
     $template = $form->getTemplate();
     $template['TITLE_WARNING'] = dgettext('rss', 'Feed title will be used if left empty');
     $template['REFRESH_WARNING'] = dgettext('rss', 'In seconds');
     $content = PHPWS_Template::process($template, 'rss', 'add_feed.tpl');
     return $content;
 }
Ejemplo n.º 20
0
 /**
  * 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');
 }
Ejemplo n.º 21
0
 /**
  * Creates the edit form for an event
  */
 public static function event_form(Calendar_Event $event, $suggest = false)
 {
     Layout::addStyle('calendar');
     javascript('datetimepicker');
     // the form id is linked to the check_date javascript
     $form = new PHPWS_Form('event_form');
     if (isset($_REQUEST['js'])) {
         $form->addHidden('js', 1);
     }
     $form->addHidden('module', 'calendar');
     if ($suggest) {
         $form->addHidden('uop', 'post_suggestion');
     } else {
         $form->addHidden('aop', 'post_event');
     }
     $form->addHidden('event_id', $event->id);
     $form->addHidden('sch_id', $event->_schedule->id);
     $form->addText('summary', $event->summary);
     $form->setLabel('summary', dgettext('calendar', 'Summary'));
     $form->setSize('summary', 60);
     $form->addText('location', $event->location);
     $form->setLabel('location', dgettext('calendar', 'Location'));
     $form->setSize('location', 60);
     $form->addText('loc_link', $event->loc_link);
     $form->setLabel('loc_link', dgettext('calendar', 'Location link'));
     $form->setSize('loc_link', 60);
     $form->addTextArea('description', $event->description);
     if ($suggest) {
         $form->setRows('description', 8);
         $form->setCols('description', 55);
     } else {
         $form->useEditor('description');
     }
     $form->setLabel('description', dgettext('calendar', 'Description'));
     $form->addText('start_date', $event->getStartTime('%Y/%m/%d'));
     $form->setLabel('start_date', dgettext('calendar', 'Start time'));
     $form->setExtra('start_date', 'onblur="check_start_date()"');
     $form->addText('end_date', $event->getEndTime('%Y/%m/%d'));
     $form->setLabel('end_date', dgettext('calendar', 'End time'));
     $form->setExtra('end_date', 'onblur="check_end_date()" onfocus="check_start_date()"');
     $event->timeForm('start_time', $event->start_time, $form);
     $event->timeForm('end_time', $event->end_time, $form);
     $form->setExtra('start_time_hour', 'onchange="check_start_date()"');
     $form->setExtra('end_time_hour', 'onchange="check_end_date()"');
     $form->addCheck('all_day', 1);
     $form->setMatch('all_day', $event->all_day);
     $form->setLabel('all_day', dgettext('calendar', 'All day event'));
     $form->setExtra('all_day', 'onchange="alter_date(this)"');
     if (!$suggest) {
         $form->addCheck('show_busy', 1);
         $form->setMatch('show_busy', $event->show_busy);
         $form->setLabel('show_busy', dgettext('calendar', 'Show busy'));
     }
     if ($suggest) {
         $form->addSubmit('save', dgettext('calendar', 'Suggest event'));
     } else {
         // Suggested events are not allowed repeats
         /**
          * Repeat form elements
          */
         $form->addCheck('repeat_event', 1);
         $form->setLabel('repeat_event', dgettext('calendar', 'Make a repeating event'));
         $form->addText('end_repeat_date', $event->getEndRepeat('%Y/%m/%d'));
         $form->setLabel('end_repeat_date', dgettext('calendar', 'Repeat event until:'));
         $modes = array('daily', 'weekly', 'monthly', 'yearly', 'every');
         $modes_label = array(dgettext('calendar', 'Daily'), dgettext('calendar', 'Weekly'), dgettext('calendar', 'Monthly'), dgettext('calendar', 'Yearly'), dgettext('calendar', 'Every'));
         $form->addRadio('repeat_mode', $modes);
         $form->setLabel('repeat_mode', $modes_label);
         $weekdays = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7);
         $weekday_labels = array(1 => strftime('%A', mktime(0, 0, 0, 1, 5, 1970)), 2 => strftime('%A', mktime(0, 0, 0, 1, 6, 1970)), 3 => strftime('%A', mktime(0, 0, 0, 1, 7, 1970)), 4 => strftime('%A', mktime(0, 0, 0, 1, 8, 1970)), 5 => strftime('%A', mktime(0, 0, 0, 1, 9, 1970)), 6 => strftime('%A', mktime(0, 0, 0, 1, 10, 1970)), 7 => strftime('%A', mktime(0, 0, 0, 1, 11, 1970)));
         $form->addCheck('weekday_repeat', $weekdays);
         $form->setLabel('weekday_repeat', $weekday_labels);
         $monthly = array('begin' => dgettext('calendar', 'Beginning of each month'), 'end' => dgettext('calendar', 'End of each month'), 'start' => dgettext('calendar', 'Every month on start date'));
         $form->addSelect('monthly_repeat', $monthly);
         $every_repeat_week = array(1 => dgettext('calendar', '1st'), 2 => dgettext('calendar', '2nd'), 3 => dgettext('calendar', '3rd'), 4 => dgettext('calendar', '4th'), 5 => dgettext('calendar', 'Last'));
         $frequency = array('every_month' => dgettext('calendar', 'Every month'), 1 => strftime('%B', mktime(0, 0, 0, 1, 1, 1970)), 2 => strftime('%B', mktime(0, 0, 0, 2, 1, 1970)), 3 => strftime('%B', mktime(0, 0, 0, 3, 1, 1970)), 4 => strftime('%B', mktime(0, 0, 0, 4, 1, 1970)), 5 => strftime('%B', mktime(0, 0, 0, 5, 1, 1970)), 6 => strftime('%B', mktime(0, 0, 0, 6, 1, 1970)), 7 => strftime('%B', mktime(0, 0, 0, 7, 1, 1970)), 8 => strftime('%B', mktime(0, 0, 0, 8, 1, 1970)), 9 => strftime('%B', mktime(0, 0, 0, 9, 1, 1970)), 10 => strftime('%B', mktime(0, 0, 0, 10, 1, 1970)), 11 => strftime('%B', mktime(0, 0, 0, 11, 1, 1970)), 12 => strftime('%B', mktime(0, 0, 0, 12, 1, 1970)));
         $form->addSelect('every_repeat_number', $every_repeat_week);
         $form->addSelect('every_repeat_weekday', $weekday_labels);
         $form->addSelect('every_repeat_frequency', $frequency);
         /* set repeat form matches */
         if (!empty($event->repeat_type)) {
             $repeat_info = explode(':', $event->repeat_type);
             $repeat_mode_match = $repeat_info[0];
             if (isset($repeat_info[1])) {
                 $repeat_vars = explode(';', $repeat_info[1]);
             } else {
                 $repeat_vars = null;
             }
             $form->setMatch('repeat_mode', $repeat_mode_match);
             switch ($repeat_mode_match) {
                 case 'weekly':
                     $form->setMatch('weekday_repeat', $repeat_vars);
                     break;
                 case 'monthly':
                     $form->setMatch('monthly_repeat', $repeat_vars[0]);
                     break;
                 case 'every':
                     $form->setMatch('every_repeat_number', $repeat_vars[0]);
                     $form->setMatch('every_repeat_weekday', $repeat_vars[1]);
                     $form->setMatch('every_repeat_frequency', $repeat_vars[2]);
                     break;
             }
             $form->setMatch('repeat_event', 1);
         }
         if ($event->pid) {
             $form->addHidden('pid', $event->pid);
             // This is a repeat copy, if saved it removes it from the copy list
             $form->addSubmit('save', dgettext('calendar', 'Save and remove repeat'));
             $form->setExtra('save', sprintf('onclick="return confirm(\'%s\')"', dgettext('calendar', 'Remove event from repeat list?')));
         } elseif ($event->id && $event->repeat_type) {
             // This is event is a source repeating event
             // Save this
             // Not sure if coding this portion. commenting for now
             // $form->addSubmit('save_source', dgettext('calendar', 'Save this event only'));
             $form->addSubmit('save_copy', dgettext('calendar', 'Save and apply to repeats'));
             $form->setExtra('save_copy', sprintf('onclick="return confirm(\'%s\')"', dgettext('calendar', 'Apply changes to repeats?')));
         } else {
             // this is a non-repeating event
             $form->addSubmit('save', dgettext('calendar', 'Save event'));
         }
     }
     $tpl = $form->getTemplate();
     if (!$suggest) {
         $tpl['EVENT_TAB'] = dgettext('calendar', 'Event');
         $tpl['REPEAT_TAB'] = dgettext('calendar', 'Repeat');
     }
     if (isset($event->_error)) {
         $tpl['ERROR'] = implode('<br />', $event->_error);
     }
     if ($event->pid) {
         $linkvar['aop'] = 'edit_event';
         $linkvar['sch_id'] = $event->_schedule->id;
         $linkvar['event_id'] = $event->pid;
         if (javascriptEnabled()) {
             $linkvar['js'] = 1;
         }
         $source_link = PHPWS_Text::moduleLink(dgettext('calendar', 'Click here if you would prefer to edit the source event.'), 'calendar', $linkvar);
         $tpl['REPEAT_WARNING'] = dgettext('calendar', 'This is a repeat of another event.') . '<br />' . $source_link;
     }
     $tpl['SYNC'] = sprintf('<input type="button" style="display : none" id="sync-dates" onclick="sync_dates(); return false;" name="sync-dates" value="%s" />', dgettext('calendar', 'Sync dates'));
     if (javascriptEnabled()) {
         Layout::addJSHeader('<script src="' . PHPWS_SOURCE_HTTP . 'mod/calendar/javascript/edit_event/head.js"></script>');
         Layout::addJSHeader('<script src="' . PHPWS_SOURCE_HTTP . 'mod/calendar/javascript/check_date/head.js"></script>');
     }
     return PHPWS_Template::process($tpl, 'calendar', 'admin/forms/edit_event.tpl');
 }
Ejemplo n.º 22
0
 public static function forgotForm()
 {
     PHPWS_Core::initCoreClass('Captcha.php');
     $form = new PHPWS_Form('forgot-password');
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'user');
     $form->addHidden('command', 'post_forgot');
     $form->addText('fg_username');
     $form->setLabel('fg_username', dgettext('users', 'Enter your user name.'));
     $form->addText('fg_email');
     $form->setSize('fg_email', 40);
     $form->setLabel('fg_email', dgettext('users', 'Forgotten your user name? Enter your email address instead.'));
     if (ALLOW_CAPTCHA) {
         $form->addTplTag('CAPTCHA_IMAGE', Captcha::get());
     }
     $form->addSubmit(dgettext('users', 'Send reminder'));
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'users', 'forms/forgot.tpl');
 }
Ejemplo n.º 23
0
 public static function showEditForm(Tracker $tracker)
 {
     $tpl = array();
     $tpl['TRACKER_TYPE'] = $tracker->trackerType();
     $form = new PHPWS_Form('tracker');
     $form->addHidden('module', 'analytics');
     $form->addHidden('command', 'save_tracker');
     $form->addSubmit('submit', dgettext('analytics', 'Save Tracker'));
     if (isset($_REQUEST['tracker'])) {
         $form->addHidden('tracker', $_REQUEST['tracker']);
     }
     if ($tracker->getId() > 0) {
         $form->addHidden('tracker_id', $tracker->getId());
     }
     $form->addText('name', $tracker->getName());
     $form->setLabel('name', dgettext('analytics', 'Friendly Name'));
     $form->setRequired('name');
     $form->addCheck('active', 1);
     $form->setMatch('active', $tracker->isActive());
     $form->setLabel('active', dgettext('analytics', 'Currently Active'));
     $form->addCheck('disable_if_logged', 1);
     $form->setMatch('disable_if_logged', $tracker->getDisableIfLogged());
     $form->setLabel('disable_if_logged', dgettext('analytics', 'Disable Analytics if a user is logged in'));
     $tracker->addForm($form);
     $tpl = array_merge($tpl, $form->getTemplate());
     $tpl['TRACKER_FORM'] = PHPWS_Template::process($tpl, 'analytics', $tracker->getFormTemplate());
     return PHPWS_Template::process($tpl, 'analytics', 'edit.tpl');
 }
Ejemplo n.º 24
0
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 function getSearchBox()
 {
     static $id_count = 0;
     if ($id_count) {
         $id = 'search_list_' . $id_count;
     } else {
         $id = 'search_list';
         $id_count++;
     }
     $form = new PHPWS_Form($id);
     $form->setMethod('get');
     $values = $this->getLinkValues();
     unset($values['pager_search']);
     unset($values['go']);
     $form->addHidden($values);
     $form->addText('pager_c_search', $this->search);
     $form->setSize('pager_c_search', 20);
     if ($this->search_label) {
         $form->setLabel('pager_c_search', _('Search'));
     }
     if ($this->clear_button) {
         $form->addButton('clear', _('Clear'));
         $form->setExtra('clear', 'onclick="this.form.search_list_pager_c_search.value=\'\'"');
     }
     if ($this->search_button) {
         $form->addSubmit('go', _('Search'));
     }
     $template = $form->getTemplate();
     if (PHPWS_Error::isError($template)) {
         PHPWS_Error::log($template);
         return null;
     }
     return implode("\n", $template);
 }
Ejemplo n.º 26
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->setSize('login_link', 30);
     $form->addText('email', \PHPWS_Settings::get('properties', 'email'));
     $form->setLabel('email', 'Site email');
     $form->setSize('email', 30);
     $form->addCheck('roommate_only');
     $form->setMatch('roommate_only', \PHPWS_Settings::get('properties', 'roommate_only'));
     $form->setLabel('roommate_only', 'Only use the roommate functionality');
     $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');
 }
Ejemplo n.º 27
0
 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');
 }
Ejemplo n.º 28
0
 public function display()
 {
     // Set up search fields
     $form = new \PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'intern');
     $form->addHidden('action', 'results');
     $form->useRowRepeat();
     // Student name or Banner ID
     $form->addText('name');
     $form->setLabel('name', "Name or Banner ID");
     /***************
      * Course Info *
      ***************/
     $terms = Term::getTermsAssoc();
     $form->addSelect('term_select', $terms);
     $form->setLabel('term_select', 'Term');
     $form->setClass('term_select', 'form-control');
     $subjects = array('-1' => 'Select subject ') + Subject::getSubjects();
     $form->addSelect('course_subj', $subjects);
     $form->setLabel('course_subj', 'Subject');
     $form->setClass('course_subj', 'form-control');
     $form->addText('course_no');
     $form->setLabel('course_no', 'Course Number');
     $form->setSize('course_no', 6);
     $form->setMaxSize('course_no', 4);
     $form->setClass('course_no', 'form-control');
     $form->addText('course_sect');
     $form->setLabel('course_sect', 'Section');
     $form->setSize('course_sect', 6);
     $form->setMaxSize('course_sect', 4);
     $form->setClass('course_sect', 'form-control');
     /****************
      * Faculty Info *
      ****************/
     // Deity can search for any department. Other users are restricted.
     if (\Current_User::isDeity()) {
         $depts = Department::getDepartmentsAssoc();
     } else {
         $depts = Department::getDepartmentsAssocForUsername(\Current_User::getUsername());
     }
     $depts = array('-1' => 'Select Department') + $depts;
     $form->addSelect('dept', $depts);
     $form->setLabel('dept', 'Department');
     //$form->setClass('', 'form-control');
     $form->setClass('dept', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $form->setMatch('dept', $keys[1]);
     }
     // Student level radio button
     javascript('jquery');
     javascriptMod('intern', 'majorSelector', array('form_id' => $form->id));
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $form->addDropBox('student_major', $levels);
     $form->setLabel('student_major', 'Major / Program');
     $form->addCssClass('student_major', 'form-control');
     // Get the majors list
     $majorsList = MajorsProviderFactory::getProvider()->getMajors(Term::timeToTerm(time()));
     // Undergrad major drop down
     $undergradMajors = array('-1' => 'Select Undergraduate Major') + $majorsList->getUndergradMajorsAssoc();
     $form->addSelect('undergrad_major', $undergradMajors);
     $form->setMatch('undergrad_major', '-1');
     $form->setClass('undergrad_major', 'form-control');
     // Graduate major drop down
     $graduateMajors = array('-1' => 'Select Graduate Major') + $majorsList->getGraduateMajorsAssoc();
     $form->addSelect('graduate_major', $graduateMajors);
     $form->setMatch('graduate_major', '-1');
     $form->setClass('graduate_major', 'form-control');
     /*******************
      * Internship Type *
      *******************/
     // Handeled directly in the html template
     /************
      * Location *
      ************/
     // Campus Handeled directly in the html template
     // International vs Domestic - Handeled directly in the html template
     // State search
     /*******************
      * Workflow States *
      *******************/
     $workflowStates = WorkflowStateFactory::getStatesAssoc();
     unset($workflowStates['Intern\\WorkflowState\\CreationState']);
     // Remove this state, since it's not valid (internal only state for initial creation)
     $form->addCheckAssoc('workflow_state', $workflowStates);
     $form->addSubmit('submit', 'Search');
     // Javascript...
     javascriptMod('intern', 'resetSearch');
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'search.tpl');
 }
Ejemplo n.º 29
0
 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();
 }
Ejemplo n.º 30
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');
 }