</div> <!-- #content --> <?php include ROOT_PATH . "views/footer.php"; ?> </div> <!-- #wrapper<!-- #content --> <input type="hidden" id="userId" value="<?php echo $user->getId(); ?> "/> <input type="hidden" id="domainName" value="<?php echo App::getDomainName(); ?> "/> <?php include ROOT_PATH . "views/assets/footer_common.php"; ?> <script src="<?php echo BASE_URL; ?> assets/js/plugins/autosize/jquery.autosize.min.js"></script> <script src="<?php echo BASE_URL; ?> assets/js/plugins/textarea-counter/jquery.textarea-counter.js"></script>
public static function sendRecover($email) { User::validateExistingEmail($email, UserFetcher::DB_TABLE); $user = UserFetcher::retrieveUsingEmail($email); if ($user[UserFetcher::DB_COLUMN_ACTIVE] != 1) { throw new Exception("Sorry, you account has been de-activated."); } $userId = $user[UserFetcher::DB_COLUMN_ID]; $receiverName = $user[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $user[UserFetcher::DB_COLUMN_LAST_NAME]; $genString = User::generateNewPasswordString($userId); # First, instantiate the SDK with your API credentials and define your domain. $mg = new Mailgun(App::getMailgunKey()); $domain = App::getMailgunDomain(); // Load mail template $emailVerificationTemplate = file_get_contents(ROOT_PATH . 'mail/templates/verify_recovery.html'); $verifyAccountRecoveryLink = App::getDomainName() . "/login/set/" . $userId . "/" . $genString; try { # Now, compose and send the message. $mg->sendMessage($domain, ['from' => "SASS App admin@" . App::getHostname(), 'to' => $email, 'subject' => 'SASS Account Recovery', 'text' => 'Your mail does not support html', 'html' => $emailVerificationTemplate, 'recipient-variables' => '{"' . $email . '": {"id":' . $userId . ',"verifyAccountRecoveryLink":"' . $verifyAccountRecoveryLink . '","fullName":"' . $receiverName . '"}}']); } catch (Exception $e) { throw new Exception("Sorry, we could not send your recovery email. Please contact the secretariat at your earliest\n\t\t\tconvenience or submit a bug issue <a href='" . App::getGithubNewIssueUrl() . "' target='_blank'>here</a>."); } }
public static function recoverPassword($id, $newPassword1, $newPassword2, $generatedString) { if (strcmp($newPassword1, $newPassword2) !== 0) { throw new Exception("There was a mismatch with the new passwords"); } User::validatePassword($newPassword1); if (!UserFetcher::generatedStringExists($id, $generatedString)) { throw new Exception("Could not verify generated string exists. Please make sure url sent was not modified."); } if (User::isGeneratedStringExpired($id, $generatedString)) { throw new Exception("Sorry that link has expired. Please <a href='" . App::getDomainName() . "/login/confirm-password'\n\t\t\t\t\t\t\ttarget='_self'>request</a> a new one"); } UserFetcher::updatePassword($id, $newPassword1); }
/** * @param $startTerm * @param $endTerm * @param $weekStart * @param $dayOfWeek * @param $workingHour * @param $workingHoursJSON * @return array */ function generateDay($startTerm, $endTerm, $weekStart, $dayOfWeek, $workingHour) { $dayScheduleStart = new DateTime($workingHour[ScheduleFetcher::DB_COLUMN_START_TIME]); $dayScheduleEnd = new DateTime($workingHour[ScheduleFetcher::DB_COLUMN_END_TIME]); $dayScheduleYearStart = $startTerm->format("Y"); $dayScheduleYearEnd = $endTerm->format("Y"); $dayScheduleStart->setISODate($dayScheduleYearStart, $weekStart, $dayOfWeek); $dayScheduleEnd->setISODate($dayScheduleYearEnd, $weekStart, $dayOfWeek); $tutorName = $workingHour[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $workingHour[UserFetcher::DB_COLUMN_LAST_NAME]; $tutorsUrl = App::getDomainName() . "/staff/edit/" . $workingHour[UserFetcher::DB_TABLE . "_" . UserFetcher::DB_COLUMN_ID]; return array('title' => $tutorName, 'start' => $dayScheduleStart->format('Y-m-d H:i:s'), 'end' => $dayScheduleEnd->format('Y-m-d H:i:s'), 'allDay' => false, 'url' => $tutorsUrl, 'color' => '#f0ad4e'); }
public static function getAppointmentsForCourseAndTutor($tutorId, $courseId, $termId) { Tutor::validateId($tutorId); Term::validateId($termId); $appointmentHours = AppointmentFetcher::getAppointmentsForTutorAndCourse($tutorId, $courseId, $termId); $appointmentHoursJSON = []; foreach ($appointmentHours as $appointmentHour) { $appointmentTitle = $appointmentHour[CourseFetcher::DB_COLUMN_CODE] . " - " . $appointmentHour[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $appointmentHour[UserFetcher::DB_COLUMN_LAST_NAME]; $students = AppointmentHasStudentFetcher::retrieveStudentsWithAppointment($appointmentHour[AppointmentFetcher::DB_COLUMN_ID]); $appointmentTitle .= " - "; foreach ($students as $student) { $appointmentTitle .= $student[StudentFetcher::DB_TABLE . "_" . StudentFetcher::DB_COLUMN_FIRST_NAME] . " " . $student[StudentFetcher::DB_TABLE . "_" . StudentFetcher::DB_COLUMN_LAST_NAME] . ", "; } $appointmentTitle = rtrim($appointmentTitle, ", "); $startDate = new DateTime($appointmentHour[AppointmentFetcher::DB_COLUMN_START_TIME]); $endDate = new DateTime($appointmentHour[AppointmentFetcher::DB_COLUMN_END_TIME]); $appointmentUrl = App::getDomainName() . "/appointments/" . $appointmentHour[UserFetcher::DB_COLUMN_ID]; switch ($appointmentHour[AppointmentFetcher::DB_COLUMN_LABEL_COLOR]) { case Appointment::LABEL_COLOR_PENDING: $color = '#888888'; break; case Appointment::LABEL_COLOR_CANCELED: $color = '#e5412d'; break; case Appointment::LABEL_COLOR_SUCCESS: $color = '#3fa67a'; break; case Appointment::LABEL_COLOR_WARNING: $color = '#f0ad4e'; break; default: $color = '#444'; break; } $appointmentHoursJSON[] = ['title' => $appointmentTitle, 'start' => $startDate->format('Y-m-d H:i:s'), 'end' => $endDate->format('Y-m-d H:i:s'), 'allDay' => false, 'url' => $appointmentUrl, 'color' => $color]; } return json_encode($appointmentHoursJSON); }