| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.3 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2013 | |
| 7 | +--------------------------------------------------------------------+ |
| 8 | | This file is a part of CiviCRM. | |
| 9 | | | |
| 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. | |
| 13 | | | |
| 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. | |
| 18 | | | |
| 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 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @package CRM |
| 31 | * @copyright CiviCRM LLC (c) 2004-2013 |
| 32 | * $Id$ |
| 33 | * |
| 34 | */ |
| 35 | class CRM_Upgrade_TwoTwo_Form_Step2 extends CRM_Upgrade_Form { |
| 36 | function verifyPreDBState(&$errorMessage) { |
| 37 | $errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '2')); |
| 38 | |
| 39 | return $this->checkVersion('2.1.101'); |
| 40 | } |
| 41 | |
| 42 | function upgrade() { |
| 43 | $sqlFile = implode(DIRECTORY_SEPARATOR, |
| 44 | array( |
| 45 | dirname(__FILE__), '..', '..', |
| 46 | 'Incremental', 'sql', '2.2.alpha1.mysql', |
| 47 | ) |
| 48 | ); |
| 49 | $tplFile = "$sqlFile.tpl"; |
| 50 | |
| 51 | $isMultilingual = FALSE; |
| 52 | if (file_exists($tplFile)) { |
| 53 | $isMultilingual = $this->processLocales($tplFile, '2.2'); |
| 54 | } |
| 55 | else { |
| 56 | if (!file_exists($sqlFile)) { |
| 57 | CRM_Core_Error::fatal("sqlfile - $rev.mysql not found."); |
| 58 | } |
| 59 | $this->source($sqlFile); |
| 60 | } |
| 61 | |
| 62 | if ($isMultilingual) { |
| 63 | $domain = new CRM_Core_DAO_Domain(); |
| 64 | $domain->find(TRUE); |
| 65 | $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); |
| 66 | CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, '2.2'); |
| 67 | } |
| 68 | |
| 69 | $this->setVersion('2.1.102'); |
| 70 | } |
| 71 | |
| 72 | function verifyPostDBState(&$errorMessage) { |
| 73 | // check if civicrm_event_page tables droped |
| 74 | if (CRM_Core_DAO::checkTableExists('civicrm_event_page')) { |
| 75 | $errorMessage .= ' civicrm_event_page table is not droped.'; |
| 76 | return FALSE; |
| 77 | } |
| 78 | // check fields which MUST be present civicrm_event |
| 79 | if (!CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') || |
| 80 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'footer_text') || |
| 81 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_title') || |
| 82 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_text') || |
| 83 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_footer_text') || |
| 84 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_email_confirm') || |
| 85 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_email_text') || |
| 86 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_name') || |
| 87 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_email') || |
| 88 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'cc_confirm') || |
| 89 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'bcc_confirm') || |
| 90 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_fee_id') || |
| 91 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_discount_id') || |
| 92 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_title') || |
| 93 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_text') || |
| 94 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_footer_text') || |
| 95 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_pay_later') || |
| 96 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_text') || |
| 97 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_receipt') || |
| 98 | !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations') |
| 99 | ) { |
| 100 | $errorMessage .= ' Few important fields were found missing in civicrm_event table.'; |
| 101 | return FALSE; |
| 102 | } |
| 103 | |
| 104 | $errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '2')); |
| 105 | |
| 106 | return $this->checkVersion('2.1.102'); |
| 107 | } |
| 108 | |
| 109 | function getTitle() { |
| 110 | return ts('CiviCRM 2.2 Upgrade: Step Two (Merge CiviEvent Tables)'); |
| 111 | } |
| 112 | |
| 113 | function getTemplateMessage() { |
| 114 | return '<p>' . ts('Step Two will merge the table EventPage into Event table in your database.') . '</p>'; |
| 115 | } |
| 116 | |
| 117 | function getButtonTitle() { |
| 118 | return ts('Upgrade & Continue'); |
| 119 | } |
| 120 | } |
| 121 | |