<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
*
*/
class CRM_Upgrade_Form extends CRM_Core_Form {
- CONST QUEUE_NAME = 'CRM_Upgrade';
+ const QUEUE_NAME = 'CRM_Upgrade';
/**
* Minimum size of MySQL's thread_stack option
* Upgrade for multilingual
*
* @var boolean
- * @public
*/
public $multilingual = FALSE;
* Locales available for multilingual upgrade
*
* @var array
- * @public
*/
public $locales;
* Number to string mapper
*
* @var array
- * @public
*/
static $_numberMap = array(
0 => 'Zero',
* We should not use QuickForm directly. This class provides a lot
* of default convenient functions, rules and buttons
*
- * @param object $state State associated with this form
+ * @param object $state
+ * State associated with this form.
* @param \const|\enum $action The mode the form is operating in (None/Create/View/Update/Delete)
- * @param string $method The type of http method used (GET/POST)
- * @param string $name The name of the form if different from class name
+ * @param string $method
+ * The type of http method used (GET/POST).
+ * @param string $name
+ * The name of the form if different from class name.
*
* @return \CRM_Core_Form
@access public
*
* @return mixed
*/
- static function &incrementalPhpObject($version) {
+ public static function &incrementalPhpObject($version) {
static $incrementalPhpObject = array();
$versionParts = explode('.', $version);
*
* @return bool
*/
- function checkVersionRelease($version, $release) {
+ public function checkVersionRelease($version, $release) {
$versionParts = explode('.', $version);
if ($versionParts[2] == $release) {
return TRUE;
*
* @return array
*/
- function checkSQLConstraints(&$constraints) {
+ public function checkSQLConstraints(&$constraints) {
$pass = $fail = 0;
foreach ($constraints as $constraint) {
if ($this->checkSQLConstraint($constraint)) {
*
* @return bool
*/
- function checkSQLConstraint($constraint) {
+ public function checkSQLConstraint($constraint) {
// check constraint here
return TRUE;
}
* @param string $fileName
* @param bool $isQueryString
*/
- function source($fileName, $isQueryString = FALSE) {
+ public function source($fileName, $isQueryString = FALSE) {
CRM_Utils_File::sourceSQLFile($this->_config->dsn,
$fileName, NULL, $isQueryString
);
}
- function preProcess() {
+ public function preProcess() {
CRM_Utils_System::setTitle($this->getTitle());
if (!$this->verifyPreDBState($errorMessage)) {
if (!isset($errorMessage)) {
$this->assign('recentlyViewed', FALSE);
}
- function buildQuickForm() {
+ public function buildQuickForm() {
$this->addDefaultButtons($this->getButtonTitle(),
'next',
NULL,
* Getter function for title. Should be over-ridden by derived class
*
* @return string
- * @access public
*/
/**
* @return string
*/
- function getTitle() {
+ public function getTitle() {
return ts('Title not Set');
}
/**
* @return string
*/
- function getFieldsetTitle() {
+ public function getFieldsetTitle() {
return ts('');
}
/**
* @return string
*/
- function getButtonTitle() {
+ public function getButtonTitle() {
return ts('Continue');
}
* Use the form name to create the tpl file name
*
* @return string
- * @access public
*/
/**
* @return string
*/
- function getTemplateFileName() {
+ public function getTemplateFileName() {
$this->assign('title',
$this->getFieldsetTitle()
);
return 'CRM/Upgrade/Base.tpl';
}
- function postProcess() {
+ public function postProcess() {
$this->upgrade();
if (!$this->verifyPostDBState($errorMessage)) {
*
* @return Object
*/
- function runQuery($query) {
+ public function runQuery($query) {
return CRM_Core_DAO::executeQuery($query,
CRM_Core_DAO::$_nullArray
);
*
* @return Object
*/
- function setVersion($version) {
+ public function setVersion($version) {
$this->logVersion($version);
$query = "
*
* @return bool
*/
- function logVersion($newVersion) {
+ public function logVersion($newVersion) {
if ($newVersion) {
$oldVersion = CRM_Core_BAO_Domain::version();
*
* @return bool
*/
- function checkVersion($version) {
+ public function checkVersion($version) {
$domainID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain',
$version, 'id',
'version'
* @return array
* @throws Exception
*/
- function getRevisionSequence() {
+ public function getRevisionSequence() {
$revList = array();
$sqlDir = implode(DIRECTORY_SEPARATOR,
array(dirname(__FILE__), 'Incremental', 'sql')
*
* @return null
*/
- static function getRevisionPart($rev, $index = 1) {
+ public static function getRevisionPart($rev, $index = 1) {
$revPattern = '/^((\d{1,2})\.\d{1,2})\.(\d{1,2}|\w{4,7})?$/i';
preg_match($revPattern, $rev, $matches);
*
* @return bool
*/
- function processLocales($tplFile, $rev) {
+ public function processLocales($tplFile, $rev) {
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('domainID', CRM_Core_Config::domainID());
/**
* @param $rev
*/
- function setSchemaStructureTables($rev) {
+ public function setSchemaStructureTables($rev) {
if ($this->multilingual) {
CRM_Core_I18n_Schema::schemaStructureTables($rev, TRUE);
}
*
* @throws Exception
*/
- function processSQL($rev) {
+ public function processSQL($rev) {
$sqlFile = implode(DIRECTORY_SEPARATOR,
array(
dirname(__FILE__), 'Incremental',
*
* @return array(0=>$currentVer, 1=>$latestVer)
*/
- function getUpgradeVersions() {
+ public function getUpgradeVersions() {
$latestVer = CRM_Utils_System::version();
$currentVer = CRM_Core_BAO_Domain::version(true);
if (!$currentVer) {
*
* @return mixed, a string error message or boolean 'false' if OK
*/
- function checkUpgradeableVersion($currentVer, $latestVer) {
+ public function checkUpgradeableVersion($currentVer, $latestVer) {
$error = FALSE;
// since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
// lets do a pattern check -
*
* @return mixed, a string error message or boolean 'false' if OK
*/
- function checkCurrentVersion($currentVer, $latestVer) {
+ public function checkCurrentVersion($currentVer, $latestVer) {
$error = FALSE;
// since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
/**
* Fill the queue with upgrade tasks
*
- * @param $currentVer string, the original revision
- * @param $latestVer string, the target (final) revision
- * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
+ * @param $currentVer
+ * String, the original revision.
+ * @param $latestVer
+ * String, the target (final) revision.
+ * @param $postUpgradeMessageFile
+ * String, path of a modifiable file which lists the post-upgrade messages.
*
* @return CRM_Queue
*/
- static function buildQueue($currentVer, $latestVer, $postUpgradeMessageFile) {
+ public static function buildQueue($currentVer, $latestVer, $postUpgradeMessageFile) {
$upgrade = new CRM_Upgrade_Form();
// hack to make 4.0.x (D7,J1.6) codebase go through 3.4.x (d6, J1.5) upgrade files,
* Perform an incremental version update
*
* @param CRM_Queue_TaskContext $ctx
- * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1'
+ * @param $rev
+ * String, the target (intermediate) revision e.g '3.2.alpha1'.
*
* @return bool
*/
- static function doIncrementalUpgradeStart(CRM_Queue_TaskContext $ctx, $rev) {
+ public static function doIncrementalUpgradeStart(CRM_Queue_TaskContext $ctx, $rev) {
$upgrade = new CRM_Upgrade_Form();
// as soon as we start doing anything we append ".upgrade" to version.
* Perform an incremental version update
*
* @param CRM_Queue_TaskContext $ctx
- * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1'
- * @param $originalVer string, the original revision
- * @param $latestVer string, the target (final) revision
- * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
+ * @param $rev
+ * String, the target (intermediate) revision e.g '3.2.alpha1'.
+ * @param $originalVer
+ * String, the original revision.
+ * @param $latestVer
+ * String, the target (final) revision.
+ * @param $postUpgradeMessageFile
+ * String, path of a modifiable file which lists the post-upgrade messages.
*
* @return bool
*/
- static function doIncrementalUpgradeStep(CRM_Queue_TaskContext$ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) {
+ public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext$ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) {
$upgrade = new CRM_Upgrade_Form();
$phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
* Perform an incremental version update
*
* @param CRM_Queue_TaskContext $ctx
- * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1'
- * @param $currentVer string, the original revision
- * @param $latestVer string, the target (final) revision
- * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
+ * @param $rev
+ * String, the target (intermediate) revision e.g '3.2.alpha1'.
+ * @param $currentVer
+ * String, the original revision.
+ * @param $latestVer
+ * String, the target (final) revision.
+ * @param $postUpgradeMessageFile
+ * String, path of a modifiable file which lists the post-upgrade messages.
*
* @return bool
*/
- static function doIncrementalUpgradeFinish(CRM_Queue_TaskContext $ctx, $rev, $currentVer, $latestVer, $postUpgradeMessageFile) {
+ public static function doIncrementalUpgradeFinish(CRM_Queue_TaskContext $ctx, $rev, $currentVer, $latestVer, $postUpgradeMessageFile) {
$upgrade = new CRM_Upgrade_Form();
$upgrade->setVersion($rev);
CRM_Utils_System::flushCache();
return TRUE;
}
- static function doFinish() {
+ public static function doFinish() {
$upgrade = new CRM_Upgrade_Form();
list($ignore, $latestVer) = $upgrade->getUpgradeVersions();
// Seems extraneous in context, but we'll preserve old behavior
* by calling the 'setPreUpgradeMessage' on each incremental upgrade
* object.
*
- * @param $preUpgradeMessage string, alterable
+ * @param $preUpgradeMessage
+ * String, alterable.
* @param $currentVer
* @param $latestVer
*/
- function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
+ public function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
CRM_Upgrade_Incremental_Legacy::setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
// Scan through all php files and see if any file is interested in setting pre-upgrade-message