SmsPlugin.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class SmsPlugin.
  5. *
  6. * @author Julio Montoya
  7. */
  8. class SmsPlugin extends Plugin
  9. {
  10. const WELCOME_LOGIN_PASSWORD = 0;
  11. const NEW_FILE_SHARED_COURSE_BY = 1;
  12. const ACCOUNT_APPROVED_CONNECT = 2;
  13. const NEW_COURSE_BEEN_CREATED = 3;
  14. const NEW_USER_SUBSCRIBED_COURSE = 4;
  15. const NEW_COURSE_SUGGESTED_TEACHER = 5;
  16. const COURSE_OPENING_REQUEST_CODE_REGISTERED = 6;
  17. const COURSE_OPENING_REQUEST_CODE_APPROVED = 7;
  18. const COURSE_OPENING_REQUEST_CODE_REJECTED = 8;
  19. const COURSE_OPENING_REQUEST_CODE = 9;
  20. const BEEN_SUBSCRIBED_COURSE = 10;
  21. const ASSIGNMENT_BEEN_CREATED_COURSE = 11;
  22. const ACCOUNT_CREATED_UPDATED_LOGIN_PASSWORD = 12;
  23. const PASSWORD_UPDATED_LOGIN_PASSWORD = 13;
  24. const REQUESTED_PASSWORD_CHANGE = 14;
  25. const RECEIVED_NEW_PERSONAL_MESSAGES = 15;
  26. const NEW_USER_PENDING_APPROVAL = 16;
  27. const POSTED_FORUM_COURSE = 17;
  28. const CHECK_EMAIL_CONNECT_MORE_INFO = 18;
  29. const STUDENT_ANSWERED_TEST = 19;
  30. const STUDENT_ANSWERED_TEST_OPEN_QUESTION = 20;
  31. const STUDENT_ANSWERED_TEST_VOICE_QUESTION = 21;
  32. const ANSWER_OPEN_QUESTION_TEST_REVIEWED = 22;
  33. const NEW_THREAD_STARTED_FORUM = 23;
  34. const NEW_ANSWER_POSTED_FORUM = 24;
  35. const NEW_SYSTEM_ANNOUNCEMENT_ADDED = 25;
  36. const TEST_NEW_SYSTEM_ANNOUNCEMENT_ADDED = 26;
  37. const SYSTEM_ANNOUNCEMENT_UPDATE = 27;
  38. const TEST_SYSTEM_ANNOUNCEMENT_UPDATE = 28;
  39. const USER_UPLOADED_ASSIGNMENT_COURSE_STUDENT_SUBMITS_PAPER = 29;
  40. const USER_UPLOADED_ASSIGNMENT_CHECK_STUDENT_SUBMITS_PAPER = 30;
  41. const USER_UPLOADED_ASSIGNMENT_COURSE = 31;
  42. const USER_UPLOADED_ASSIGNMENT_CHECK = 32;
  43. const SUBSCRIBED_SESSION = 33;
  44. const SUBSCRIBED_SESSION_CSV = 34;
  45. const USER_SUGGESTED_BE_FRIENDS = 35;
  46. const USER_ANSWERED_INBOX_MESSAGE = 36;
  47. const BEEN_INVITED_JOIN_GROUP = 37;
  48. const MESSAGES_SENT_EDITED_GROUP_EDITED = 38;
  49. const MESSAGES_SENT_EDITED_GROUP_ADDED = 39;
  50. const BEEN_INVITED_COMPLETE_SURVEY_COURSE = 40;
  51. const REMINDER_ASSIGNMENT_COURSE_DUE = 41;
  52. const USER_DETAILS_MODIFIED = 42;
  53. const CERTIFICATE_NOTIFICATION = 43;
  54. public $isCoursePlugin = true;
  55. public $isMailPlugin = true;
  56. /**
  57. * getSmsTypeOptions (returns all SMS types).
  58. *
  59. * @return array SMS types
  60. */
  61. public function getSmsTypeOptions()
  62. {
  63. return [
  64. 'MessageWelcomeXLoginXPasswordX',
  65. 'MessageXNewFileSharedCourseXByX',
  66. 'MessageXAccountApprovedConnectX',
  67. 'MessageXNewCourseXBeenCreatedX',
  68. 'MessageXNewUserXSubscribedCourseX',
  69. 'MessageXNewCourseSuggestedTeacherX',
  70. 'MessageXCourseOpeningRequestCodeXRegistered',
  71. 'MessageXCourseOpeningRequestCourseCodeXApproved',
  72. 'MessageXRequestOpenCourseCodeXReject',
  73. 'MessageXCourseOpeningRequestCourseCodeX',
  74. 'MessageXBeenSubscribedCourseX',
  75. 'MessageXAssignmentBeenCreatedCourseX',
  76. 'MessageXAccountCreatedUpdatedLoginXPasswordX',
  77. 'MessageXPasswordUpdatedLoginXPasswordX',
  78. 'MessageXRequestedPasswordChange',
  79. 'MessageXReceivedNewPersonalMessages',
  80. 'MessageXNewUserXPendingApproval',
  81. 'MessageXXPostedForumXCourseX',
  82. 'MessageXXXCheckEmailConnectMoreInfo',
  83. 'MessageXXStudentXAnsweredTestX',
  84. 'MessageXXStudentXAnsweredTestXOpenQuestion',
  85. 'MessageXXStudentXAnsweredTestXVoiceQuestion',
  86. 'MessageXXAnswerOpenQuestionTestXReviewed',
  87. 'MessageXXNewThreadXStartedForumX',
  88. 'MessageXXNewAnswerPostedXForumX',
  89. 'MessageXXNewSystemAnnouncementAdded',
  90. 'MessageXTestXNewSystemAnnouncementAdded',
  91. 'MessageXXSystemAnnouncementUpdate',
  92. 'MessageXTestXSystemAnnouncementUpdate',
  93. 'MessageXUserXUploadedAssignmentXCourseXStudentSubmitsPaper',
  94. 'MessageXUserXUploadedAssignmentXCheckXStudentSubmitsPaper',
  95. 'MessageXUserXUploadedAssignmentXCourseX',
  96. 'MessageXUserXUploadedAssignmentXCheckX',
  97. 'MessageXSubscribedSessionX',
  98. 'MessageXSubscribedSessionXCSV',
  99. 'MessageXUserXSuggestedBeFriends',
  100. 'MessageXUserXAnsweredInboxMessage',
  101. 'MessageXBeenInvitedJoinGroupX',
  102. 'MessageXMessagesSentEditedGroupXEdited',
  103. 'MessageXMessagesSentEditedGroupXAdded',
  104. 'MessageXBeenInvitedCompleteSurveyXCourseX',
  105. 'MessageXReminderAssignmentXCourseXDue',
  106. 'MessageXUserDetailsModified',
  107. ];
  108. }
  109. /**
  110. * install (installs the plugin).
  111. */
  112. public function install()
  113. {
  114. $this->addMobilePhoneNumberField();
  115. }
  116. /**
  117. * addMobilePhoneNumberField (adds a mobile phone number field if it is not
  118. * already created).
  119. */
  120. private function addMobilePhoneNumberField()
  121. {
  122. $extraField = new ExtraField('user');
  123. $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable('mobile_phone_number');
  124. if (empty($extraFieldInfo)) {
  125. $extraField->save([
  126. 'field_type' => 1,
  127. 'variable' => 'mobile_phone_number',
  128. 'display_text' => $this->get_lang('mobile_phone_number'),
  129. 'default_value' => null,
  130. 'field_order' => 2,
  131. 'visible' => 1,
  132. 'changeable' => 1,
  133. 'filter' => null,
  134. ]);
  135. }
  136. }
  137. }