public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryApplication.php');
     $this->setTitle('Special Interest Group');
     javascript('jquery');
     $tpl = array();
     $groups = HMS_Lottery::getSpecialInterestGroupsMap();
     // If a group was selected
     if (!is_null($this->group) && $this->group != 'none') {
         $tpl['GROUP_PAGER'] = LotteryApplication::specialInterestPager($this->group, PHPWS_Settings::get('hms', 'lottery_term'));
         $tpl['GROUP'] = $groups[$this->group];
     }
     // Show the drop down box of groups
     $form = new PHPWS_Form('special_interest');
     $form->setMethod('get');
     $form->addDropBox('group', $groups);
     $form->setClass('group', 'form-control');
     $form->setMatch('group', $this->group);
     $cmd = CommandFactory::getCommand('ShowSpecialInterestGroupApproval');
     $cmd->initForm($form);
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'admin/special_interest_approval.tpl');
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $tpl = array();
     $form = new PHPWS_Form();
     $submitCmd = CommandFactory::getCommand('LotterySettingsSubmit');
     $submitCmd->initForm($form);
     $form->addDropBox('lottery_term', Term::getTermsAssoc());
     $form->setMatch('lottery_term', PHPWS_Settings::get('hms', 'lottery_term'));
     $form->setLabel('lottery_term', 'Lottery Term');
     $form->setClass('lottery_term', 'form-control');
     $form->addText('hard_cap');
     $form->setLabel('hard_cap', 'Max # Returning Students (hard cap):');
     $form->setValue('hard_cap', PHPWS_Settings::get('hms', 'lottery_hard_cap'));
     $form->setClass('hard_cap', 'form-control');
     /*
     $form->addText('soph_goal');
     $form->setLabel('soph_goal', 'Sophomores:');
     $form->setValue('soph_goal', PHPWS_Settings::get('hms', 'lottery_soph_goal'));
     */
     $form->addText('jr_goal');
     $form->setLabel('jr_goal', 'Juniors:');
     $form->setValue('jr_goal', PHPWS_Settings::get('hms', 'lottery_jr_goal'));
     $form->setClass('jr_goal', 'form-control');
     $form->addText('sr_goal');
     $form->setLabel('sr_goal', 'Senior:');
     $form->setValue('sr_goal', PHPWS_Settings::get('hms', 'lottery_sr_goal'));
     $form->setClass('sr_goal', 'form-control');
     $form->addSubmit('submit', 'Save');
     $form->mergeTemplate($tpl);
     Layout::addPageTitle("Lottery Settings");
     return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/lottery_settings.tpl');
 }
예제 #3
0
파일: User.php 프로젝트: HaldunA/phpwebsite
 public static function searchBox()
 {
     if (SEARCH_DEFAULT) {
         $onclick = sprintf('onclick="if(this.value == \'%s\')this.value = \'\';"', SEARCH_DEFAULT);
     }
     PHPWS_Core::initCoreClass('Form.php');
     $form = new PHPWS_Form('search_box');
     $form->setProtected(false);
     $form->setMethod('get');
     $form->addHidden('module', 'search');
     $form->addHidden('user', 'search');
     $form->addText('search', SEARCH_DEFAULT);
     $form->setLabel('search', dgettext('search', 'Search'));
     if (PHPWS_Settings::get('search', 'show_alternates')) {
         Search_User::addAlternates($form);
     }
     if (isset($onclick)) {
         $form->setExtra('search', $onclick);
     }
     $form->addSubmit('go', dgettext('search', 'Search'));
     $mod_list = Search_User::getModList();
     $form->addSelect('mod_title', $mod_list);
     $key = Key::getCurrent();
     if (!empty($key) && !$key->isDummy()) {
         $form->setMatch('mod_title', $key->module);
     } elseif (isset($_REQUEST['mod_title'])) {
         $form->setMatch('mod_title', $_REQUEST['mod_title']);
     }
     $template = $form->getTemplate();
     $content = PHPWS_Template::process($template, 'search', 'search_box.tpl');
     Layout::add($content, 'search', 'search_box');
 }
예제 #4
0
 private function getVotingData()
 {
     $election = Factory::getCurrent();
     // If there's no election going on, then return empty data
     if (empty($election)) {
         return array('hasVoted' => false, 'election' => null, 'single' => array(), 'multiple' => array(), 'referendum' => array(), 'unqualified' => array());
     }
     // Check if student has voted already
     $hasVoted = $this->student->hasVoted($election['id']);
     // If already voted, return minimal voting info
     if ($hasVoted) {
         return array('hasVoted' => true, 'election' => $election, 'single' => array(), 'multiple' => array(), 'referendum' => array(), 'unqualified' => array());
     }
     // Assemble the voting data
     $single = \election\Factory\Single::getListWithTickets($election['id']);
     $multiple = \election\Factory\Multiple::getListWithCandidates($election['id']);
     if (!empty($multiple)) {
         $unqualified = \election\Factory\Multiple::filter($multiple, $this->student);
     } else {
         $unqualified = array();
     }
     $referendum = \election\Factory\Referendum::getList($election['id']);
     $voting_data = array('hasVoted' => false, 'election' => $election, 'single' => $single, 'multiple' => $multiple, 'referendum' => $referendum, 'unqualified' => $unqualified, 'supportLink' => \PHPWS_Settings::get('election', 'supportLink'));
     return $voting_data;
 }
예제 #5
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'ReapplicationWaitingListMenuBlockView.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $application = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term, 'lottery');
     return new ReapplicationWaitingListMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $application);
 }
 /**
  * @param string $currentUserName - Username of the user currently logged in. Will be sent to web service
  */
 public function __construct($currentUserName)
 {
     $this->currentUserName = $currentUserName;
     // Get the WSDL URI from module's settings
     $wsdlUri = \PHPWS_Settings::get('intern', 'wsdlUri');
     // Create the SOAP instance
     $this->client = new \SoapClient($wsdlUri, array('WSDL_CACHE_MEMORY'));
 }
예제 #7
0
파일: init.php 프로젝트: HaldunA/phpwebsite
function propertiesLoginLink()
{
    $login = \PHPWS_Settings::get('properties', 'login_link');
    if (empty($login)) {
        $login = '******';
    }
    return $login;
}
 public function __construct()
 {
     $this->apiUrl = \PHPWS_Settings::get('election', 'studentOrgApiUrl');
     if (is_null($this->apiUrl)) {
         throw new \InvalidArgumentException('Student org API url is not configured.');
     }
     // Create a Guzzle instance
     $this->client = new Client($this->apiUrl, array('request.options' => array('verify' => false)));
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php');
     $requestId = $context->get('requestId');
     $mealPlan = $context->get('mealPlan');
     $errorCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest');
     $errorCmd->setRequestId($requestId);
     $errorCmd->setMealPlan($mealPlan);
     // Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     // Check for a meal plan
     if (!isset($mealPlan) || $mealPlan == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a meal plan.');
         $errorCmd->redirect();
     }
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Update the meal plan field on the application
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $app->setMealPlan($mealPlan);
     try {
         $app->save();
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     // Try to actually make the assignment
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     try {
         HMS_Lottery::confirm_roommate_request(UserStatus::getUsername(), $requestId, $mealPlan);
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log the fact that the roommate was accepted and successfully assigned
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_CONFIRMED_ROOMMATE, UserStatus::getUsername(), "Captcha: \"{$captcha}\"");
     // Check for an RLC membership and update status if necessary
     // If this student was an RLC self-select, update the RLC memberhsip state
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
         $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment));
     }
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId);
     $successCmd = CommandFactory::getCommand('LotteryShowConfirmedRoommateThanks');
     $successCmd->setRequestId($requestId);
     $successCmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryDenyRoommateRequestView.php');
     $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $view = new LotteryDenyRoommateRequestView($request, $term);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     $roomId = $context->get('roomId');
     $roommates = $context->get('roommates');
     $mealPlan = $context->get('mealPlan');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     PHPWS_Core::initModClass('hms', 'LotteryConfirmView.php');
     $view = new LotteryConfirmView($roomId, $mealPlan, $roommates, $term);
     $context->setContent($view->show());
 }
예제 #12
0
 public function show()
 {
     $basePath = PHPWS_Settings::get('faxmaster', 'fax_path');
     if (is_null($basePath) || !isset($basePath)) {
         throw new InvalidArgumentException('Please set fax_path setting.');
     }
     header('Content-Disposition: attachment; filename="' . $this->fax->getFileName() . '"');
     readfile($basePath . $this->fax->getFileName());
     exit;
 }
예제 #13
0
 public function show()
 {
     $basePath = PHPWS_Settings::get('faxmaster', 'archive_path');
     if (is_null($basePath) || !isset($basePath)) {
         throw new InvalidArgumentException('Please set archive_path setting.');
     }
     header('Content-Type: application/x-gtar');
     header('Content-Disposition: attachment; filename="' . $this->tar . '"');
     header('Content-Length: ' . filesize($basePath . $this->tar));
     readfile($basePath . $this->tar);
     exit;
 }
예제 #14
0
 public function showForStudent(Student $student, $term)
 {
     // for freshmen
     if ($student->getApplicationTerm() > Term::getCurrentTerm()) {
         return true;
     }
     // for returning students (summer terms)
     if ($term > $student->getApplicationTerm() && $term != PHPWS_Settings::get('hms', 'lottery_term') && (Term::getTermSem($term) == TERM_SUMMER1 || Term::getTermSem($term) == TERM_SUMMER2)) {
         return true;
     }
     return false;
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'LotteryChooseRoommatesView.php');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $roomId = $context->get('roomId');
     if (!isset($roomId) || is_null($roomId) || empty($roomId)) {
         throw new InvalidArgumentException('Missing room id.');
     }
     $view = new LotteryChooseRoommatesView($student, $term, $roomId);
     $context->setContent($view->show());
 }
예제 #16
0
 public function getHtmlView($data, \Request $request)
 {
     javascript('jquery');
     $tplvars['studentDataApiUrl'] = \PHPWS_Settings::get('election', 'studentDataApiUrl');
     $tplvars['studentOrgApiUrl'] = \PHPWS_Settings::get('election', 'studentOrgApiUrl');
     $tplvars['fromAddress'] = \PHPWS_Settings::get('election', 'fromAddress');
     $tplvars['surveyLink'] = \PHPWS_Settings::get('election', 'surveyLink');
     $tplvars['supportLink'] = \PHPWS_Settings::get('election', 'supportLink');
     $template = new \Template($tplvars);
     $template->setModuleTemplate('election', 'Admin/Settings.html');
     $content = $template->get();
     $view = new \View\HtmlView($content);
     return $view;
 }
예제 #17
0
 public function __construct()
 {
     // Get the REST API URL from the module's settings
     $apiUrl = \PHPWS_Settings::get('election', 'studentDataApiUrl');
     if (is_null($apiUrl)) {
         throw new \InvalidArgumentException('Student data API url is not configured.');
     }
     // If the URL doesn't end with a trailing slash, then add one
     if (substr($apiUrl, -1) != '/') {
         $apiUrl .= '/';
     }
     // Create a Guzzle instance
     $this->client = new Client($apiUrl);
 }
예제 #18
0
function purgeProperties()
{
    $last_purge = \PHPWS_Settings::get('properties', 'last_purge') + 86400;
    $current_time = time();
    if ($last_purge < $current_time) {
        \PHPWS_Settings::set('properties', 'last_purge', $current_time);
        \PHPWS_Settings::save('properties');
        $db = new PHPWS_DB('properties');
        $db->addWhere('timeout', time(), '<');
        $db->addValue('active', 0);
        $db->update();
        $db = new PHPWS_DB('prop_roommate');
        $db->addWhere('timeout', time(), '<');
        $db->delete();
    }
}
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $lotteryTerm = PHPWS_Settings::get('hms', 'lottery_term');
     if (is_null($lotteryTerm)) {
         PHPWS_Core::initModClass('hms', 'exception/InvalidConfigurationException.php');
         throw new InvalidConfigurationException('Lottery term is not configured.');
     }
     if ($lotteryTerm < Term::getCurrentTerm()) {
         PHPWS_Core::initModClass('hms', 'exception/InvalidConfigurationException.php');
         throw new InvalidConfigurationException('Lottery term must be in the future. You probably forgot to update it.');
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $lotteryTerm);
     PHPWS_Core::initModClass('hms', 'ReturningMainMenuView.php');
     $view = new ReturningMainMenuView($student, $lotteryTerm);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'LotteryChooseFloorView.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     $hallId = $context->get('hallId');
     if (!isset($hallId) || is_null($hallId) || empty($hallId)) {
         throw new InvalidArgumentException('Missing hall id.');
     }
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment == false) {
         $rlcAssignment = null;
     }
     $view = new LotteryChooseFloorView($student, $term, $hallId, $rlcAssignment);
     $context->setContent($view->show());
 }
예제 #21
0
 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 function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryRoommateRequestView.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $housingApp = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Check for a self-select RLC membership for the logged-in student
     $rlcAssign = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssign == false) {
         $rlcAssign = null;
     }
     $view = new LotteryRoommateRequestView($request, $term, $housingApp, $rlcAssign);
     $context->setContent($view->show());
 }
예제 #23
0
 public static function moduleWarning($module)
 {
     // disabling as it is broken
     return;
     if (!LOG_DEPRECATIONS) {
         return;
     }
     $dep_name = $module . '_deprecated';
     $last_warned = PHPWS_Settings::get('users', $dep_name);
     $spacing = time() - 86400 * DEPRECATE_DAY_SPACING;
     // It hasn't been long enough to log the warning.
     if ($last_warned && $last_warned > $spacing) {
         return;
     }
     $warning = "The {$module} module is deprecated and support is discontinued. Please consider uninstalling it.";
     PHPWS_Core::log($warning, 'deprecated.log');
     PHPWS_Settings::set('users', $dep_name, time());
     PHPWS_Settings::save('users');
 }
예제 #24
0
 function editSettings()
 {
     $form = new PHPWS_Form('whatsnew_settings');
     $form->addHidden('module', 'whatsnew');
     $form->addHidden('aop', 'post_settings');
     $form->addCheckbox('enable', 1);
     $form->setMatch('enable', PHPWS_Settings::get('whatsnew', 'enable'));
     $form->setLabel('enable', dgettext('whatsnew', 'Enable whatsnew'));
     $form->addCheckbox('homeonly', 1);
     $form->setMatch('homeonly', PHPWS_Settings::get('whatsnew', 'homeonly'));
     $form->setLabel('homeonly', dgettext('whatsnew', 'Show whatsnew sidebox on home page only'));
     $form->addTextField('title', PHPWS_Settings::get('whatsnew', 'title'));
     $form->setLabel('title', dgettext('whatsnew', 'Sidebox title'));
     $form->setSize('title', 30);
     $form->addTextArea('text', PHPWS_Settings::get('whatsnew', 'text'));
     $form->setRows('text', '4');
     $form->setCols('text', '40');
     $form->setLabel('text', dgettext('whatsnew', 'Sidebox text'));
     $form->addTextField('cache_timeout', PHPWS_Settings::get('whatsnew', 'cache_timeout'));
     $form->setLabel('cache_timeout', dgettext('whatsnew', 'Cache duration for whatsnew list (in seconds, 0-7200)'));
     $form->setSize('cache_timeout', 4, 4);
     $form->addTextField('qty_items', PHPWS_Settings::get('whatsnew', 'qty_items'));
     $form->setLabel('qty_items', dgettext('whatsnew', 'Number of recent items to display (0-50)'));
     $form->setSize('qty_items', 4, 4);
     $form->addCheckbox('show_summaries', 1);
     $form->setMatch('show_summaries', PHPWS_Settings::get('whatsnew', 'show_summaries'));
     $form->setLabel('show_summaries', dgettext('whatsnew', 'Show item summaries'));
     $form->addCheckbox('show_dates', 1);
     $form->setMatch('show_dates', PHPWS_Settings::get('whatsnew', 'show_dates'));
     $form->setLabel('show_dates', dgettext('whatsnew', 'Show item update dates'));
     $form->addCheckbox('show_source_modules', 1);
     $form->setMatch('show_source_modules', PHPWS_Settings::get('whatsnew', 'show_source_modules'));
     $form->setLabel('show_source_modules', dgettext('whatsnew', 'Show item source module names'));
     $form->addSubmit('save', dgettext('whatsnew', 'Save settings'));
     $tpl = $form->getTemplate();
     $tpl['SETTINGS_LABEL'] = dgettext('whatsnew', 'General Settings');
     $tpl['FLUSH_LINK'] = PHPWS_Text::secureLink(dgettext('whatsnew', 'Flush cache'), 'whatsnew', array('aop' => 'flush_cache'));
     $tpl['EXCLUDE'] = $this->whatsnew->getKeyMods(unserialize(PHPWS_Settings::get('whatsnew', 'exclude')), 'exclude');
     $tpl['EXCLUDE_LABEL'] = dgettext('whatsnew', 'Select any modules you wish to exclude from your whatsnew box.');
     $this->whatsnew->title = dgettext('whatsnew', 'Settings');
     $this->whatsnew->content = PHPWS_Template::process($tpl, 'whatsnew', 'edit_settings.tpl');
 }
예제 #25
0
 private static function emailStudent(\election\Resource\Student $student, array $election)
 {
     if (STUDENT_DATA_TEST) {
         $email_address = TEST_STUDENT_EMAIL;
     } else {
         $email_address = $student->getEmail();
     }
     $transport = \Swift_MailTransport::newInstance();
     $template = new \Template();
     $template->setModuleTemplate('election', 'Admin/VoteSuccess.html');
     $template->add('title', $election['title']);
     $content = $template->get();
     $message = \Swift_Message::newInstance();
     $message->setSubject('Vote complete');
     $message->setFrom(\PHPWS_Settings::get('election', 'fromAddress'));
     $message->setTo($email_address);
     $message->setBody($content, 'text/html');
     $mailer = \Swift_Mailer::newInstance($transport);
     $mailer->send($message);
 }
 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 remove students from the waiting list.');
     }
     $username = $context->get('username');
     $cmd = CommandFactory::getCommand('ShowLotteryWaitingList');
     if (!is_null($username)) {
         $app = HousingApplication::getApplicationByUser($username, PHPWS_Settings::get('hms', 'lottery_term'));
         $app->waiting_list_hide = 1;
         $result = $app->save();
         if (!PHPWS_Error::logIfError($result)) {
             NQ::simple('hms', hms\NotificationView::SUCCESS, "{$username} removed from the waiting list!");
             $cmd->redirect();
         }
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, "Unable to remove {$username} from the waiting list!");
     $cmd->redirect();
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'LotteryChooseHallView.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'LotteryProcess.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     // Check the hard cap!
     if (LotteryProcess::hardCapReached($term)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, re-application is now closed.');
         $errorCmd = CommandFactory::getCommand('ShowStudentMenu');
         $errorCmd->redirect();
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment == false) {
         $rlcAssignment = null;
     }
     $view = new LotteryChooseHallView($student, $term, $rlcAssignment);
     $context->setContent($view->show());
 }
예제 #28
0
 /**
  * Returns a RSS feed. Cached result is returned if exists.
  */
 public function view()
 {
     $cache_key = $this->module . '_cache_key';
     $content = PHPWS_Cache::get($cache_key, RSS_CACHE_TIMEOUT);
     if (!empty($content)) {
         return $content;
     }
     if (empty($this->_feeds)) {
         $this->loadFeeds();
     }
     $home_http = PHPWS_Core::getHomeHttp();
     $template['CHANNEL_TITLE'] = $this->EncodeString($this->title);
     $template['CHANNEL_ADDRESS'] = $this->getAddress();
     $template['HOME_ADDRESS'] = $home_http;
     $template['CHANNEL_DESCRIPTION'] = $this->EncodeString($this->description);
     $template['LANGUAGE'] = CURRENT_LANGUAGE;
     // change later
     $template['SEARCH_LINK'] = sprintf('%sindex.php?module=search&amp;mod_title=%s&amp;user=search', $home_http, $this->module);
     $template['SEARCH_DESCRIPTION'] = sprintf('Search in %s', $this->title);
     $template['SEARCH_NAME'] = 'search';
     $template['COPYRIGHT'] = PHPWS_Settings::get('rss', 'copyright');
     $template['WEBMASTER'] = PHPWS_Settings::get('rss', 'webmaster');
     $template['MANAGING_EDITOR'] = PHPWS_Settings::get('rss', 'editor');
     //        $template['LAST_BUILD_DATE'] = $this->_last_build_date;
     $timezone = strftime('%z');
     $timezone = substr($timezone, 0, 3) . ':' . substr($timezone, 3, 2);
     if ($this->_feeds) {
         foreach ($this->_feeds as $key) {
             $itemTpl = NULL;
             $url = preg_replace('/^\\.\\//', '', $key->url);
             $url = $home_http . preg_replace('/&(?!amp;)/', '&amp;', $url);
             $itemTpl['ITEM_LINK'] = $url;
             $itemTpl['ITEM_TITLE'] = $this->EncodeString($key->title);
             $itemTpl['ITEM_GUID'] = $url;
             $itemTpl['ITEM_LINK'] = $url;
             $itemTpl['ITEM_SOURCE'] = sprintf('%sindex.php?module=rss&amp;mod_title=%s', $home_http, $this->module);
             $itemTpl['ITEM_DESCRIPTION'] = strip_tags(trim($this->EncodeString($key->summary)));
             $itemTpl['ITEM_AUTHOR'] = $key->creator;
             //              $itemTpl['ITEM_PUBDATE']      = $key->getCreateDate('%Y-%m-%d %H:%M:%S CST');
             $itemTpl['ITEM_PUBDATE'] = $this->rssDate($key->create_date);
             $itemTpl['ITEM_DC_DATE'] = $key->getCreateDate('%Y-%m-%dT%H:%M:%S') . $timezone;
             $itemTpl['ITEM_DC_TYPE'] = 'Text';
             //pull from db later
             $itemTpl['ITEM_DC_CREATOR'] = $key->creator;
             $itemTpl['ITEM_SOURCE_TITLE'] = $this->EncodeString($this->title);
             $template['item-listing'][] = $itemTpl;
         }
     }
     if (PHPWS_Settings::get('rss', 'rssfeed') == 2) {
         $tpl_file = 'rss20.tpl';
     } else {
         $tpl_file = 'rss10.tpl';
     }
     $content = PHPWS_Template::process($template, 'rss', $tpl_file);
     $content = utf8_encode($content);
     PHPWS_Cache::save($cache_key, $content);
     return $content;
 }
예제 #29
0
 public static function settings()
 {
     $form = new PHPWS_Form('rss-settings');
     $form->addHidden('module', 'rss');
     $form->addHidden('command', 'save_settings');
     $files = array(1 => '1', 2 => '2');
     $filenames = array(1 => 'RSS 1.0', 2 => 'RSS 2.0');
     $form->addRadio('rssfeed', $files);
     $form->setLabel('rssfeed', $filenames);
     $form->setMatch('rssfeed', PHPWS_Settings::get('rss', 'rssfeed'));
     $form->addText('editor', PHPWS_Settings::get('rss', 'editor'));
     $form->setLabel('editor', dgettext('rss', 'Managing editor email address'));
     $form->setSize('editor', 30);
     $form->addText('webmaster', PHPWS_Settings::get('rss', 'webmaster'));
     $form->setLabel('webmaster', dgettext('rss', 'Webmaster email address'));
     $form->setSize('webmaster', 30);
     $form->addText('copyright', PHPWS_Settings::get('rss', 'copyright'));
     $form->setLabel('copyright', dgettext('rss', 'Copyright'));
     $form->setSize('copyright', 40);
     $form->addSubmit(dgettext('rss', 'Save settings'));
     $tpl = $form->getTemplate();
     $fc['TITLE'] = dgettext('rss', 'General Settings');
     $fc['CONTENT'] = PHPWS_Template::process($tpl, 'rss', 'settings.tpl');
     return $fc;
 }
예제 #30
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $roomId = $context->get('roomId');
     $roommates = $context->get('roommates');
     $mealPlan = $context->get('mealPlan');
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('LotteryShowConfirm');
     $errorCmd->setRoomId($roomId);
     $errorCmd->setRoommates($roommates);
     $errorCmd->setMealPlan($mealPlan);
     $successCmd = CommandFactory::getCommand('LotteryShowConfirmed');
     $successCmd->setRoomId($roomId);
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     // returns the words entered if correct, FALSE otherwise
     //$captcha = TRUE;
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, the words you eneted were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'HMS_Room.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php');
     $room = new HMS_Room($roomId);
     // Check for an RLC assignment in the self-select status
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     // Check roommates for validity
     foreach ($roommates as $bed_id => $username) {
         // Double check the student is valid
         try {
             $roommate = StudentFactory::getStudentByUsername($username, $term);
         } catch (StudentNotFoundException $e) {
             NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not a valid student. Please choose a different roommate.");
             $errorCmd->redirect();
         }
         // Make sure the bed is still empty
         $bed = new HMS_Bed($bed_id);
         if ($bed->has_vacancy() != TRUE) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.');
             $errorCmd->redirect();
         }
         // Make sure none of the needed beds are reserved
         if ($bed->is_lottery_reserved()) {
             NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.');
             $errorCmd->redirect();
         }
         // Double check the genders are all the same as the person logged in
         if ($student->getGender() != $roommate->getGender()) {
             NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender.");
             $errorCmd->redirect();
         }
         // Double check the genders are the same as the room (as long as the room isn't AUTO)
         if ($room->gender_type != AUTO && $roommate->getGender() != $room->gender_type) {
             NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender.");
             $errorCmd->redirect();
         }
         // If this student is an RLC-self-selection, then each roommate must be in the same RLC and in the selfselect-invite state too
         if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
             // This student is an RLC-self-select, so check the roommate's RLC status
             $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term);
             // Make sure the roommate is a member of the same RLC and is eligible for self-selection
             if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) {
                 NQ::simple('hms', hms\NotificationView::ERROR, "{$roommate} must be a member of the same learning community as you, and must also be eligible for self-selction.");
                 $errorCmd->redirect();
             }
             // Otherwise (if not RLC members), make sure each roommate is eligible
         } else {
             if (HMS_Lottery::determineEligibility($username) !== TRUE) {
                 NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not eligible for assignment.");
                 $errorCmd->redirect();
             }
         }
         // If this student is a self-select RLC member, then this student must also be a self-select RLC member of the same RLC
         if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
             $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term);
             if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) {
                 NQ::simple('hms', hms\NotificationView::ERROR, "{$username} must be a member of the same learning community as you, and must also be eligible for self-selction.");
                 $errorCmd->redirect();
             }
         }
     }
     // If the room's gender is 'AUTO' and no one is assigned to it yet, switch it to the student's gender
     if ($room->gender_type == AUTO && $room->get_number_of_assignees() == 0) {
         $room->gender_type = $student->getGender();
         $room->save();
     }
     // Assign the student to the requested bed
     $bed_id = array_search(UserStatus::getUsername(), $roommates);
     // Find the bed id of the student who's logged in
     try {
         $result = HMS_Assignment::assignStudent($student, PHPWS_Settings::get('hms', 'lottery_term'), NULL, $bed_id, $mealPlan, 'Confirmed lottery invite', TRUE, ASSIGN_LOTTERY);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error creating your room assignment. Please try again or contact University Housing.');
         $errorCmd->redirect();
     }
     // Log the assignment
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOM_CHOSEN, UserStatus::getUsername(), 'Captcha: ' . $captcha);
     // Update the student's meal plan in the housing application, just for future reference
     $app = HousingApplication::getApplicationByUser($student->getUsername(), $term);
     $app->setMealPlan($mealPlan);
     $app->save();
     // If this student was an RLC self-select, update the RLC memberhsip state
     if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
         $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment));
     }
     foreach ($roommates as $bed_id => $username) {
         // Skip the current user
         if ($username == $student->getUsername()) {
             continue;
         }
         # Reserve the bed for the roommate
         $expires_on = time() + INVITE_TTL_HRS * 3600;
         $bed = new HMS_Bed($bed_id);
         if (!$bed->lottery_reserve($username, $student->getUsername(), $expires_on)) {
             NQ::smiple('hms', hms\NotificationView::WARNING, "You were assigned, but there was a problem reserving space for your roommates. Please contact University Housing.");
             $successCmd->redirect();
         }
         HMS_Activity_Log::log_activity($username, ACTIVITY_LOTTERY_REQUESTED_AS_ROOMMATE, $student->getUsername(), 'Expires: ' . HMS_Util::get_long_date_time($expires_on));
         # Invite the selected roommates
         $roomie = StudentFactory::getStudentByUsername($username, $term);
         $term = PHPWS_Settings::get('hms', 'lottery_term');
         $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term));
         HMS_Email::send_lottery_roommate_invite($roomie, $student, $expires_on, $room->where_am_i(), $year);
     }
     HMS_Email::send_lottery_assignment_confirmation($student, $room->where_am_i(), $term);
     $successCmd->redirect();
 }