engagements.install

  1. 7.x modules/engagements/engagements.install
  2. 6.x modules/engagements/engagements.install

File

modules/engagements/engagements.install
View source
  1. <?php
  2. /**
  3. * This file should contain only hooks relating to installing, enabling, disabling, and uninstalling this module.
  4. *
  5. */
  6. /**
  7. * Hook install. Called when the module is installed on the admin modules page.
  8. *
  9. */
  10. function engagements_install() {
  11. $q = "
  12. CREATE TABLE `content__engagement` (
  13. `cid` int(10) unsigned NOT NULL,
  14. `vid` int(10) unsigned NOT NULL,
  15. `field__student_id` varchar(255) DEFAULT NULL,
  16. `field__faculty_id` varchar(255) DEFAULT NULL,
  17. `field__engagement_type` varchar(255) DEFAULT NULL,
  18. `field__engagement_msg` longtext DEFAULT NULL,
  19. `field__direction` varchar(255) DEFAULT NULL,
  20. `field__phone_outcome` varchar(255) DEFAULT NULL,
  21. `field__activity_datetime` datetime DEFAULT NULL,
  22. `field__visibility` varchar(255) DEFAULT NULL,
  23. `field__attachment` varchar(255) DEFAULT NULL,
  24. `field__manual_entry` varchar(10) DEFAULT NULL,
  25. `field__from_sms_phone` varchar(255) DEFAULT NULL,
  26. `field__to_sms_phone` varchar(255) DEFAULT NULL,
  27. `field__external_msg_id` varchar(255) DEFAULT NULL,
  28. PRIMARY KEY (`vid`),
  29. KEY `cid` (`cid`),
  30. KEY `field__student_id` (`field__student_id`),
  31. KEY `field__faculty_id` (`field__faculty_id`),
  32. KEY `field__engagement_type` (`field__engagement_type`),
  33. KEY `field__direction` (`field__direction`),
  34. KEY `field__phone_outcome` (`field__phone_outcome`),
  35. KEY `field__activity_datetime` (`field__activity_datetime`),
  36. KEY `field__visibility` (`field__visibility`),
  37. KEY `field__attachment` (`field__attachment`),
  38. KEY `field__from_sms_phone` (`field__from_sms_phone`),
  39. KEY `field__to_sms_phone` (`field__to_sms_phone`),
  40. KEY `field__external_msg_id` (`field__external_msg_id`),
  41. KEY `field__manual_entry` (`field__manual_entry`)
  42. );
  43. ";
  44. db_query($q);
  45. $q = "
  46. CREATE TABLE `engagements_tracking` (
  47. `cid` INT ( 11 ) NOT NULL,
  48. `token` VARCHAR ( 255 ) DEFAULT NULL,
  49. `opens` INT ( 10 ) UNSIGNED DEFAULT NULL,
  50. `updated` INT ( 10 ) UNSIGNED DEFAULT NULL,
  51. PRIMARY KEY ( `cid` ),
  52. KEY `opens` ( `opens` ),
  53. KEY `updated` ( `updated` ),
  54. KEY `token` ( `token` )
  55. );
  56. ";
  57. db_query($q);
  58. $q = "
  59. CREATE TABLE `sms_history` (
  60. `mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  61. `message_sid` varchar(255) DEFAULT NULL,
  62. `sw_type` varchar(255) DEFAULT NULL,
  63. `body` longtext DEFAULT NULL,
  64. `num_segments` tinyint(4) DEFAULT 0,
  65. `direction` varchar(255) DEFAULT NULL,
  66. `from_number` varchar(255) DEFAULT NULL,
  67. `to_number` varchar(255) DEFAULT NULL,
  68. `sw_price` decimal(15,10) DEFAULT NULL,
  69. `fp_price` decimal(15,10) DEFAULT NULL,
  70. `to_cwid` varchar(30) DEFAULT NULL,
  71. `from_cwid` varchar(30) DEFAULT NULL,
  72. `media_filenames` longtext DEFAULT '',
  73. `date_sent` int(10) unsigned DEFAULT NULL,
  74. `updated` int(10) unsigned DEFAULT NULL,
  75. `price_processed` tinyint(3) unsigned DEFAULT 0,
  76. `delivery_status` varchar(255) DEFAULT NULL,
  77. `err_code` varchar(255) DEFAULT NULL,
  78. `err_message` varchar(255) DEFAULT NULL,
  79. `err_friendly_message` varchar(255) DEFAULT NULL,
  80. PRIMARY KEY (`mid`),
  81. KEY `from_number` (`from_number`),
  82. KEY `to_number` (`to_number`),
  83. KEY `sw_price` (`sw_price`),
  84. KEY `fp_price` (`fp_price`),
  85. KEY `updated` (`updated`),
  86. KEY `cwid` (`to_cwid`),
  87. KEY `direction` (`direction`),
  88. KEY `date_sent` (`date_sent`),
  89. KEY `from_cwid` (`from_cwid`),
  90. KEY `message_sid` (`message_sid`),
  91. KEY `num_segements` (`num_segments`),
  92. KEY `delivery_status` (`delivery_status`),
  93. KEY `err_code` (`err_code`),
  94. KEY `sw_type` (`sw_type`)
  95. );
  96. ";
  97. db_query($q);
  98. $q = "
  99. CREATE TABLE `sms_do_not_txt` (
  100. `mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  101. `user_id` int(10) unsigned DEFAULT NULL,
  102. `cwid` varchar(30) DEFAULT NULL,
  103. `phone_number` varchar(255) DEFAULT NULL,
  104. `prev_notification_method` varchar(255) DEFAULT NULL,
  105. `updated` int(10) unsigned DEFAULT NULL,
  106. PRIMARY KEY (`mid`),
  107. KEY `phone_number` (`phone_number`),
  108. KEY `updated` (`updated`),
  109. KEY `cwid` (`cwid`),
  110. KEY `user_id` (`user_id`),
  111. KEY `prev_notification_method` (`prev_notification_method`)
  112. );
  113. ";
  114. db_query($q);
  115. }
  116. function engagements_update($old_schema, $new_schema) {
  117. if (intval($old_schema) < 2) {
  118. // Convert text fields to longtext.
  119. db_query("ALTER TABLE content__engagement MODIFY field__engagement_msg LONGTEXT");
  120. db_query("ALTER TABLE sms_history MODIFY `body` LONGTEXT");
  121. db_query("ALTER TABLE sms_history MODIFY `media_filenames` LONGTEXT");
  122. fpm("Altered engagements tables to use LONGTEXT instead of just TEXT.");
  123. }
  124. if (intval($old_schema) < 3) {
  125. // Add new fields to content__engagement table.
  126. db_query("ALTER TABLE content__engagement ADD COLUMN `field__from_sms_phone` varchar(255) DEFAULT NULL ");
  127. db_query("ALTER TABLE content__engagement ADD COLUMN `field__external_msg_id` varchar(255) DEFAULT NULL ");
  128. db_query("ALTER TABLE content__engagement ADD INDEX (`field__from_sms_phone`) ");
  129. db_query("ALTER TABLE content__engagement ADD INDEX (`field__external_msg_id`) ");
  130. }
  131. if (intval($old_schema) < 4) {
  132. $q = "
  133. CREATE TABLE `sms_do_not_txt` (
  134. `mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  135. `user_id` int(10) unsigned DEFAULT NULL,
  136. `cwid` varchar(30) DEFAULT NULL,
  137. `phone_number` varchar(255) DEFAULT NULL,
  138. `prev_notification_method` varchar(255) DEFAULT NULL,
  139. `updated` int(10) unsigned DEFAULT NULL,
  140. PRIMARY KEY (`mid`),
  141. KEY `phone_number` (`phone_number`),
  142. KEY `updated` (`updated`),
  143. KEY `cwid` (`cwid`),
  144. KEY `user_id` (`user_id`),
  145. KEY `prev_notification_method` (`prev_notification_method`)
  146. );
  147. ";
  148. db_query($q);
  149. }
  150. if (intval($old_schema) < 5) {
  151. db_query("ALTER TABLE sms_history ADD COLUMN `delivery_status` varchar(255) DEFAULT NULL ");
  152. db_query("ALTER TABLE sms_history ADD COLUMN `err_code` varchar(255) DEFAULT NULL ");
  153. db_query("ALTER TABLE sms_history ADD COLUMN `err_message` varchar(255) DEFAULT NULL ");
  154. db_query("ALTER TABLE sms_history ADD COLUMN `err_friendly_message` varchar(255) DEFAULT NULL ");
  155. db_query("ALTER TABLE sms_history ADD INDEX (`delivery_status`) ");
  156. db_query("ALTER TABLE sms_history ADD INDEX (`err_code`) ");
  157. }
  158. if (intval($old_schema < 6)) {
  159. db_query("ALTER TABLE content__engagement ADD COLUMN `field__to_sms_phone` varchar(255) DEFAULT NULL ");
  160. db_query("ALTER TABLE content__engagement ADD INDEX (`field__to_sms_phone`) ");
  161. }
  162. } // hook_update

Functions

Namesort descending Description
engagements_install Hook install. Called when the module is installed on the admin modules page.
engagements_update