本文整理汇总了PHP中CRM_Contact_DAO_RelationshipType类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_RelationshipType类的具体用法?PHP CRM_Contact_DAO_RelationshipType怎么用?PHP CRM_Contact_DAO_RelationshipType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contact_DAO_RelationshipType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del
/**
* Delete Relationship Types.
*
* @param int $relationshipTypeId
*
* @throws CRM_Core_Exception
* @return mixed
*/
public static function del($relationshipTypeId)
{
// make sure relationshipTypeId is an integer
// @todo review this as most delete functions rely on the api & form layer for this
// or do a find first & throw error if no find
if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
throw new CRM_Core_Exception(ts('Invalid relationship type'));
}
//check dependencies
// delete all relationships
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->relationship_type_id = $relationshipTypeId;
$relationship->delete();
// remove this relationship type from membership types
$mems = civicrm_api3('MembershipType', 'get', array('relationship_type_id' => array('LIKE' => "%{$relationshipTypeId}%"), 'return' => array('id', 'relationship_type_id', 'relationship_direction')));
foreach ($mems['values'] as $membershipTypeId => $membershipType) {
$pos = array_search($relationshipTypeId, $membershipType['relationship_type_id']);
// Api call may have returned false positives but currently the relationship_type_id uses
// nonstandard serialization which makes anything more accurate impossible.
if ($pos !== FALSE) {
unset($membershipType['relationship_type_id'][$pos], $membershipType['relationship_direction'][$pos]);
civicrm_api3('MembershipType', 'create', $membershipType);
}
}
//fixed for CRM-3323
$mappingField = new CRM_Core_DAO_MappingField();
$mappingField->relationship_type_id = $relationshipTypeId;
$mappingField->find();
while ($mappingField->fetch()) {
$mappingField->delete();
}
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
return $relationshipType->delete();
}
示例2: runImport
public function runImport(&$form, $timeout = 55)
{
$mapper = $this->_mapper;
$mapperFields = array();
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
//initialize mapper perperty value.
$mapperPeroperties = array('mapperRelated' => 'mapperRelatedVal', 'mapperLocTypes' => 'mapperLocTypesVal', 'mapperPhoneTypes' => 'mapperPhoneTypesVal', 'mapperImProviders' => 'mapperImProvidersVal', 'mapperWebsiteTypes' => 'mapperWebsiteTypesVal', 'mapperRelatedContactType' => 'mapperRelatedContactTypeVal', 'mapperRelatedContactDetails' => 'mapperRelatedContactDetailsVal', 'mapperRelatedContactLocType' => 'mapperRelatedContactLocTypeVal', 'mapperRelatedContactPhoneType' => 'mapperRelatedContactPhoneTypeVal', 'mapperRelatedContactImProvider' => 'mapperRelatedContactImProviderVal', 'mapperRelatedContactWebsiteType' => 'mapperRelatedContactWebsiteTypeVal');
foreach ($mapper as $key => $value) {
//set respective mapper value to null.
foreach (array_values($mapperPeroperties) as $perpertyVal) {
${$perpertyVal} = NULL;
}
$fldName = CRM_Utils_Array::value(0, $mapper[$key]);
$header = array($this->_mapFields[$fldName]);
$selOne = CRM_Utils_Array::value(1, $mapper[$key]);
$selTwo = CRM_Utils_Array::value(2, $mapper[$key]);
$selThree = CRM_Utils_Array::value(3, $mapper[$key]);
$this->_mapperKeys[$key] = $fldName;
//need to differentiate non location elements.
if ($selOne && is_numeric($selOne)) {
if ($fldName == 'url') {
$header[] = $websiteTypes[$selOne];
$mapperWebsiteTypesVal = $selOne;
} else {
$header[] = $locationTypes[$selOne];
$mapperLocTypesVal = $selOne;
if ($selTwo && is_numeric($selTwo)) {
if ($fldName == 'phone') {
$header[] = $phoneTypes[$selTwo];
$mapperPhoneTypesVal = $selTwo;
} elseif ($fldName == 'im') {
$header[] = $imProviders[$selTwo];
$mapperImProvidersVal = $selTwo;
}
}
}
}
$fldNameParts = explode('_', $fldName, 3);
$id = $fldNameParts[0];
$first = isset($fldNameParts[1]) ? $fldNameParts[1] : NULL;
$second = isset($fldNameParts[2]) ? $fldNameParts[2] : NULL;
if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
$header[] = ucwords(str_replace("_", " ", $selOne));
$relationType = new CRM_Contact_DAO_RelationshipType();
$relationType->id = $id;
$relationType->find(TRUE);
$mapperRelatedContactTypeVal = $relationType->{"contact_type_{$second}"};
$mapperRelatedVal = $fldName;
if ($selOne) {
$mapperRelatedContactDetailsVal = $selOne;
if ($selTwo) {
if ($selOne == 'url') {
$header[] = $websiteTypes[$selTwo];
$mapperRelatedContactWebsiteTypeVal = $selTwo;
} else {
$header[] = $locationTypes[$selTwo];
$mapperRelatedContactLocTypeVal = $selTwo;
if ($selThree) {
if ($selOne == 'phone') {
$header[] = $phoneTypes[$selThree];
$mapperRelatedContactPhoneTypeVal = $selThree;
} elseif ($selOne == 'im') {
$header[] = $imProviders[$selThree];
$mapperRelatedContactImProviderVal = $selThree;
}
}
}
}
}
}
$mapperFields[] = implode(' - ', $header);
//set the respective mapper param array values.
foreach ($mapperPeroperties as $mapperProKey => $mapperProVal) {
$this->{"_{$mapperProKey}"}[$key] = ${$mapperProVal};
}
}
$this->_parser = new CRM_Contact_Import_Parser_Contact($this->_mapperKeys, $this->_mapperLocTypes, $this->_mapperPhoneTypes, $this->_mapperImProviders, $this->_mapperRelated, $this->_mapperRelatedContactType, $this->_mapperRelatedContactDetails, $this->_mapperRelatedContactLocType, $this->_mapperRelatedContactPhoneType, $this->_mapperRelatedContactImProvider, $this->_mapperWebsiteTypes, $this->_mapperRelatedContactWebsiteType);
$this->_parser->run($this->_tableName, $mapperFields, CRM_Import_Parser::MODE_IMPORT, $this->_contactType, $this->_primaryKeyName, $this->_statusFieldName, $this->_onDuplicate, $this->_statusID, $this->_totalRowCount, $this->_doGeocodeAddress, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->_contactSubType, $this->_dedupe);
$contactIds = $this->_parser->getImportedContacts();
//get the related contactIds. CRM-2926
$relatedContactIds = $this->_parser->getRelatedImportedContacts();
if ($relatedContactIds) {
$contactIds = array_merge($contactIds, $relatedContactIds);
if ($form) {
$form->set('relatedCount', count($relatedContactIds));
}
}
if ($this->_newGroupName || count($this->_groups)) {
$groupAdditions = $this->_addImportedContactsToNewGroup($contactIds, $this->_newGroupName, $this->_newGroupDesc);
if ($form) {
$form->set('groupAdditions', $groupAdditions);
}
}
if ($this->_newTagName || count($this->_tag)) {
$tagAdditions = $this->_tagImportedContactsWithNewTag($contactIds, $this->_newTagName, $this->_newTagDesc);
if ($form) {
$form->set('tagAdditions', $tagAdditions);
//.........这里部分代码省略.........
示例3: addDisplayEnums
/**
* adds $value['foo_display'] for each $value['foo'] enum from civicrm_relationship_type
*
* @param array $values (reference) the array up for enhancing
* @return void
*/
static function addDisplayEnums(&$values)
{
$enumFields =& CRM_Contact_DAO_RelationshipType::getEnums();
foreach ($enumFields as $enum) {
if (isset($values[$enum])) {
$values[$enum . '_display'] = CRM_Contact_DAO_RelationshipType::tsEnum($enum, $values[$enum]);
}
}
}
示例4: checkRelationshipType
/**
* Function to check if the relationship type selected between two contacts is correct
*
* @param int $contact_a 1st contact id
* @param int $contact_b 2nd contact id
* @param int $relationshipTypeId relationship type id
*
* @return boolean true if it is valid relationship else false
* @access public
* @static
*/
static function checkRelationshipType($contact_a, $contact_b, $relationshipTypeId)
{
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
$relationshipType->selectAdd();
$relationshipType->selectAdd('contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b');
if ($relationshipType->find(true)) {
require_once 'CRM/Contact/BAO/Contact.php';
$contact_type_a = CRM_Contact_BAO_Contact::getContactType($contact_a);
$contact_type_b = CRM_Contact_BAO_Contact::getContactType($contact_b);
$contact_sub_type_a = CRM_Contact_BAO_Contact::getContactSubType($contact_a);
$contact_sub_type_b = CRM_Contact_BAO_Contact::getContactSubType($contact_b);
if ((!$relationshipType->contact_type_a || $relationshipType->contact_type_a == $contact_type_a) && (!$relationshipType->contact_type_b || $relationshipType->contact_type_b == $contact_type_b) && (!$relationshipType->contact_sub_type_a || $relationshipType->contact_sub_type_a == $contact_sub_type_a) && (!$relationshipType->contact_sub_type_b || $relationshipType->contact_sub_type_b == $contact_sub_type_b)) {
return true;
} else {
return false;
}
}
return false;
}
示例5: search
/**
* This function is to get the result of the search for contact in relationship form
*
* @param array $params This contains elements for search criteria
*
* @access public
* @return None
*
*/
function search(&$params)
{
//max records that will be listed
$searchValues = array();
if (CRM_Utils_Array::value('rel_contact', $params)) {
if (is_numeric($params['rel_contact_id'])) {
$searchValues[] = array('contact_id', '=', $params['rel_contact_id'], 0, 1);
} else {
$searchValues[] = array('sort_name', 'LIKE', $params['rel_contact'], 0, 1);
}
}
$contactTypeAdded = false;
$excludedContactIds = array($this->_contactId);
if ($params['relationship_type_id']) {
$relationshipType = new CRM_Contact_DAO_RelationshipType();
list($rid, $direction) = explode('_', $params['relationship_type_id'], 2);
$relationshipType->id = $rid;
if ($relationshipType->find(true)) {
if ($direction == 'a_b') {
$type = $relationshipType->contact_type_b;
$subType = $relationshipType->contact_sub_type_b;
} else {
$type = $relationshipType->contact_type_a;
$subType = $relationshipType->contact_sub_type_a;
}
$this->set('contact_type', $type);
$this->set('contact_sub_type', $subType);
if ($type == 'Individual' || $type == 'Organization' || $type == 'Household') {
$searchValues[] = array('contact_type', '=', $type, 0, 0);
$contactTypeAdded = true;
}
if ($subType) {
$searchValues[] = array('contact_sub_type', '=', $subType, 0, 0);
}
}
}
if (!$contactTypeAdded && CRM_Utils_Array::value('contact_type', $params)) {
$searchValues[] = array('contact_type', '=', $params['contact_type'], 0, 0);
}
// get the count of contact
$contactBAO = new CRM_Contact_BAO_Contact();
$query = new CRM_Contact_BAO_Query($searchValues);
$searchCount = $query->searchQuery(0, 0, null, true);
$this->set('searchCount', $searchCount);
if ($searchCount <= self::MAX_RELATIONSHIPS) {
// get the result of the search
$result = $query->searchQuery(0, 50, null);
$config = CRM_Core_Config::singleton();
$searchRows = array();
//variable is set if only one record is foun and that record already has relationship with the contact
$duplicateRelationship = 0;
while ($result->fetch()) {
$contactID = $result->contact_id;
if (in_array($contactID, $excludedContactIds)) {
$duplicateRelationship++;
continue;
}
$duplicateRelationship = 0;
$searchRows[$contactID]['id'] = $contactID;
$searchRows[$contactID]['name'] = $result->sort_name;
$searchRows[$contactID]['city'] = $result->city;
$searchRows[$contactID]['state'] = $result->state_province;
$searchRows[$contactID]['email'] = $result->email;
$searchRows[$contactID]['phone'] = $result->phone;
$contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$searchRows[$contactID]['type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
}
$this->set('searchRows', $searchRows);
$this->set('duplicateRelationship', $duplicateRelationship);
} else {
// resetting the session variables if many records are found
$this->set('searchRows', null);
$this->set('duplicateRelationship', null);
}
}
示例6: checkRelationshipType
/**
* Check if the relationship type selected between two contacts is correct.
*
* @param int $contact_a
* 1st contact id.
* @param int $contact_b
* 2nd contact id.
* @param int $relationshipTypeId
* Relationship type id.
*
* @return bool
* true if it is valid relationship else false
*/
public static function checkRelationshipType($contact_a, $contact_b, $relationshipTypeId)
{
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
$relationshipType->selectAdd();
$relationshipType->selectAdd('contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b');
if ($relationshipType->find(TRUE)) {
$contact_type_a = CRM_Contact_BAO_Contact::getContactType($contact_a);
$contact_type_b = CRM_Contact_BAO_Contact::getContactType($contact_b);
$contact_sub_type_a = CRM_Contact_BAO_Contact::getContactSubType($contact_a);
$contact_sub_type_b = CRM_Contact_BAO_Contact::getContactSubType($contact_b);
if ((!$relationshipType->contact_type_a || $relationshipType->contact_type_a == $contact_type_a) && (!$relationshipType->contact_type_b || $relationshipType->contact_type_b == $contact_type_b) && (!$relationshipType->contact_sub_type_a || in_array($relationshipType->contact_sub_type_a, $contact_sub_type_a)) && (!$relationshipType->contact_sub_type_b || in_array($relationshipType->contact_sub_type_b, $contact_sub_type_b))) {
return TRUE;
} else {
return FALSE;
}
}
return FALSE;
}
示例7: import
//.........这里部分代码省略.........
$this->_retCode = CRM_IMPORT_PARSER_NO_MATCH;
}
}
if (is_a($newContact, CRM_Contact_BAO_Contact)) {
$relationship = true;
} else {
if (is_a($error, CRM_Core_Error)) {
$newContact = $error;
$relationship = true;
}
}
if ($newContact && !is_a($newContact, CRM_Core_Error)) {
$this->_newContacts[] = $newContact->id;
}
} else {
$newContact = crm_create_contact_formatted($formatted, $onDuplicate);
$relationship = true;
}
if ($relationship) {
if (CRM_Import_Parser_Contact::isDuplicate($newContact)) {
foreach ($newContact->_errors[0]['params'] as $cid) {
$primaryContactId = $cid;
}
} else {
$primaryContactId = $newContact->id;
}
if (CRM_Import_Parser_Contact::isDuplicate($newContact) || is_a($newContact, CRM_Contact_BAO_Contact)) {
//relationship contact insert
foreach ($params as $key => $field) {
list($id, $first, $second) = explode('_', $key);
if (!($first == 'a' && $second == 'b') && !($first == 'b' && $second == 'a')) {
continue;
}
$relationType = new CRM_Contact_DAO_RelationshipType();
$relationType->id = $id;
$relationType->find(true);
$name_a_b = $relationType->name_a_b;
if ($params[$key]['contact_type']) {
$formatting = array('contact_type' => $params[$key]['contact_type']);
} else {
$fld = array_keys($params[$key]);
foreach (CRM_Core_SelectValues::contactType() as $cType => $val) {
if ($cType) {
$contactFields =& CRM_Contact_BAO_Contact::importableFields($cType);
if (array_key_exists($fld[0], $contactFields)) {
$formatting['contact_type'] = $cType;
$params[$key]['contact_type'] = $cType;
$field['contact_type'] = $cType;
break;
}
}
}
}
$contactFields = null;
if ($contactFields == null) {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $params[$key]['contact_type']) . ".php";
eval('$contactFields =& CRM_Contact_DAO_' . $params[$key]['contact_type'] . '::import();');
}
foreach ($field as $k => $v) {
if ($v == null || $v === '') {
continue;
}
if (is_array($v)) {
foreach ($v as $value) {
$break = false;
foreach ($value as $testForEmpty) {
示例8: search
/**
* Get the result of the search for Add to * forms.
*
* @param CRM_Core_Form $form
* @param array $params
* This contains elements for search criteria.
*/
public function search(&$form, &$params)
{
//max records that will be listed
$searchValues = array();
if (!empty($params['rel_contact'])) {
if (isset($params['rel_contact_id']) && is_numeric($params['rel_contact_id'])) {
$searchValues[] = array('contact_id', '=', $params['rel_contact_id'], 0, 1);
} else {
$searchValues[] = array('sort_name', 'LIKE', $params['rel_contact'], 0, 1);
}
}
$contactTypeAdded = FALSE;
$excludedContactIds = array();
if (isset($form->_contactId)) {
$excludedContactIds[] = $form->_contactId;
}
if (!empty($params['relationship_type_id'])) {
$relationshipType = new CRM_Contact_DAO_RelationshipType();
list($rid, $direction) = explode('_', $params['relationship_type_id'], 2);
$relationshipType->id = $rid;
if ($relationshipType->find(TRUE)) {
if ($direction == 'a_b') {
$type = $relationshipType->contact_type_b;
$subType = $relationshipType->contact_sub_type_b;
} else {
$type = $relationshipType->contact_type_a;
$subType = $relationshipType->contact_sub_type_a;
}
$form->set('contact_type', $type);
$form->set('contact_sub_type', $subType);
if ($type == 'Individual' || $type == 'Organization' || $type == 'Household') {
$searchValues[] = array('contact_type', '=', $type, 0, 0);
$contactTypeAdded = TRUE;
}
if ($subType) {
$searchValues[] = array('contact_sub_type', '=', $subType, 0, 0);
}
}
}
if (!$contactTypeAdded && !empty($params['contact_type'])) {
$searchValues[] = array('contact_type', '=', $params['contact_type'], 0, 0);
}
// get the count of contact
$contactBAO = new CRM_Contact_BAO_Contact();
$query = new CRM_Contact_BAO_Query($searchValues);
$searchCount = $query->searchQuery(0, 0, NULL, TRUE);
$form->set('searchCount', $searchCount);
if ($searchCount <= 50) {
// get the result of the search
$result = $query->searchQuery(0, 50, NULL);
$config = CRM_Core_Config::singleton();
$searchRows = array();
//variable is set if only one record is foun and that record already has relationship with the contact
$duplicateRelationship = 0;
while ($result->fetch()) {
$query->convertToPseudoNames($result);
$contactID = $result->contact_id;
if (in_array($contactID, $excludedContactIds)) {
$duplicateRelationship++;
continue;
}
$duplicateRelationship = 0;
$searchRows[$contactID]['id'] = $contactID;
$searchRows[$contactID]['name'] = $result->sort_name;
$searchRows[$contactID]['city'] = $result->city;
$searchRows[$contactID]['state'] = $result->state_province;
$searchRows[$contactID]['email'] = $result->email;
$searchRows[$contactID]['phone'] = $result->phone;
$contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
$searchRows[$contactID]['type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
}
$form->set('searchRows', $searchRows);
$form->set('duplicateRelationship', $duplicateRelationship);
} else {
// resetting the session variables if many records are found
$form->set('searchRows', NULL);
$form->set('duplicateRelationship', NULL);
}
}
示例9: del
/**
* Function to delete Relationship Types
*
* @param int $relationshipTypeId
* @static
*/
static function del($relationshipTypeId)
{
// make sure relationshipTypeId is an integer
if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
CRM_Core_Error::fatal(ts('Invalid relationship type'));
}
//check dependencies
// delete all relationships
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->relationship_type_id = $relationshipTypeId;
$relationship->delete();
// set all membership_type to null
$query = "\nUPDATE civicrm_membership_type\n SET relationship_type_id = NULL\n WHERE relationship_type_id = %1\n";
$params = array(1 => array($relationshipTypeId, 'Integer'));
CRM_Core_DAO::executeQuery($query, $params);
//fixed for CRM-3323
$mappingField = new CRM_Core_DAO_MappingField();
$mappingField->relationship_type_id = $relationshipTypeId;
$mappingField->find();
while ($mappingField->fetch()) {
$mappingField->delete();
}
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
return $relationshipType->delete();
}
示例10: browse
/**
* browse all entities.
*
* @param int $action
*
* @return void
* @access public
*/
function browse()
{
$n = func_num_args();
$action = $n > 0 ? func_get_arg(0) : NULL;
$sort = $n > 0 ? func_get_arg(1) : NULL;
$links =& $this->links();
if ($action == NULL) {
if (!empty($links)) {
$action = array_sum(array_keys($links));
}
}
if ($action & CRM_Core_Action::DISABLE) {
$action -= CRM_Core_Action::DISABLE;
}
if ($action & CRM_Core_Action::ENABLE) {
$action -= CRM_Core_Action::ENABLE;
}
$baoString = $this->getBAOName();
$object = new $baoString();
$values = array();
/*
* lets make sure we get the stuff sorted by name if it exists
*/
$fields =& $object->fields();
$key = '';
if (CRM_Utils_Array::value('title', $fields)) {
$key = 'title';
} elseif (CRM_Utils_Array::value('label', $fields)) {
$key = 'label';
} elseif (CRM_Utils_Array::value('name', $fields)) {
$key = 'name';
}
if (trim($sort)) {
$object->orderBy($sort);
} elseif ($key) {
$object->orderBy($key . ' asc');
}
// find all objects
$object->find();
while ($object->fetch()) {
if (!isset($object->mapping_type_id) || $object->mapping_type_id != 1) {
$permission = CRM_Core_Permission::EDIT;
if ($key) {
$permission = $this->checkPermission($object->id, $object->{$key});
}
if ($permission) {
$values[$object->id] = array();
CRM_Core_DAO::storeValues($object, $values[$object->id]);
CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
// populate action links
$this->action($object, $action, $values[$object->id], $links, $permission);
if (isset($object->mapping_type_id)) {
$mappintTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id');
$values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id];
}
}
}
}
$this->assign('rows', $values);
}
示例11: CRM_Contact_BAO_RelationshipType
/**
* class constructor
*/
function CRM_Contact_BAO_RelationshipType()
{
parent::CRM_Contact_DAO_RelationshipType();
}
示例12: browse
/**
* browse all entities.
*
* @param int $action
*
* @return void
* @access public
*/
function browse($action = null)
{
$links =& $this->links();
if ($action == null) {
$action = array_sum(array_keys($links));
}
if ($action & CRM_CORE_ACTION_DISABLE) {
$action -= CRM_CORE_ACTION_DISABLE;
}
if ($action & CRM_CORE_ACTION_ENABLE) {
$action -= CRM_CORE_ACTION_ENABLE;
}
eval('$object =& new ' . $this->getBAOName() . '( );');
$values = array();
/*
* lets make sure we get the stuff sorted by name if it exists
*/
$fields =& $object->fields();
$key = '';
if (CRM_Utils_Array::value('title', $fields)) {
$key = 'title';
} else {
if (CRM_Utils_Array::value('label', $fields)) {
$key = 'label';
} else {
if (CRM_Utils_Array::value('name', $fields)) {
$key = 'name';
}
}
}
if ($key) {
$object->orderBy($key . ' asc');
}
// set the domain_id parameter
$config =& CRM_Core_Config::singleton();
$object->domain_id = $config->domainID();
// find all objects
$object->find();
while ($object->fetch()) {
$permission = CRM_CORE_PERMISSION_EDIT;
if ($key) {
$permission = $this->checkPermission($object->id, $object->{$key});
}
if ($permission) {
$values[$object->id] = array();
CRM_Core_DAO::storeValues($object, $values[$object->id]);
CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
// populate action links
CRM_Core_Page_Basic::action($object, $action, $values[$object->id], $links, $permission);
}
}
$this->assign('rows', $values);
}
示例13: array
/**
* Get all Relationship Types from database.
*
* The static array group is returned, and if it's
* called the first time, the <b>RelationshipType DAO</b> is used
* to get all the relationship types.
*
* Note: any database errors will be trapped by the DAO.
*
* @param string $valueColumnName db column name/label.
* @param boolean $reset reset relationship types if true
*
* @access public
* @static
*
* @return array - array reference of all relationship types.
*/
public static function &relationshipType($valueColumnName = 'label', $reset = FALSE)
{
if (!CRM_Utils_Array::value($valueColumnName, self::$relationshipType) || $reset) {
self::$relationshipType[$valueColumnName] = array();
//now we have name/label columns CRM-3336
$column_a_b = "{$valueColumnName}_a_b";
$column_b_a = "{$valueColumnName}_b_a";
$relationshipTypeDAO = new CRM_Contact_DAO_RelationshipType();
$relationshipTypeDAO->selectAdd();
$relationshipTypeDAO->selectAdd("id, {$column_a_b}, {$column_b_a}, contact_type_a, contact_type_b, contact_sub_type_a, contact_sub_type_b");
$relationshipTypeDAO->is_active = 1;
$relationshipTypeDAO->find();
while ($relationshipTypeDAO->fetch()) {
self::$relationshipType[$valueColumnName][$relationshipTypeDAO->id] = array('id' => $relationshipTypeDAO->id, $column_a_b => $relationshipTypeDAO->{$column_a_b}, $column_b_a => $relationshipTypeDAO->{$column_b_a}, 'contact_type_a' => "{$relationshipTypeDAO->contact_type_a}", 'contact_type_b' => "{$relationshipTypeDAO->contact_type_b}", 'contact_sub_type_a' => "{$relationshipTypeDAO->contact_sub_type_a}", 'contact_sub_type_b' => "{$relationshipTypeDAO->contact_sub_type_b}");
}
}
return self::$relationshipType[$valueColumnName];
}
示例14: browse
/**
* browse all entities.
*
* @param int $action
*
* @return void
* @access public
*/
function browse($action = null, $sort)
{
$links =& $this->links();
if ($action == null) {
if (!empty($links)) {
$action = array_sum(array_keys($links));
}
}
if ($action & CRM_Core_Action::DISABLE) {
$action -= CRM_Core_Action::DISABLE;
}
if ($action & CRM_Core_Action::ENABLE) {
$action -= CRM_Core_Action::ENABLE;
}
eval('$object =& new ' . $this->getBAOName() . '( );');
$values = array();
/*
* lets make sure we get the stuff sorted by name if it exists
*/
$fields =& $object->fields();
$key = '';
if (CRM_Utils_Array::value('title', $fields)) {
$key = 'title';
} else {
if (CRM_Utils_Array::value('label', $fields)) {
$key = 'label';
} else {
if (CRM_Utils_Array::value('name', $fields)) {
$key = 'name';
}
}
}
if (trim($sort)) {
$object->orderBy($sort);
} else {
if ($key) {
$object->orderBy($key . ' asc');
}
}
// find all objects
$object->find();
while ($object->fetch()) {
if (!isset($object->mapping_type_id) || $object->mapping_type_id != 1) {
// "1 for Search Builder"
$permission = CRM_Core_Permission::EDIT;
if ($key) {
$permission = $this->checkPermission($object->id, $object->{$key});
}
if ($permission) {
$values[$object->id] = array();
CRM_Core_DAO::storeValues($object, $values[$object->id]);
require_once 'CRM/Contact/DAO/RelationshipType.php';
CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
// populate action links
$this->action($object, $action, $values[$object->id], $links, $permission);
if (isset($object->mapping_type_id)) {
require_once 'CRM/Core/PseudoConstant.php';
$mappintTypes = CRM_Core_PseudoConstant::mappingTypes();
$values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id];
}
}
$this->assign('rows', $values);
}
}
}
示例15: civicrm_relationship_types_get
/**
* Function to get all relationship type
* retruns An array of Relationship_type
* * @access public
*/
function civicrm_relationship_types_get($params = null)
{
_civicrm_initialize();
require_once 'CRM/Contact/DAO/RelationshipType.php';
$relationshipTypes = array();
$relationshipType = array();
$relationType = new CRM_Contact_DAO_RelationshipType();
if (!empty($params) && is_array($params)) {
$properties = array_keys($relationType->fields());
foreach ($properties as $name) {
if (array_key_exists($name, $params)) {
$relationType->{$name} = $params[$name];
}
}
}
$relationType->find();
while ($relationType->fetch()) {
_civicrm_object_to_array(clone $relationType, $relationshipType);
$relationshipTypes[] = $relationshipType;
}
return $relationshipTypes;
}