本文整理汇总了PHP中CRM_Core_DAO::query方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO::query方法的具体用法?PHP CRM_Core_DAO::query怎么用?PHP CRM_Core_DAO::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO
的用法示例。
在下文中一共展示了CRM_Core_DAO::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
//Test database user privilege to create table(Temporary) CRM-4725
CRM_Core_Error::ignoreException();
$daoTestPrivilege = new CRM_Core_DAO();
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("DROP TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
CRM_Core_Error::setCallback();
if ($daoTestPrivilege->_lastError) {
CRM_Core_Error::fatal(ts('Database Configuration Error: Insufficient permissions. Import requires that the CiviCRM database user has permission to create temporary tables. Contact your site administrator for assistance.'));
}
$this->_dataSourceIsValid = false;
$this->_dataSource = CRM_Utils_Request::retrieve('dataSource', 'String', CRM_Core_DAO::$_nullObject);
$this->_params = $this->controller->exportValues($this->_name);
if (!$this->_dataSource) {
//considering dataSource as base criteria instead of hidden_dataSource.
$this->_dataSource = CRM_Utils_Array::value('dataSource', $_POST, CRM_Utils_Array::value('dataSource', $this->_params));
$this->assign('showOnlyDataSourceFormPane', false);
} else {
$this->assign('showOnlyDataSourceFormPane', true);
}
if (strpos($this->_dataSource, 'CRM_Import_DataSource_') === 0) {
$this->_dataSourceIsValid = true;
$this->assign('showDataSourceFormPane', true);
$dataSourcePath = split('_', $this->_dataSource);
$templateFile = "CRM/Import/Form/" . $dataSourcePath[3] . ".tpl";
$this->assign('dataSourceFormTemplateFile', $templateFile);
}
}
示例2: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
//Test database user privilege to create table(Temporary) CRM-4725
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$daoTestPrivilege = new CRM_Core_DAO();
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("DROP TEMPORARY TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
unset($errorScope);
if ($daoTestPrivilege->_lastError) {
CRM_Core_Error::fatal(ts('Database Configuration Error: Insufficient permissions. Import requires that the CiviCRM database user has permission to create temporary tables. Contact your site administrator for assistance.'));
}
$results = array();
$config = CRM_Core_Config::singleton();
$handler = opendir($config->uploadDir);
$errorFiles = array('sqlImport.errors', 'sqlImport.conflicts', 'sqlImport.duplicates', 'sqlImport.mismatch');
// check for post max size avoid when called twice
$snippet = CRM_Utils_Array::value('snippet', $_GET, 0);
if (empty($snippet)) {
CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
}
while ($file = readdir($handler)) {
if ($file != '.' && $file != '..' && in_array($file, $errorFiles) && !is_writable($config->uploadDir . $file)) {
$results[] = $file;
}
}
closedir($handler);
if (!empty($results)) {
CRM_Core_Error::fatal(ts('<b>%1</b> file(s) in %2 directory are not writable. Listed file(s) might be used during the import to log the errors occurred during Import process. Contact your site administrator for assistance.', array(1 => implode(', ', $results), 2 => $config->uploadDir)));
}
$this->_dataSourceIsValid = FALSE;
$this->_dataSource = CRM_Utils_Request::retrieve('dataSource', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
$this->_params = $this->controller->exportValues($this->_name);
if (!$this->_dataSource) {
//considering dataSource as base criteria instead of hidden_dataSource.
$this->_dataSource = CRM_Utils_Array::value('dataSource', $_POST, CRM_Utils_Array::value('dataSource', $this->_params));
$this->assign('showOnlyDataSourceFormPane', FALSE);
} else {
$this->assign('showOnlyDataSourceFormPane', TRUE);
}
$dataSources = $this->_getDataSources();
if ($this->_dataSource && isset($dataSources[$this->_dataSource])) {
$this->_dataSourceIsValid = TRUE;
$this->assign('showDataSourceFormPane', TRUE);
$dataSourcePath = explode('_', $this->_dataSource);
$templateFile = "CRM/Contact/Import/Form/" . $dataSourcePath[3] . ".tpl";
$this->assign('dataSourceFormTemplateFile', $templateFile);
} elseif ($this->_dataSource) {
throw new \CRM_Core_Exception("Invalid data source");
}
}
示例3: defined
function __construct()
{
// don’t display the ‘Add these Contacts to Group’ button
$this->_add2groupSupported = FALSE;
$dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
$this->db = $dsn['database'];
$this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'Integer', CRM_Core_DAO::$_nullObject);
$this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
$this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject);
parent::__construct();
CRM_Utils_System::resetBreadCrumb();
$breadcrumb = array(array('title' => ts('Home'), 'url' => CRM_Utils_System::url()), array('title' => ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm', 'reset=1')), array('title' => ts('View Contact'), 'url' => CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->cid}")), array('title' => ts('Search Results'), 'url' => CRM_Utils_System::url('civicrm/contact/search', "force=1")));
CRM_Utils_System::appendBreadCrumb($breadcrumb);
if (CRM_Utils_Request::retrieve('revert', 'Boolean', CRM_Core_DAO::$_nullObject)) {
$reverter = new CRM_Logging_Reverter($this->log_conn_id, $this->log_date);
$reverter->revert($this->tables);
CRM_Core_Session::setStatus(ts('The changes have been reverted.'));
if ($this->cid) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE));
} else {
CRM_Utils_System::redirect(CRM_Report_Utils_Report::getNextUrl($this->summary, 'reset=1', FALSE, TRUE));
}
}
// make sure the report works even without the params
if (!$this->log_conn_id or !$this->log_date) {
$dao = new CRM_Core_DAO();
$dao->query("SELECT log_conn_id, log_date FROM `{$this->db}`.log_{$this->tables[0]} WHERE log_action = 'Update' ORDER BY log_date DESC LIMIT 1");
$dao->fetch();
$this->log_conn_id = $dao->log_conn_id;
$this->log_date = $dao->log_date;
}
$this->_columnHeaders = array('field' => array('title' => ts('Field')), 'from' => array('title' => ts('Changed From')), 'to' => array('title' => ts('Changed To')));
}
示例4: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
//Test database user privilege to create table(Temporary) CRM-4725
CRM_Core_Error::ignoreException();
$daoTestPrivilege = new CRM_Core_DAO();
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("DROP TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
CRM_Core_Error::setCallback();
if ($daoTestPrivilege->_lastError) {
CRM_Core_Error::fatal(ts('Database Configuration Error: Insufficient permissions. Import requires that the CiviCRM database user has permission to create temporary tables. Contact your site administrator for assistance.'));
}
$results = array();
$config = CRM_Core_Config::singleton();
$handler = opendir($config->uploadDir);
$errorFiles = array('sqlImport.errors', 'sqlImport.conflicts', 'sqlImport.duplicates', 'sqlImport.mismatch');
while ($file = readdir($handler)) {
if ($file != '.' && $file != '..' && in_array($file, $errorFiles) && !is_writable($config->uploadDir . $file)) {
$results[] = $file;
}
}
closedir($handler);
if (!empty($results)) {
CRM_Core_Error::fatal(ts('<b>%1</b> file(s) in %2 directory are not writable. Listed file(s) might be used during the import to log the errors occurred during Import process. Contact your site administrator for assistance.', array(1 => implode(', ', $results), 2 => $config->uploadDir)));
}
$this->_dataSourceIsValid = false;
$this->_dataSource = CRM_Utils_Request::retrieve('dataSource', 'String', CRM_Core_DAO::$_nullObject);
$this->_params = $this->controller->exportValues($this->_name);
if (!$this->_dataSource) {
//considering dataSource as base criteria instead of hidden_dataSource.
$this->_dataSource = CRM_Utils_Array::value('dataSource', $_POST, CRM_Utils_Array::value('dataSource', $this->_params));
$this->assign('showOnlyDataSourceFormPane', false);
} else {
$this->assign('showOnlyDataSourceFormPane', true);
}
if (strpos($this->_dataSource, 'CRM_Import_DataSource_') === 0) {
$this->_dataSourceIsValid = true;
$this->assign('showDataSourceFormPane', true);
$dataSourcePath = explode('_', $this->_dataSource);
$templateFile = "CRM/Import/Form/" . $dataSourcePath[3] . ".tpl";
$this->assign('dataSourceFormTemplateFile', $templateFile);
}
}
示例5: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$values = $ids = array();
$params = array('id' => $this->get('id'));
CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
$values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
$values['honor_type'] = $honor[$values['honor_type_id']];
}
//handle custom data.
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
if (!empty($values['contribution_page_id'])) {
$values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
}
$values['financial_type'] = CRM_Utils_Array::value($values['financial_type_id'], CRM_Contribute_PseudoConstant::financialType());
if ($values['status_id']) {
$values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
}
$url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
$displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
$this->assign('displayName', $displayName);
$title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['financial_type'] . ')';
// add Pledge to Recent Items
CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], NULL, $recentOther);
// Check if this is default domain contact CRM-10482
if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
$displayName .= ' (' . ts('default organization') . ')';
}
// omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
$this->assign($values);
}
示例6: setDefaultValues
function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if (!CRM_Utils_Array::value('weight', $defaults)) {
$query = "SELECT max( `weight` ) as weight FROM `civicrm_booking_resource_config_set`";
$dao = new CRM_Core_DAO();
$dao->query($query);
$dao->fetch();
$defaults['weight'] = $dao->weight + 1;
}
return $defaults;
}
示例7: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Pledge/BAO/Pledge.php';
$values = $ids = array();
$params = array('id' => $this->get('id'));
CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
$values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::honor();
$values['honor_type'] = $honor[$values['honor_type_id']];
}
//handle custom data.
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
if (CRM_Utils_Array::value('contribution_page_id', $values)) {
$values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
}
$values['contribution_type'] = CRM_Utils_Array::value($values['contribution_type_id'], CRM_Contribute_PseudoConstant::contributionType());
if ($values['status_id']) {
$values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
}
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
require_once 'CRM/Utils/Money.php';
$displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
$this->assign('displayName', $displayName);
$title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['contribution_type'] . ')';
// add Pledge to Recent Items
CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], null, $recentOther);
$this->assign($values);
}
示例8: defined
function __construct()
{
$this->_add2groupSupported = false;
// don’t display the ‘Add these Contacts to Group’ button
$dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
$this->loggingDB = $dsn['database'];
$this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'Integer', CRM_Core_DAO::$_nullObject);
$this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
// make sure the report works even without the params
if (!$this->log_conn_id or !$this->log_date) {
$dao = new CRM_Core_DAO();
$dao->query("SELECT log_conn_id, log_date FROM `{$this->loggingDB}`.log_civicrm_contact WHERE log_action = 'Update' ORDER BY log_date DESC LIMIT 1");
$dao->fetch();
$this->log_conn_id = $dao->log_conn_id;
$this->log_date = $dao->log_date;
}
$this->_columnHeaders = array('field' => array('title' => ts('Field')), 'from' => array('title' => ts('Changed From')), 'to' => array('title' => ts('Changed To')));
parent::__construct();
}
示例9: finish
/**
* @param int $newState
* @void
*/
public function finish($newState = self::F_DONE)
{
if ($this->state == self::F_FORCED) {
return;
}
assert('$this->state === self::F_ACTIVE');
$this->state = $newState;
if ($this->doCommit) {
$this->invokeCallbacks(\CRM_Core_Transaction::PHASE_PRE_COMMIT);
if ($this->commitStmt) {
$this->dao->query($this->commitStmt);
}
$this->invokeCallbacks(\CRM_Core_Transaction::PHASE_POST_COMMIT);
} else {
$this->invokeCallbacks(\CRM_Core_Transaction::PHASE_PRE_ROLLBACK);
if ($this->rollbackStmt) {
$this->dao->query($this->rollbackStmt);
}
$this->invokeCallbacks(\CRM_Core_Transaction::PHASE_POST_ROLLBACK);
}
}
示例10: setDefaultValues
/**
* This function sets the default values for the form. Relationship that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
if ($this->_action & CRM_Core_Action::UPDATE) {
if (!empty($this->_values)) {
$defaults['relationship_type_id'] = $this->_rtypeId;
if (CRM_Utils_Array::value('start_date', $this->_values)) {
list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults($this->_values['start_date']);
}
if (CRM_Utils_Array::value('end_date', $this->_values)) {
list($defaults['end_date']) = CRM_Utils_Date::setDateDefaults($this->_values['end_date']);
}
$defaults['description'] = CRM_Utils_Array::value('description', $this->_values);
$defaults['is_active'] = CRM_Utils_Array::value('is_active', $this->_values);
$defaults['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_a_b', $this->_values);
$defaults['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_b_a', $this->_values);
$contact = new CRM_Contact_DAO_Contact();
if ($this->_rtype == 'a_b' && $this->_values['contact_id_a'] == $this->_contactId) {
$contact->id = $this->_values['contact_id_b'];
} else {
$contact->id = $this->_values['contact_id_a'];
}
if ($contact->find(true)) {
$this->_display_name_b = $contact->display_name;
$this->assign('sort_name_b', $this->_display_name_b);
//is current employee/employer.
if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employee of' && $contact->id == CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'employer_id')) {
$defaults['is_current_employer'] = 1;
$this->_values['current_employee_id'] = $this->_contactId;
$this->_values['current_employer_id'] = $contact->id;
} else {
if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employer of' && $this->_contactId == $contact->employer_id) {
$defaults['is_current_employer'] = 1;
$this->_values['current_employee_id'] = $contact->id;
$this->_values['current_employer_id'] = $this->_contactId;
}
}
}
$relationshipID = $this->_values['id'];
$query = "SELECT id, note FROM civicrm_note where entity_table = 'civicrm_relationship' and entity_id = {$relationshipID} order by modified_date desc";
$dao = new CRM_Core_DAO();
$dao->query($query);
if ($dao->fetch($query)) {
$defaults['note'] = $dao->note;
}
}
} else {
$defaults['is_active'] = 1;
$defaults['relationship_type_id'] = $this->_rtypeId;
}
return $defaults;
}
示例11: checkTriggerViewPermission
/**
* @param bool $view
* @param bool $trigger
*
* @return bool
*/
public static function checkTriggerViewPermission($view = TRUE, $trigger = TRUE)
{
// test for create view and trigger permissions and if allowed, add the option to go multilingual
// and logging
// I'm not sure why we use the getStaticProperty for an error, rather than checking for DB_Error
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$dao = new CRM_Core_DAO();
if ($view) {
$dao->query('CREATE OR REPLACE VIEW civicrm_domain_view AS SELECT * FROM civicrm_domain');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
return FALSE;
}
}
if ($trigger) {
$result = $dao->query('CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EACH ROW BEGIN END');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError') || is_a($result, 'DB_Error')) {
if ($view) {
$dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
}
return FALSE;
}
$dao->query('DROP TRIGGER IF EXISTS civicrm_domain_trigger');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
if ($view) {
$dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
}
return FALSE;
}
}
if ($view) {
$dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
return FALSE;
}
}
return TRUE;
}
示例12: usedByModule
/**
* Check if profile Group used by any module.
*
* @param int $id
* Profile Id.
*
* @return bool
*
*/
public static function usedByModule($id)
{
//check whether this group is used by any module(check uf join records)
$sql = "SELECT id\n FROM civicrm_uf_join\n WHERE civicrm_uf_join.uf_group_id={$id}";
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
return TRUE;
} else {
return FALSE;
}
}
示例13: getDisplayAndImage
/**
* Get the display name and image of a contact.
*
* @param int $id
* The contactId.
*
* @param bool $includeTypeInReturnParameters
* Should type be part of the returned array?
*
* @return array
* the displayName and contactImage for this contact
*/
public static function getDisplayAndImage($id, $includeTypeInReturnParameters = FALSE)
{
//CRM-14276 added the * on the civicrm_contact table so that we have all the contact info available
$sql = "\nSELECT civicrm_contact.*,\n civicrm_email.email as email\nFROM civicrm_contact\nLEFT JOIN civicrm_email ON civicrm_email.contact_id = civicrm_contact.id\n AND civicrm_email.is_primary = 1\nWHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
$image = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? $dao->contact_sub_type : $dao->contact_type, FALSE, $id);
$imageUrl = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? $dao->contact_sub_type : $dao->contact_type, TRUE, $id);
// use email if display_name is empty
if (empty($dao->display_name)) {
$displayName = $dao->email;
} else {
$displayName = $dao->display_name;
}
CRM_Utils_Hook::alterDisplayName($displayName, $id, $dao);
return $includeTypeInReturnParameters ? array($displayName, $image, $dao->contact_type, $dao->contact_sub_type, $imageUrl) : array($displayName, $image, $imageUrl);
}
return NULL;
}
示例14: completeTransaction
function completeTransaction(&$input, &$ids, &$objects, &$transaction, $recur = FALSE)
{
$contribution =& $objects['contribution'];
$primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
$memberships =& $objects['membership'];
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
}
$participant =& $objects['participant'];
$event =& $objects['event'];
$changeToday = CRM_Utils_Array::value('trxn_date', $input, self::$_now);
$recurContrib =& $objects['contributionRecur'];
$values = array();
if (isset($input['is_email_receipt'])) {
$values['is_email_receipt'] = $input['is_email_receipt'];
}
$source = NULL;
if ($input['component'] == 'contribute') {
if ($contribution->contribution_page_id) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
$source = ts('Online Contribution') . ': ' . $values['title'];
} elseif ($recurContrib && $recurContrib->id) {
$contribution->contribution_page_id = NULL;
$values['amount'] = $recurContrib->amount;
$values['financial_type_id'] = $objects['contributionType']->id;
$values['title'] = $source = ts('Offline Recurring Contribution');
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$values['receipt_from_name'] = $domainValues[0];
$values['receipt_from_email'] = $domainValues[1];
}
if ($recurContrib && $recurContrib->id && !isset($input['is_email_receipt'])) {
//CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
// but CRM-16124 if $input['is_email_receipt'] is set then that should not be overridden.
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
$contribution->source = $source;
if (CRM_Utils_Array::value('is_email_receipt', $values)) {
$contribution->receipt_date = self::$_now;
}
if (!empty($memberships)) {
$membershipsUpdate = array();
foreach ($memberships as $membershipTypeIdKey => $membership) {
if ($membership) {
$format = '%Y%m%d';
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id, $membership->membership_type_id, $membership->is_test, $membership->id);
// CRM-8141 update the membership type with the value recorded in log when membership created/renewed
// this picks up membership type changes during renewals
$sql = "\nSELECT membership_type_id\nFROM civicrm_membership_log\nWHERE membership_id={$membership->id}\nORDER BY id DESC\nLIMIT 1;";
$dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
$membership->membership_type_id = $dao->membership_type_id;
$membership->save();
}
// else fall back to using current membership type
}
// else fall back to using current membership type
$dao->free();
$num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id, $primaryContributionID);
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
* In BAO/Membership.php(renewMembership function), we skip the extend membership date and status
* when Contribution mode is notify and membership is for renewal )
*/
CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
// @todo - we should pass membership_type_id instead of null here but not
// adding as not sure of testing
$dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday, NULL, $num_terms);
$dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
} else {
$dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $num_terms);
}
//get the status for membership.
$calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($dates['start_date'], $dates['end_date'], $dates['join_date'], 'today', TRUE, $membership->membership_type_id, (array) $membership);
$formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format));
//we might be renewing membership,
//so make status override false.
$formatedParams['is_override'] = FALSE;
$membership->copyValues($formatedParams);
$membership->save();
//updating the membership log
$membershipLog = array();
$membershipLog = $formatedParams;
$logStartDate = $formatedParams['start_date'];
if (CRM_Utils_Array::value('log_start_date', $dates)) {
$logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
$logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
}
$membershipLog['start_date'] = $logStartDate;
$membershipLog['membership_id'] = $membership->id;
$membershipLog['modified_id'] = $membership->contact_id;
$membershipLog['modified_date'] = date('Ymd');
$membershipLog['membership_type_id'] = $membership->membership_type_id;
CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
//update related Memberships.
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
//update the membership type key of membership relatedObjects array
//if it has changed after membership update
//.........这里部分代码省略.........
示例15: dupesByParams
/**
* Return an array of possible dupes, based on the provided array of
* params, using the default rule group for the given contact type and
* level.
*
* check_permission is a boolean flag to indicate if permission should be considered.
* default is to always check permissioning but public pages for example might not want
* permission to be checked for anonymous users. Refer CRM-6211. We might be beaking
* Multi-Site dedupe for public pages.
*
* @param array $params array of params of the form $params[$table][$field] == $value
* @param string $ctype contact type to match against
* @param string $level dedupe rule group level ('Fuzzy' or 'Strict')
* @param array $except array of contacts that shouldn't be considered dupes
* @param int $ruleGroupID the id of the dedupe rule we should be using
*
* @return array matching contact ids
*/
static function dupesByParams($params, $ctype, $level = 'Strict', $except = array(), $ruleGroupID = NULL)
{
// If $params is empty there is zero reason to proceed.
if (!$params) {
return array();
}
$foundByID = FALSE;
if ($ruleGroupID) {
$rgBao = new CRM_Dedupe_BAO_RuleGroup();
$rgBao->id = $ruleGroupID;
$rgBao->contact_type = $ctype;
if ($rgBao->find(TRUE)) {
$foundByID = TRUE;
}
}
if (!$foundByID) {
$rgBao = new CRM_Dedupe_BAO_RuleGroup();
$rgBao->contact_type = $ctype;
$rgBao->level = $level;
$rgBao->is_default = 1;
if (!$rgBao->find(TRUE)) {
CRM_Core_Error::fatal("{$level} rule for {$ctype} does not exist");
}
}
$params['check_permission'] = CRM_Utils_Array::value('check_permission', $params, TRUE);
$rgBao->params = $params;
$rgBao->fillTable();
$dao = new CRM_Core_DAO();
$dao->query($rgBao->thresholdQuery($params['check_permission']));
$dupes = array();
while ($dao->fetch()) {
if (isset($dao->id) && $dao->id) {
$dupes[] = $dao->id;
}
}
$dao->query($rgBao->tableDropQuery());
return array_diff($dupes, $except);
}