本文整理汇总了PHP中CRM_Core_BAO_Domain::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Domain::getTableName方法的具体用法?PHP CRM_Core_BAO_Domain::getTableName怎么用?PHP CRM_Core_BAO_Domain::getTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Domain
的用法示例。
在下文中一共展示了CRM_Core_BAO_Domain::getTableName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
*
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setUp();
$this->useTransaction(TRUE);
// taken from form code - couldn't find good method to use
$params['entity_id'] = 1;
$params['entity_table'] = CRM_Core_BAO_Domain::getTableName();
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$domContact = $this->callAPISuccess('contact', 'create', array('contact_type' => 'Organization', 'organization_name' => 'new org', 'api.phone.create' => array('location_type_id' => $defaultLocationType->id, 'phone_type_id' => 1, 'phone' => '456-456'), 'api.address.create' => array('location_type_id' => $defaultLocationType->id, 'street_address' => '45 Penny Lane'), 'api.email.create' => array('location_type_id' => $defaultLocationType->id, 'email' => 'my@email.com')));
$this->callAPISuccess('domain', 'create', array('id' => 1, 'contact_id' => $domContact['id']));
$this->params = array('name' => 'A-team domain', 'description' => 'domain of chaos', 'domain_version' => '4.2', 'contact_id' => $domContact['id']);
}
示例2: add
/**
* takes an associative array and creates a contact object
*
* the function extract all the params it needs to initialize the create a
* contact object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
* @param array $locationId
*
* @return object CRM_Core_BAO_Location object on success, null otherwise
* @access public
* @static
*/
function add(&$params, &$ids, $locationId)
{
if (!CRM_Core_BAO_Location::dataExists($params, $locationId, $ids)) {
return null;
}
$location =& new CRM_Core_BAO_Location();
if (!isset($params['contact_id'])) {
require_once 'CRM/Core/BAO/Domain.php';
$location->entity_table = CRM_Core_BAO_Domain::getTableName();
$location->entity_id = $params['domain_id'];
} else {
$location->entity_table = CRM_Contact_BAO_Contact::getTableName();
$location->entity_id = $params['contact_id'];
}
$location->location_type_id = CRM_Utils_Array::value('location_type_id', $params['location'][$locationId]);
$location->name = CRM_Utils_Array::value('name', $params['location'][$locationId]);
$location->is_primary = CRM_Utils_Array::value('is_primary', $params['location'][$locationId], false);
// check if there exists another location has is_primary set, and if so reset that
// if no location has is_primary, make this one is_primart
if ($location->is_primary) {
// reset all other locations with the same entity table entity id
$sql = "UPDATE " . CRM_Core_BAO_Location::getTableName() . "\n SET is_primary = 0 WHERE \n entity_table = '{$location->entity_table}' AND\n entity_id = '{$location->entity_id}' ";
CRM_Core_DAO::executeQuery($sql);
} else {
// make sure there is at once location with is_primary set
$sql = "SELECT count( " . CRM_Core_BAO_Location::getTableName() . ".id )\n FROM " . CRM_Core_BAO_Location::getTableName() . " WHERE\n entity_table = '{$location->entity_table}' AND\n entity_id = '{$location->entity_id}' AND\n is_primary = 1";
$count = CRM_Core_DAO::singleValueQuery($sql);
if ($count == 0) {
$location->is_primary = true;
}
}
$location->id = CRM_Utils_Array::value('id', $ids['location'][$locationId]);
$location->save();
$params['location'][$locationId]['id'] = $location->id;
$address_object = CRM_Core_BAO_Address::add($params, $ids, $locationId);
$location->address = $address_object;
// set this to true if this has been made the primary IM.
// the rule is the first entered value is the primary object
$isPrimaryPhone = $isPrimaryEmail = $isPrimaryIM = true;
$location->phone = array();
$location->email = array();
$location->im = array();
for ($i = 1; $i <= CRM_CONTACT_FORM_LOCATION_BLOCKS; $i++) {
$location->phone[$i] = CRM_Core_BAO_Phone::add($params, $ids, $locationId, $i, $isPrimaryPhone);
$location->email[$i] = CRM_Core_BAO_Email::add($params, $ids, $locationId, $i, $isPrimaryEmail);
$location->im[$i] = CRM_Core_BAO_IM::add($params, $ids, $locationId, $i, $isPrimaryIM);
}
return $location;
}
示例3: postProcess
/**
* Process the form when submitted
*
* @return void
* @access public
*/
public function postProcess()
{
require_once 'CRM/Core/BAO/Domain.php';
$params = array();
$params = $this->exportValues();
$params['entity_id'] = $this->_id;
$params['entity_table'] = CRM_Core_BAO_Domain::getTableName();
$domain = CRM_Core_BAO_Domain::edit($params, $this->_id);
require_once 'CRM/Core/BAO/LocationType.php';
$defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
$location = array();
$params['address'][1]['location_type_id'] = $defaultLocationType->id;
$params['phone'][1]['location_type_id'] = $defaultLocationType->id;
$params['email'][1]['location_type_id'] = $defaultLocationType->id;
$location = CRM_Core_BAO_Location::create($params, true, 'domain');
$params['loc_block_id'] = $location['id'];
require_once 'CRM/Core/BAO/Domain.php';
CRM_Core_BAO_Domain::edit($params, $this->_id);
//set domain from email address, CRM-3552
$emailName = '"' . $params['email_name'] . '"<' . $params['email_address'] . '>';
$emailParams = array('label' => $emailName, 'description' => $params['description'], 'is_active' => 1, 'is_default' => 1);
$groupParams = array('name' => 'from_email_address');
//get the option value wt.
if ($this->_fromEmailId) {
$action = $this->_action;
$emailParams['weight'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_fromEmailId, 'weight');
} else {
//add from email address.
$action = CRM_Core_Action::ADD;
require_once 'CRM/Utils/Weight.php';
$grpId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'from_email_address', 'id', 'name');
$fieldValues = array('option_group_id' => $grpId);
$emailParams['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
}
require_once 'CRM/Core/OptionValue.php';
//reset default within domain.
$emailParams['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID());
CRM_Core_OptionValue::addOptionValue($emailParams, $groupParams, $action, $this->_fromEmailId);
CRM_Core_Session::setStatus(ts('Domain information for \'%1\' has been saved.', array(1 => $domain->name)));
$session =& CRM_Core_Session::singleton();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
}
示例4: postProcess
/**
* Process the form when submitted.
*
* @return void
*/
public function postProcess()
{
$params = $this->exportValues();
$params['entity_id'] = $this->_id;
$params['entity_table'] = CRM_Core_BAO_Domain::getTableName();
$domain = CRM_Core_BAO_Domain::edit($params, $this->_id);
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
if (isset($this->_locationDefaults['address'][1]['location_type_id'])) {
$params['address'][1]['location_type_id'] = $this->_locationDefaults['address'][1]['location_type_id'];
} else {
$params['address'][1]['location_type_id'] = $defaultLocationType->id;
}
if (isset($this->_locationDefaults['phone'][1]['location_type_id'])) {
$params['phone'][1]['location_type_id'] = $this->_locationDefaults['phone'][1]['location_type_id'];
} else {
$params['phone'][1]['location_type_id'] = $defaultLocationType->id;
}
if (isset($this->_locationDefaults['email'][1]['location_type_id'])) {
$params['email'][1]['location_type_id'] = $this->_locationDefaults['email'][1]['location_type_id'];
} else {
$params['email'][1]['location_type_id'] = $defaultLocationType->id;
}
$params += array('contact_id' => $this->_contactId);
$contactParams = array('sort_name' => $domain->name, 'display_name' => $domain->name, 'legal_name' => $domain->name, 'organization_name' => $domain->name, 'contact_id' => $this->_contactId, 'contact_type' => 'Organization');
if ($this->_contactId) {
$contactParams['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId);
}
CRM_Contact_BAO_Contact::add($contactParams);
CRM_Core_BAO_Location::create($params, TRUE);
CRM_Core_BAO_Domain::edit($params, $this->_id);
//set domain from email address, CRM-3552
$emailName = '"' . $params['email_name'] . '" <' . $params['email_address'] . '>';
$emailParams = array('label' => $emailName, 'description' => $params['description'], 'is_active' => 1, 'is_default' => 1);
$groupParams = array('name' => 'from_email_address');
//get the option value wt.
if ($this->_fromEmailId) {
$action = $this->_action;
$emailParams['weight'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_fromEmailId, 'weight');
} else {
//add from email address.
$action = CRM_Core_Action::ADD;
$grpId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'from_email_address', 'id', 'name');
$fieldValues = array('option_group_id' => $grpId);
$emailParams['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
}
//reset default within domain.
$emailParams['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID());
CRM_Core_OptionValue::addOptionValue($emailParams, $groupParams, $action, $this->_fromEmailId);
CRM_Core_Session::setStatus(ts("Domain information for '%1' has been saved.", array(1 => $domain->name)), ts('Saved'), 'success');
$session = CRM_Core_Session::singleton();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
}
示例5: array
/**
* Get the location values of a domain
*
* @param NULL
*
* @return array Location::getValues
* @access public
*/
function &getLocationValues()
{
if ($this->_location == null) {
$params = array('domain_id' => $this->id, 'entity_id' => $this->id, 'entity_table' => CRM_Core_BAO_Domain::getTableName());
$values = array();
$ids = array();
CRM_Core_BAO_Location::getValues($params, $values, $ids, 1);
if (!CRM_Utils_Array::value('location', $values) || !CRM_Utils_Array::value('1', $values['location'])) {
$this->_location = null;
return $this->_location;
}
$loc =& $values['location'];
/* Translate the state/province and country ids to names */
if (CRM_Utils_Array::value('address', $loc[1])) {
if (!array_key_exists('state_province', $loc[1]['address'])) {
$loc[1]['state_province'] = CRM_Core_PseudoConstant::stateProvince($loc[1]['address']['state_province_id']);
if (!$loc[1]['address']['state_province']) {
$loc[1]['address']['state_province'] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($loc[1]['address']['state_province_id']);
}
}
if (!array_key_exists('country', $loc[1]['address'])) {
$loc[1]['address']['country'] = CRM_Core_PseudoConstant::country($loc[1]['address']['country_id']);
if (!$loc[1]['address']['country']) {
$loc[1]['address']['country'] = CRM_Core_PseudoConstant::countryIsoCode($loc[1]['address']['country_id']);
}
}
}
$this->_location = $loc[1];
}
return $this->_location;
}
示例6: CRM_Core_BAO_ACL
/**
* Retrieve ACLs for a contact or group. Note that including a contact id
* without a group id will return those ACL rules which are granted
* directly to the contact, but not those granted to the contact through
* any/all of his group memberships.
*
* @param int $contact_id - ID of a contact to search for
* @param int $group_id - ID of a group to search for
* @param boolean $aclGroups - Should we include ACL Groups
* @return array - Array of assoc. arrays of ACL rules
* @access public
* @static
*/
function &getACLs($contact_id = null, $group_id = null, $aclGroups = false)
{
$contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');
$group_id = CRM_Utils_Type::escape($group_id, 'Integer');
$rule =& new CRM_Core_BAO_ACL();
$acl = CRM_Core_BAO_ACL::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();
$c2g = CRM_Contact_BAO_GroupContact::getTableName();
$domain = CRM_Core_BAO_Domain::getTableName();
$group = CRM_Contact_BAO_Group::getTableName();
$session =& CRM_Core_Session::singleton();
$domainId = $session->get('domainID');
$query = " SELECT {$acl}.*\n FROM {$acl} ";
if (!empty($group_id)) {
$query .= " INNER JOIN {$c2g}\n ON {$acl}.entity_id = {$c2g}.group_id\n WHERE {$acl}.entity_table = '{$group}'\n AND {$c2g}.group_id = {$group_id}";
if (!empty($contact_id)) {
$query .= " AND {$c2g}.contact_id = {$contact_id}\n AND {$c2g}.status = 'Added'";
}
} else {
if (!empty($contact_id)) {
$query .= " WHERE {$acl}.entity_table = '{$contact}'\n AND {$acl}.entity_id = {$contact_id}";
} else {
$query .= " WHERE {$acl}.entity_table = '{$domain}'\n AND {$acl}.entity_id = {$domainId}";
}
}
$rule->query($query);
$results = array();
while ($rule->fetch()) {
$results[] =& $rule->toArray();
}
if ($aclGroups) {
$results += CRM_Core_BAO_ACL::getACLGroups($contact_id, $group_id);
}
return $results;
}