395e3437eb7a7d06409696dab94213e76e29eb91
[civicrm-core.git] / CRM / Upgrade / TwoOne / Form / Step4.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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_TwoOne_Form_Step4 extends CRM_Upgrade_Form {
36 function verifyPreDBState(&$errorMessage) {
37 $errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '2'));
38
39 if (!CRM_Core_DAO::checkTableExists('civicrm_cache') ||
40 !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') ||
41 !CRM_Core_DAO::checkTableExists('civicrm_menu') ||
42 !CRM_Core_DAO::checkTableExists('civicrm_discount') ||
43 !CRM_Core_DAO::checkTableExists('civicrm_pledge') ||
44 !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') ||
45 !CRM_Core_DAO::checkTableExists('civicrm_pledge_payment')
46 ) {
47 return FALSE;
48 }
49
50 // check fields which MUST be present if a proper 2.1 db
51 if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') ||
52 !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') ||
53 !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') ||
54 !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') ||
55 !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') ||
56 !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') ||
57 !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') ||
58 !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') ||
59 !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type') ||
60 !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') ||
61 !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') ||
62 !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name')
63 ) {
64 // db looks to have stuck somewhere between 2.0 & 2.1
65 $errorMessage .= ' Few important fields were found missing in some of the tables.';
66 return FALSE;
67 }
68 if ($this->checkVersion('2.03')) {
69 $this->setVersion($this->latestVersion);
70 }
71 else {
72 return FALSE;
73 }
74
75 return $this->checkVersion($this->latestVersion);
76 }
77
78 function buildQuickForm() {}
79
80 function getTitle() {
81 return ts('Database Upgrade to v2.1 Completed');
82 }
83
84 function getTemplateMessage() {
85 if ($this->_config->userSystem->is_drupal) {
86 $upgradeDoc = 'http://wiki.civicrm.org/confluence/x/7IFH';
87 }
88 else {
89 $upgradeDoc = 'http://wiki.civicrm.org/confluence/x/SoJH';
90 }
91 return '<p><strong>' . ts('Your CiviCRM database has been successfully upgraded to v2.1.') . '</strong></p><p>' . ts('Please be sure to follow the remaining steps in the <a href=\'%1\' target=\'_blank\'><strong>Upgrade Instructions</strong></a>.', array(
92 1 => $upgradeDoc)) . '</p><p>' . ts('Thank you for using CiviCRM.') . '</p>';
93 }
94 }
95