当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Upgrade_Form::processSQL方法代码示例

本文整理汇总了PHP中CRM_Upgrade_Form::processSQL方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Upgrade_Form::processSQL方法的具体用法?PHP CRM_Upgrade_Form::processSQL怎么用?PHP CRM_Upgrade_Form::processSQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Upgrade_Form的用法示例。


在下文中一共展示了CRM_Upgrade_Form::processSQL方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:9,代码来源:FourSeven.php

示例2: upgrade

 /**
  * @param $rev
  */
 function upgrade($rev)
 {
     // fix CRM-5270: if civicrm_report_instance.description is localised,
     // recreate it based on the first locale’s description_xx_YY contents
     // and drop all the description_xx_YY columns
     if (!CRM_Core_DAO::checkFieldExists('civicrm_report_instance', 'description')) {
         $domain = new CRM_Core_DAO_Domain();
         $domain->find(TRUE);
         $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
         CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance ADD description VARCHAR(255)");
         CRM_Core_DAO::executeQuery("UPDATE civicrm_report_instance SET description = description_{$locales[0]}");
         CRM_Core_DAO::executeQuery("DROP TRIGGER IF EXISTS civicrm_report_instance_before_insert");
         foreach ($locales as $locale) {
             CRM_Core_DAO::executeQuery("DROP VIEW civicrm_report_instance_{$locale}");
             CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance DROP description_{$locale}");
         }
     }
     //We execute some part of php after sql and then again sql
     //So using conditions for skipping some part of sql CRM-4575
     $upgrade = new CRM_Upgrade_Form();
     //Run the SQL file (1)
     $upgrade->processSQL($rev);
     //replace  with ; in report instance
     $sql = "UPDATE civicrm_report_instance\n                       SET form_values = REPLACE(form_values,'#',';') ";
     CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
     //delete unnecessary activities
     $bulkEmailID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
     if ($bulkEmailID) {
         $mailingActivityIds = array();
         $query = "\n            SELECT max( ca.id ) as aid,\n                   ca.source_record_id sid\n            FROM civicrm_activity ca\n            WHERE ca.activity_type_id = %1\n            GROUP BY ca.source_record_id";
         $params = array(1 => array($bulkEmailID, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
         while ($dao->fetch()) {
             $updateQuery = "\n                UPDATE civicrm_activity_target cat, civicrm_activity ca\n                    SET cat.activity_id = {$dao->aid}\n                WHERE ca.source_record_id IS NOT NULL   AND\n                      ca.activity_type_id = %1          AND\n                      ca.id <> {$dao->aid}              AND\n                      ca.source_record_id = {$dao->sid} AND\n                      ca.id = cat.activity_id";
             $updateParams = array(1 => array($bulkEmailID, 'Integer'));
             CRM_Core_DAO::executeQuery($updateQuery, $updateParams);
             $deleteQuery = "\n                DELETE ca.*\n                FROM civicrm_activity ca\n                WHERE ca.source_record_id IS NOT NULL  AND\n                      ca.activity_type_id = %1         AND\n                      ca.id <> {$dao->aid}             AND\n                      ca.source_record_id = {$dao->sid}";
             $deleteParams = array(1 => array($bulkEmailID, 'Integer'));
             CRM_Core_DAO::executeQuery($deleteQuery, $deleteParams);
         }
     }
     //CRM-4453
     //lets insert column in civicrm_aprticipant table
     $query = "\n        ALTER TABLE `civicrm_participant`\n            ADD `fee_currency` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '3 character string, value derived from config setting.' AFTER `discount_id`";
     CRM_Core_DAO::executeQuery($query);
     //get currency from contribution table if exists/default
     //insert currency when fee_amount != NULL or event is paid.
     $query = "\n        SELECT  civicrm_participant.id\n        FROM    civicrm_participant\n            LEFT JOIN  civicrm_event\n                   ON ( civicrm_participant.event_id = civicrm_event.id )\n        WHERE  civicrm_participant.fee_amount IS NOT NULL OR\n               civicrm_event.is_monetary = 1";
     $participant = CRM_Core_DAO::executeQuery($query);
     while ($participant->fetch()) {
         $query = "\n            SELECT civicrm_contribution.currency\n            FROM   civicrm_contribution,\n                   civicrm_participant_payment\n            WHERE  civicrm_contribution.id = civicrm_participant_payment.contribution_id AND\n                   civicrm_participant_payment.participant_id = {$participant->id}";
         $currencyID = CRM_Core_DAO::singleValueQuery($query);
         if (!$currencyID) {
             $config = CRM_Core_Config::singleton();
             $currencyID = $config->defaultCurrency;
         }
         //finally update participant record.
         CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $participant->id, 'fee_currency', $currencyID);
     }
     //CRM-4575
     //check whether {contact.name} is set in mailing labels
     $mailingFormat = self::getPreference('mailing_format');
     $addNewAddressee = TRUE;
     if (strpos($mailingFormat, '{contact.contact_name}') === FALSE) {
         $addNewAddressee = FALSE;
     } else {
         //else compare individual name format with default individual addressee.
         $individualNameFormat = self::getPreference('individual_name_format');
         $defaultAddressee = CRM_Core_OptionGroup::values('addressee', FALSE, FALSE, FALSE, " AND v.filter = 1 AND v.is_default =  1", 'label');
         if (array_search($individualNameFormat, $defaultAddressee) !== FALSE) {
             $addNewAddressee = FALSE;
         }
     }
     $docURL = CRM_Utils_System::docURL2('Update Greetings and Address Data for Contacts', FALSE, NULL, NULL, 'color: white; text-decoration: underline;', "wiki");
     if ($addNewAddressee) {
         //otherwise insert new token in addressee and set as a default
         $addresseeGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'addressee', 'id', 'name');
         $optionValueParams = array('label' => $individualNameFormat, 'is_active' => 1, 'contactOptions' => 1, 'filter' => 1, 'is_default' => 1, 'reset_default_for' => array('filter' => "0, 1"));
         $action = CRM_Core_Action::ADD;
         $addresseeGroupParams = array('name' => 'addressee');
         $fieldValues = array('option_group_id' => $addresseeGroupId);
         $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
         $optionValueParams['weight'] = $weight;
         $addresseeToken = CRM_Core_OptionValue::addOptionValue($optionValueParams, $addresseeGroupParams, $action, $optionId = NULL);
         $afterUpgradeMessage = ts("During this upgrade, Postal Addressee values have been stored for each contact record using the system default format - %2.You will need to run the included command-line script to update your Individual contact records to use the \"Individual Name Format\" previously specified for your site %1", array(1 => $docURL, 2 => array_pop($defaultAddressee)));
     } else {
         $afterUpgradeMessage = ts("Email Greeting, Postal Greeting and Postal Addressee values have been stored for all contact records based on the system default formats. If you want to use a different format for any of these contact fields - you can run the provided command line script to update contacts to a different format %1 ", array(1 => $docURL));
     }
     //replace contact.contact_name with contact.addressee in civicrm_preference.mailing_format
     $updateQuery = "\n        UPDATE civicrm_preferences\n               SET `mailing_format` =\n                    replace(`mailing_format`, '{contact.contact_name}','{contact.addressee}')";
     CRM_Core_DAO::executeQuery($updateQuery);
     //drop column individual_name_format
     $alterQuery = "\n        ALTER TABLE `civicrm_preferences`\n              DROP `individual_name_format`";
     CRM_Core_DAO::executeQuery($alterQuery);
     //set status message for default greetings
     $template = CRM_Core_Smarty::singleton();
     $template->assign('afterUpgradeMessage', $afterUpgradeMessage);
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:ThreeZero.php

示例3:

 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);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:8,代码来源:Upgrade.php

示例4: array

 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);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:23,代码来源:ThreeThree.php

示例5: 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);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:26,代码来源:ThreeFour.php

示例6: 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;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:12,代码来源:FourTwo.php

示例7: 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);
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:11,代码来源:FourOne.php

示例8: 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;
             }
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:ThreeOne.php

示例9: 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);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:21,代码来源:ThreeTwo.php

示例10: doIncrementalUpgradeStep

 /**
  * Perform an incremental version update.
  *
  * @param CRM_Queue_TaskContext $ctx
  * @param string $rev
  *   the target (intermediate) revision e.g '3.2.alpha1'.
  * @param string $originalVer
  *   the original revision.
  * @param string $latestVer
  *   the target (final) revision.
  * @param string $postUpgradeMessageFile
  *   path of a modifiable file which lists the post-upgrade messages.
  *
  * @return bool
  */
 public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext $ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile)
 {
     $upgrade = new CRM_Upgrade_Form();
     $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
     $versionObject = $upgrade->incrementalPhpObject($rev);
     // pre-db check for major release.
     if ($upgrade->checkVersionRelease($rev, 'alpha1')) {
         if (!is_callable(array($versionObject, 'verifyPreDBstate'))) {
             CRM_Core_Error::fatal("verifyPreDBstate method was not found for {$rev}");
         }
         $error = NULL;
         if (!$versionObject->verifyPreDBstate($error)) {
             if (!isset($error)) {
                 $error = "post-condition failed for current upgrade for {$rev}";
             }
             CRM_Core_Error::fatal($error);
         }
     }
     $upgrade->setSchemaStructureTables($rev);
     if (is_callable(array($versionObject, $phpFunctionName))) {
         $versionObject->{$phpFunctionName}($rev, $originalVer, $latestVer);
     } else {
         $upgrade->processSQL($rev);
     }
     // set post-upgrade-message if any
     if (is_callable(array($versionObject, 'setPostUpgradeMessage'))) {
         $postUpgradeMessage = file_get_contents($postUpgradeMessageFile);
         $versionObject->setPostUpgradeMessage($postUpgradeMessage, $rev);
         file_put_contents($postUpgradeMessageFile, $postUpgradeMessage);
     }
     return TRUE;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:47,代码来源:Form.php

示例11:

 /**
  * 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);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:12,代码来源:Legacy.php


注:本文中的CRM_Upgrade_Form::processSQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。