| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM Widget Creation Interface (WCI) Version 1.0 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright Zyxware Technologies (c) 2014 | |
| 7 | +--------------------------------------------------------------------+ |
| 8 | | This file is a part of CiviCRM WCI. | |
| 9 | | | |
| 10 | | CiviCRM WCI is free software; you can copy, modify, and distribute | |
| 11 | | it under the terms of the GNU Affero General Public License | |
| 12 | | Version 3, 19 November 2007. | |
| 13 | | | |
| 14 | | CiviCRM WCI is distributed in the hope that it will be useful, | |
| 15 | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 17 | | See the GNU Affero General Public License for more details. | |
| 18 | | | |
| 19 | | You should have received a copy of the GNU Affero General Public | |
| 20 | | License along with this program; if not, contact Zyxware | |
| 21 | | Technologies at info[AT]zyxware[DOT]com. | |
| 22 | +--------------------------------------------------------------------+ |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * Collection of upgrade steps |
| 27 | */ |
| 28 | class CRM_Wci_Upgrader extends CRM_Wci_Upgrader_Base { |
| 29 | |
| 30 | // By convention, functions that look like "function upgrade_NNNN()" are |
| 31 | // upgrade tasks. They are executed in order (like Drupal's hook_update_N). |
| 32 | |
| 33 | /** |
| 34 | * Example: Run an external SQL script when the module is installed |
| 35 | */ |
| 36 | public function install() { |
| 37 | $this->executeSqlFile('sql/install.sql'); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Example: Run an external SQL script when the module is uninstalled |
| 42 | */ |
| 43 | public function uninstall() { |
| 44 | $this->executeSqlFile('sql/uninstall.sql'); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Example: Run a simple query when a module is enabled |
| 49 | * |
| 50 | public function enable() { |
| 51 | CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"'); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Example: Run a simple query when a module is disabled |
| 56 | * |
| 57 | public function disable() { |
| 58 | CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"'); |
| 59 | } // */ |
| 60 | |
| 61 | /** |
| 62 | * Example: Run a couple simple queries |
| 63 | * |
| 64 | * @return TRUE on success |
| 65 | * @throws Exception |
| 66 | */ |
| 67 | public function upgrade_1000() { |
| 68 | $this->ctx->log->info('Applying update 1000'); |
| 69 | CRM_Core_DAO::executeQuery(' |
| 70 | ALTER TABLE `civicrm_wci_widget` |
| 71 | ADD `show_pb_perc` TINYINT(4) NOT NULL DEFAULT "1" |
| 72 | COMMENT "show pb in percentage or amount" |
| 73 | AFTER `hide_pbcap` |
| 74 | '); |
| 75 | CRM_Core_DAO::executeQuery(' |
| 76 | ALTER TABLE `civicrm_wci_widget` |
| 77 | ADD `color_progress_bar_bg` VARCHAR(10) COLLATE utf8_unicode_ci NOT NULL |
| 78 | COMMENT "Progress bar background color." |
| 79 | AFTER `color_progress_bar` |
| 80 | '); |
| 81 | |
| 82 | return TRUE; |
| 83 | } |
| 84 | |
| 85 | public function upgrade_1001() { |
| 86 | $this->ctx->log->info('Applying update 1001'); |
| 87 | CRM_Core_DAO::executeQuery(' |
| 88 | CREATE TABLE IF NOT EXISTS `civicrm_wci_widget_cache` ( |
| 89 | `widget_id` int(10) unsigned NOT NULL COMMENT "widget id.", |
| 90 | `widget_code` text DEFAULT NULL COMMENT "Widget code.", |
| 91 | `expire` int(10) DEFAULT 0 COMMENT "A Unix timestamp indicating when the cache entry should expire.", |
| 92 | `createdtime` int(10) DEFAULT 0 COMMENT "A Unix timestamp indicating create time.", |
| 93 | PRIMARY KEY (`widget_id`) |
| 94 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; |
| 95 | '); |
| 96 | return TRUE; |
| 97 | } |
| 98 | |
| 99 | } |