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'); }
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'); }
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 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'); }
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'); }
/** * 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(); }