本文整理汇总了PHP中NQ类的典型用法代码示例。如果您正苦于以下问题:PHP NQ类的具体用法?PHP NQ怎么用?PHP NQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NQ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show()
{
$submitCmd = CommandFactory::getCommand('SaveTermSettings');
$form = new PHPWS_Form('docusign');
$submitCmd->initForm($form);
// Over 18 template
$existingTemplate = '';
try {
$existingTemplate = $this->term->getDocusignTemplate();
} catch (InvalidConfigurationException $e) {
NQ::simple('hms', hms\NotificationView::WARNING, 'No DocuSign template id has been set for students over 18.');
}
$form->addText('template', $existingTemplate);
$form->addCssClass('template', 'form-control');
// Under 18 template
$under18Template = '';
try {
$under18Template = $this->term->getDocusignUnder18Template();
} catch (InvalidConfigurationException $e) {
NQ::simple('hms', hms\NotificationView::WARNING, 'No DocuSign template id has been set for students under 18.');
}
$form->addText('under18_template', $under18Template);
$form->addCssClass('under18_template', 'form-control');
$tpl = $form->getTemplate();
return PHPWS_Template::process($tpl, 'hms', 'admin/TermsConditionsAdminView.tpl');
}
示例2: execute
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'StudentDataProvider.php');
$provider = StudentDataProvider::getInstance();
$provider->clearCache();
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Cache cleared.');
}
示例3: execute
/**
* (non-PHPdoc)
* @see Command::execute()
*/
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'StudentFactory.php');
PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
$term = $context->get('term');
if (!isset($term)) {
throw new InvalidArgumentException('Missing term.');
}
$user = UserStatus::getUsername();
$student = StudentFactory::getStudentByUsername($user, $term);
// Load the student's application. Should be a lottery application.
$application = HousingApplicationFactory::getAppByStudent($student, $term);
// If there isn't a valid application in the DB, then we have a problem.
if (!isset($application) || !$application instanceof LotteryApplication) {
throw new InvalidArgumentException('Null application object.');
}
// Check to make sure the date isn't already set
$time = $application->getWaitingListDate();
if (isset($time)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'You have already applied for the waiting list.');
$cmd = CommandFactory::getCommand('ShowStudentMenu');
$cmd->redirect();
}
// Set the date
$application->setWaitingListDate(time());
// Save the application again
$application->save();
// Log it to the activity log
HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_REAPP_WAITINGLIST_APPLY, UserStatus::getUsername());
// Success command
$cmd = CommandFactory::getCommand('ShowStudentMenu');
$cmd->redirect();
}
示例4: execute
/**
* Shows the requested report's HTML output.
*
* @param CommandContext $context
* @throws InvalidArgumentExection
*/
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'reports')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do no have permission to run reports.');
}
$reportId = $context->get('reportId');
if (!isset($reportId) || is_null($reportId)) {
throw new InvalidArgumentExection('Missing report id.');
}
// Instantiate the report controller with the requested report id
PHPWS_Core::initModClass('hms', 'ReportFactory.php');
$report = ReportFactory::getReportById($reportId);
Layout::addPageTitle($report->getFriendlyName());
$detailCmd = CommandFactory::getCommand('ShowReportDetail');
$detailCmd->setReportClass($report->getClass());
$content = '<div> ' . $detailCmd->getLink('« back') . ' </div>';
$content .= file_get_contents($report->getHtmlOutputFilename());
if ($content === FALSE) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
$reportCmd = CommandFactory::getCommand('ShowReportDetail');
$reportCmd->setReportClass($report->getClass());
$reportCmd->redirect();
}
$context->setContent($content);
}
示例5: execute
public function execute(CommandContext $context)
{
$id = $context->get('roommateId');
if (is_null($id)) {
throw new InvalidArgumentException('Must set roommateId');
}
PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
$roommate = new HMS_Roommate($id);
if ($roommate->id == 0) {
throw new InvalidArgumentException('Invalid roommateId ' . $id);
}
if (UserStatus::getUsername() != $roommate->requestee) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException("{$username} tried to reject roommate pairing {$roommate->id}");
}
$requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
$name = $requestor->getFullName();
$username = $requestor->getUsername();
$roommate->delete();
HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
// Email both parties
PHPWS_Core::initModClass('hms', 'HMS_Email.php');
HMS_Email::send_reject_emails($roommate);
NQ::Simple('hms', hms\NotificationView::SUCCESS, "<b>You rejected the roommate request from {$name}.</b> If this was an error, you may re-request using their username, <b>{$username}</b>.");
$cmd = CommandFactory::getCommand('ShowStudentMenu');
$cmd->redirect();
}
示例6: execute
public function execute(CommandContext $context)
{
// Check for report ID
$reportId = $context->get('reportId');
if (!isset($reportId) || is_null($reportId)) {
throw new InvalidArgumentException('Missing report id.');
}
PHPWS_Core::initModClass('hms', 'ReportFactory.php');
// Load the report to get its class
try {
$report = ReportFactory::getReportById($reportId);
} catch (InvalidArgumentException $e) {
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
$context->goBack();
}
$db = new PHPWS_DB('hms_report');
$db->addWhere('id', $reportId);
$result = $db->delete();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
$cmd = CommandFactory::getCommand('ShowReportDetail');
$cmd->setReportClass($report->getClass());
$cmd->redirect();
}
示例7: rawToRead
/**
* Converts the database entry of Term into human
* If $super is true then <sup> tags will be used in 1st and 2nd.
* readable form. (Ex: 20111 => 'Spring 2011')
*/
public static function rawToRead($t, $super = false)
{
$semester = substr($t, strlen($t) - 1, 1);
$year = substr($t, 0, strlen($t) - 1);
switch ($semester) {
case '1':
return "Spring {$year}";
case '2':
if ($super) {
return "1<sup>st</sup> Summer {$year}";
} else {
return "1st Summer {$year}";
}
case '3':
if ($super) {
return "2<sup>nd</sup> Summer {$year}";
} else {
return "2nd Summer {$year}";
}
case '4':
return "Fall {$year}";
default:
// Whaattt??
\NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, 'Term error: ' . $t);
return "{$year}";
}
}
示例8: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to remove a bed.');
}
PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
$viewCmd = CommandFactory::getCommand('EditRoomView');
$viewCmd->setRoomId($context->get('roomId'));
$bedId = $context->get('bedId');
$roomId = $context->get('roomId');
if (!isset($roomId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing room ID.');
$viewCmd->redirect();
}
if (!isset($bedId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing bed ID.');
$viewCmd->redirect();
}
# Try to delete the bed
try {
HMS_Bed::deleteBed($bedId);
} catch (Exception $e) {
NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error deleting the bed: ' . $e->getMessage());
$viewCmd->redirect();
}
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Bed successfully deleted.');
$viewCmd->redirect();
}
示例9: execute
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.');
}
*/
if (is_null($context->get('hall')) && is_null($context->get('floor'))) {
NQ::simple('hms', hms\NotificationView::ERROR, 'You must select a hall 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') : false;
$halls = $context->get('hall');
$floors = $context->get('floor');
$cmd = CommandFactory::getCommand('ShowHallNotificationEdit');
if (empty($subject)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'You must fill in the subject line of the email.');
$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->loadContext($context);
$cmd->redirect();
}
}
$view = new ReviewHallNotificationMessageView($subject, $body, $anonymous, $halls, $floors);
$context->setContent($view->show());
}
示例10: execute
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 RLC applications.');
}
PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
PHPWS_Core::initModClass('hms', 'StudentFactory.php');
# Foreach rlc assignment made
# $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
# $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
if ($rlc_id <= 0) {
continue;
}
$app = HMS_RLC_Application::getApplicationById($app_id);
$student = StudentFactory::getStudentByUsername($app->username, $app->term);
# Insert a new assignment in the 'learning_community_assignment' table
$assign = new HMS_RLC_Assignment();
$assign->rlc_id = $rlc_id;
$assign->gender = $student->getGender();
$assign->assigned_by = UserStatus::getUsername();
$assign->application_id = $app->id;
$assign->state = 'new';
$assign->save();
# Log the assignment
PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
}
// Show a success message
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
$context->goBack();
}
示例11: execute
public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php');
PHPWS_Core::initModClass('hms', 'StudentFactory.php');
PHPWS_Core::initModClass('hms', 'HMS_Email.php');
PHPWS_Core::initModClass('hms', 'CheckinFactory.php');
PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
$term = Term::getSelectedTerm();
// Get the total damages assessed for each student
$damages = RoomDamageFactory::getAssessedDamagesStudentTotals($term);
foreach ($damages as $dmg) {
$student = StudentFactory::getStudentByBannerId($dmg['banner_id'], $term);
// Get the student's last checkout
// (NB: the damages may be for multiple check-outs,
// but we'll just take the last one)
$checkout = CheckinFactory::getLastCheckoutForStudent($student);
$bed = new HMS_Bed($checkout->getBedId());
$room = $bed->get_parent();
$floor = $room->get_parent();
$hall = $floor->get_parent();
$coordinators = $hall->getCoordinators();
if ($coordinators != null) {
$coordinatorName = $coordinators[0]->getDisplayName();
$coordinatorEmail = $coordinators[0]->getEmail();
} else {
$coordinatorName = '(No coordinator set for this hall.)';
$coordinatorEmail = '(No coordinator set for this hall.)';
}
HMS_Email::sendDamageNotification($student, $term, $dmg['sum'], $coordinatorName, $coordinatorEmail);
}
// Show a success message and redirect back to the main admin menu
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Room damage noties sent.');
$cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
$cmd->redirect();
}
示例12: execute
public function execute(CommandContext $context)
{
NQ::close();
header('HTTP/1.1 303 See Other');
header("Location: {$_SERVER['SCRIPT_NAME']}?module=controlpanel");
HMS::quit();
}
示例13: getPagerTags
/**
* Generates the activity log table
*/
public function getPagerTags()
{
PHPWS_Core::initModClass('hms', 'StudentFactory.php');
$tpl = array();
try {
$student = StudentFactory::getStudentByUsername($this->get_user_id(), Term::getSelectedTerm());
} catch (StudentNotFoundException $e) {
NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for student: {$this->get_user_id()}");
$student = null;
}
if (is_null($student)) {
$tpl['ACTEE'] = 'UNKNOWN';
} else {
$tpl['ACTEE'] = $student->getProfileLink();
}
if (strcmp($this->get_user_id(), $this->get_actor()) == 0) {
$tpl['ACTOR'] = NULL;
} else {
$tpl['ACTOR'] = $this->get_actor();
}
$time = $this->get_timestamp();
$tpl['DATE'] = date('j M Y', $time);
$tpl['TIME'] = date('g:i a', $time);
$tpl['ACTIVITY'] = $this->get_text_activity();
$notes = $this->get_notes();
if (!is_null($notes)) {
$tpl['NOTES'] = $notes;
}
return $tpl;
}
示例14: execute
/**
* Exec
*
* @param CommandContext $context
* @throws InvalidArgumentExection
*/
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'reports')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do no have permission to run reports.');
}
$reportId = $context->get('reportId');
if (!isset($reportId) || is_null($reportId)) {
throw new InvalidArgumentExection('Missing report id.');
}
// Instantiate the report controller with the requested report id
PHPWS_Core::initModClass('hms', 'ReportFactory.php');
$report = ReportFactory::getReportById($reportId);
// Check to make sure the file exists
if (!file_exists($report->getCsvOutputFilename())) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
$reportCmd = CommandFactory::getCommand('ShowReportDetail');
$reportCmd->setReportClass($report->getClass());
$reportCmd->redirect();
}
$pdf = file_get_contents($report->getCsvOutputFilename());
// Hoepfully force the browser to open a 'save as' dialogue
header('Content-Type: text/csv');
header('Cache-Control: public, must-revalidate, max-age=0');
// HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen($pdf));
header('Content-Disposition: attachment; filename="' . basename($report->getCsvOutputFilename()) . '";');
echo $pdf;
exit;
}
示例15: execute
public function execute(CommandContext $context)
{
// Check permissions
if (!Current_User::allow('hms', 'checkin')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to checkin students.');
}
PHPWS_Core::initModClass('hms', 'StudentFactory.php');
PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
$bannerId = $context->get('banner_id');
$hallId = $context->get('residence_hall_hidden');
$errorCmd = CommandFactory::getCommand('ShowCheckoutStart');
// TODO
if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.');
$errorCmd->redirect();
}
if (!isset($hallId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.');
$errorCmd->redirect();
}
// Everything checks out, so redirect to the form
$cmd = CommandFactory::getCommand('ShowCheckoutForm');
// TODO
$cmd->setBannerId($bannerId);
$cmd->setHallId($hallId);
$cmd->redirect();
}