engagements.install
Search API
File
modules/engagements/engagements.installView source
- <?php
-
- /**
- * This file should contain only hooks relating to installing, enabling, disabling, and uninstalling this module.
- *
- */
-
-
- /**
- * Hook install. Called when the module is installed on the admin modules page.
- *
- */
- function engagements_install() {
-
- $q = "
- CREATE TABLE `content__engagement` (
- `cid` int(10) unsigned NOT NULL,
- `vid` int(10) unsigned NOT NULL,
- `field__student_id` varchar(255) DEFAULT NULL,
- `field__faculty_id` varchar(255) DEFAULT NULL,
- `field__engagement_type` varchar(255) DEFAULT NULL,
- `field__engagement_msg` longtext DEFAULT NULL,
- `field__direction` varchar(255) DEFAULT NULL,
- `field__phone_outcome` varchar(255) DEFAULT NULL,
- `field__activity_datetime` datetime DEFAULT NULL,
- `field__visibility` varchar(255) DEFAULT NULL,
- `field__attachment` varchar(255) DEFAULT NULL,
- `field__manual_entry` varchar(10) DEFAULT NULL,
- `field__from_sms_phone` varchar(255) DEFAULT NULL,
- `field__to_sms_phone` varchar(255) DEFAULT NULL,
- `field__external_msg_id` varchar(255) DEFAULT NULL,
- PRIMARY KEY (`vid`),
- KEY `cid` (`cid`),
- KEY `field__student_id` (`field__student_id`),
- KEY `field__faculty_id` (`field__faculty_id`),
- KEY `field__engagement_type` (`field__engagement_type`),
- KEY `field__direction` (`field__direction`),
- KEY `field__phone_outcome` (`field__phone_outcome`),
- KEY `field__activity_datetime` (`field__activity_datetime`),
- KEY `field__visibility` (`field__visibility`),
- KEY `field__attachment` (`field__attachment`),
- KEY `field__from_sms_phone` (`field__from_sms_phone`),
- KEY `field__to_sms_phone` (`field__to_sms_phone`),
- KEY `field__external_msg_id` (`field__external_msg_id`),
- KEY `field__manual_entry` (`field__manual_entry`)
- );
- ";
- db_query($q);
-
-
- $q = "
- CREATE TABLE `engagements_tracking` (
- `cid` INT ( 11 ) NOT NULL,
- `token` VARCHAR ( 255 ) DEFAULT NULL,
- `opens` INT ( 10 ) UNSIGNED DEFAULT NULL,
- `updated` INT ( 10 ) UNSIGNED DEFAULT NULL,
- PRIMARY KEY ( `cid` ),
- KEY `opens` ( `opens` ),
- KEY `updated` ( `updated` ),
- KEY `token` ( `token` )
- );
- ";
- db_query($q);
-
-
- $q = "
- CREATE TABLE `sms_history` (
- `mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `message_sid` varchar(255) DEFAULT NULL,
- `sw_type` varchar(255) DEFAULT NULL,
- `body` longtext DEFAULT NULL,
- `num_segments` tinyint(4) DEFAULT 0,
- `direction` varchar(255) DEFAULT NULL,
- `from_number` varchar(255) DEFAULT NULL,
- `to_number` varchar(255) DEFAULT NULL,
- `sw_price` decimal(15,10) DEFAULT NULL,
- `fp_price` decimal(15,10) DEFAULT NULL,
- `to_cwid` varchar(30) DEFAULT NULL,
- `from_cwid` varchar(30) DEFAULT NULL,
- `media_filenames` longtext DEFAULT '',
- `date_sent` int(10) unsigned DEFAULT NULL,
- `updated` int(10) unsigned DEFAULT NULL,
- `price_processed` tinyint(3) unsigned DEFAULT 0,
- `delivery_status` varchar(255) DEFAULT NULL,
- `err_code` varchar(255) DEFAULT NULL,
- `err_message` varchar(255) DEFAULT NULL,
- `err_friendly_message` varchar(255) DEFAULT NULL,
- PRIMARY KEY (`mid`),
- KEY `from_number` (`from_number`),
- KEY `to_number` (`to_number`),
- KEY `sw_price` (`sw_price`),
- KEY `fp_price` (`fp_price`),
- KEY `updated` (`updated`),
- KEY `cwid` (`to_cwid`),
- KEY `direction` (`direction`),
- KEY `date_sent` (`date_sent`),
- KEY `from_cwid` (`from_cwid`),
- KEY `message_sid` (`message_sid`),
- KEY `num_segements` (`num_segments`),
- KEY `delivery_status` (`delivery_status`),
- KEY `err_code` (`err_code`),
- KEY `sw_type` (`sw_type`)
- );
- ";
- db_query($q);
-
-
- $q = "
- CREATE TABLE `sms_do_not_txt` (
- `mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `user_id` int(10) unsigned DEFAULT NULL,
- `cwid` varchar(30) DEFAULT NULL,
- `phone_number` varchar(255) DEFAULT NULL,
- `prev_notification_method` varchar(255) DEFAULT NULL,
- `updated` int(10) unsigned DEFAULT NULL,
- PRIMARY KEY (`mid`),
- KEY `phone_number` (`phone_number`),
- KEY `updated` (`updated`),
- KEY `cwid` (`cwid`),
- KEY `user_id` (`user_id`),
- KEY `prev_notification_method` (`prev_notification_method`)
- );
- ";
- db_query($q);
-
-
-
-
- }
-
-
-
- function engagements_update($old_schema, $new_schema) {
-
- if (intval($old_schema) < 2) {
- // Convert text fields to longtext.
- db_query("ALTER TABLE content__engagement MODIFY field__engagement_msg LONGTEXT");
-
- db_query("ALTER TABLE sms_history MODIFY `body` LONGTEXT");
- db_query("ALTER TABLE sms_history MODIFY `media_filenames` LONGTEXT");
-
-
- fpm("Altered engagements tables to use LONGTEXT instead of just TEXT.");
-
- }
-
-
- if (intval($old_schema) < 3) {
- // Add new fields to content__engagement table.
-
- db_query("ALTER TABLE content__engagement ADD COLUMN `field__from_sms_phone` varchar(255) DEFAULT NULL ");
- db_query("ALTER TABLE content__engagement ADD COLUMN `field__external_msg_id` varchar(255) DEFAULT NULL ");
-
- db_query("ALTER TABLE content__engagement ADD INDEX (`field__from_sms_phone`) ");
- db_query("ALTER TABLE content__engagement ADD INDEX (`field__external_msg_id`) ");
-
- }
-
-
- if (intval($old_schema) < 4) {
- $q = "
- CREATE TABLE `sms_do_not_txt` (
- `mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `user_id` int(10) unsigned DEFAULT NULL,
- `cwid` varchar(30) DEFAULT NULL,
- `phone_number` varchar(255) DEFAULT NULL,
- `prev_notification_method` varchar(255) DEFAULT NULL,
- `updated` int(10) unsigned DEFAULT NULL,
- PRIMARY KEY (`mid`),
- KEY `phone_number` (`phone_number`),
- KEY `updated` (`updated`),
- KEY `cwid` (`cwid`),
- KEY `user_id` (`user_id`),
- KEY `prev_notification_method` (`prev_notification_method`)
- );
- ";
- db_query($q);
- }
-
-
- if (intval($old_schema) < 5) {
-
- db_query("ALTER TABLE sms_history ADD COLUMN `delivery_status` varchar(255) DEFAULT NULL ");
- db_query("ALTER TABLE sms_history ADD COLUMN `err_code` varchar(255) DEFAULT NULL ");
- db_query("ALTER TABLE sms_history ADD COLUMN `err_message` varchar(255) DEFAULT NULL ");
- db_query("ALTER TABLE sms_history ADD COLUMN `err_friendly_message` varchar(255) DEFAULT NULL ");
-
- db_query("ALTER TABLE sms_history ADD INDEX (`delivery_status`) ");
- db_query("ALTER TABLE sms_history ADD INDEX (`err_code`) ");
-
-
- }
-
-
- if (intval($old_schema < 6)) {
-
- db_query("ALTER TABLE content__engagement ADD COLUMN `field__to_sms_phone` varchar(255) DEFAULT NULL ");
-
- db_query("ALTER TABLE content__engagement ADD INDEX (`field__to_sms_phone`) ");
-
-
- }
-
-
-
-
- } // hook_update
-
-
-
-
-
-
-
-
-
-
-
-
Functions
Name | Description |
---|---|
engagements_install | Hook install. Called when the module is installed on the admin modules page. |
engagements_update |