SmsPlugin.php 5.4 KB

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