本文整理汇总了PHP中CRM_Upgrade_Form类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Upgrade_Form类的具体用法?PHP CRM_Upgrade_Form怎么用?PHP CRM_Upgrade_Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Upgrade_Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Perform an upgrade without using the web-frontend
*
* @param bool $enablePrint
*
* @throws Exception
* @return array, with keys:
* - message: string, HTML-ish blob
*/
public function run($enablePrint = TRUE)
{
// lets get around the time limit issue if possible for upgrades
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
$upgrade = new CRM_Upgrade_Form();
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
throw new Exception($error);
}
// Disable our SQL triggers
CRM_Core_DAO::dropTriggers();
// CRM-11156
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
$postUpgradeMessageFile = CRM_Utils_File::tempnam('civicrm-post-upgrade');
$queueRunner = new CRM_Queue_Runner(array('title' => ts('CiviCRM Upgrade Tasks'), 'queue' => CRM_Upgrade_Form::buildQueue($currentVer, $latestVer, $postUpgradeMessageFile)));
$queueResult = $queueRunner->runAll();
if ($queueResult !== TRUE) {
$errorMessage = CRM_Core_Error::formatTextException($queueResult['exception']);
CRM_Core_Error::debug_log_message($errorMessage);
if ($enablePrint) {
print $errorMessage;
}
throw $queueResult['exception'];
// FIXME test
}
CRM_Upgrade_Form::doFinish();
$message = file_get_contents($postUpgradeMessageFile);
return array('latestVer' => $latestVer, 'message' => $message, 'text' => CRM_Utils_String::htmlToText($message));
}
示例2: run
function run()
{
$upgrade = new CRM_Upgrade_Form();
$message = ts('CiviCRM upgrade successful');
if ($upgrade->checkVersion($upgrade->latestVersion)) {
$message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $upgrade->latestVersion));
} elseif ($upgrade->checkVersion('2.1.2') || $upgrade->checkVersion('2.1.3') || $upgrade->checkVersion('2.1.4') || $upgrade->checkVersion('2.1.5')) {
// do nothing, db version is changed for all upgrades
} elseif ($upgrade->checkVersion('2.1.0') || $upgrade->checkVersion('2.1') || $upgrade->checkVersion('2.1.1')) {
// 2.1 to 2.1.2
$this->runTwoOneTwo();
} else {
// 2.0 to 2.1
for ($i = 1; $i <= 4; $i++) {
$this->runForm($i);
}
// 2.1 to 2.1.2
$this->runTwoOneTwo();
}
// just change the ver in the db, since nothing to upgrade
$upgrade->setVersion($upgrade->latestVersion);
// also cleanup the templates_c directory
$config = CRM_Core_Config::singleton();
$config->cleanup(1);
$template = CRM_Core_Smarty::singleton();
$template->assign('message', $message);
$template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $upgrade->latestVersion)));
$template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
$contents = $template->fetch('CRM/common/success.tpl');
echo $contents;
}
示例3: runFinish
/**
* Display any final messages, clear caches, etc
*/
public function runFinish()
{
$upgrade = new CRM_Upgrade_Form();
$template = CRM_Core_Smarty::singleton();
// If we're redirected from queue-runner, then isUpgradePending=true.
// If user then reloads the finish page, the isUpgradePending will be unset. (Because the session has been cleared.)
if ($this->get('isUpgradePending')) {
// TODO: Use structured message store
$postUpgradeMessage = file_get_contents($this->get('postUpgradeMessageFile'));
// This destroys $session, so do it after get('postUpgradeMessageFile')
CRM_Upgrade_Form::doFinish();
} else {
$postUpgradeMessage = '';
// Session was destroyed! Can't recover messages.
}
// do a version check - after doFinish() sets the final version
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
if ($error = $upgrade->checkCurrentVersion($currentVer, $latestVer)) {
CRM_Core_Error::fatal($error);
}
$template->assign('message', $postUpgradeMessage);
$template->assign('upgraded', TRUE);
$template->assign('sid', CRM_Utils_System::getSiteID());
// Render page header
if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
$content = $template->fetch('CRM/common/success.tpl');
echo CRM_Utils_System::theme($content, $this->_print, TRUE);
}
示例4: task_4_7_x_runSql
/**
* (Queue Task Callback)
*/
public static function task_4_7_x_runSql(CRM_Queue_TaskContext $ctx, $rev)
{
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
return TRUE;
}
示例5: upgrade_3_1_4
function upgrade_3_1_4($rev)
{
require_once 'CRM/Upgrade/ThreeOne/ThreeOne.php';
$threeOne = new CRM_Upgrade_ThreeOne_ThreeOne();
$threeOne->upgrade_3_1_4();
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
}
示例6: upgrade_3_3_7
function upgrade_3_3_7($rev)
{
$dao = new CRM_Contact_DAO_Contact();
$dbName = $dao->_database;
$chkExtQuery = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %1\n AND TABLE_NAME = 'civicrm_phone' AND COLUMN_NAME = 'phone_ext'";
$extensionExists = CRM_Core_DAO::singleValueQuery($chkExtQuery, array(1 => array($dbName, 'String')), TRUE, FALSE);
if (!$extensionExists) {
$colQuery = 'ALTER TABLE `civicrm_phone` ADD `phone_ext` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `phone` ';
CRM_Core_DAO::executeQuery($colQuery);
}
// handle db changes done for CRM-8218
$alterContactDashboard = FALSE;
$dao = new CRM_Contact_DAO_DashboardContact();
$dbName = $dao->_database;
$chkContentQuery = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %1\n AND TABLE_NAME = 'civicrm_dashboard_contact' AND COLUMN_NAME = 'content'";
$contentExists = CRM_Core_DAO::singleValueQuery($chkContentQuery, array(1 => array($dbName, 'String')), TRUE, FALSE);
if (!$contentExists) {
$alterContactDashboard = TRUE;
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('alterContactDashboard', $alterContactDashboard);
$upgrade->processSQL($rev);
}
示例7: task_4_2_x_runSql
/**
* (Queue Task Callback)
*/
public static function task_4_2_x_runSql(CRM_Queue_TaskContext $ctx, $rev)
{
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
// now rebuild all the triggers
// CRM-9716
// FIXME // CRM_Core_DAO::triggerRebuild();
return TRUE;
}
示例8: task_4_6_x_runOnlySql
/**
* Queue Task Callback for CRM-16846
*
* Run a sql file without resetting locale to that version
*/
public static function task_4_6_x_runOnlySql(CRM_Queue_TaskContext $ctx, $rev)
{
$upgrade = new CRM_Upgrade_Form();
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('domainID', CRM_Core_Config::domainID());
$fileName = "CRM/Upgrade/Incremental/sql/{$rev}.mysql.tpl";
$upgrade->source($smarty->fetch($fileName), TRUE);
return TRUE;
}
示例9: doFinish
static function doFinish()
{
$upgrade = new CRM_Upgrade_Form();
list($ignore, $latestVer) = $upgrade->getUpgradeVersions();
// Seems extraneous in context, but we'll preserve old behavior
$upgrade->setVersion($latestVer);
// cleanup caches CRM-8739
$config = CRM_Core_Config::singleton();
$config->cleanupCaches(1, FALSE);
}
示例10: upgrade_3_1_4
/**
* Perform an incremental upgrade
*
* @param $rev string, the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final)
*/
static function upgrade_3_1_4($rev)
{
$threeOne = new CRM_Upgrade_ThreeOne_ThreeOne();
$threeOne->upgrade_3_1_4();
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
}
示例11: upgrade_4_1_1
/**
* @param $rev
*/
public function upgrade_4_1_1($rev)
{
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('addDedupeEmail', !CRM_Core_DAO::checkFieldExists('civicrm_mailing', 'dedupe_email'));
$sql = "SELECT id FROM civicrm_worldregion LIMIT 1";
$upgrade->assign('worldRegionEmpty', !CRM_Core_DAO::singleValueQuery($sql));
$upgrade->processSQL($rev);
}
示例12: upgrade_3_4_7
/**
* @param $rev
*
* @throws Exception
*/
public function upgrade_3_4_7($rev)
{
$onBehalfProfileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'on_behalf_organization', 'id', 'name');
if (!$onBehalfProfileId) {
CRM_Core_Error::fatal();
}
$pages = CRM_Core_DAO::executeQuery("\nSELECT civicrm_contribution_page.id\nFROM civicrm_contribution_page\nLEFT JOIN civicrm_uf_join ON entity_table = 'civicrm_contribution_page' AND entity_id = civicrm_contribution_page.id AND module = 'OnBehalf'\nWHERE is_for_organization = 1\nAND civicrm_uf_join.id IS NULL\n");
while ($pages->fetch()) {
$query = "\nINSERT INTO civicrm_uf_join\n (is_active, module, entity_table, entity_id, weight, uf_group_id)\nVALUES\n (1, 'OnBehalf', 'civicrm_contribution_page', %1, 1, %2)";
$params = array(1 => array($pages->id, 'Integer'), 2 => array($onBehalfProfileId, 'Integer'));
CRM_Core_DAO::executeQuery($query, $params);
}
// CRM-8774
$config = CRM_Core_Config::singleton();
if ($config->userFramework == 'Drupal' || $config->userFramework == 'Drupal6') {
db_query("UPDATE {system} SET weight = 100 WHERE name = 'civicrm'");
drupal_flush_all_caches();
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
}
示例13: upgrade
function upgrade($rev)
{
$upgrade = new CRM_Upgrade_Form();
//Run the SQL file
$upgrade->processSQL($rev);
// fix for CRM-5162
// we need to encrypt all smtpPasswords if present
require_once "CRM/Core/DAO/Preferences.php";
$mailingDomain = new CRM_Core_DAO_Preferences();
$mailingDomain->find();
while ($mailingDomain->fetch()) {
if ($mailingDomain->mailing_backend) {
$values = unserialize($mailingDomain->mailing_backend);
if (isset($values['smtpPassword'])) {
require_once 'CRM/Utils/Crypt.php';
$values['smtpPassword'] = CRM_Utils_Crypt::encrypt($values['smtpPassword']);
$mailingDomain->mailing_backend = serialize($values);
$mailingDomain->save();
}
}
}
require_once "CRM/Core/DAO/Domain.php";
$domain = new CRM_Core_DAO_Domain();
$domain->selectAdd();
$domain->selectAdd('config_backend');
$domain->find(true);
if ($domain->config_backend) {
$defaults = unserialize($domain->config_backend);
if ($dateFormat = CRM_Utils_Array::value('dateformatQfDate', $defaults)) {
$dateFormatArray = explode(" ", $dateFormat);
//replace new date format based on previous month format
//%b month name [abbreviated]
//%B full month name ('January'..'December')
//%m decimal number, 0-padded ('01'..'12')
if ($dateFormat == '%b %d %Y') {
$defaults['dateInputFormat'] = 'mm/dd/yy';
} else {
if ($dateFormat == '%d-%b-%Y') {
$defaults['dateInputFormat'] = 'dd-mm-yy';
} else {
if (in_array('%b', $dateFormatArray)) {
$defaults['dateInputFormat'] = 'M d, yy';
} else {
if (in_array('%B', $dateFormatArray)) {
$defaults['dateInputFormat'] = 'MM d, yy';
} else {
$defaults['dateInputFormat'] = 'mm/dd/yy';
}
}
}
}
}
// %p - lowercase ante/post meridiem ('am', 'pm')
// %P - uppercase ante/post meridiem ('AM', 'PM')
if ($dateTimeFormat = CRM_Utils_Array::value('dateformatQfDatetime', $defaults)) {
$defaults['timeInputFormat'] = 2;
$dateTimeFormatArray = explode(" ", $dateFormat);
if (in_array('%P', $dateTimeFormatArray) || in_array('%p', $dateTimeFormatArray)) {
$defaults['timeInputFormat'] = 1;
}
unset($defaults['dateformatQfDatetime']);
}
unset($defaults['dateformatQfDate']);
unset($defaults['dateformatTime']);
require_once "CRM/Core/BAO/Setting.php";
CRM_Core_BAO_Setting::add($defaults);
}
$sql = "SELECT id, form_values FROM civicrm_report_instance";
$instDAO = CRM_Core_DAO::executeQuery($sql);
while ($instDAO->fetch()) {
$fromVal = @unserialize($instDAO->form_values);
foreach ((array) $fromVal as $key => $value) {
if (strstr($key, '_relative')) {
$elementName = substr($key, 0, strlen($key) - strlen('_relative'));
$fromNamekey = $elementName . '_from';
$toNamekey = $elementName . '_to';
$fromNameVal = $fromVal[$fromNamekey];
$toNameVal = $fromVal[$toNamekey];
//check 'choose date range' is set
if ($value == '0') {
if (CRM_Utils_Date::isDate($fromNameVal)) {
$fromDate = CRM_Utils_Date::setDateDefaults(CRM_Utils_Date::format($fromNameVal));
$fromNameVal = $fromDate[0];
} else {
$fromNameVal = '';
}
if (CRM_Utils_Date::isDate($toNameVal)) {
$toDate = CRM_Utils_Date::setDateDefaults(CRM_Utils_Date::format($toNameVal));
$toNameVal = $toDate[0];
} else {
$toNameVal = '';
}
} else {
$fromNameVal = '';
$toNameVal = '';
}
$fromVal[$fromNamekey] = $fromNameVal;
$fromVal[$toNamekey] = $toNameVal;
continue;
}
//.........这里部分代码省略.........
示例14: upgrade_3_2_1
/**
* @param $rev
*/
public function upgrade_3_2_1($rev)
{
//CRM-6565 check if Activity Index is already exists or not.
$addActivityTypeIndex = TRUE;
$indexes = CRM_Core_DAO::executeQuery('SHOW INDEXES FROM civicrm_activity');
while ($indexes->fetch()) {
if ($indexes->Key_name == 'UI_activity_type_id') {
$addActivityTypeIndex = FALSE;
}
}
// CRM-6563: restrict access to the upload dir, tighten access to the config-and-log dir
$config = CRM_Core_Config::singleton();
CRM_Utils_File::restrictAccess($config->uploadDir);
CRM_Utils_File::restrictAccess($config->configAndLogDir);
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('addActivityTypeIndex', $addActivityTypeIndex);
$upgrade->processSQL($rev);
}
示例15: 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
$upgrade->setVersion($latestVer);
// lets rebuild the config array in case we've made a few changes in the
// code base
// this also helps us always store the latest version of civi in the DB
$params = array();
CRM_Core_BAO_ConfigSetting::add($params);
// CRM-12804 comment-51411 : add any missing settings
// at the end of upgrade
CRM_Core_BAO_Setting::updateSettingsFromMetaData();
// cleanup caches CRM-8739
$config = CRM_Core_Config::singleton();
$config->cleanupCaches(1);
// Rebuild all triggers and re-enable logging if needed
$logging = new CRM_Logging_Schema();
$logging->fixSchemaDifferences();
//CRM-16257 update Config.IDS.ini might be an old copy
CRM_Core_IDS::createConfigFile(TRUE);
}