コード例 #1
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');
 }
コード例 #2
0
 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');
 }
コード例 #3
0
ファイル: Election.php プロジェクト: AppStateESS/election
 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;
 }
コード例 #4
0
 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');
 }
コード例 #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);
 }
コード例 #6
0
ファイル: init.php プロジェクト: HaldunA/phpwebsite
function propertiesLoginLink()
{
    $login = \PHPWS_Settings::get('properties', 'login_link');
    if (empty($login)) {
        $login = '******';
    }
    return $login;
}
コード例 #7
0
 /**
  * @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'));
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 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)));
 }
コード例 #10
0
 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());
 }
コード例 #11
0
 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
ファイル: FaxDownload.php プロジェクト: sinkdb/faxserv
 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
ファイル: update.php プロジェクト: sinkdb/faxserv
/**
 * update.php - FaxMaster update script
 *
 */
function faxmaster_update(&$content, $currentVersion)
{
    switch ($currentVersion) {
        case version_compare($currentVersion, '0.1.0', '<'):
            $db = new PHPWS_DB();
            $result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/faxmaster/boost/update-0.1.1.sql');
            if (PEAR::isError($result)) {
                return $result;
            }
        case version_compare($currentVersion, '0.1.2', '<'):
            $db = new PHPWS_DB();
            $result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/faxmaster/boost/update-0.1.2.sql');
            if (PEAR::isError($result)) {
                return $result;
            }
        case version_compare($currentVersion, '0.1.3', '<'):
            PHPWS_Core::initModClass('users', 'Permission.php');
            Users_Permission::registerPermissions('faxmaster', $content);
        case version_compare($currentVersion, '0.1.5', '<'):
            PHPWS_Settings::set('faxmaster', 'fax_path', '/var/fax/');
            PHPWS_Settings::save('faxmaster');
        case version_compare($currentVersion, '0.1.6', '<'):
            $content[] = '<pre>';
            slcUpdateFiles(array('class/FaxPager.php', 'class/Faxmaster.php', 'templates/faxList.tpl', 'templates/style.css', 'templates/statistics.tpl'), $content);
            $content[] = '0.1.6 Changes
---------------
+ Added a statistics page to view monthly fax stats.
+ Added CSV export to the new statistics page.</pre>';
        case version_compare($currentVersion, '0.1.7', '<'):
            $content[] = '<pre>';
            // Add 2 new columns to the database related to archiving
            $db = new PHPWS_DB();
            $result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/faxmaster/boost/update-0.1.7.sql');
            if (PEAR::isError($result)) {
                return $result;
            }
            slcUpdateFiles(array('boost/boost.php', 'boost/install.sql', 'boost/permission.php', 'boost/update.php', 'boost/update-0.1.7.sql', 'class/ArchiveDownload.php', 'class/exception/InstallException.php', 'class/Fax.php', 'class/FaxPager.php', 'class/Faxmaster.php', 'inc/settings.php', 'templates/archivePager.tpl', 'templates/faxList.tpl', 'templates/settings.tpl', 'templates/style.css'), $content);
            $content[] = '0.1.7 Changes
---------------
+ Added an archive method that is only accessbile by URL.
+ Added the ability to Download an Archive file.
+ Added permissions related to archiving and settings.
+ Added 2 database columns needed for archiving.
+ Added a View Archive page to view a list of all archived faxes.
+ Added a Settings page to configure the fax and archive paths.
</pre>';
        case version_compare($currentVersion, '0.1.8', '<'):
            $db = new PHPWS_DB();
            $result = $db->importFile(PHPWS_SOURCE_DIR . 'mod/faxmaster/boost/update-0.1.8.sql');
            if (PEAR::isError($result)) {
                return $result;
            }
    }
    return true;
}
コード例 #14
0
ファイル: ArchiveDownload.php プロジェクト: sinkdb/faxserv
 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;
 }
コード例 #15
0
ファイル: Application.php プロジェクト: jlbooker/homestead
 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;
 }
コード例 #16
0
 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());
 }
コード例 #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
ファイル: Settings.php プロジェクト: AppStateESS/election
 private function save($request)
 {
     $studentDataApiUrl = $request->getVar('studentDataApiUrl');
     \PHPWS_Settings::set('election', 'studentDataApiUrl', $studentDataApiUrl);
     $studentOrgApiUrl = $request->getVar('studentOrgApiUrl');
     \PHPWS_Settings::set('election', 'studentOrgApiUrl', $studentOrgApiUrl);
     $fromAddress = $request->getVar('fromAddress');
     \PHPWS_Settings::set('election', 'fromAddress', $fromAddress);
     $surveyLink = $request->getVar('surveyLink');
     \PHPWS_Settings::set('election', 'surveyLink', $surveyLink);
     $supportLink = $request->getVar('supportLink');
     \PHPWS_Settings::set('election', 'supportLink', $supportLink);
     \PHPWS_Settings::save('election');
 }
コード例 #19
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();
    }
}
コード例 #20
0
 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());
 }
コード例 #21
0
 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());
 }
コード例 #22
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();
 }
コード例 #23
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.');
     }
     $viewCmd = CommandFactory::getCommand('ShowLotterySettings');
     $lotteryTerm = $context->get('lottery_term');
     $hardCap = !is_null($context->get('hard_cap')) ? $context->get('hard_cap') : 0;
     $jrGoal = !is_null($context->get('jr_goal')) ? $context->get('jr_goal') : 0;
     $srGoal = !is_null($context->get('sr_goal')) ? $context->get('sr_goal') : 0;
     PHPWS_Settings::set('hms', 'lottery_term', $lotteryTerm);
     PHPWS_Settings::set('hms', 'lottery_hard_cap', $hardCap);
     PHPWS_Settings::set('hms', 'lottery_jr_goal', $jrGoal);
     PHPWS_Settings::set('hms', 'lottery_sr_goal', $srGoal);
     PHPWS_Settings::save('hms');
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Lottery settings saved.');
     $viewCmd->redirect();
 }
コード例 #24
0
 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());
 }
コード例 #25
0
ファイル: Deprecate.php プロジェクト: HaldunA/phpwebsite
 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');
 }
コード例 #26
0
ファイル: Whatsnew_Forms.php プロジェクト: HaldunA/phpwebsite
 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');
 }
コード例 #27
0
ファイル: Vote.php プロジェクト: AppStateESS/election
 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);
 }
コード例 #28
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 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();
 }
コード例 #29
0
 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());
 }
コード例 #30
0
ファイル: Channel.php プロジェクト: HaldunA/phpwebsite
 /**
  * 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;
 }