本文整理汇总了PHP中CRM_Core_Component::getQueryFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Component::getQueryFields方法的具体用法?PHP CRM_Core_Component::getQueryFields怎么用?PHP CRM_Core_Component::getQueryFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Component
的用法示例。
在下文中一共展示了CRM_Core_Component::getQueryFields方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* class constructor which also does all the work
*
* @param array $params
* @param array $returnProperties
* @param array $fields
* @param boolean $includeContactIds
* @param boolean $strict
* @param boolean $mode - mode the search is operating on
*
* @return Object
* @access public
*/
function __construct($params = NULL, $returnProperties = NULL, $fields = NULL, $includeContactIds = FALSE, $strict = FALSE, $mode = 1, $skipPermission = FALSE, $searchDescendentGroups = TRUE, $smartGroupCache = TRUE, $displayRelationshipType = NULL, $operator = 'AND')
{
// CRM_Core_Error::backtrace( );
// CRM_Core_Error::debug( 'params', $params );
// CRM_Core_Error::debug( 'post', $_POST );
// CRM_Core_Error::debug( 'r', $returnProperties );
$this->_params =& $params;
if ($this->_params == NULL) {
$this->_params = array();
}
if (empty($returnProperties)) {
$this->_returnProperties = self::defaultReturnProperties($mode);
} else {
$this->_returnProperties =& $returnProperties;
}
$this->_includeContactIds = $includeContactIds;
$this->_strict = $strict;
$this->_mode = $mode;
$this->_skipPermission = $skipPermission;
$this->_smartGroupCache = $smartGroupCache;
$this->_displayRelationshipType = $displayRelationshipType;
$this->setOperator($operator);
if ($fields) {
$this->_fields =& $fields;
$this->_search = FALSE;
$this->_skipPermission = TRUE;
} else {
$this->_fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE, TRUE);
$fields = CRM_Core_Component::getQueryFields();
unset($fields['note']);
$this->_fields = array_merge($this->_fields, $fields);
// add activity fields
$fields = CRM_Activity_BAO_Activity::exportableFields();
$this->_fields = array_merge($this->_fields, $fields);
}
// basically do all the work once, and then reuse it
$this->initialize();
}
示例2: getImportableFields
/**
* @param $showAll
* @param $profileType
* @param $contactActivityProfile
*
* @return array
*/
protected static function getImportableFields($showAll, $profileType, $contactActivityProfile)
{
if (!$showAll) {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, FALSE, FALSE, TRUE, TRUE);
} else {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, TRUE, FALSE, TRUE, TRUE);
}
if ($profileType == 'Activity' || $contactActivityProfile) {
$componentFields = CRM_Activity_BAO_Activity::getProfileFields();
} else {
$componentFields = CRM_Core_Component::getQueryFields();
}
$importableFields = array_merge($importableFields, $componentFields);
$importableFields['group']['title'] = ts('Group(s)');
$importableFields['group']['where'] = NULL;
$importableFields['tag']['title'] = ts('Tag(s)');
$importableFields['tag']['where'] = NULL;
return $importableFields;
}
示例3: fields
static function fields()
{
$fields = array_merge(CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE), CRM_Core_Component::getQueryFields(), CRM_Contact_BAO_Query_Hook::singleton()->getFields(), CRM_Activity_BAO_Activity::exportableFields());
return $fields;
}
示例4: getFields
/**
* get all the fields that belong to the group with the name title
*
* @param int $id the id of the UF group
* @param int $register are we interested in registration fields
* @param int $action what action are we doing
* @param int $visibility visibility of fields we are interested in
* @param $searchable
* @param boolean $showall
* @param string $restrict should we restrict based on a specified profile type
*
* @return array the fields that belong to this title
* @static
* @access public
*/
static function getFields($id, $register = false, $action = null, $visibility = null, $searchable = null, $showAll = false, $restrict = null, $skipPermission = false, $ctype = null, $permissionType = CRM_Core_Permission::CREATE)
{
if ($restrict) {
$query = "SELECT g.* from civicrm_uf_group g, civicrm_uf_join j \n WHERE g.is_active = 1\n AND g.id = %1 \n AND j.uf_group_id = %1 \n AND j.module = %2\n ";
$params = array(1 => array($id, 'Integer'), 2 => array($restrict, 'String'));
} else {
$query = "SELECT g.* from civicrm_uf_group g WHERE g.is_active = 1 AND g.id = %1 ";
$params = array(1 => array($id, 'Integer'));
}
// add permissioning for profiles only if not registration
if (!$skipPermission) {
require_once 'CRM/Core/Permission.php';
$permissionClause = CRM_Core_Permission::ufGroupClause($permissionType, 'g.');
$query .= " AND {$permissionClause} ";
}
$group =& CRM_Core_DAO::executeQuery($query, $params);
$fields = array();
if ($group->fetch()) {
$where = " WHERE uf_group_id = {$group->id}";
if ($searchable) {
$where .= " AND is_searchable = 1";
}
if (!$showAll) {
$where .= " AND is_active = 1";
}
if ($visibility) {
$clause = array();
if ($visibility & self::PUBLIC_VISIBILITY) {
$clause[] = 'visibility = "Public Pages"';
}
if ($visibility & self::ADMIN_VISIBILITY) {
$clause[] = 'visibility = "User and User Admin Only"';
}
if ($visibility & self::LISTINGS_VISIBILITY) {
$clause[] = 'visibility = "Public Pages and Listings"';
}
if (!empty($clause)) {
$where .= ' AND ( ' . implode(' OR ', $clause) . ' ) ';
}
}
$query = "SELECT * FROM civicrm_uf_field {$where} ORDER BY weight, field_name";
$field =& CRM_Core_DAO::executeQuery($query);
require_once 'CRM/Contact/BAO/Contact.php';
if (!$showAll) {
$importableFields =& CRM_Contact_BAO_Contact::importableFields("All");
} else {
$importableFields =& CRM_Contact_BAO_Contact::importableFields("All", false, true);
}
require_once 'CRM/Core/Component.php';
$importableFields = array_merge($importableFields, CRM_Core_Component::getQueryFields());
$importableFields['group']['title'] = ts('Group(s)');
$importableFields['group']['where'] = null;
$importableFields['tag']['title'] = ts('Tag(s)');
$importableFields['tag']['where'] = null;
$specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'county', 'phone', 'email', 'im', 'address_name');
//get location type
$locationType = array();
$locationType =& CRM_Core_PseudoConstant::locationType();
require_once 'CRM/Core/BAO/CustomField.php';
$customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype);
// hack to add custom data for components
$components = array("Contribution", "Participant", "Membership");
foreach ($components as $value) {
$customFields = array_merge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value));
}
while ($field->fetch()) {
$name = $title = $locType = $phoneType = '';
$name = $field->field_name;
$title = $field->label;
if ($field->location_type_id) {
$name .= "-{$field->location_type_id}";
$locType = " ( {$locationType[$field->location_type_id]} ) ";
} else {
if (in_array($field->field_name, $specialFields)) {
$name .= '-Primary';
$locType = ' ( Primary ) ';
}
}
if (isset($field->phone_type_id)) {
$name .= "-{$field->phone_type_id}";
if ($field->phone_type_id != '1') {
// this hack is to prevent Phone Phone (work)
$phoneType = "-{$field->phone_type_id}";
}
}
//.........这里部分代码省略.........
示例5: __construct
/**
* Class constructor which also does all the work.
*
* @param array $params
* @param array $returnProperties
* @param array $fields
* @param bool $includeContactIds
* @param bool $strict
* @param bool|int $mode - mode the search is operating on
*
* @param bool $skipPermission
* @param bool $searchDescendentGroups
* @param bool $smartGroupCache
* @param null $displayRelationshipType
* @param string $operator
*
* @return \CRM_Contact_BAO_Query
*/
public function __construct($params = NULL, $returnProperties = NULL, $fields = NULL, $includeContactIds = FALSE, $strict = FALSE, $mode = 1, $skipPermission = FALSE, $searchDescendentGroups = TRUE, $smartGroupCache = TRUE, $displayRelationshipType = NULL, $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->_includeContactIds = $includeContactIds;
$this->_strict = $strict;
$this->_mode = $mode;
$this->_skipPermission = $skipPermission;
$this->_smartGroupCache = $smartGroupCache;
$this->_displayRelationshipType = $displayRelationshipType;
$this->setOperator($operator);
if ($fields) {
$this->_fields =& $fields;
$this->_search = FALSE;
$this->_skipPermission = TRUE;
} else {
$this->_fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE, TRUE, FALSE, !$skipPermission);
$fields = CRM_Core_Component::getQueryFields(!$this->_skipPermission);
unset($fields['note']);
$this->_fields = array_merge($this->_fields, $fields);
// add activity fields
$fields = CRM_Activity_BAO_Activity::exportableFields();
$this->_fields = array_merge($this->_fields, $fields);
// add any fields provided by hook implementers
$extFields = CRM_Contact_BAO_Query_Hook::singleton()->getFields();
$this->_fields = array_merge($this->_fields, $extFields);
}
// basically do all the work once, and then reuse it
$this->initialize();
}
示例6: formRule
/**
* global validation rules for the form
*
* @param array $fields posted values of the form
*
* @return array list of errors to be posted back to the form
* @static
* @access public
*/
static function formRule(&$values)
{
//CRM_Core_Error::debug('s', $values);
if (CRM_Utils_Array::value('addMore', $values) || CRM_Utils_Array::value('addBlock', $values)) {
return true;
}
require_once 'CRM/Contact/BAO/Contact.php';
$fields = array();
$fields = CRM_Contact_BAO_Contact::exportableFields('All', false, true);
require_once 'CRM/Core/Component.php';
$compomentFields =& CRM_Core_Component::getQueryFields();
$fields = array_merge($fields, $compomentFields);
$fld = array();
$fld = CRM_Core_BAO_Mapping::formattedFields($values, true);
require_once 'CRM/Utils/Type.php';
$errorMsg = array();
foreach ($fld as $k => $v) {
if (!$v[1]) {
$errorMsg["operator[{$v['3']}][{$v['4']}]"] = ts("Please enter the operator.");
} else {
if (in_array($v[1], array('IS NULL', 'IS NOT NULL')) && $v[2]) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts('Please clear your value if you want to use %1 operator.', array(1 => $v[1]));
} else {
if ($v[0] == 'group' || $v[0] == 'tag') {
$grpId = array_keys($v[2]);
if (!key($v[2])) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the value.");
}
if (count($grpId) > 1) {
if ($v[1] != 'IN' && $v[1] != 'NOT IN') {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the valid value.");
}
foreach ($grpId as $val) {
$error = CRM_Utils_Type::validate($val, 'Integer', false);
if ($error != $val) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter valid value.");
break;
}
}
} else {
$error = CRM_Utils_Type::validate($grpId[0], 'Integer', false);
if ($error != $grpId[0]) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts('Please enter valid %1 id.', array(1 => $v[0]));
}
}
} else {
if (substr($v[0], 0, 7) === 'do_not_' or substr($v[0], 0, 3) === 'is_') {
if ($v[2]) {
$v2 = array($v[2]);
if (!isset($v[2])) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the value.");
}
$error = CRM_Utils_Type::validate($v2[0], 'Integer', false);
if ($error != $v2[0]) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter valid value.");
}
} else {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the value.");
}
} else {
if ($v[0] === 'sort_name' || $v[0] === 'display_name') {
$v2 = trim($v[2]);
if (empty($v2)) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the value.");
}
} else {
if (substr($v[0], 0, 7) == 'custom_') {
$type = $fields[$v[0]]['data_type'];
// hack to handle custom data of type state and country
if (in_array($type, array('Country', 'StateProvince'))) {
$type = "Integer";
}
} else {
$fldName = $v[0];
// FIXME: no idea at this point what to do with this,
// FIXME: but definitely needs fixing.
if (substr($v[0], 0, 13) == 'contribution_') {
$fldName = substr($v[0], 13);
}
$fldType = CRM_Utils_Array::value('type', $fields[$fldName]);
$type = CRM_Utils_Type::typeToString($fldType);
// Check Empty values for Integer Or Boolean Or Date type For operators other than IS NULL and IS NOT NULL.
if (!in_array($v[1], array('IS NULL', 'IS NOT NULL'))) {
if (($type == 'Int' || $type == 'Boolean') && !trim($v[2]) && $v[2] != '0') {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the value.");
} else {
if ($type == 'Date' && !trim($v[2])) {
$errorMsg["value[{$v['3']}][{$v['4']}]"] = ts("Please enter the value.");
}
}
}
//.........这里部分代码省略.........
示例7: __construct
/**
* class constructor which also does all the work
*
* @param array $params
* @param array $returnProperties
* @param array $fields
* @param boolean $includeContactIds
* @param boolean $strict
* @param boolean $mode - mode the search is operating on
*
* @return Object
* @access public
*/
function __construct($params = null, $returnProperties = null, $fields = null, $includeContactIds = false, $strict = false, $mode = 1, $skipPermission = false, $searchDescendentGroups = true, $smartGroupCache = true)
{
require_once 'CRM/Contact/BAO/Contact.php';
// CRM_Core_Error::backtrace( );
// CRM_Core_Error::debug_var( 'params', $params );
// CRM_Core_Error::debug( 'post', $_POST );
// CRM_Core_Error::debug( 'r', $returnProperties );
$this->_params =& $params;
if ($this->_params == null) {
$this->_params = array();
}
if (empty($returnProperties)) {
$this->_returnProperties =& self::defaultReturnProperties($mode);
} else {
$this->_returnProperties =& $returnProperties;
}
$this->_includeContactIds = $includeContactIds;
$this->_strict = $strict;
$this->_mode = $mode;
$this->_skipPermission = $skipPermission;
$this->_smartGroupCache = $smartGroupCache;
if ($fields) {
$this->_fields =& $fields;
$this->_search = false;
$this->_skipPermission = true;
} else {
require_once 'CRM/Contact/BAO/Contact.php';
$this->_fields = CRM_Contact_BAO_Contact::exportableFields('All', false, true);
require_once 'CRM/Core/Component.php';
$fields =& CRM_Core_Component::getQueryFields();
unset($fields['note']);
$this->_fields = array_merge($this->_fields, $fields);
// add activity fields
require_once 'CRM/Activity/BAO/Activity.php';
$fields = CRM_Activity_BAO_Activity::exportableFields();
$this->_fields = array_merge($this->_fields, $fields);
}
// basically do all the work once, and then reuse it
$this->initialize();
// CRM_Core_Error::debug( $this );
}
示例8: getFields
/**
* get all the fields that belong to the group with the name title
*
* @param mix $id the id of the UF group or ids of ufgroup
* @param int $register are we interested in registration fields
* @param int $action what action are we doing
* @param int $visibility visibility of fields we are interested in
* @param $searchable
* @param boolean $showall
* @param string $restrict should we restrict based on a specified profile type
*
* @return array the fields that belong to this ufgroup(s)
* @static
* @access public
*/
static function getFields($id, $register = FALSE, $action = NULL, $visibility = NULL, $searchable = NULL, $showAll = FALSE, $restrict = NULL, $skipPermission = FALSE, $ctype = NULL, $permissionType = CRM_Core_Permission::CREATE, $orderBy = 'field_name', $orderProfiles = NULL)
{
if (!is_array($id)) {
$id = CRM_Utils_Type::escape($id, 'Positive');
$profileIds = array($id);
} else {
$profileIds = $id;
}
$gids = implode(',', $profileIds);
$params = array();
if ($restrict) {
$query = "SELECT g.* from civicrm_uf_group g, civicrm_uf_join j\n WHERE g.id IN ( {$gids} )\n AND j.uf_group_id IN ( {$gids} )\n AND j.module = %1\n ";
$params = array(1 => array($restrict, 'String'));
} else {
$query = "SELECT g.* from civicrm_uf_group g WHERE g.id IN ( {$gids} ) ";
}
if (!$showAll) {
$query .= " AND g.is_active = 1";
}
// add permissioning for profiles only if not registration
if (!$skipPermission) {
$permissionClause = CRM_Core_Permission::ufGroupClause($permissionType, 'g.');
$query .= " AND {$permissionClause} ";
}
if ($orderProfiles and count($profileIds) > 1) {
$query .= " ORDER BY FIELD( g.id, {$gids} )";
}
$group = CRM_Core_DAO::executeQuery($query, $params);
$fields = array();
$validGroup = FALSE;
while ($group->fetch()) {
$validGroup = TRUE;
$where = " WHERE uf_group_id = {$group->id}";
if ($searchable) {
$where .= " AND is_searchable = 1";
}
if (!$showAll) {
$where .= " AND is_active = 1";
}
if ($visibility) {
$clause = array();
if ($visibility & self::PUBLIC_VISIBILITY) {
$clause[] = 'visibility = "Public Pages"';
}
if ($visibility & self::ADMIN_VISIBILITY) {
$clause[] = 'visibility = "User and User Admin Only"';
}
if ($visibility & self::LISTINGS_VISIBILITY) {
$clause[] = 'visibility = "Public Pages and Listings"';
}
if (!empty($clause)) {
$where .= ' AND ( ' . implode(' OR ', $clause) . ' ) ';
}
}
$query = "SELECT * FROM civicrm_uf_field {$where} ORDER BY weight";
if ($orderBy) {
$query .= ", " . $orderBy;
}
$field = CRM_Core_DAO::executeQuery($query);
if (!$showAll) {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All');
} else {
$importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, TRUE);
}
$profileType = CRM_Core_BAO_UFField::getProfileType($group->id);
$contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($group->id);
if ($profileType == 'Activity' || $contactActivityProfile) {
$componentFields = CRM_Activity_BAO_Activity::getProfileFields();
} else {
$componentFields = CRM_Core_Component::getQueryFields();
}
$importableFields = array_merge($importableFields, $componentFields);
$importableFields['group']['title'] = ts('Group(s)');
$importableFields['group']['where'] = NULL;
$importableFields['tag']['title'] = ts('Tag(s)');
$importableFields['tag']['where'] = NULL;
$locationFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'county', 'phone', 'email', 'im', 'address_name');
//get location type
$locationType = array();
$locationType = CRM_Core_PseudoConstant::locationType();
$customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype);
// hack to add custom data for components
$components = array('Contribution', 'Participant', 'Membership', 'Activity');
foreach ($components as $value) {
$customFields = array_merge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value));
//.........这里部分代码省略.........