$station->stationid = NULL; } if (isset($_POST[PARAM_SAVE])) { $titleEnums = JobTitle::titleEnums($station->expoid); try { $station->startTime = swwat_parse_date(html_entity_decode($_POST[PARAM_DATE] . " " . $_POST[PARAM_STARTHOUR]), true); $station->stopTime = swwat_parse_date(html_entity_decode($_POST[PARAM_DATE] . " " . $_POST[PARAM_STOPHOUR]), true); $station->jobTitle = swwat_parse_enum($_POST[PARAM_JOB], $titleEnums, false); $station->maxCrew = swwat_parse_integer(html_entity_decode($_POST[PARAM_MAXCREW]), 11, true); $station->minCrew = swwat_parse_integer(html_entity_decode($_POST[PARAM_MINCREW]), 11, true); $station->maxSupervisor = swwat_parse_integer(html_entity_decode($_POST[PARAM_MAXSUPERVISOR]), 11, true); $station->minSupervisor = swwat_parse_integer(html_entity_decode($_POST[PARAM_MINSUPERVISOR]), 11, true); $station->description = swwat_parse_string(html_entity_decode($_POST[PARAM_DESCRIPTION]), true); $station->title = swwat_parse_string(html_entity_decode($_POST[PARAM_TITLE]), true); $station->location = swwat_parse_string(html_entity_decode($_POST[PARAM_LOCATION]), true); $station->instruction = swwat_parse_string(html_entity_decode($_POST[PARAM_INSTRUCTION]), true); } catch (Exception $ex) { header('Location: WorkerLoginPage.php'); include 'WorkerLoginPage.php'; return; } $station = is_null($station->stationid) ? $station->insert() : $station->update(); setStationCurrent($station); // if saved header('Location: StationViewPage.php'); include 'StationViewPage.php'; return; } // else, if not saved header('Location: SiteAdminPage.php'); include 'SiteAdminPage.php';
} } // send emails Invitation::inviteWorkers($expo, $expirationDate, $workerArray); $workerArray = NULL; Invitation::inviteUnknown($expo, $expirationDate, $unknownArray, $withCode, $uniqueCode); $unknownArray = NULL; if (strlen($errorMessage) > 0) { $_SESSION[PARAM_MESSAGE] = $errorMessage; } header('Location: InvitationPage.php'); include 'InvitationPage.php'; } else { if ($upload) { // move defaults from _POST to _SESSION $_SESSION[PARAM_UPLOADFILETYPE] = swwat_parse_string("5 degrees"); $_SESSION[PARAM_STOPTIME] = $_POST[PARAM_STOPTIME]; $_SESSION[PARAM_WITHCODE] = $_POST[PARAM_WITHCODE]; $_SESSION[PARAM_UNIQUE] = $_POST[PARAM_UNIQUE]; if (isset($_SESSION[PARAM_UNIQUE])) { $_SESSION[PARAM_WITHCODE] = PARAM_WITHCODE; // ensure set if UNIQUE is } header('Location: InvitationFileUploadPage.php'); include 'InvitationFileUploadPage.php'; return; } } /* * else the select a set of workers item; analogous to ExpoAssignPage $workerArray = array(); // set from UI
function wizardActionContent($author, $expo) { if (isset($_POST[PARAM_MAXHOURS]) && !is_null($_POST[PARAM_MAXHOURS])) { $author->updateMaxHours($expo->expoid, swwat_parse_string(html_entity_decode($_POST[PARAM_MAXHOURS]))); } $dateSpanList = $_SESSION[PARAM_DATETIME]; $locationList = $_SESSION[PARAM_LOCATION]; // Location Preference $k = 0; while (isset($_POST[PARAM_LOCATION . $k])) { $desire = parsePreferenceNumber(PARAM_LOCATION, $k); $locationDesires[$locationList[$k]] = 0 == $desire ? NULL : $desire; $locationTest[$k] = parsePreferenceNumber(PARAM_LOCATION, $k); $k += 1; } $jp = new JobPreference(); $jp->workerid = $author->workerid; $jp->expoid = $expo->expoid; $count_jobs = $jp->number_jobs; for ($k = 0; $k < $count_jobs; $k++) { $field = 'job' . ($k + 1); if (isset($locationTest[$k])) { $jp->{$field} = $locationTest[$k]; } else { $jp->{$field} = 0; } } $test = JobPreference::selectID($author->workerid, $expo->expoid); if (!is_null($test)) { $jp->update(); } else { $jp->insert(); } // Time Preference $k = 0; while (isset($_POST[PARAM_DATETIME . $k])) { $desire = parsePreferenceNumber(PARAM_DATETIME, $k); $dateSpanDesires[$dateSpanList[$k]] = 0 == $desire ? NULL : $desire; $dateSpanTest[$k] = parsePreferenceNumber(PARAM_DATETIME, $k); $k += 1; } $tp = new TimePreference(); $tp->workerid = $author->workerid; $tp->expoid = $expo->expoid; $count_shifts = $tp->number_shifts; for ($k = 0; $k < $count_shifts; $k++) { $field = 'shift' . ($k + 1); if (isset($dateSpanTest[$k])) { $tp->{$field} = $dateSpanTest[$k]; } else { $tp->{$field} = 0; } } $test = TimePreference::selectID($author->workerid, $expo->expoid); if (!is_null($test)) { $tp->update(); } else { $tp->insert(); } //exit; $gp = GrossPreference::updateHelper_Location_DateSpan($expo->expoid, $author->workerid, $locationDesires, $dateSpanDesires); }
<?php // $Id: SendMessageAction.php 921 2012-07-14 16:03:23Z preston $ Copyright (c) ConSked, LLC. All Rights Reserved. include 'util/authenticate.php'; require_once 'properties/constants.php'; require_once 'db/Worker.php'; require_once 'util/log.php'; require_once 'util/mail.php'; require_once 'util/session.php'; require_once 'swwat/gizmos/parse.php'; $author = getWorkerAuthenticated(); $type = swwat_parse_string(html_entity_decode($_POST[PARAM_TYPE_MESSAGE]), true); $typeFlag = 0 != strcmp($type, PARAM_SMS_SERVICE); // email TRUE (default), sms FALsE $subject = swwat_parse_string(html_entity_decode($_POST[PARAM_SUBJECT_MESSAGE])); $message = swwat_parse_string(html_entity_decode($_POST[PARAM_MESSAGE])); $list = $_POST[PARAM_LIST_INDEX]; if (!is_null($list) && ($typeFlag && (!is_null($subject) || !is_null($message)) || !$typeFlag && !is_null($message))) { if (!$typeFlag) { $subject = ""; // ensure blank $message = substr($message, 0, 160); } $workerList = $_SESSION[PARAM_LIST]; for ($k = 0; $k < count($list); $k++) { try { $listIndex = swwat_parse_number(html_entity_decode($list[$k]), FALSE); $worker = $workerList[$listIndex]; $to = $typeFlag ? $worker->email : $worker->smsemail; if (!is_null($to) && strlen($to) > 0) { FormMail::send($to, $subject, $message);
function swwat_parse_enum($str, $enumArray, $blankOk = true) { $str = swwat_parse_string($str, $blankOk); if (is_null($str)) { return NULL; } // note blankOk = false exception already thrown if (!in_array($str, $enumArray)) { throw new ParseSWWATException('parse_enum:' . $str); } return $str; }
<?php // $Id: ExpoEditAction.php 2431 2003-01-07 20:24:44Z cross $ Copyright (c) ConSked, LLC. All Rights Reserved. include 'util/authenticateOrganizer.php'; require_once 'properties/constants.php'; require_once 'db/Expo.php'; require_once 'db/JobTitle.php'; require_once 'util/log.php'; require_once 'util/session.php'; require_once 'swwat/gizmos/parse.php'; $expo = getExpoCurrent(); if (isset($_POST[PARAM_SAVE])) { $expo->title = swwat_parse_string(html_entity_decode($_POST[PARAM_TITLE]), true); $expo->description = swwat_parse_string(html_entity_decode($_POST[PARAM_DESCRIPTION]), true); $expo->expoHourCeiling = swwat_parse_string(html_entity_decode($_POST[PARAM_MAXHOURS]), true); $expo->startTime = swwat_parse_date(html_entity_decode($_POST[PARAM_STARTTIME]), true); $expo->stopTime = swwat_parse_date(html_entity_decode($_POST[PARAM_STOPTIME]), true); $expo->scheduleAssignAsYouGo = isset($_POST[PARAM_SCHEDULE_ALGO]); $expo->scheduleVisible = isset($_POST[PARAM_SCHEDULE_PUBLISH]); $expo->allowScheduleTimeConflict = isset($_POST[PARAM_SCHEDULE_TIME_CONFLICT]); $expo->newUserAddedOnRegistration = isset($_POST[PARAM_NEWUSER_ADDED_ON_REGISTRATION]); if (is_null($expo->expoid)) { $expo->insert(); $jobTitle = new JobTitle(); $jobTitle->expoid = $expo->expoid; $jobTitle->jobTitle = 'Crew'; $jobTitle->insert(); } else { $expo->update(); } setExpoCurrent($expo);
// custom isLoggedIn such that a temp login can change pw require_once 'properties/constants.php'; require_once 'util/session.php'; session_cache_limiter('nocache'); session_start(); if (!isset($_SESSION[AUTHENTICATED_TEMP]) && !isLoggedIn()) { logMessage('authentication', 'worker not logged in'); header('Location: WorkerLoginPage.php'); include 'WorkerLoginPage.php'; return; } require_once 'db/Worker.php'; require_once 'db/WorkerLogin.php'; require_once 'util/log.php'; require_once 'swwat/gizmos/parse.php'; $password = swwat_parse_string(html_entity_decode($_POST[PARAM_PASSWORD]), true); if (is_null($password)) { header('Location: WorkerLoginChangePage.php'); include 'WorkerLoginChangePage.php'; return; } // else $worker = isset($_SESSION[AUTHENTICATED_TEMP]) ? $_SESSION[AUTHENTICATED_TEMP] : getWorkerAuthenticated(); WorkerLogin::password_change($worker->workerid, $password); $worker = getWorkerAuthenticated(); $password = NULL; if ($worker->isOrganizer()) { header('Location: SiteAdminPage.php'); include 'SiteAdminPage.php'; } else { header('Location: WorkerViewPage.php');
function parsePreferenceString($param, $i) { $value = html_entity_decode($_POST[$param . $i]); if (0 == strcmp(PARAM_UNAVAILABLE, $value)) { $value = NULL; } else { $value = swwat_parse_string($value, FALSE); } return $value; }
<?php // $Id: SnapShotStation.php 2227 2012-09-23 21:12:29Z cross $ Copyright (c) ConSked, LLC. All Rights Reserved. require_once 'report.php'; require_once 'db/dbutil.php'; require_once 'properties/constants.php'; require_once 'swwat/gizmos/html.php'; require_once 'swwat/gizmos/parse.php'; $stationid = NULL; $rows = array(); if (isset($_POST[PARAM_SAVE])) { $lname = swwat_parse_string(html_entity_decode($_POST[PARAM_TITLE]), TRUE); $email = swwat_parse_string(html_entity_decode($_POST[PARAM_LOCATION]), TRUE); $sql = "SELECT stationid, lastName, email FROM station WHERE "; $params = array(); if (!is_null($lname)) { $sql .= " lastName LIKE lower(?) "; $params[] = "%" . $lname . "%"; } if (!is_null($email)) { if (!is_null($lname)) { $sql .= " OR "; } $sql .= " email LIKE lower(?) "; $params[] = "%" . $email . "%"; } $sql .= " ORDER BY lastName ASC, email ASC"; if (count($params) > 0) { try { $dbh = getPDOConnection(); $stmt = $dbh->prepare($sql);
<body onload="init()"> <div id="container"> <?php $expo = getExpoCurrent(); unset($_SESSION[PARAM_UPLOAD]); if (!isset($_POST[PARAM_SAVE])) { $expDate = $expo->startTime; // default $_POST[PARAM_WITHCODE] = PARAM_WITHCODE; unset($_POST[PARAM_UNIQUE]); } else { $expDate = swwat_parse_date(html_entity_decode($_POST[PARAM_STOPTIME]), true); } $email = isset($_POST[PARAM_EMAIL]) ? swwat_parse_string(html_entity_decode($_REQUEST[PARAM_EMAIL]), true) : NULL; $withCode = isset($_POST[PARAM_WITHCODE]); $uniqueCode = isset($_POST[PARAM_UNIQUE]); if (is_null($expDate)) { $expDate = $expo->startTime; // default } // ok, start the html include 'section/header.php'; ?> <div id="main"> <?php if (!is_null($expo->expoid)) { include 'section/LinkExpo.php'; }
<?php // $Id: SnapShotWorker.php 2294 2012-09-28 20:07:57Z cross $ Copyright (c) ConSked, LLC. All Rights Reserved. require_once 'report.php'; require_once 'db/dbutil.php'; require_once 'properties/constants.php'; require_once 'swwat/gizmos/html.php'; require_once 'swwat/gizmos/parse.php'; $workerid = NULL; $rows = array(); if (isset($_POST[PARAM_SAVE])) { $lname = swwat_parse_string(html_entity_decode($_POST[PARAM_LASTNAME]), TRUE); $email = swwat_parse_string(html_entity_decode($_POST[PARAM_EMAIL]), TRUE); $workerid = swwat_parse_string(html_entity_decode($_POST[PARAM_WORKERID]), TRUE); $sql = "SELECT workerid, lastName, email FROM worker WHERE "; $params = array(); if (!is_null($lname)) { $sql .= " lastName LIKE lower(?) "; $params[] = "%" . $lname . "%"; } if (!is_null($email)) { if (!is_null($lname)) { $sql .= " OR "; } $sql .= " email LIKE lower(?) "; $params[] = $email . "%"; } if (!is_null($workerid)) { if (!is_null($workerid)) { $sql .= " OR "; }
for ($k = 0; $k < $c; $k++) { $shiftstatus_new[$k] = new ShiftStatus(); if ($_POST[PARAM_STATUSDATE][$k] != "" && $_POST[PARAM_STATUSHOUR][$k] != "") { $shiftstatus_new[$k]->shiftstatusid = swwat_parse_integer(html_entity_decode($_POST[PARAM_STATUSID][$k]), 11, true); $shiftstatus_new[$k]->workerid = swwat_parse_integer(html_entity_decode($worker->workerid), 11, true); $shiftstatus_new[$k]->stationid = swwat_parse_integer(html_entity_decode($station->stationid), 11, true); $shiftstatus_new[$k]->expoid = swwat_parse_integer(html_entity_decode($expo->expoid), 11, true); $shiftstatus_new[$k]->statusType = swwat_parse_string(html_entity_decode($_POST[PARAM_STATUSTYPE][$k]), true); $shiftstatus_new[$k]->statusTime = swwat_parse_date(html_entity_decode($_POST[PARAM_STATUSDATE][$k] . " " . $_POST[PARAM_STATUSHOUR][$k]), true); } else { if ($_POST[PARAM_STATUSDATE][$k] == "" && $_POST[PARAM_STATUSHOUR][$k] != "") { $shiftstatus_new[$k]->shiftstatusid = swwat_parse_integer(html_entity_decode($_POST[PARAM_STATUSID][$k]), 11, true); $shiftstatus_new[$k]->workerid = swwat_parse_integer(html_entity_decode($worker->workerid), 11, true); $shiftstatus_new[$k]->stationid = swwat_parse_integer(html_entity_decode($station->stationid), 11, true); $shiftstatus_new[$k]->expoid = swwat_parse_integer(html_entity_decode($expo->expoid), 11, true); $shiftstatus_new[$k]->statusType = swwat_parse_string(html_entity_decode($_POST[PARAM_STATUSTYPE][$k]), true); if ($_POST[PARAM_STATUSTYPE][$k] == "CHECK_IN") { $shiftstatus_new[$k]->statusTime = swwat_parse_date(html_entity_decode($_POST[PARAM_STATUSDATE][$k + 1] . " " . $_POST[PARAM_STATUSHOUR][$k]), true); } else { if ($_POST[PARAM_STATUSTYPE][$k] == "CHECK_OUT") { $shiftstatus_new[$k]->statusTime = swwat_parse_date(html_entity_decode($_POST[PARAM_STATUSDATE][$k - 1] . " " . $_POST[PARAM_STATUSHOUR][$k]), true); } } } else { $shiftstatus_new[$k]->shiftstatusid = NULL; $shiftstatus_new[$k]->workerid = NULL; $shiftstatus_new[$k]->stationid = NULL; $shiftstatus_new[$k]->expoid = NULL; $shiftstatus_new[$k]->statusType = NULL; $shiftstatus_new[$k]->statusTime = NULL; }
<?php // $Id: WorkerEditAction.php 914 2012-07-14 13:26:32Z preston $ Copyright (c) ConSked, LLC. All Rights Reserved. include 'util/authenticate.php'; require_once 'properties/constants.php'; require_once 'db/Worker.php'; require_once 'util/log.php'; require_once 'util/session.php'; require_once 'util/SMSEnum.php'; require_once 'swwat/gizmos/parse.php'; $worker = getWorkerCurrent(); if (isset($_POST[PARAM_SAVE])) { $worker->firstName = swwat_parse_string(html_entity_decode($_POST[PARAM_FIRSTNAME]), true); $worker->middleName = swwat_parse_string(html_entity_decode($_POST[PARAM_MIDDLENAME]), true); $worker->lastName = swwat_parse_string(html_entity_decode($_POST[PARAM_LASTNAME]), true); $worker->email = swwat_parse_string(html_entity_decode($_POST[PARAM_EMAIL]), true); $worker->phone = swwat_parse_phone(html_entity_decode($_POST[PARAM_PHONE]), true); $sms = swwat_parse_enum(html_entity_decode($_POST[PARAM_SMS_SERVICE]), SMSEnum::$SMS_ARRAY, true); if (0 == strcmp(SMSEnum::$NONE, $sms)) { $sms = NULL; } $worker->smsemail = is_null($worker->phone) || is_null($sms) ? NULL : $worker->phone . "@" . $sms; $worker = $worker->update(); if ($worker->workerid == getWorkerAuthenticated()->workerid) { $_SESSION[AUTHENTICATED] = $worker; // unusual; but I believe the only place required to do so } else { setWorkerCurrent($worker); } } // in all cases
function reviewActionContent($author, $expo) { if (isset($_POST[PARAM_MAXHOURS]) && !is_null($_POST[PARAM_MAXHOURS])) { $author->updateMaxHours($expo->expoid, swwat_parse_string(html_entity_decode($_POST[PARAM_MAXHOURS]))); } $jobList = Job::selectExpo($expo->expoid); usort($jobList, "JobCompare"); $prefJobidList = array(); $prefDesireList = array(); if (count($_POST) > 0) { $keys = array_keys($_POST); $values = array_values($_POST); for ($k = 0; $k < count($_POST); $k++) { if (strpos($keys[$k], 'title') !== false) { list($prefJobidList[], $prefDesireList[]) = explode(':', $values[$k]); } } } $shiftpreference = new ShiftPreference(); foreach ($jobList as $j) { $shiftpreference->workerid = $author->workerid; $shiftpreference->jobid = $j->jobid; $shiftpreference->stationid = $j->stationid; $shiftpreference->expoid = $j->expoid; $pos = array_search($j->jobid, $prefJobidList); if ($pos === false) { $shiftpreference->desirePercent = NULL; } else { $shiftpreference->desirePercent = $prefDesireList[$pos]; if ($shiftpreference->desirePercent == 0) { $shiftpreference->desirePercent = NULL; } } $shiftpreference->update(); } // note post $shiftpreference save if ($expo->scheduleAssignAsYouGo) { if ($expo->scheduleWorkerReset) { $shifts = ShiftAssignment::selectWorker($expo->expoid, $author->workerid); ShiftAssignment::deleteList($shifts); } FirstComeFirstServed::assignAsYouGo($expo, $author); if ($expo->scheduleVisible) { mailSchedule($expo, $author); header('Location: WorkerSchedulePage.php'); include 'WorkerSchedulePage.php'; return; } } // assignAsYouGo }