Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. function checkGuardianEmail($emailAddress, $school_id) {
  2.  
  3. // Check to see if emailAddress and school_id exist
  4. if(!$emailAddress || !$school_id) return false;
  5.  
  6. // If so then continue
  7. $school = new school;
  8. $school->loadFrontendForLogin($school_id);
  9.  
  10. // Check to see if school_id exist
  11. if(!$school->id) return false;
  12.  
  13. // If so then continue
  14. $guardian = new guardian;
  15. $guardian->loadAllTotal($school->id);
  16.  
  17. // Loop through guardian records for selected school
  18. foreach($guardian->guardians as $item) {
  19.  
  20. // Check to see if guardian is active
  21. if(!$item->active)continue;
  22.  
  23. // If so then check to see if emailAddress matches database records
  24. if(strtolower($item->email) == strtolower($emailAddress) || strtolower($item->email_2) == strtolower($emailAddress))
  25. {
  26. // Guardians username, password and school
  27. $username = $item->username;
  28. $password = $item->password;
  29.  
  30. // Set body for what is shown in email sent to guardian
  31. $body = "
  32. The following details are to the parent login. We recommend you change your password straight away.
  33.  
  34. Username: $username
  35.  
  36. Password: $password
  37.  
  38. <br>
  39. <br>
  40. ";
  41.  
  42. $email = new email; //initialise and connect. We are keeping the connection open for
  43. $email->connect();
  44.  
  45. $recipients = array($item->email, $item->email_2);
  46.  
  47. $email->schoolTitle = $school->title;
  48. $email->schoolEmail = $school->school_contact->email;
  49. $email->to = implode(',', $recipients);
  50. $email->subject = "School Spider: Forgot Password";
  51. $email->message = $body;
  52.  
  53. return ($email->sendSingle()) ? true : false;
  54. }
  55. }
  56. // else return false
  57. return false;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement