當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_DAO::makeAttribute方法代碼示例

本文整理匯總了PHP中CRM_Core_DAO::makeAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_DAO::makeAttribute方法的具體用法?PHP CRM_Core_DAO::makeAttribute怎麽用?PHP CRM_Core_DAO::makeAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_DAO的用法示例。


在下文中一共展示了CRM_Core_DAO::makeAttribute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: formatUFField

 /**
  * Prepare a field for rendering with CRM_Core_BAO_UFGroup::buildProfile.
  *
  * @param CRM_Core_DAO_UFGroup|CRM_Core_DAO $group
  * @param CRM_Core_DAO_UFField|CRM_Core_DAO $field
  * @param array $customFields
  * @param array $addressCustomFields
  * @param array $importableFields
  * @param int $permissionType
  *   Eg CRM_Core_Permission::CREATE.
  * @return array
  */
 protected static function formatUFField($group, $field, $customFields, $addressCustomFields, $importableFields, $permissionType = CRM_Core_Permission::CREATE)
 {
     $name = $field->field_name;
     $title = $field->label;
     $addressCustom = FALSE;
     if (in_array($permissionType, array(CRM_Core_Permission::CREATE, CRM_Core_Permission::EDIT)) && in_array($field->field_name, array_keys($addressCustomFields))) {
         $addressCustom = TRUE;
         $name = "address_{$name}";
     }
     if ($field->field_name == 'url') {
         $name .= "-{$field->website_type_id}";
     } elseif (!empty($field->location_type_id)) {
         $name .= "-{$field->location_type_id}";
     } else {
         $locationFields = self::getLocationFields();
         if (in_array($field->field_name, $locationFields) || $addressCustom) {
             $name .= '-Primary';
         }
     }
     if (isset($field->phone_type_id)) {
         $name .= "-{$field->phone_type_id}";
     }
     // No lie: this is bizarre; why do we need to mix so many UFGroup properties into UFFields?
     // I guess to make field self sufficient with all the required data and avoid additional calls
     $formattedField = array('name' => $name, 'groupTitle' => $group->title, 'groupName' => $group->name, 'groupHelpPre' => empty($group->help_pre) ? '' : $group->help_pre, 'groupHelpPost' => empty($group->help_post) ? '' : $group->help_post, 'title' => $title, 'where' => CRM_Utils_Array::value('where', CRM_Utils_Array::value($field->field_name, $importableFields)), 'attributes' => CRM_Core_DAO::makeAttribute(CRM_Utils_Array::value($field->field_name, $importableFields)), 'is_required' => $field->is_required, 'is_view' => $field->is_view, 'help_pre' => $field->help_pre, 'help_post' => $field->help_post, 'visibility' => $field->visibility, 'in_selector' => $field->in_selector, 'rule' => CRM_Utils_Array::value('rule', CRM_Utils_Array::value($field->field_name, $importableFields)), 'location_type_id' => isset($field->location_type_id) ? $field->location_type_id : NULL, 'website_type_id' => isset($field->website_type_id) ? $field->website_type_id : NULL, 'phone_type_id' => isset($field->phone_type_id) ? $field->phone_type_id : NULL, 'group_id' => $group->id, 'add_to_group_id' => isset($group->add_to_group_id) ? $group->add_to_group_id : NULL, 'add_captcha' => isset($group->add_captcha) ? $group->add_captcha : NULL, 'field_type' => $field->field_type, 'field_id' => $field->id, 'pseudoconstant' => CRM_Utils_Array::value('pseudoconstant', CRM_Utils_Array::value($field->field_name, $importableFields)), 'dbName' => CRM_Utils_Array::value('dbName', CRM_Utils_Array::value($field->field_name, $importableFields)), 'skipDisplay' => 0);
     //adding custom field property
     if (substr($field->field_name, 0, 6) == 'custom' || substr($field->field_name, 0, 14) === 'address_custom') {
         // if field is not present in customFields, that means the user
         // DOES NOT HAVE permission to access that field
         if (array_key_exists($field->field_name, $customFields)) {
             $formattedField['is_search_range'] = $customFields[$field->field_name]['is_search_range'];
             // fix for CRM-1994
             $formattedField['options_per_line'] = $customFields[$field->field_name]['options_per_line'];
             $formattedField['data_type'] = $customFields[$field->field_name]['data_type'];
             $formattedField['html_type'] = $customFields[$field->field_name]['html_type'];
             if (CRM_Utils_Array::value('html_type', $formattedField) == 'Select Date') {
                 $formattedField['date_format'] = $customFields[$field->field_name]['date_format'];
                 $formattedField['time_format'] = $customFields[$field->field_name]['time_format'];
             }
             $formattedField['is_multi_summary'] = $field->is_multi_summary;
             return array($name, $formattedField);
         } else {
             $formattedField = NULL;
             return array($name, $formattedField);
         }
     }
     return array($name, $formattedField);
 }
開發者ID:rollox,項目名稱:civicrm-core,代碼行數:60,代碼來源:UFGroup.php

示例2: getFields


//.........這裏部分代碼省略.........
         $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}";
                 }
             }
             $fields[$name] = array('name' => $name, 'groupTitle' => $group->title, 'groupHelpPre' => $group->help_pre, 'groupHelpPost' => $group->help_post, 'title' => $title, 'where' => CRM_Utils_Array::value('where', $importableFields[$field->field_name]), 'attributes' => CRM_Core_DAO::makeAttribute(CRM_Utils_Array::value($field->field_name, $importableFields)), 'is_required' => $field->is_required, 'is_view' => $field->is_view, 'help_post' => $field->help_post, 'visibility' => $field->visibility, 'in_selector' => $field->in_selector, 'rule' => CRM_Utils_Array::value('rule', $importableFields[$field->field_name]), 'location_type_id' => $field->location_type_id, 'phone_type_id' => isset($field->phone_type_id) ? $field->phone_type_id : NULL, 'group_id' => $group->id, 'add_to_group_id' => $group->add_to_group_id, 'add_captcha' => $group->add_captcha, 'field_type' => $field->field_type, 'field_id' => $field->id);
             //adding custom field property
             if (substr($name, 0, 6) == 'custom') {
                 // if field is not present in customFields, that means the user
                 // DOES NOT HAVE permission to access that field
                 if (array_key_exists($name, $customFields)) {
                     $fields[$name]['is_search_range'] = $customFields[$name]['is_search_range'];
                     // fix for CRM-1994
                     $fields[$name]['options_per_line'] = $customFields[$name]['options_per_line'];
                     $fields[$name]['data_type'] = $customFields[$name]['data_type'];
                     $fields[$name]['html_type'] = $customFields[$name]['html_type'];
                 } else {
                     unset($fields[$name]);
                 }
             }
         }
     } else {
         CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.', array(1 => $id)));
     }
     return $fields;
 }
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:101,代碼來源:UFGroup.php

示例3: getAttribute

 /**
  * Get the size and maxLength attributes for this text field
  * (or for all text fields) in the DAO object.
  *
  * @param string $class     name of DAO class
  * @param string $fieldName field that i'm interested in or null if 
  *                          you want the attributes for all DAO text fields
  *
  * @return array assoc array of name => attribute pairs
  * @access public
  * @static
  */
 function getAttribute($class, $fieldName = null)
 {
     require_once str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
     eval('$fields =& ' . $class . '::fields( );');
     if ($fieldName != null) {
         $field = CRM_Utils_Array::value($fieldName, $fields);
         return CRM_Core_DAO::makeAttribute($field);
     } else {
         $attributes = array();
         foreach ($fields as $name => $field) {
             $attribute = CRM_Core_DAO::makeAttribute($field);
             if ($attribute) {
                 $attributes[$name] = $attribute;
             }
         }
         if (!empty($attributes)) {
             return $attributes;
         }
     }
     return null;
 }
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:33,代碼來源:DAO.php

示例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
  *
  *
  * @return array   the fields that belong to this title
  * @static
  * @access public
  */
 function getFields($id, $register = false, $action = null, $visibility = null, $searchable = null, $showAll = false)
 {
     //get location type
     $locationType = array();
     $locationType =& CRM_Core_PseudoConstant::locationType();
     $fields = array();
     $group =& new CRM_Core_DAO_UFGroup();
     $group->id = $id;
     if ($group->find(true)) {
         if ($searchable) {
             $where = "WHERE uf_group_id = {$group->id} AND is_searchable = 1";
         } else {
             $where = "WHERE uf_group_id = {$group->id}";
         }
         if (!$showAll) {
             $where .= " AND is_active = 1";
         } else {
             $where .= " AND 1";
         }
         if ($visibility) {
             $clause = array();
             if ($visibility & CRM_CORE_BAO_UFGROUP_PUBLIC_VISIBILITY) {
                 $clause[] = 'visibility = "Public User Pages"';
             }
             if ($visibility & CRM_CORE_BAO_UFGROUP_ADMIN_VISIBILITY) {
                 $clause[] = 'visibility = "User and User Admin Only"';
             }
             if ($visibility & CRM_CORE_BAO_UFGROUP_LISTINGS_VISIBILITY) {
                 $clause[] = 'visibility = "Public User 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);
         if (!$showAll) {
             $importableFields =& CRM_Contact_BAO_Contact::importableFields("All");
         } else {
             $importableFields =& CRM_Contact_BAO_Contact::importableFields("All", false, true);
         }
         $importableFields['group']['title'] = ts('Group(s)');
         $importableFields['group']['where'] = null;
         $importableFields['tag']['title'] = ts('Tag(s)');
         $importableFields['tag']['where'] = null;
         while ($field->fetch()) {
             if ($field->is_view && $action == CRM_CORE_ACTION_VIEW || !$field->is_view) {
                 $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] . ') ';
                 }
                 if ($field->phone_type) {
                     $name .= '-' . $field->phone_type;
                     if ($field->phone_type != 'Phone') {
                         // this hack is to prevent Phone Phone (work)
                         $phoneType = '-' . $field->phone_type;
                     }
                 }
                 $fields[$name] = array('name' => $name, 'groupTitle' => $group->title, 'groupHelpPre' => $group->help_pre, 'groupHelpPost' => $group->help_post, 'title' => $title, 'where' => $importableFields[$field->field_name]['where'], 'attributes' => CRM_Core_DAO::makeAttribute($importableFields[$field->field_name]), 'is_required' => $field->is_required, 'is_view' => $field->is_view, 'is_match' => $field->is_match, 'help_post' => $field->help_post, 'visibility' => $field->visibility, 'in_selector' => $field->in_selector, 'default' => $field->default_value, 'rule' => CRM_Utils_Array::value('rule', $importableFields[$field->field_name]), 'options_per_line' => $importableFields[$field->field_name]['options_per_line'], 'location_type_id' => $field->location_type_id, 'phone_type' => $field->phone_type, 'group_id' => $group->id);
             }
         }
     }
     return $fields;
 }
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:82,代碼來源:UFGroup.php

示例5: getFields


//.........這裏部分代碼省略.........
             $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));
         }
         $addressCustomFields = CRM_Core_BAO_CustomField::getFieldsForImport('Address');
         $customFields = array_merge($customFields, $addressCustomFields);
         while ($field->fetch()) {
             $name = $title = $locType = $phoneType = '';
             $name = $field->field_name;
             $title = $field->label;
             $addressCustom = FALSE;
             if (in_array($permissionType, array(CRM_Core_Permission::CREATE, CRM_Core_Permission::EDIT)) && in_array($field->field_name, array_keys($addressCustomFields))) {
                 $addressCustom = TRUE;
                 $name = "address_{$name}";
             }
             if ($field->location_type_id) {
                 $name .= "-{$field->location_type_id}";
                 $locType = " ( {$locationType[$field->location_type_id]} ) ";
             } else {
                 if (in_array($field->field_name, $locationFields) || $addressCustom) {
                     $name .= '-Primary';
                     $locType = ' ( Primary ) ';
                 }
             }
             if (isset($field->phone_type_id)) {
                 $name .= "-{$field->phone_type_id}";
                 // this hack is to prevent Phone Phone (work)
                 if ($field->phone_type_id != '1') {
                     $phoneType = "-{$field->phone_type_id}";
                 }
             }
             $fields[$name] = array('name' => $name, 'groupTitle' => $group->title, 'groupHelpPre' => $group->help_pre, 'groupHelpPost' => $group->help_post, 'title' => $title, 'where' => CRM_Utils_Array::value('where', CRM_Utils_Array::value($field->field_name, $importableFields)), 'attributes' => CRM_Core_DAO::makeAttribute(CRM_Utils_Array::value($field->field_name, $importableFields)), 'is_required' => $field->is_required, 'is_view' => $field->is_view, 'help_pre' => $field->help_pre, 'help_post' => $field->help_post, 'visibility' => $field->visibility, 'in_selector' => $field->in_selector, 'rule' => CRM_Utils_Array::value('rule', CRM_Utils_Array::value($field->field_name, $importableFields)), 'location_type_id' => $field->location_type_id, 'phone_type_id' => isset($field->phone_type_id) ? $field->phone_type_id : NULL, 'group_id' => $group->id, 'add_to_group_id' => $group->add_to_group_id, 'add_captcha' => $group->add_captcha, 'field_type' => $field->field_type, 'field_id' => $field->id);
             //adding custom field property
             if (substr($field->field_name, 0, 6) == 'custom' || substr($field->field_name, 0, 14) === 'address_custom') {
                 // if field is not present in customFields, that means the user
                 // DOES NOT HAVE permission to access that field
                 if (array_key_exists($field->field_name, $customFields)) {
                     $fields[$name]['is_search_range'] = $customFields[$field->field_name]['is_search_range'];
                     // fix for CRM-1994
                     $fields[$name]['options_per_line'] = $customFields[$field->field_name]['options_per_line'];
                     $fields[$name]['data_type'] = $customFields[$field->field_name]['data_type'];
                     $fields[$name]['html_type'] = $customFields[$field->field_name]['html_type'];
                     if (CRM_Utils_Array::value('html_type', $fields[$name]) == 'Select Date') {
                         $fields[$name]['date_format'] = $customFields[$field->field_name]['date_format'];
                         $fields[$name]['time_format'] = $customFields[$field->field_name]['time_format'];
                     }
                 } else {
                     unset($fields[$name]);
                 }
             }
         }
         $field->free();
     }
     if (empty($fields) && !$validGroup) {
         CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.', array(1 => implode(',', $profileIds))));
     }
     return $fields;
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:101,代碼來源:UFGroup.php


注:本文中的CRM_Core_DAO::makeAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。