3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | 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. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Upgrade_TwoOne_Form_Step2
extends CRM_Upgrade_Form
{
37 * @param $errorMessage
41 function verifyPreDBState(&$errorMessage) {
42 $errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '2'));
44 return $this->checkVersion('2.01');
48 $currentDir = dirname(__FILE__
);
50 // 1. remove domain_ids from the entire db
51 $sqlFile = implode(DIRECTORY_SEPARATOR
,
52 array($currentDir, '../sql', 'group_values.mysql')
54 $this->source($sqlFile);
56 // 2. Add option group "safe_file_extension" and its option
57 // values to db, if not already present. CRM-3238
59 SELECT id FROM civicrm_option_group WHERE name = 'safe_file_extension'";
60 $sfeGroup = CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
62 if (!isset($sfeGroup->id
)) {
64 INSERT INTO civicrm_option_group (name, description, is_reserved, is_active)
65 VALUES ('safe_file_extension', 'Safe File Extension', 0, 1)";
66 $dao = CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
69 SELECT id FROM civicrm_option_group WHERE name = 'safe_file_extension'";
70 $dao = CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
74 INSERT INTO `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`)
76 ( %1, 'jpg', 1, NULL, NULL, 0, 0, 1, NULL, 0, 0, 1, NULL),
77 ( %1, 'jpeg', 2, NULL, NULL, 0, 0, 2, NULL, 0, 0, 1, NULL),
78 ( %1, 'png', 3, NULL, NULL, 0, 0, 3, NULL, 0, 0, 1, NULL),
79 ( %1, 'gif', 4, NULL, NULL, 0, 0, 4, NULL, 0, 0, 1, NULL),
80 ( %1, 'txt', 5, NULL, NULL, 0, 0, 5, NULL, 0, 0, 1, NULL),
81 ( %1, 'pdf', 6, NULL, NULL, 0, 0, 6, NULL, 0, 0, 1, NULL),
82 ( %1, 'doc', 7, NULL, NULL, 0, 0, 7, NULL, 0, 0, 1, NULL),
83 ( %1, 'xls', 8, NULL, NULL, 0, 0, 8, NULL, 0, 0, 1, NULL),
84 ( %1, 'rtf', 9, NULL, NULL, 0, 0, 9, NULL, 0, 0, 1, NULL),
85 ( %1, 'csv', 10, NULL, NULL, 0, 0, 10, NULL, 0, 0, 1, NULL),
86 ( %1, 'ppt', 11, NULL, NULL, 0, 0, 11, NULL, 0, 0, 1, NULL)
88 $params = array(1 => array($dao->id
, 'Integer'));
89 $dao = CRM_Core_DAO
::executeQuery($query, $params);
94 //delete records from db.
98 FROM `civicrm_option_value`
99 WHERE `option_group_id` = %1
100 AND `label` IN ('html', 'htm')
102 $params = array(1 => array($sfeGroup->id
, 'Integer'));
103 $dao = CRM_Core_DAO
::executeQuery($query, $params);
106 $this->setVersion('2.02');
110 * @param $errorMessage
114 function verifyPostDBState(&$errorMessage) {
115 // check if Option Group & Option Values tables exists
116 if (!CRM_Core_DAO
::checkTableExists('civicrm_option_group') ||
117 !CRM_Core_DAO
::checkTableExists('civicrm_option_value')
119 $errorMessage .= ' option group or option value table is missing.';
122 // check fields which MUST be present civicrm_option_group & civicrm_option_value
123 if (!CRM_Core_DAO
::checkFieldExists('civicrm_option_group', 'id') ||
124 !CRM_Core_DAO
::checkFieldExists('civicrm_option_group', 'name') ||
125 !CRM_Core_DAO
::checkFieldExists('civicrm_option_group', 'label') ||
126 !CRM_Core_DAO
::checkFieldExists('civicrm_option_group', 'description') ||
127 !CRM_Core_DAO
::checkFieldExists('civicrm_option_group', 'is_reserved') ||
128 !CRM_Core_DAO
::checkFieldExists('civicrm_option_group', 'is_active')
130 $errorMessage .= ' Few important fields were found missing in civicrm_option_group table.';
133 if (!CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'id') ||
134 !CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'option_group_id') ||
135 !CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'name') ||
136 !CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'label') ||
137 !CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'description') ||
138 !CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'component_id') ||
139 !CRM_Core_DAO
::checkFieldExists('civicrm_option_value', 'is_active')
141 $errorMessage .= ' Few important fields were found missing in civicrm_option_value table.';
144 $errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '1'));
146 return $this->checkVersion('2.02');
152 function getTitle() {
153 return ts('CiviCRM 2.1 Upgrade: Step Two (Option Group And Values)');
159 function getTemplateMessage() {
160 return '<p>' . ts('Step Two will upgrade the Option Group And Values in your database.') . '</p>';
166 function getButtonTitle() {
167 return ts('Upgrade & Continue');