public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'lottery_admin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to administer re-application features.'); } PHPWS_Core::initModClass('hms', 'HMS_Eligibility_Waiver.php'); PHPWS_Core::initModClass('hms', 'SOAP.php'); $usernames = explode("\n", $context->get('usernames')); $term = PHPWS_Settings::get('hms', 'lottery_term'); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $error = false; foreach ($usernames as $user) { $trimmed = trim($user); // Check for blank lines and skip them if ($trimmed == '') { continue; } // Remove everything after '@'. $splode = explode('@', $trimmed); $user = trim($splode[0]); # Username is at [0] if ($user == '') { continue; } if (!$soap->isValidStudent($user, $term)) { NQ::simple('hms', hms\NotificationView::ERROR, "Invalid username: {$user}"); $error = true; } else { $waiver = new HMS_Eligibility_Waiver($user, $term); $result = $waiver->save(); if (!$result) { NQ::simple('hms', hms\NotificationView::ERROR, 'Error creating waiver for: ' . $user); $error = true; } } } if (!$error) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Waivers created successfully.'); } $cmd = CommandFactory::getCommand('ShowLotteryEligibilityWaiver'); $cmd->redirect(); }
public static function determineEligibility($username) { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Eligibility_Waiver.php'); // First, check for an assignment in the current term if (HMS_Assignment::checkForAssignment($username, Term::getCurrentTerm())) { return true; // If that didn't work, check for a waiver in the lottery term } elseif (HMS_Eligibility_Waiver::checkForWaiver($username, PHPWS_Settings::get('hms', 'lottery_term'))) { return true; // If that didn't work either, then the student is not elibible, so return false } else { return false; } }