本文整理汇总了PHP中CRM_Contact_BAO_RelationshipType::fields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_RelationshipType::fields方法的具体用法?PHP CRM_Contact_BAO_RelationshipType::fields怎么用?PHP CRM_Contact_BAO_RelationshipType::fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_RelationshipType
的用法示例。
在下文中一共展示了CRM_Contact_BAO_RelationshipType::fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor which also does all the work.
*
* @param array $params
* @param array $returnProperties
* @param array $fields
* @param bool $includeRelationshipIds
* @param bool $strict
*
* @param bool $skipPermission
* @param string $operator
*
* @return \CRM_Relationship_BAO_Query
*/
public function __construct($params = NULL, $returnProperties = NULL, $fields = NULL, $includeRelationshipIds = FALSE, $strict = FALSE, $mode = 1, $skipPermission = FALSE, $operator = 'AND')
{
$this->_params =& $params;
if ($this->_params == NULL) {
$this->_params = array();
}
if (empty($returnProperties)) {
$this->_returnProperties = self::defaultReturnProperties($mode);
} else {
$this->_returnProperties =& $returnProperties;
}
$this->_includeRelationshipIds = $includeRelationshipIds;
$this->_strict = $strict;
$this->_mode = $mode;
$this->_skipPermission = $skipPermission;
//$this->setOperator($operator);
if ($fields) {
$this->_fields =& $fields;
$this->_search = FALSE;
$this->_skipPermission = TRUE;
} else {
$this->_fields = CRM_Contact_BAO_Relationship::fields();
foreach ($this->_fields as $defaultFieldKey => $defaultField) {
$this->_fields[$defaultFieldKey]['where'] = 'relationship.' . $defaultFieldKey;
}
// Add display_name for both contacts
$contact_fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE, TRUE);
$this->_fields['contact_a'] = $contact_fields['display_name'];
$this->_fields['contact_a']['where'] = 'contact_a.display_name';
$this->_fields['contact_b'] = $contact_fields['display_name'];
$this->_fields['contact_b']['where'] = 'contact_b.display_name';
// Add relationship type field
$relationship_type_fields = CRM_Contact_BAO_RelationshipType::fields();
$this->_fields['relationship_type'] = $relationship_type_fields['label_a_b'];
$this->_fields['relationship_type']['where'] = 'relationship_type.label_a_b';
// Add custom fields
$this->_fields = array_merge($this->_fields, CRM_Core_BAO_CustomField::getFieldsForImport('Relationship'));
}
// basically do all the work once, and then reuse it
$this->initialize();
}
示例2: exportComponents
public static function exportComponents($selectAll, $ids, $params, $order = NULL, $fields = NULL, $moreReturnProperties = NULL, $exportMode = CRM_Export_Form_Select_Relationship::RELATIONSHIP_EXPORT, $componentClause = NULL, $componentTable = NULL, $mergeSameAddress = FALSE, $mergeSameHousehold = FALSE, $exportParams = array(), $queryOperator = 'AND')
{
$headerRows = $returnProperties = array();
$queryMode = CRM_Relationship_BAO_Query::MODE_RELATIONSHIPS;
//Welke velden exporteren, gezet bij een mapping, indien niet gezet, primary fields.
if ($fields) {
foreach ($fields as $key => $value) {
$fieldName = CRM_Utils_Array::value(0, $value);
if (!$fieldName) {
continue;
}
$returnProperties[$fieldName] = 1;
}
} else {
// Copied from CRM_Relationship_BAO_QUERY should be refactored to seperate
// method.
$fields = CRM_Contact_BAO_Relationship::fields();
// Add display_name for both contacts
$contact_fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE, TRUE);
$fields['contact_a'] = $contact_fields['display_name'];
$fields['contact_a']['where'] = 'contact_a.display_name';
$fields['contact_b'] = $contact_fields['display_name'];
$fields['contact_b']['where'] = 'contact_b.display_name';
// Add relationship type field
$relationship_type_fields = CRM_Contact_BAO_RelationshipType::fields();
$fields['relationship_type'] = $relationship_type_fields['label_a_b'];
$fields['relationship_type']['where'] = 'relationship_type.label_a_b';
// Add custom fields
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Relationship'));
$returnProperties = CRM_Relationship_BAO_Query::defaultReturnProperties();
}
if ($moreReturnProperties) {
$returnProperties = array_merge($returnProperties, $moreReturnProperties);
}
$query = new CRM_Relationship_BAO_Query($params, $returnProperties, NULL, FALSE, FALSE, FALSE, TRUE, $queryOperator);
//sort by state
//CRM-15301
$query->_sort = $order;
list($select, $from, $where, $having) = $query->query();
$allRelContactArray = $relationQuery = array();
if (!$selectAll && $componentTable) {
// TODO For not select all
//$from .= " INNER JOIN $componentTable ctTable ON ctTable.contact_id = contact_a.id ";
} elseif ($componentClause) {
if (empty($where)) {
$where = "WHERE {$componentClause}";
} else {
$where .= " AND {$componentClause}";
}
}
$queryString = "{$select} {$from} {$where} {$having}";
$groupBy = "";
if ($queryMode & CRM_Relationship_BAO_Query::MODE_RELATIONSHIPS && $query->_useGroupBy) {
$groupBy = " GROUP BY relationship.id";
}
$queryString .= $groupBy;
// always add relationship.id to the ORDER clause
// so the order is deterministic
if (strpos('relationship.id', $order) === FALSE) {
$order .= ", relationship.id";
}
if ($order) {
list($field, $dir) = explode(' ', $order, 2);
$field = trim($field);
if (!empty($returnProperties[$field])) {
//CRM-15301
$queryString .= " ORDER BY {$order}";
}
}
$componentDetails = $headerRows = $sqlColumns = array();
$setHeader = TRUE;
$rowCount = self::EXPORT_ROW_COUNT;
$offset = 0;
// we write to temp table often to avoid using too much memory
$tempRowCount = 100;
$count = -1;
// for CRM-3157 purposes
$i18n = CRM_Core_I18n::singleton();
$outputColumns = array();
//@todo - it would be clearer to start defining output columns earlier in this function rather than stick with return properties until this point
// as the array is not actually 'returnProperties' after the sql query is formed - making the alterations to it confusing
foreach ($returnProperties as $key => $value) {
$outputColumns[$key] = $value;
}
while (1) {
$limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
$dao = CRM_Core_DAO::executeQuery($limitQuery);
if ($dao->N <= 0) {
break;
}
while ($dao->fetch()) {
$count++;
$row = array();
//convert the pseudo constants
// CRM-14398 there is problem in this architecture that is not easily solved. For now we are using the cloned
// temporary iterationDAO object to get around it.
// the issue is that the convertToPseudoNames function is adding additional properties (e.g for campaign) to the DAO object
// these additional properties are NOT reset when the $dao cycles through the while loop
// nor are they overwritten as they are not in the loop
// the convertToPseudoNames will not adequately over-write them either as it doesn't 'kick-in' unless the
//.........这里部分代码省略.........