本文整理汇总了PHP中CRM_Core_DAO::checkFieldExists方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO::checkFieldExists方法的具体用法?PHP CRM_Core_DAO::checkFieldExists怎么用?PHP CRM_Core_DAO::checkFieldExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO
的用法示例。
在下文中一共展示了CRM_Core_DAO::checkFieldExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
function buildQuickForm()
{
require_once 'UK_Direct_Debit/Form/Main.php';
// If no civicrm_sd, then create that table
if (!CRM_Core_DAO::checkTableExists('civicrm_sd')) {
$creatSql = "CREATE TABLE `civicrm_sd` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `start_date` datetime NOT NULL,\n `frequency_unit` enum('day','week','month','year') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'month',\n `frequency_interval` int(10) unsigned DEFAULT NULL,\n\t\t\t\t\t`amount` decimal(20,2) DEFAULT NULL,\n `transaction_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,\n `contact_id` int(10) unsigned DEFAULT NULL,\n `external_id` int(10) unsigned DEFAULT NULL,\n `membership_id` int(10) unsigned DEFAULT NULL,\n `member_count` int(10) unsigned DEFAULT NULL,\n `payment_processor_id` varchar(255) DEFAULT NULL,\n `payment_instrument_id` int(10) unsigned DEFAULT NULL,\n `cycle_day` int(10) unsigned NOT NULL DEFAULT '1',\n `contribution_status_id` int(10) DEFAULT '1',\n `is_valid` int(4) NOT NULL DEFAULT '1',\n `payerReference` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,\n\t `recur_id` int(10) unsigned DEFAULT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB AUTO_INCREMENT=350 DEFAULT CHARSET=latin1";
CRM_Core_DAO::executeQuery($creatSql);
$columnExists = CRM_Core_DAO::checkFieldExists('civicrm_contribution_recur', 'membership_id');
if (!$columnExists) {
$query = "\n ALTER TABLE civicrm_contribution_recur\n ADD membership_id int(10) unsigned AFTER contact_id,\n ADD CONSTRAINT FK_civicrm_contribution_recur_membership_id\n FOREIGN KEY(membership_id) REFERENCES civicrm_membership(id) ON DELETE CASCADE ON UPDATE RESTRICT";
CRM_Core_DAO::executeQuery($query);
}
} else {
$emptySql = "TRUNCATE TABLE `civicrm_sd`";
CRM_Core_DAO::executeQuery($emptySql);
}
$smartDebitArray = self::getSmartDebitPayments(NULL);
foreach ($smartDebitArray as $key => $smartDebitRecord) {
if ($smartDebitRecord['current_state'] == 10 || $smartDebitRecord['current_state'] == 1 || $smartDebitRecord['current_state'] == 11) {
$regularAmount = substr($smartDebitRecord['regular_amount'], 2);
// Extract the number from reference_number
$output = preg_match("/\\d+/", $smartDebitRecord['reference_number'], $results);
if ($regularAmount && $results[0]) {
list($y, $m, $d) = explode('-', $smartDebitRecord['start_date']);
$sql = "INSERT INTO `civicrm_sd`(`start_date`, `frequency_unit`, `amount`, `transaction_id`, `external_id`, `payment_processor_id`, `payment_instrument_id`, `cycle_day`, `contribution_status_id`, `frequency_interval`, `payerReference`) VALUES (%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11)";
$params = array(1 => array($smartDebitRecord['start_date'], 'String'), 2 => array(self::translateSmartDebitFrequencyUnit($smartDebitRecord['frequency_type']), 'String'), 3 => array($regularAmount, 'Float'), 4 => array($smartDebitRecord['reference_number'], 'String'), 5 => array($results[0], 'Int'), 6 => array(self::getSmartDebitPaymentProcessorID(), 'Int'), 7 => array(5, 'Int'), 8 => array($d, 'Int'), 9 => array(5, 'Int'), 10 => array($smartDebitRecord['frequency_factor'], 'Int'), 11 => array($smartDebitRecord['payerReference'], 'String'));
CRM_Core_DAO::executeQuery($sql, $params);
}
}
}
if ($smartDebitArray) {
CRM_Core_Session::setStatus('Smart debit data retreived successfully.', 'Success', 'info');
}
}
示例2: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$latestVer = CRM_Utils_System::version();
$errorMessage = ts('Pre-condition failed for upgrade to %1.', array(1 => $latestVer));
// check table, if the db is 3.1
if (CRM_Core_DAO::checkTableExists('civicrm_acl_contact_cache')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded db and you will need to reload the correct db on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
// check table-column, if the db is 3.1
if (CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'date_format')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded db and you will need to reload the correct db on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
//check previous version table e.g 3.0.*
if (!CRM_Core_DAO::checkTableExists('civicrm_participant_status_type') || !CRM_Core_DAO::checkTableExists('civicrm_navigation')) {
$errorMessage .= ' Few important tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 3.0.* db
if (!CRM_Core_DAO::checkFieldExists('civicrm_relationship_type', 'label_a_b') || !CRM_Core_DAO::checkFieldExists('civicrm_mapping_field', 'im_provider_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'email_greeting_id')) {
// db looks to have stuck somewhere between 2.2 & 3.0
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
return true;
}
示例3: verifyPreDBState
/**
* @param $errorMessage
*
* @return bool
*/
function verifyPreDBState(&$errorMessage)
{
$errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '4'));
if (CRM_Core_DAO::checkTableExists('civicrm_event_page')) {
return FALSE;
}
// check fields which MUST be present if a proper 2.2 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_email_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_email_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_name') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_email') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'cc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'bcc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_fee_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_receipt') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations')) {
// db looks to have stuck somewhere between 2.1 & 2.2
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return FALSE;
}
if ($this->checkVersion('2.1.103')) {
$this->setVersion('2.2');
} else {
return FALSE;
}
// update config defaults
$domain = new CRM_Core_DAO_Domain();
$domain->selectAdd();
$domain->selectAdd('config_backend');
$domain->find(TRUE);
if ($domain->config_backend) {
$defaults = unserialize($domain->config_backend);
// reset components
$defaults['enableComponents'] = array('CiviContribute', 'CiviPledge', 'CiviMember', 'CiviEvent', 'CiviMail');
$defaults['enableComponentIDs'] = array(1, 6, 2, 3, 4);
$defaults['moneyvalueformat'] = '%!i';
$defaults['fieldSeparator'] = ',';
$defaults['fatalErrorTemplate'] = 'CRM/common/fatal.tpl';
// serialise settings
CRM_Core_BAO_ConfigSetting::add($defaults);
}
return $this->checkVersion('2.2');
}
示例4: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$errorMessage = ts('Pre-condition failed for upgrade to 2.1.2.');
// check if the db is 2.2
if (!CRM_Core_DAO::checkTableExists('civicrm_event_page') && CRM_Core_DAO::checkTableExists('civicrm_pcp_block') && CRM_Core_DAO::checkTableExists('civicrm_pcp') && CRM_Core_DAO::checkTableExists('civicrm_contribution_soft')) {
$errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
// check if the db is 2.2
if (CRM_Core_DAO::checkFieldExists('civicrm_participant', 'registered_by_id') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'tellfriend_limit') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'supporter_profile_id') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'status_id') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'goal_amount') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'pcp_display_in_roll') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'amount')) {
$errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_payment')) {
$errorMessage .= ' Few important tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 2.1 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name')) {
// db looks to have stuck somewhere between 2.0 & 2.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
return true;
}
示例5: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
// check if log file is writable
$config = CRM_Core_Config::singleton();
if (!is_writable($config->uploadDir . 'CiviCRM.log') && !is_writable($config->uploadDir . 'CiviCRM.log.' . md5($config->dsn . $config->userFrameworkResourceURL))) {
$errorMessage = ts('Log file CiviCRM.log is not writable. Make sure files directory is writable.', array(1 => $config->uploadDir));
return false;
}
$errorMessage = ts('Database check failed - the current database is not v2.1.');
$is21db = true;
// abort if partial upgraded db found.
if ($this->checkVersion('2.1.101') || $this->checkVersion('2.1.102') || $this->checkVersion('2.1.103')) {
$errorMessage = ts('Corrupt / Partial Upgraded database found. Looks like upgrade wizard failed to complete all the required steps to convert your database to v2.2. Please fix any errors and start the upgrade process again with a clean v2.1 database.');
return false;
}
// abort if already 2.2
if ($this->checkVersion('2.2')) {
$errorMessage = ts('Database check failed - looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
// check if 2.1 version
if (!$this->checkVersion('2.1.2') || !$this->checkVersion('2.1.3') || !$this->checkVersion('2.1.4')) {
$is21db = false;
}
// check if 2.1 tables exists
if (!CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_case_contact')) {
// db is not 2.1
$errorMessage .= ' Few 2.1 tables were found missing.';
$is21db = false;
}
// check fields which MUST be present if a proper 2.1 db
if ($is21db) {
if (!CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'is_recur_interval') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'recur_frequency_unit') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'for_organization') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'is_for_organization') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_membership', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_membership_status', 'is_reserved') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'fee_amount') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'registered_by_id') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contact', 'employer_id') || !CRM_Core_DAO::checkFieldExists('civicrm_domain', 'locales') || !CRM_Core_DAO::checkFieldExists('civicrm_mapping', 'mapping_type_id') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'is_view') || !CRM_Core_DAO::checkFieldExists('civicrm_group', 'cache_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group', 'parents') || !CRM_Core_DAO::checkFieldExists('civicrm_group', 'children') || !CRM_Core_DAO::checkFieldExists('civicrm_preferences', 'editor_id') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_group', 'group_type') || !CRM_Core_DAO::checkFieldExists('civicrm_address', 'name') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'language')) {
// db looks to have stuck somewhere between 2.1 & 2.2
$errorMessage .= ' Few important fields were found missing in some of the tables.';
$is21db = false;
}
}
// check if the db is 2.2
if (!CRM_Core_DAO::checkTableExists('civicrm_event_page') && CRM_Core_DAO::checkFieldExists('civicrm_participant', 'registered_by_id') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') && CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations') && CRM_Core_DAO::checkTableExists('civicrm_pcp_block') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'tellfriend_limit') && CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'supporter_profile_id') && CRM_Core_DAO::checkTableExists('civicrm_pcp') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'status_id') && CRM_Core_DAO::checkFieldExists('civicrm_pcp', 'goal_amount') && CRM_Core_DAO::checkTableExists('civicrm_contribution_soft') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'pcp_display_in_roll') && CRM_Core_DAO::checkFieldExists('civicrm_contribution_soft', 'amount')) {
$errorMessage = ts('Database check failed - it looks like you have already upgraded to the latest version (v2.2) of the database.');
return false;
}
// check tables which should not exist for v2.x
if (CRM_Core_DAO::checkTableExists('civicrm_custom_option') || CRM_Core_DAO::checkTableExists('civicrm_custom_value') || CRM_Core_DAO::checkTableExists('civicrm_email_history') || CRM_Core_DAO::checkTableExists('civicrm_geo_coord') || CRM_Core_DAO::checkTableExists('civicrm_individual') || CRM_Core_DAO::checkTableExists('civicrm_location') || CRM_Core_DAO::checkTableExists('civicrm_meeting') || CRM_Core_DAO::checkTableExists('civicrm_organization') || CRM_Core_DAO::checkTableExists('civicrm_phonecall') || CRM_Core_DAO::checkTableExists('civicrm_sms_history') || CRM_Core_DAO::checkTableExists('civicrm_validation')) {
// table(s) found in the db which are no longer required
// for v2.x, though would not do any harm it's recommended
// to remove them.
CRM_Core_Session::setStatus(ts("Table(s) found in your db which are no longer required for v2.x, though would not do any harm it's recommended to remove them"));
}
// show error if any of the tables, use 'MyISAM' storage engine.
// just check the first 10 civicrm tables, rather than checking all 106!
if (CRM_Core_DAO::isDBMyISAM(10)) {
$errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB before proceeding.');
return false;
}
return true;
}
示例6: addContributionToBatch
/**
* Given an array of contributionIDs, add them to a batch
*
* @param array $contributionIDs (reference ) the array of contribution ids to be added
* @param int $batchID - the batchID to be added to
*
* @return array (total, added, notAdded) ids of contributions added to the batch
* @access public
* @static
*/
static function addContributionToBatch($contributionIDs, $batchID)
{
$date = date('YmdHis');
$contributionsAdded = array();
$contributionsNotAdded = array();
require_once "GiftAid/Utils/GiftAid.php";
require_once "CRM/Contribute/BAO/Contribution.php";
require_once 'CRM/Core/DAO/EntityBatch.php';
require_once "CRM/Core/BAO/Address.php";
require_once "CRM/Contact/BAO/Contact.php";
require_once "CRM/Utils/Address.php";
$charityColumnExists = CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_submission', 'charity');
foreach ($contributionIDs as $contributionID) {
$batchContribution =& new CRM_Core_DAO_EntityBatch();
$batchContribution->entity_table = 'civicrm_contribution';
$batchContribution->entity_id = $contributionID;
// check if the selected contribution id already in a batch
// if not, add to batchContribution else keep the count of contributions that are not added
if ($batchContribution->find(true)) {
$contributionsNotAdded[] = $contributionID;
continue;
}
// get additional info
// get contribution details from Contribution using contribution id
$params = array('id' => $contributionID);
CRM_Contribute_BAO_Contribution::retrieve($params, $contribution, $ids);
$contactId = $contribution['contact_id'];
// check if contribution is valid for gift aid
if (GiftAid_Utils_GiftAid::isEligibleForGiftAid($contactId, $contribution['receive_date'], $contributionID)) {
$batchContribution->batch_id = $batchID;
$batchContribution->save();
// get display name
$displayName = CRM_Contact_BAO_Contact::displayName($contactId);
// get Address & Postal Code from Address
$params = array('contact_id' => $contactId, 'is_primary' => 1);
$address = CRM_Core_BAO_Address::getValues($params);
$address = $address[1];
//adds all address lines to the report
$fullFormatedAddress = CRM_Utils_Address::format($address);
// get gift aid amount
$giftAidAmount = self::_calculateGiftAidAmt($contribution['total_amount']);
// FIXME: check if there is customTable method
$query = "\nINSERT INTO civicrm_value_gift_aid_submission \n(entity_id, eligible_for_gift_aid, name, address, post_code, amount, gift_aid_amount) \nVALUES \n ( %1, 1, %2, %3, %4, %5, %6 )\nON DUPLICATE KEY UPDATE \nname = %2, \naddress = %3,\npost_code = %4,\namount = %5,\ngift_aid_amount = %6\n";
$sqlParams = array(1 => array($contributionID, 'Integer'), 2 => array($displayName, 'String'), 3 => array($fullFormatedAddress, 'String'), 4 => array($address['postal_code'], 'String'), 5 => array($contribution['total_amount'], 'Money'), 6 => array($giftAidAmount, 'Money'));
CRM_Core_DAO::executeQuery($query, $sqlParams);
$contributionsAdded[] = $contributionID;
} else {
$contributionsNotAdded[] = $contributionID;
}
}
if (!empty($contributionsAdded)) {
// if there is any extra work required to be done for contributions that are batched,
// should be done via hook
GiftAid_Utils_Hook::batchContributions($batchID, $contributionsAdded);
}
return array(count($contributionIDs), count($contributionsAdded), count($contributionsNotAdded));
}
示例7: install
/**
* Add column to table on install
*/
public function install()
{
if (CRM_Core_DAO::checkTableExists('civicrm_contact_segment')) {
if (!CRM_Core_DAO::checkFieldExists('civicrm_contact_segment', 'is_main')) {
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_contact_segment\n ADD COLUMN is_main TINYINT(3) NULL DEFAULT 0 AFTER is_active");
}
} else {
throw new Exception('This extension requires table civicrm_contact_segment
(extension org.civicoop.contactsegment), could not find this table!');
}
}
示例8: verifyPostDBState
function verifyPostDBState(&$errorMessage)
{
// check if civicrm_event_page tables droped
if (CRM_Core_DAO::checkTableExists('civicrm_event_page')) {
$errorMessage .= ' civicrm_event_page table is not droped.';
return false;
}
// check fields which MUST be present civicrm_event
if (!CRM_Core_DAO::checkFieldExists('civicrm_event', 'intro_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_email_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_email_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_name') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'confirm_from_email') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'cc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'bcc_confirm') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_fee_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'default_discount_id') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_title') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'thankyou_footer_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_pay_later') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_text') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'pay_later_receipt') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_multiple_registrations')) {
$errorMessage .= ' Few important fields were found missing in civicrm_event table.';
return false;
}
$errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '2'));
return $this->checkVersion('2.1.102');
}
示例9: verifyPostDBState
function verifyPostDBState(&$errorMessage)
{
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_menu')) {
// db is not 2.1
$errorMessage .= ' Few 2.1 tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 2.1 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type')) {
// db looks to have stuck somewhere between 2.0 & 2.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
$errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '1'));
return $this->checkVersion('2.03');
}
示例10: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$errorMessage = ts('Pre-condition failed for upgrade step %1.', array(1 => '2'));
if (!CRM_Core_DAO::checkTableExists('civicrm_cache') || !CRM_Core_DAO::checkTableExists('civicrm_group_contact_cache') || !CRM_Core_DAO::checkTableExists('civicrm_menu') || !CRM_Core_DAO::checkTableExists('civicrm_discount') || !CRM_Core_DAO::checkTableExists('civicrm_pledge') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_block') || !CRM_Core_DAO::checkTableExists('civicrm_pledge_payment')) {
return false;
}
// check fields which MUST be present if a proper 2.1 db
if (!CRM_Core_DAO::checkFieldExists('civicrm_cache', 'group_name') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_cache', 'expired_date') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_discount', 'end_date') || !CRM_Core_DAO::checkFieldExists('civicrm_group_contact_cache', 'contact_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'path_arguments') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'is_exposed') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'page_type') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name')) {
// db looks to have stuck somewhere between 2.0 & 2.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
if ($this->checkVersion('2.03')) {
$this->setVersion($this->latestVersion);
} else {
return false;
}
return $this->checkVersion($this->latestVersion);
}
示例11: verifyPostDBState
function verifyPostDBState(&$errorMessage)
{
// check if Option Group & Option Values tables exists
if (!CRM_Core_DAO::checkTableExists('civicrm_option_group') || !CRM_Core_DAO::checkTableExists('civicrm_option_value')) {
$errorMessage .= ' option group or option value table is missing.';
return FALSE;
}
// check fields which MUST be present civicrm_option_group & civicrm_option_value
if (!CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'name') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'label') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'description') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'is_reserved') || !CRM_Core_DAO::checkFieldExists('civicrm_option_group', 'is_active')) {
$errorMessage .= ' Few important fields were found missing in civicrm_option_group table.';
return FALSE;
}
if (!CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'option_group_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'name') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'label') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'description') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'component_id') || !CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'is_active')) {
$errorMessage .= ' Few important fields were found missing in civicrm_option_value table.';
return FALSE;
}
$errorMessage = ts('Post-condition failed for upgrade step %1.', array(1 => '1'));
return $this->checkVersion('2.02');
}
示例12: verifyPreDBState
function verifyPreDBState(&$errorMessage)
{
$latestVer = CRM_Utils_System::version();
$errorMessage = ts('Pre-condition failed for upgrade to %1.', array(1 => $latestVer));
// check tables and table-columns, if the db is already 3.1
if (CRM_Core_DAO::checkTableExists('civicrm_acl_contact_cache') || CRM_Core_DAO::checkTableExists('civicrm_contact_type') || CRM_Core_DAO::checkTableExists('civicrm_dashboard') || CRM_Core_DAO::checkTableExists('civicrm_dashboard_contact') || CRM_Core_DAO::checkFieldExists('civicrm_country', 'is_province_abbreviated') || CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'date_format') || CRM_Core_DAO::checkFieldExists('civicrm_custom_field', 'time_format') || CRM_Core_DAO::checkFieldExists('civicrm_mail_settings', 'domain_id') || CRM_Core_DAO::checkFieldExists('civicrm_msg_template', 'workflow_id') || CRM_Core_DAO::checkFieldExists('civicrm_msg_template', 'is_default') || CRM_Core_DAO::checkFieldExists('civicrm_msg_template', 'is_reserved') || CRM_Core_DAO::checkFieldExists('civicrm_option_value', 'domain_id') || CRM_Core_DAO::checkFieldExists('civicrm_preferences', 'contact_autocomplete_options') || CRM_Core_DAO::checkFieldExists('civicrm_preferences_date', 'date_format') || CRM_Core_DAO::checkFieldExists('civicrm_preferences_date', 'time_format') || CRM_Core_DAO::checkFieldExists('civicrm_price_set', 'domain_id') || CRM_Core_DAO::checkFieldExists('civicrm_price_set', 'extends') || CRM_Core_DAO::checkFieldExists('civicrm_relationship_type', 'contact_sub_type_a') || CRM_Core_DAO::checkFieldExists('civicrm_relationship_type', 'contact_sub_type_b') || CRM_Core_DAO::checkFieldExists('civicrm_report_instance', 'domain_id')) {
$errorMessage = ts("Database check failed - it looks like you have already upgraded to the latest version (v%1) of the database. OR If you think this message is wrong, it is very likely that this a partially upgraded database and you will need to reload the correct database from backup on which upgrade was never tried.", array(1 => $latestVer));
return false;
}
//check previous version tables e.g 3.0.*
if (!CRM_Core_DAO::checkTableExists('civicrm_participant_status_type') || !CRM_Core_DAO::checkTableExists('civicrm_navigation')) {
$errorMessage .= ' Few important tables were found missing.';
return false;
}
// check fields which MUST be present if a proper 3.0.* db
if (!CRM_Core_DAO::checkFieldExists('civicrm_contact', 'email_greeting_id') || !CRM_Core_DAO::checkFieldExists('civicrm_contribution_page', 'created_id') || !CRM_Core_DAO::checkFieldExists('civicrm_custom_group', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'is_template') || !CRM_Core_DAO::checkFieldExists('civicrm_event', 'created_id') || !CRM_Core_DAO::checkFieldExists('civicrm_mailing', 'created_date') || !CRM_Core_DAO::checkFieldExists('civicrm_mapping_field', 'im_provider_id') || !CRM_Core_DAO::checkFieldExists('civicrm_membership_type', 'domain_id') || !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'domain_id') || !CRM_Core_DAO::checkFieldExists('civicrm_participant', 'fee_currency') || !CRM_Core_DAO::checkFieldExists('civicrm_payment_processor', 'domain_id') || !CRM_Core_DAO::checkFieldExists('civicrm_payment_processor_type', 'payment_type') || !CRM_Core_DAO::checkFieldExists('civicrm_preferences', 'domain_id') || !CRM_Core_DAO::checkFieldExists('civicrm_preferences', 'navigation') || !CRM_Core_DAO::checkFieldExists('civicrm_relationship_type', 'label_a_b') || !CRM_Core_DAO::checkFieldExists('civicrm_report_instance', 'navigation_id') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_field', 'is_reserved') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_group', 'created_id') || !CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
// db looks to have stuck somewhere between 3.0 & 3.1
$errorMessage .= ' Few important fields were found missing in some of the tables.';
return false;
}
return true;
}
示例13: loadValues
/**
* Load all explicit settings that apply to this domain or contact.
*
* @return $this
*/
public function loadValues()
{
// Note: Don't use DAO child classes. They require fields() which require
// translations -- which are keyed off settings!
$this->values = array();
$this->combined = NULL;
// Ordinarily, we just load values from `civicrm_setting`. But upgrades require care.
// In v4.0 and earlier, all values were stored in `civicrm_domain.config_backend`.
// In v4.1-v4.6, values were split between `civicrm_domain` and `civicrm_setting`.
// In v4.7+, all values are stored in `civicrm_setting`.
// Whenever a value is available in civicrm_setting, it will take precedence.
$isUpgradeMode = \CRM_Core_Config::isUpgradeMode();
if ($isUpgradeMode && empty($this->contactId) && \CRM_Core_DAO::checkFieldExists('civicrm_domain', 'config_backend', FALSE)) {
$config_backend = \CRM_Core_DAO::singleValueQuery('SELECT config_backend FROM civicrm_domain WHERE id = %1', array(1 => array($this->domainId, 'Positive')));
$oldSettings = \CRM_Upgrade_Incremental_php_FourSeven::convertBackendToSettings($this->domainId, $config_backend);
\CRM_Utils_Array::extend($this->values, $oldSettings);
}
// Normal case. Aside: Short-circuit prevents unnecessary query.
if (!$isUpgradeMode || \CRM_Core_DAO::checkTableExists('civicrm_setting')) {
$dao = \CRM_Core_DAO::executeQuery($this->createQuery()->toSQL());
while ($dao->fetch()) {
$this->values[$dao->name] = $dao->value !== NULL ? unserialize($dao->value) : NULL;
}
}
return $this;
}
示例14: get
static function get($path)
{
// return null if menu rebuild
$config =& CRM_Core_Config::singleton();
$params = array();
$args = explode('/', $path);
$elements = array();
while (!empty($args)) {
$string = implode('/', $args);
$string = CRM_Core_DAO::escapeString($string);
$elements[] = "'{$string}'";
array_pop($args);
}
$queryString = implode(', ', $elements);
$domainID = CRM_Core_Config::domainID();
$domainWhereClause = " AND domain_id = {$domainID} ";
if ($path == 'civicrm/upgrade' && !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'domain_id')) {
//domain_id wouldn't be available for earlier version of
//3.0 and therefore can't be used as part of query for
//upgrade case
$domainWhereClause = "";
}
$query = "\n( \n SELECT * \n FROM civicrm_menu \n WHERE path in ( {$queryString} )\n {$domainWhereClause}\n ORDER BY length(path) DESC\n LIMIT 1 \n)\n";
if ($path != 'navigation') {
$query .= "\nUNION ( \n SELECT *\n FROM civicrm_menu \n WHERE path IN ( 'navigation' )\n {$domainWhereClause}\n)\n";
}
require_once "CRM/Core/DAO/Menu.php";
$menu =& new CRM_Core_DAO_Menu();
$menu->query($query);
self::$_menuCache = array();
$menuPath = null;
while ($menu->fetch()) {
self::$_menuCache[$menu->path] = array();
CRM_Core_DAO::storeValues($menu, self::$_menuCache[$menu->path]);
foreach (self::$_serializedElements as $element) {
self::$_menuCache[$menu->path][$element] = unserialize($menu->{$element});
if (strpos($path, $menu->path) !== false) {
$menuPath =& self::$_menuCache[$menu->path];
}
}
}
// *FIXME* : hack for 2.1 -> 2.2 upgrades.
if ($path == 'civicrm/upgrade') {
$menuPath['page_callback'] = 'CRM_Upgrade_Page_Upgrade';
$menuPath['access_arguments'][0][] = 'administer CiviCRM';
$menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
}
$i18n =& CRM_Core_I18n::singleton();
$i18n->localizeTitles($menuPath);
return $menuPath;
}
示例15: retrieve
/**
* Retrieve the settings values from db.
*
* @param $defaults
*
* @return array
*/
public static function retrieve(&$defaults)
{
$domain = new CRM_Core_DAO_Domain();
$isUpgrade = CRM_Core_Config::isUpgradeMode();
//we are initializing config, really can't use, CRM-7863
$urlVar = 'q';
if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') {
$urlVar = 'task';
}
if ($isUpgrade && CRM_Core_DAO::checkFieldExists('civicrm_domain', 'config_backend')) {
$domain->selectAdd('config_backend');
} else {
$domain->selectAdd('locales');
}
$domain->id = CRM_Core_Config::domainID();
$domain->find(TRUE);
if ($domain->config_backend) {
$defaults = unserialize($domain->config_backend);
if ($defaults === FALSE || !is_array($defaults)) {
$defaults = array();
return FALSE;
}
$skipVars = self::skipVars();
foreach ($skipVars as $skip) {
if (array_key_exists($skip, $defaults)) {
unset($defaults[$skip]);
}
}
}
if (!$isUpgrade) {
CRM_Core_BAO_ConfigSetting::applyLocale(Civi::settings($domain->id), $domain->locales);
}
}