public function execute(CommandContext $context) { $term = Term::getSelectedTerm(); $messageAll = Current_User::allow('hms', 'email_all'); $db = new PHPWS_DB('hms_residence_hall'); $db->addWhere('term', $term); $results = $db->getObjects('HMS_Residence_Hall'); if (PHPWS_Error::logIfError($results) || is_null($results)) { $errorMsg = array(); if (is_null($results)) { $errorMsg['error'] = 'You do not have permission to message any halls, sorry.'; } else { $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page. If the problem persists contact ESS.'; } echo json_encode($errorMsg); exit; } $permission = new HMS_Permission(); $data = array(); foreach ($results as $hall) { $somethingEnabled = false; $floors = $hall->get_floors(); unset($obj); $obj = new stdClass(); $obj->name = $hall->getHallName(); $obj->id = $hall->getId(); $obj->floors = array(); //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false'); if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) { $obj->enabled = true; $somethingEnabled = true; foreach ($floors as $floor) { unset($floor_obj); $floor_obj = new stdClass(); $floor_obj->name = "Floor: " . $floor->getFloorNumber(); $floor_obj->id = $floor->getId(); $floor_obj->enabled = true; $obj->floors[] = $floor_obj; } } else { $obj->enabled = false; foreach ($floors as $floor) { unset($floor_obj); $floor_obj = new stdClass(); $floor_obj->name = "Floor: " . $floor->getFloorNumber(); $floor_obj->id = $floor->getId(); $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email'); $obj->floors[] = $floor_obj; if ($floor_obj->enabled) { $somethingEnabled = true; } } } if ($somethingEnabled) { $data[] = $obj; } } echo json_encode($data); exit; }
public static function getUsername($respectMask = true) { if (self::isMasquerading() && $respectMask) { return $_SESSION['hms_masquerade_username']; } return Current_User::getUsername(); }
/** * The main function for executing the command. */ public function execute() { $returnData = array('username' => \Current_User::getUsername(), 'deity' => \Current_User::isDeity(), 'view' => \Current_User::allow('appsync', 'view'), 'purge' => \Current_User::allow('appsync', 'purge')); // Echo the values back to the front end after encoding them. echo json_encode($returnData); exit; }
public function __construct($asu_username, $term) { $this->asu_username = $asu_username; $this->term = $term; $this->created_on = time(); $this->created_by = Current_User::getUsername(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'approve_rlc_applications')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to approve/deny RLC applications.'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); // Remove assignment $assignment = HMS_RLC_Assignment::getAssignmentById($context->get('assignId')); $rlcName = $assignment->getRlcName(); $rlcApp = $assignment->getApplication(); if (!is_null($assignment)) { $assignment->delete(); } else { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not find an RLC assignment with that id.'); } HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_RLC_UNASSIGN, Current_User::getUsername(), "Removed from {$rlcName}"); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Removed from RLC'); // Deny application $rlcApp->denied = 1; $rlcApp->save(); NQ::simple('hms', hms\NotificationView::SUCCESS, 'RLC Application denied'); HMS_Activity_Log::log_activity($rlcApp->getUsername(), ACTIVITY_DENIED_RLC_APPLICATION, Current_User::getUsername(), 'RLC Application Denied'); $context->goBack(); }
/** * Returns a concrete instance of a MajorsProvider object, * which can be then be used to fetch the array of Major objects * * @return MajorsProvider */ public static function getProvider() { if (STUDENT_DATA_TEST) { return new TestMajorsProvider(\Current_User::getUsername()); } return new BannerMajorsProvider(\Current_User::getUsername()); }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $umbrellaId = $_REQUEST['umbrellaId']; // Retrieve other important values and objects $username = \Current_User::getUsername(); $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId); // If the permissions array is empty then the user does not have permission to use this command // throw an error back to the front end. if (sizeof($permissions) == 0) { echo '<div style="display: none;">User does not have permission to access this data.</div>'; exit; } // Attempt to retrieve the portals and do a fuzzy search of them for the searchString try { $portals = \AppSync\PortalFactory::getPortals(); $searchString = $_REQUEST['searchString']; $umbrella = $_REQUEST['umbrellaId']; $portList = $this->portalFuzzySearch($searchString, $umbrella, $portals); echo $this->encodePortals($portList); } catch (\Exception $e) { echo '<div style="display: none;">' . $e->getMessage() . '</div>'; } exit; }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $tpl = array(); $template = new PHPWS_Template('hms'); $template->setFile('admin/review_hall_email.tpl'); if (is_array($this->floors)) { foreach ($this->floors as $floorId) { $floor = new HMS_Floor(); $floor->id = $floorId; $floor->load(); $floor->loadHall(); $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber(); } } else { $floor = new HMS_Floor(); $floor->id = $this->floors; $floor->load(); $floor->loadHall(); $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber(); } $tpl['FROM'] = $this->anonymous && Current_User::allow('hms', 'anonymous_notifications') ? FROM_ADDRESS : Current_User::getUsername() . '@' . DOMAIN_NAME; $tpl['SUBJECT'] = $this->subject; $tpl['BODY'] = preg_replace('/\\n/', '<br />', $this->body); $editCmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $tpl['EDIT_URI'] = $editCmd->getUri(); /* $form->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : ''); $form->addHidden('subject', $this->subject); $form->addHidden('body', $this->body); $form->addHidden('hall', $this->halls); $form->addHidden('floor', $this->floors); $form->addSubmit('back', 'Edit Message'); */ $form2 = new PHPWS_Form('review_email'); $sendCmd = CommandFactory::getCommand('SendNotificationEmails'); $sendCmd->initForm($form2); $form2->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : ''); $form2->addHidden('subject', $this->subject); $form2->addHidden('body', $this->body); $form2->addHidden('hall', $this->halls); $form2->addHidden('floor', $this->floors); foreach ($tpl['halls'] as $hall => $floors) { foreach ($floors as $floor) { $template->setCurrentBlock('floors'); $template->setData(array("FLOOR" => $floor)); $template->parseCurrentBlock(); } $template->setCurrentBlock('halls'); $template->setData(array("HALL" => $hall)); $template->parseCurrentBlock(); } $form2->mergeTemplate($tpl); $tpl = $form2->getTemplate(); $template->setCurrentBlock('remainder'); $template->setData($tpl); $template->parseCurrentBlock(); return $template->get(); }
/** * Returns a concrete instance of a StudenDataProvider object, * which can then be used to create Student object * * @return StudentDataProvider */ public static function getProvider() { if (STUDENT_DATA_TEST) { return new TestStudentProvider(\Current_User::getUsername()); } // Other data providers could be used here.. return new BannerStudentProvider(\Current_User::getUsername()); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
/** * (non-PHPdoc) * @see UI::display() */ public function display() { // Get the list of departments the current user has access to $departments = Department::getDepartmentsAssocForUsername(\Current_User::getUsername()); $renderedDepts = ''; foreach ($departments as $key => $val) { $renderedDepts .= \PHPWS_Template::process(array('ID' => $key, 'DEPT' => $val), 'intern', 'facultySelectOption.tpl'); } $tpl = array(); $tpl['FACULTY_EDIT'] = javascriptMod('intern', 'facultyEdit', array('DEPTS' => $renderedDepts)); return \PHPWS_Template::process($tpl, 'intern', 'editFaculty.tpl'); }
/** * Constructor * * @param HMS_Room $room * @param integer $damageType * @param string $note */ public function __construct(HMS_Room $room, $term, $damageType, $side, $note) { $this->id = null; $this->room_persistent_id = $room->getPersistentId(); $this->term = $term; $this->damage_type = $damageType; $this->side = $side; $this->repaired = false; $this->note = $note; $this->reported_by = Current_User::getUsername(); $this->reported_on = time(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'approve_rlc_applications')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to approve/deny RLC applications.'); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $app = HMS_RLC_Application::getApplicationById($context->get('applicationId')); $app->denied = 1; $app->save(); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($app->username, 28, Current_User::getUsername(), 'Application Denied'); NQ::simple('hms', hms\NotificationView::SUCCESS, 'Application denied.'); $context->goBack(); }
public static function log($message) { if (class_exists('Current_User') && isset($_SESSION['User'])) { $username = Current_User::getUsername(); } else { $username = _('Unknown user'); } $ip = $_SERVER['REMOTE_ADDR']; if (isset($_SERVER['HTTP_REFERER'])) { $via = sprintf(_('Coming from: %s'), $_SERVER['HTTP_REFERER']); } else { $via = _('Unknown source'); } $infraction = sprintf('%s@%s %s -- %s', $username, $ip, $via, $message); PHPWS_Core::log(escapeshellcmd($infraction), 'security.log', _('Warning')); }
public static function loggedIn() { $auth = Current_User::getAuthorization(); $template['GREETING'] = dgettext('users', 'Hello'); $template['USERNAME'] = Current_User::getUsername(); $template['DISPLAY_NAME'] = Current_User::getDisplayName(); $template['PANEL'] = $template['MODULES'] = PHPWS_ControlPanel::panelLink(); $logout_link = $auth->getLogoutLink(); $template['ACCOUNT'] = '<a href="index.php?module=users&action=user&tab=my_page">' . dgettext('users', '<span class="glyphicon glyphicon-user"></span> Account') . '</a>'; if ($logout_link) { $template['LOGOUT'] =& $logout_link; } else { $template['LOGOUT'] = PHPWS_Text::moduleLink(dgettext('users', '<span class="fa fa-sign-out"></span> Log Out'), 'users', array('action' => 'user', 'command' => 'logout')); } $template['HOME_USER_PANEL'] = $template['HOME'] = PHPWS_Text::moduleLink(dgettext('users', 'Home')); $usermenu = PHPWS_User::getUserSetting('user_menu'); return PHPWS_Template::process($template, 'users', 'usermenus/' . $usermenu); }
public function process() { // This hack is the most awful hack ever. Fix phpWebSite so that // user logins are logged separately. if (Current_User::isLogged() && !isset($_SESSION['HMS_LOGGED_THE_LOGIN'])) { $username = strtolower(Current_User::getUsername()); HMS_Activity_Log::log_activity($username, ACTIVITY_LOGIN, $username, NULL); $_SESSION['HMS_LOGGED_THE_LOGIN'] = $username; } if (!Current_User::isLogged() && $this->context->get('action') != 'ShowFrontPage') { NQ::simple('hms', hms\NotificationView::ERROR, 'You must be logged in to do that.'); $action = 'ShowFrontPage'; } else { $action = $this->context->get('action'); } $cmd = CommandFactory::getCommand($action); if (HMS_DEBUG) { $cmd->execute($this->context); } else { try { $cmd->execute($this->context); } catch (PermissionException $p) { NQ::Simple('hms', hms\NotificationView::ERROR, 'You do not have permission to perform that action. If you believe this is an error, please contact University Housing.'); $nv = new hms\NotificationView(); $nv->popNotifications(); Layout::add($nv->show()); } catch (Exception $e) { try { $message = $this->formatException($e); NQ::Simple('hms', hms\NotificationView::ERROR, 'An internal error has occurred, and the authorities have been notified. We apologize for the inconvenience.'); $this->emailError($message); $nv = new hms\NotificationView(); $nv->popNotifications(); Layout::add($nv->show()); } catch (Exception $e) { $message2 = $this->formatException($e); echo "HMS has experienced a major internal error. Attempting to email an admin and then exit."; $message = "Something terrible has happened, and the exception catch-all threw an exception.\n\nThe first exception was:\n\n{$message}\n\nThe second exception was:\n\n{$message2}"; mail(FROM_ADDRESS, 'A Major HMS Error Has Occurred', $message); exit; } } } }
/** * The main function for executing the command. */ public function execute() { // Retrieve the current user's username $username = \Current_User::getUsername(); // Retrieve the users permissions $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdminByUsername($username); $umbrellas = array(); $i = 0; // For each permission add the id and name to the umbrella's array foreach ($permissions as $permission) { $umbrella = \AppSync\UmbrellaFactory::getUmbrellaByOrgId($permission->getUmbrellaId()); $umbrellas[$i]['umbrella_id'] = $umbrella->getOrgSyncId(); $umbrellas[$i]['umbrella_name'] = $umbrella->getName(); $i++; } // Json Encode the umbrellas array and pass it to the front end echo json_encode($umbrellas); exit; }
private function landing() { $factory = new Factory(); if (\Current_User::isLogged()) { if (!\Current_User::allow('tailgate') && !$factory->isStudent(\Current_User::getUsername())) { return $this->notStudentMessage(); } $student = $factory->getCurrentStudent(); if ($student) { // student is logged in and has account return $this->showStatus($student->getId()); } else { // student is logged in but doesn't have an account return $this->createAccount(); } } else { // student is not logged in return $this->newAccountInformation(); } }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $id = $_REQUEST['logId']; $action = $_REQUEST['logAction']; $category = $_REQUEST['logCategory']; // Set the variable to 'to' initially $toFrom = 'to'; // Retrieve the username $username = \Current_User::getUsername(); // If the action is set as removing then switch the variable to from if ($action == 'Removing') { $toFrom = 'from'; } // Create a new logEntry with the values $logEntry = new \AppSync\LogEntry(null, $action . ' students ' . $toFrom . ' ' . $category . ' with ' . $category . ' id ' . $id, $username, time()); \AppSync\LogEntryFactory::save($logEntry); // Send a confirmation back to the front end echo json_encode('logged'); exit; }
public function execute() { // Get list of departments for the current user // If user is a Deity, then get all departments if (\Current_User::isDeity()) { $departments = \Intern\Department::getDepartmentsAssoc(); } else { $departments = \Intern\Department::getDepartmentsAssocForUsername(\Current_User::getUsername()); } $departments = array('-1' => 'Select a Department') + $departments; /* * NB: Javascript objects are unordered. When the JSON data is * decoded, numeric keys may be re-arraged. Making the keys into strings * (by pre-pending an underscore) will prevent the re-ordering. */ $newDepts = array(); foreach ($departments as $key => $value) { $newDepts['_' . $key] = $value; } echo json_encode($newDepts); exit; }
/** * The main function for executing the command. */ public function execute() { // Retrieve the values from the request $portal = $_REQUEST['org_id']; // Retrieve other important values and objects $username = \Current_User::getUsername(); $portalObjs = \AppSync\PortalFactory::getPortalById($portal); $umbrellaId = $portalObjs[0]->getUmbrellaId(); $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId); // If the permissions array is empty then the user does not have permission to use this command // throw an error back to the front end. if (sizeof($permissions) == 0) { echo '<div style="display: none;">User does not have permission to access this data.</div>'; exit; } // Attempt to retrieve the portal members, echoing the error message back if there is an exception try { $portalMembers = $this->getOrgMembers($_REQUEST['org_id']); echo json_encode($portalMembers); } catch (\Exception $e) { echo '<div style="display: none;">' . $e->getMessage() . '</div>'; } exit; }
/** * PHPWS_Email has a built-in simple logging function. This replicates * the functionality of that function for SwiftMail. */ public static function logSwiftmailMessage(Swift_Message $message) { $id = 'id:' . $message->getId(); $from = 'from:' . $message->getSender(); $to = 'to:' . implode(',', array_keys($message->getTo())); // Optional fields, If the message has them, implode the arrays to simple strings. $cc = $message->getCc() != null ? 'cc:' . implode(',', array_keys($message->getCc())) : ''; $bcc = $message->getBcc() != null ? 'bcc:' . implode(',', array_keys($message->getBcc())) : ''; $replyto = $message->getReplyTo() != null ? 'reply-to:' . implode(',', array_keys($message->getReplyTo())) : ''; $subject = 'subject:' . $message->getSubject(); $module = 'module:' . PHPWS_Core::getCurrentModule(); $user = '******' . (Current_User::isLogged() ? Current_User::getUsername() : ''); PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto}", 'phpws-mail.log', 'mail'); }
public static function currentAllowed($dept) { \PHPWS_Core::initModClass('users', 'Current_User.php'); return self::allowed(\Current_User::getUsername(), $dept); }
public function execute(CommandContext $context) { /* if(!Current_User::allow('hms', 'email_hall') && !Current_User::allow('hms', 'email_all')){ PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to send messages.'); } */ PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Floor.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Permission.php'); // Sanity checks if (is_null($context->get('hall')) && is_null($context->get('floor'))) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must select a hall or floor to continue!'); $cmd = CommandFactory::getCommand('ShowHallNotificationSelect'); $cmd->redirect(); } $subject = $context->get('subject'); $body = $context->get('body'); $anonymous = !is_null($context->get('anonymous')) && $context->get('anonymous') ? true : false; $from = $anonymous && Current_User::allow('hms', 'anonymous_notifications') ? FROM_ADDRESS : Current_User::getUsername() . '@' . DOMAIN_NAME; $halls = $context->get('hall'); $floors = $context->get('floor'); if (empty($subject)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the subject line of the email.'); $cmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $cmd->loadContext($context); $cmd->redirect(); } else { if (empty($body)) { NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the message to be sent.'); $cmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $cmd->loadContext($context); $cmd->redirect(); } } //Consider using a batch process instead of doing this this inline // Log that this is happening if ($anonymous) { HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_ANON_NOTIFICATION_SENT, Current_User::getUsername()); } else { HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_NOTIFICATION_SENT, Current_User::getUsername()); } //load the floors foreach ($floors as $key => $floor_id) { $floors[$key] = new HMS_Floor($floor_id); } // TODO accurate logging //HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_HALL_NOTIFIED_ANONYMOUSLY, Current_User::getUsername(), $hall->hall_name); //HMS_Activity_Log::log_activity(Current_User::getUsername(), ACTIVITY_HALL_NOTIFIED, Current_User::getUsername(), $hall->hall_name); $floorObj = array(); //load the halls and add floors that aren't already present, if they have js enabled should be zero foreach ($halls as $hall) { $hallObj = new HMS_Residence_Hall($hall); $hallFloors = $hallObj->get_floors(); //if the hall has zero floors, skip it if (!is_array($hallFloors)) { continue; } foreach ($hallFloors as $hallFloor) { if (!empty($floors)) { foreach ($floors as $floor) { if ($hallFloor->id == $floor->id) { break; } } } if (!in_array($hallFloor, $floors)) { $floorObj[] = $hallFloor; } } } if (!is_array($floorObj)) { $floorObj = array(); } if (!is_array($floors)) { $floors = array(); } $floorObj = array_merge($floorObj, $floors); $permission = new HMS_Permission(); foreach ($floorObj as $floor) { if (!$permission->verify(Current_User::getUsername(), $floor, 'email') && !$permission->verify(Current_User::getUsername(), $floor->get_parent(), 'email') && !Current_User::allow('hms', 'email_all')) { continue; } /** $rooms = $floor->get_rooms(); foreach($rooms as $room){ $students = $room->get_assignees(); foreach($students as $student){ $people[] = $student->getUsername(); HMS_Email::send_email($student->getUsername() . '@appstate.edu', $from, $subject, $body); } } */ $students = $floor->getUsernames(); foreach ($students as $student) { HMS_Email::send_email($student . '@' . DOMAIN_NAME, $from, $subject, $body); } HMS_Activity_Log::log_activity(Current_User::getUsername(), $anonymous ? ACTIVITY_FLOOR_NOTIFIED_ANONYMOUSLY : ACTIVITY_FLOOR_NOTIFIED, Current_User::getUsername(), $floor->where_am_i()); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Emails sent successfully!'); $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $cmd->redirect(); }
public function show() { // TODO: Load application in controller and pass it to HousingApplicationView constructor. $application = HousingApplicationFactory::getApplicationById($this->id); $student = StudentFactory::getStudentByUsername($application->username, $application->term); $tpl = array(); //If the application has been submitted plug in the date it was created if (isset($application->created_on)) { $tpl['RECEIVED_DATE'] = "Received on: " . date('d-F-Y h:i:s a', $application->created_on); } if ($application instanceof LotteryApplication && $application->getWaitingListDate() != null) { $tpl['WAITING_LIST_DATE'] = date("d-F-y h:i:sa", $application->getWaitingListDate()); } // Check if the application has been cancelled // isWithdrawn() has been depricated, but I'm leaving it here just for historical sake // on the off-chance that it catches an older application that's withdrawn but not cancelled. if ($application->isCancelled() || $application->isWithdrawn()) { NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been cancelled.'); } $tpl['STUDENT_NAME'] = $student->getFullName(); $tpl['GENDER'] = $student->getPrintableGender(); $tpl['ENTRY_TERM'] = Term::toString($application->term); $tpl['CLASSIFICATION_FOR_TERM_LBL'] = $student->getPrintableClass(); $tpl['STUDENT_STATUS_LBL'] = $student->getPrintableType(); $tpl['MEAL_OPTION'] = HMS_Util::formatMealOption($application->meal_plan); if (isset($application->lifestyle_option)) { $tpl['LIFESTYLE_OPTION'] = $application->lifestyle_option == 1 ? 'Single gender' : 'Co-ed'; } else { $tpl['LIFESTYLE_OPTION'] = 'n/a'; } if (isset($application->preferred_bedtime)) { $tpl['PREFERRED_BEDTIME'] = $application->preferred_bedtime == 1 ? 'Early' : 'Late'; } else { $tpl['PREFERRED_BEDTIME'] = 'n/a'; } if (isset($application->room_condition)) { $tpl['ROOM_CONDITION'] = $application->room_condition == 1 ? 'Neat' : 'Cluttered'; } else { $tpl['ROOM_CONDITION'] = 'n/a'; } if (isset($application->smoking_preference)) { $tpl['SMOKING_PREFERENCE'] = $application->smoking_preference == 1 ? 'No' : 'Yes'; } else { $tpl['SMOKING_PREFERENCE'] = 'n/a'; } if (isset($application->room_type)) { $tpl['ROOM_TYPE'] = $application->room_type == ROOM_TYPE_DOUBLE ? 'Double' : 'Private (if available)'; } $tpl['CELLPHONE'] = ''; if (strlen($application->cell_phone) == 10) { $tpl['CELLPHONE'] .= '(' . substr($application->cell_phone, 0, 3) . ')'; $tpl['CELLPHONE'] .= '-' . substr($application->cell_phone, 3, 3); $tpl['CELLPHONE'] .= '-' . substr($application->cell_phone, 6, 4); } /* Emergency Contact */ $tpl['EMERGENCY_CONTACT_NAME'] = $application->getEmergencyContactName(); $tpl['EMERGENCY_CONTACT_RELATIONSHIP'] = $application->getEmergencyContactRelationship(); $tpl['EMERGENCY_CONTACT_PHONE'] = $application->getEmergencyContactPhone(); $tpl['EMERGENCY_CONTACT_EMAIL'] = $application->getEmergencyContactEmail(); $tpl['EMERGENCY_MEDICAL_CONDITION'] = $application->getEmergencyMedicalCondition(); /* Missing Person */ if (Current_User::allow('hms', 'view_missing_person_info')) { $tpl['MISSING_PERSON_NAME'] = $application->getMissingPersonName(); $tpl['MISSING_PERSON_RELATIONSHIP'] = $application->getMissingPersonRelationship(); $tpl['MISSING_PERSON_PHONE'] = $application->getMissingPersonPhone(); $tpl['MISSING_PERSON_EMAIL'] = $application->getMissingPersonEmail(); } /* Special Needs */ $special_needs = ""; if ($application->physical_disability == 1) { $special_needs = 'Physical disability<br />'; } if ($application->psych_disability) { $special_needs .= 'Psychological disability<br />'; } if ($application->medical_need) { $special_needs .= 'Medical need<br />'; } if ($application->gender_need) { $special_needs .= 'Gender need<br />'; } if ($special_needs == '') { $special_needs = 'None'; } $tpl['SPECIAL_NEEDS_RESULT'] = $special_needs; if ($application instanceof FallApplication) { PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $application->getTerm()); if (!is_null($rlcApp)) { $tpl['RLC_INTEREST_1'] = 'Yes (Completed - Use the main menu to view/modify.)'; } else { $tpl['RLC_INTEREST_1'] = $application->rlc_interest == 0 ? 'No' : 'Yes'; } } if (Current_User::getUsername() == "hms_student") { $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to main menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu')); } Layout::addPageTitle("Housing Application"); return PHPWS_Template::process($tpl, 'hms', 'admin/student_application.tpl'); }
/** * Processes a queued item. This can be something actually queued, * or an immediate processing because the queue is disabled. */ public function process() { PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'SOAP.php'); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $result = null; switch ($this->type) { case BANNER_QUEUE_ASSIGNMENT: $result = $soap->reportRoomAssignment($this->asu_username, $this->term, $this->building_code, $this->bed_code, 'HOME', $this->meal_code); if ($result === TRUE) { HMS_Activity_Log::log_activity($this->asu_username, ACTIVITY_ASSIGNMENT_REPORTED, Current_User::getUsername(), $this->term . ' ' . $this->building_code . ' ' . $this->bed_code . ' ' . 'HOME' . ' ' . $this->meal_code); } break; case BANNER_QUEUE_REMOVAL: // Get the Banner ID from the user name // TODO fix this to use BannerID directly $bannerId = $soap->getBannerId($this->asu_username); $result = $soap->removeRoomAssignment($bannerId, $this->term, $this->building_code, $this->bed_code, $this->percent_refund); if ($result === TRUE) { HMS_Activity_Log::log_activity($this->asu_username, ACTIVITY_REMOVAL_REPORTED, Current_User::getUsername(), $this->term . ' ' . $this->building_code . ' ' . $this->bed_code . ' '); } break; } return $result; }
private function setNameId() { PHPWS_Core::initModClass('faxmaster', 'Fax.php'); if (!Current_User::allow('faxmaster', 'editSender')) { PHPWS_Core::initModClass('faxmaster', 'exception/PermissionException.php'); throw new PermissionException('Permission denied'); } $fax = new Fax($_REQUEST['id']); if (isset($_REQUEST['firstName'])) { $fax->setFirstName($_REQUEST['firstName']); } if (isset($_REQUEST['lastName'])) { $fax->setLastName($_REQUEST['lastName']); } if (isset($_REQUEST['bannerId'])) { $fax->setBannerId($_REQUEST['bannerId']); } echo $fax->save(); //get username, timestamp, activity, and fax id $name = Current_User::getUsername(); $timestamp = time(); $activity = "changed name or banner id"; $faxName = $fax->getFileName(); PHPWS_Core::initModClass('faxmaster', 'ActionLog.php'); $action = new ActionLog(0, $faxName, $name, $activity, $timestamp); exit; }
/** * Builds the body of the internship form. */ public function buildInternshipForm() { javascript('jquery'); javascript('jquery_ui'); javascriptMod('intern', 'spinner'); javascriptMod('intern', 'formGoodies'); // Form Submission setup $this->form->setAction('index.php?module=intern&action=add_internship'); $this->form->addSubmit('submit', 'Save'); /********************* * Workflow / Status * */ PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php'); PHPWS_Core::initModClass('intern', 'WorkflowTransitionView.php'); // Check the Internship's state, and set a default state if it's a new internship $workflowState = $this->intern->getWorkflowState(); if (is_null($workflowState)) { $state = WorkflowStateFactory::getState('CreationState'); $this->intern->setState($state); // Set this initial value } // Workflow Transitions View, adds fields to the form by reference $transView = new WorkflowTransitionView($this->intern, $this->form); $transView->show(); /***************** * OIED Approval * */ $this->form->addCheck('oied_certified'); $this->form->setLabel('oied_certified', 'Certified by Office of International Education and Development'); // If the user is not allowed to do OIED certification, disable the checkbox if (!Current_User::allow('intern', 'oied_certify') || $this->intern->isDomestic()) { $this->form->setExtra('oied_certified', 'disabled'); } // Hidden field that shadows the real field, to ensure a value is always submitted, // because disabled fields are not submitted $this->form->addHidden('oied_certified_hidden'); /****************** * Student fields * */ $this->form->addText('student_first_name'); $this->form->setLabel('student_first_name', 'First Name'); $this->form->addCssClass('student_first_name', 'form-control'); $this->form->addText('student_middle_name'); $this->form->setLabel('student_middle_name', 'Middle Name/Initial'); $this->form->addCssClass('student_middle_name', 'form-control'); $this->form->addText('student_last_name'); $this->form->setLabel('student_last_name', 'Last Name'); $this->form->addCssClass('student_last_name', 'form-control'); $this->form->addText('banner'); $this->form->setLabel('banner', 'Banner ID'); // Digits only $this->form->addCssClass('banner', 'form-control'); $this->form->addText('student_phone'); $this->form->setLabel('student_phone', 'Phone'); $this->form->addCssClass('student_phone', 'form-control'); $this->form->addText('student_email'); $this->form->setLabel('student_email', 'ASU Email'); $this->form->addCssClass('student_email', 'form-control'); /* Student Address */ $this->form->addText('student_address'); $this->form->setLabel('student_address', 'Address'); $this->form->addCssClass('student_address', 'form-control'); $this->form->addText('student_city'); $this->form->setLabel('student_city', 'City'); $this->form->addCssClass('student_city', 'form-control'); $this->form->addDropBox('student_state', State::$UNITED_STATES); $this->form->setLabel('student_state', 'State'); $this->form->addCssClass('student_state', 'form-control'); $this->form->addText('student_zip'); $this->form->setLabel('student_zip', 'Zip Code'); $this->form->addCssClass('student_zip', 'form-control'); // GPA $this->form->addText('student_gpa'); $this->form->setLabel('student_gpa', 'GPA'); $this->form->addCssClass('student_gpa', 'form-control'); // Campus $this->form->addRadioAssoc('campus', array('main_campus' => 'Main Campus', 'distance_ed' => 'Distance Ed')); $this->form->setMatch('campus', 'main_campus'); // Student level $levels = array('-1' => 'Choose level', 'ugrad' => 'Undergraduate', 'grad' => 'Graduate'); $this->form->addDropBox('student_level', $levels); $this->form->setLabel('student_level', 'Level'); $this->form->addCssClass('student_level', 'form-control'); // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected) $levels = array('-1' => 'Choose student level first'); $this->form->addDropBox('student_major', $levels); $this->form->setLabel('student_major', 'Major / Program'); $this->form->addCssClass('student_major', 'form-control'); /***************************** * Undergrad Major Drop Down * */ if (isset($this->intern)) { $majors = Major::getMajorsAssoc($this->intern->ugrad_major); } else { $majors = Major::getMajorsAssoc(); } $this->form->addSelect('ugrad_major', $majors); $this->form->setLabel('ugrad_major', 'Undergraduate Majors & Certificate Programs'); $this->form->addCssClass('ugrad_major', 'form-control'); /**************************** * Graduate Major Drop Down * */ if (isset($this->intern)) { $progs = GradProgram::getGradProgsAssoc($this->intern->grad_prog); } else { $progs = GradProgram::getGradProgsAssoc(); } $this->form->addSelect('grad_prog', $progs); $this->form->setLabel('grad_prog', 'Graduate Majors & Certificate Programs'); $this->form->addCssClass('grad_prog', 'form-control'); /************************ * Department Drop Down * */ if (Current_User::isDeity()) { if (!is_null($this->intern)) { $depts = Department::getDepartmentsAssoc($this->intern->department_id); } else { $depts = Department::getDepartmentsAssoc(); } } else { if (!is_null($this->intern)) { $depts = Department::getDepartmentsAssocForUsername(Current_User::getUsername(), $this->intern->department_id); } else { $depts = Department::getDepartmentsAssocForUsername(Current_User::getUsername()); } } $this->form->addSelect('department', $depts); $this->form->setLabel('department', 'Department'); $this->form->addCssClass('department', '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); $this->form->setMatch('department', $keys[1]); } /******************** * Faculty Member Dropdown * * The options for this drop down are provided through AJAX on page-load and * when the user changes the department dropdown above. */ $this->form->addSelect('faculty', array(-1 => 'Select Faculty Advisor')); $this->form->setExtra('faculty', 'disabled'); $this->form->setLabel('faculty', 'Faculty Advisor / Instructor of Record'); $this->form->addCssClass('faculty', 'form-control'); // Hidden field for selected faculty member $this->form->addHidden('faculty_id'); /*************** * Agency info * */ $this->form->addText('agency_name'); $this->form->setLabel('agency_name', 'Agency Name'); $this->form->addCssClass('agency_name', 'form-control'); $this->form->addCheck('copy_address_agency'); $this->form->setLabel('copy_address_agency', "Agency's address is same as Internship's"); $this->form->addText('agency_address'); $this->form->setLabel('agency_address', 'Address'); $this->form->addCssClass('agency_address', 'form-control'); $this->form->addText('agency_city'); $this->form->setLabel('agency_city', 'City'); $this->form->addCssClass('agency_city', 'form-control'); $this->form->addSelect('agency_state', State::$UNITED_STATES); $this->form->setLabel('agency_state', 'State'); $this->form->addCssClass('agency_state', 'form-control'); $this->form->addText('agency_zip'); $this->form->setLabel('agency_zip', 'Zip Code'); $this->form->addCssClass('agency_zip', 'form-control'); $this->form->addText('agency_province'); $this->form->setLabel('agency_province', 'Province/Territory'); $this->form->addCssClass('agency_province', 'form-control'); $this->form->addText('agency_country'); $this->form->setLabel('agency_country', 'Country'); $this->form->addCssClass('agency_country', 'form-control'); $this->form->addText('agency_phone'); $this->form->setLabel('agency_phone', 'Phone'); $this->form->addCssClass('agency_phone', 'form-control'); /*** * Agency supervisor info */ $this->form->addText('agency_sup_first_name'); $this->form->setLabel('agency_sup_first_name', 'First Name'); $this->form->addCssClass('agency_sup_first_name', 'form-control'); $this->form->addText('agency_sup_last_name'); $this->form->setLabel('agency_sup_last_name', 'Last Name'); $this->form->addCssClass('agency_sup_last_name', 'form-control'); $this->form->addText('agency_sup_title'); $this->form->setLabel('agency_sup_title', 'Title'); $this->form->addCssClass('agency_sup_title', 'form-control'); $this->form->addText('agency_sup_phone'); $this->form->setLabel('agency_sup_phone', 'Phone'); $this->form->addCssClass('agency_sup_phone', 'form-control'); $this->form->addText('agency_sup_email'); $this->form->setLabel('agency_sup_email', 'Email'); $this->form->addCssClass('agency_sup_email', 'form-control'); $this->form->addCheck('copy_address'); $this->form->setLabel('copy_address', "Supervisor's address is same as agency's"); $this->form->addText('agency_sup_address'); $this->form->setLabel('agency_sup_address', 'Address'); $this->form->addCssClass('agency_sup_address', 'form-control'); $this->form->addText('agency_sup_city'); $this->form->setLabel('agency_sup_city', 'City'); $this->form->addCssClass('agency_sup_city', 'form-control'); $this->form->addSelect('agency_sup_state', State::$UNITED_STATES); $this->form->setLabel('agency_sup_state', 'State'); $this->form->addCssClass('agency_sup_state', 'form-control'); $this->form->addText('agency_sup_zip'); $this->form->setLabel('agency_sup_zip', 'Zip Code'); $this->form->addCssClass('agency_sup_zip', 'form-control'); $this->form->addText('agency_sup_province'); $this->form->setLabel('agency_sup_province', 'Province'); $this->form->addCssClass('agency_sup_province', 'form-control'); $this->form->addText('agency_sup_country'); $this->form->setLabel('agency_sup_country', 'Country'); $this->form->addCssClass('agency_sup_country', 'form-control'); $this->form->addText('agency_sup_fax'); $this->form->setLabel('agency_sup_fax', 'Fax'); $this->form->addCssClass('agency_sup_fax', 'form-control'); /********************** * Internship details * */ /*********************** * Internship location * */ $loc = array('domestic' => 'Domestic', 'internat' => 'International'); $this->form->addRadioAssoc('location', $loc); //$this->form->setMatch('location', 'domestic'); // Default to domestic //$this->form->setRequired('location'); // Domestic fields $this->form->addText('loc_address'); $this->form->setLabel('loc_address', 'Address'); $this->form->addCssClass('loc_address', 'form-control'); $this->form->addText('loc_city'); $this->form->setLabel('loc_city', 'City'); $this->form->addCssClass('loc_city', 'form-control'); $this->form->addSelect('loc_state', State::getAllowedStates()); $this->form->setLabel('loc_state', 'State'); $this->form->addCssClass('loc_state', 'form-control'); $this->form->addText('loc_zip'); $this->form->setLabel('loc_zip', 'Zip'); $this->form->addCssClass('loc_zip', 'form-control'); // Itn'l location fields $this->form->addText('loc_province'); $this->form->setLabel('loc_province', 'Province/Territory'); $this->form->addCssClass('loc_province', 'form-control'); $this->form->addText('loc_country'); $this->form->setLabel('loc_country', 'Country'); $this->form->addCssClass('loc_country', 'form-control'); /************* * Term Info * */ $terms = Term::getFutureTermsAssoc(); $terms[-1] = 'Select Term'; $this->form->addSelect('term', $terms); $this->form->setLabel('term', 'Select Term'); $this->form->addCssClass('term', 'form-control'); $this->form->addText('start_date'); $this->form->setLabel('start_date', 'Start Date'); $this->form->addCssClass('start_date', 'form-control'); $this->form->addText('end_date'); $this->form->setLabel('end_date', 'End Date'); $this->form->addCssClass('end_date', 'form-control'); $this->form->addText('credits'); $this->form->setLabel('credits', 'Credit Hours'); $this->form->addCssClass('credits', 'form-control'); $this->form->addText('avg_hours_week'); $this->form->setLabel('avg_hours_week', 'Average Hours per Week'); $this->form->addCssClass('avg_hours_week', 'form-control'); $this->form->addCheck('multipart'); $this->form->setLabel('multipart', 'This internship is part of a multi-part experience.'); $this->form->addCheck('secondary_part'); $this->form->setLabel('secondary_part', 'This is a secondary part (enrollment complete through primary part).'); /*************** * Course Info * */ $subjects = Subject::getSubjects(); $this->form->addSelect('course_subj', $subjects); $this->form->setLabel('course_subj', 'Subject'); $this->form->addCssClass('course_subj', 'form-control'); $this->form->addText('course_no'); $this->form->setLabel('course_no', 'Number'); $this->form->addCssClass('course_no', 'form-control'); $this->form->addText('course_sect'); $this->form->setLabel('course_sect', 'Section'); $this->form->addCssClass('course_sect', 'form-control'); $this->form->addText('course_title'); $this->form->setLabel('course_title', 'Title'); $this->form->setMaxSize('course_title', 28); // Limit to 28 chars, per Banner $this->form->addCssClass('course_title', 'form-control'); // Corequisite if (!is_null($this->intern)) { $dept = $this->intern->getDepartment(); if ($dept->hasCorequisite()) { $this->form->addText('corequisite_course_num'); $this->form->addCssClass('corequisite_course_num', 'form-control'); $this->form->addText('corequisite_course_sect'); $this->form->addCssClass('corequisite_course_sect', 'form-control'); } } /************ * Pay Info * */ $pay = array('unpaid' => 'Unpaid', 'paid' => 'Paid'); $this->form->addRadioAssoc('payment', $pay); $this->form->setMatch('payment', 'unpaid'); // Default to unpaid $this->form->addCheck('stipend'); $this->form->setLabel('stipend', 'Stipend'); $this->form->addText('pay_rate'); $this->form->setLabel('pay_rate', 'Pay Rate'); $this->form->addCssClass('pay_rate', 'form-control'); /******************* * Internship Type * */ $this->form->addRadioAssoc('experience_type', Internship::getTypesAssoc()); $this->form->setMatch('experience_type', 'internship'); /********* * Notes * */ $this->form->addTextArea('notes'); $this->form->setLabel('notes', 'Notes'); $this->form->addCssClass('notes', 'form-control'); }
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'); }
function _saveFormData() { $error = NULL; /* Setup start and end values for the elements loop */ $start = $this->_position; if ($this->_position + $this->_pageLimit > sizeof($this->_elements)) { $end = $this->_position + (sizeof($this->_elements) - $this->_position); } else { $end = $this->_position + $this->_pageLimit; } /* Loop through elements and setup query array for database interaction */ for ($i = $start; $i < $end; $i++) { $elementInfo = explode(':', $this->_elements[$i]); $this->element = new $elementInfo[0]($elementInfo[1]); if ($this->element->isRequired() && (!isset($_REQUEST['PHAT_' . $this->element->getLabel()]) || $_REQUEST['PHAT_' . $this->element->getLabel()] == NULL)) { $error = PHPWS_Error::get(PHATFORM_REQUIRED_MISSING, 'phatform', 'PHAT_Form::_saveFormData'); } if ($this->_editData) { $this->_userData[$this->element->getLabel()] = $_REQUEST['PHAT_' . $this->element->getLabel()]; } if (isset($_REQUEST['PHAT_' . $this->element->getLabel()])) { if (is_string($_REQUEST['PHAT_' . $this->element->getLabel()]) && strlen($_REQUEST['PHAT_' . $this->element->getLabel()]) > PHAT_MAX_CHARS_TEXT_ENTRY) { $error = PHPWS_Error::get(PHATFORM_TEXT_MAXSIZE_PASSED, 'phatform', 'PHAT_Form::_saveFormData', array($this->element->getLabel())); } $queryData[$this->element->getLabel()] = $_REQUEST['PHAT_' . $this->element->getLabel()]; } } /* If no errors occured, move the user to the next page in this form */ if (!PHPWS_Error::isError($error)) { if ($this->currentPage() != $this->numPages()) { $this->_position += $this->_pageLimit; } else { $this->_position = -1; } } if (!$this->_anonymous) { $queryData['user'] = Current_User::getUsername(); } else { $queryData['user'] = '******'; } $queryData['position'] = $this->_position; $queryData['updated'] = time(); /* Check to see if this user has started entering data for this form yet */ $db = new PHPWS_DB('mod_phatform_form_' . $this->getId()); $db->addValue($queryData); if (isset($this->_dataId)) { $db->addWhere('id', $this->_dataId); $db->update(); } else { $result = $db->insert(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); } else { $this->_dataId = $result; } } return $error; }