当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_CustomGroup::setDefaults方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_CustomGroup::setDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomGroup::setDefaults方法的具体用法?PHP CRM_Core_BAO_CustomGroup::setDefaults怎么用?PHP CRM_Core_BAO_CustomGroup::setDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_CustomGroup的用法示例。


在下文中一共展示了CRM_Core_BAO_CustomGroup::setDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preProcess

 /**
  * Pre processing work done here.
  *
  * gets session variables for table name, id of entity in table, type of entity and stores them.
  */
 public function preProcess()
 {
     $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE);
     $this->_entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', $this, TRUE);
     $this->_subTypeID = CRM_Utils_Request::retrieve('subType', 'Positive', $this, TRUE);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Case', $this, $this->_entityID, $this->_groupID, $this->_subTypeID);
     // simplified formatted groupTree
     $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this);
     // Array contains only one item
     foreach ($groupTree as $groupValues) {
         $this->_customTitle = $groupValues['title'];
         CRM_Utils_System::setTitle(ts('Edit %1', array(1 => $groupValues['title'])));
     }
     $this->_defaults = array();
     CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $this->_defaults);
     $this->setDefaults($this->_defaults);
     CRM_Core_BAO_CustomGroup::buildQuickForm($this, $groupTree);
     //need to assign custom data type and subtype to the template
     $this->assign('entityID', $this->_entityID);
     $this->assign('groupID', $this->_groupID);
     $this->assign('subType', $this->_subTypeID);
     $this->assign('contactID', $this->_contactID);
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:29,代码来源:CustomData.php

示例2: array

 /**
  * Set the default form values
  * 
  * @param null
  * 
  * @return array   the default array reference
  * @access protected
  */
 function &setDefaultValues()
 {
     $defaults = array();
     require_once 'CRM/Core/BAO/CustomGroup.php';
     CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, false, false);
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:15,代码来源:Preview.php

示例3: setDefaultValues

 function setDefaultValues()
 {
     $defaults = array();
     $params = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Contact_BAO_Group::retrieve($params, $defaults);
     }
     if (isset($this->_groupTree)) {
         CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, $viewMode, $inactiveNeeded);
     }
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:13,代码来源:Edit.php

示例4: buildQuickForm


//.........这里部分代码省略.........
                 if ($name == 'country_id') {
                     $stateCountryMap[$blockId]['country'] = "address_{$blockId}_{$name}";
                     $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
                 } elseif ($name == 'state_province_id') {
                     $stateCountryMap[$blockId]['state_province'] = "address_{$blockId}_{$name}";
                     if ($countryDefault) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
                     } else {
                         $selectOptions = array('' => ts('- select a country -'));
                     }
                 } elseif ($name == 'county_id') {
                     $stateCountryMap[$blockId]['county'] = "address_{$blockId}_{$name}";
                     if ($form->getSubmitValue("address[{$blockId}][state_province_id]")) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::countyForState($form->getSubmitValue("address[{$blockId}][state_province_id]"));
                     } elseif ($form->getSubmitValue("address[{$blockId}][county_id]")) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::county();
                     } else {
                         $selectOptions = array('' => ts('- select a state -'));
                     }
                 }
                 $form->addElement('select', "address[{$blockId}][{$name}]", $title, $selectOptions);
             } else {
                 if ($name == 'address_name') {
                     $name = 'name';
                 }
                 $form->addElement('text', "address[{$blockId}][{$name}]", $title, $attributes);
             }
         } else {
             if ($name == 'state_province_id') {
                 $stateCountryMap[$blockId]['state_province'] = "address_{$blockId}_{$name}";
             }
             $form->addElement('select', "address[{$blockId}][{$name}]", $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select());
         }
     }
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
     $entityId = NULL;
     if (!empty($form->_values['address']) && !empty($form->_values['address'][$blockId])) {
         $entityId = $form->_values['address'][$blockId]['id'];
     }
     // CRM-11665 geocode override option
     $geoCode = FALSE;
     if (!empty($config->geocodeMethod)) {
         $geoCode = TRUE;
         $form->addElement('checkbox', "address[{$blockId}][manual_geo_code]", ts('Override automatic geocoding'));
     }
     $form->assign('geoCode', $geoCode);
     // Process any address custom data -
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $form, $entityId);
     if (isset($groupTree) && is_array($groupTree)) {
         // use simplified formatted groupTree
         $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form);
         // make sure custom fields are added /w element-name in the format - 'address[$blockId][custom-X]'
         foreach ($groupTree as $id => $group) {
             foreach ($group['fields'] as $fldId => $field) {
                 $groupTree[$id]['fields'][$fldId]['element_custom_name'] = $field['element_name'];
                 $groupTree[$id]['fields'][$fldId]['element_name'] = "address[{$blockId}][{$field['element_name']}]";
             }
         }
         $defaults = array();
         CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
         // since we change element name for address custom data, we need to format the setdefault values
         $addressDefaults = array();
         foreach ($defaults as $key => $val) {
             if (empty($val)) {
                 continue;
             }
             // inorder to set correct defaults for checkbox custom data, we need to converted flat key to array
             // this works for all types custom data
             $keyValues = explode('[', str_replace(']', '', $key));
             $addressDefaults[$keyValues[0]][$keyValues[1]][$keyValues[2]] = $val;
         }
         $form->setDefaults($addressDefaults);
         // we setting the prefix to 'dnc_' below, so that we don't overwrite smarty's grouptree var.
         // And we can't set it to 'address_' because we want to set it in a slightly different format.
         CRM_Core_BAO_CustomGroup::buildQuickForm($form, $groupTree, FALSE, 'dnc_');
         // during contact editing : if no address is filled
         // required custom data must not produce 'required' form rule error
         // more handling done in formRule func
         if (!$inlineEdit) {
             CRM_Contact_Form_Edit_Address::storeRequiredCustomDataInfo($form, $groupTree);
         }
         $template = CRM_Core_Smarty::singleton();
         $tplGroupTree = $template->get_template_vars('address_groupTree');
         $tplGroupTree = empty($tplGroupTree) ? array() : $tplGroupTree;
         $form->assign('address_groupTree', $tplGroupTree + array($blockId => $groupTree));
         // unset the temp smarty var that got created
         $form->assign('dnc_groupTree', NULL);
     }
     // address custom data processing ends ..
     if ($sharing) {
         // shared address
         $form->addElement('checkbox', "address[{$blockId}][use_shared_address]", NULL, ts('Use another contact\'s address'));
         // get the reserved for address
         $profileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'shared_address', 'id', 'name');
         if (!$profileId) {
             CRM_Core_Error::fatal(ts('Your install is missing required "Shared Address" profile.'));
         }
         CRM_Contact_Form_NewContact::buildQuickForm($form, $blockId, array($profileId));
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Address.php

示例5: formatParams

 /**
  * format params for update and fill mode
  *
  * @param $params       array  referance to an array containg all the
  *                             values for import
  * @param $onDuplicate  int
  * @param $cid          int    contact id
  */
 function formatParams(&$params, $onDuplicate, $cid)
 {
     if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP) {
         return;
     }
     $contactParams = array('contact_id' => $cid);
     $defaults = array();
     $contactObj = CRM_Contact_BAO_Contact::retrieve($contactParams, $defaults);
     $modeUpdate = $modeFill = false;
     if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
         $modeUpdate = true;
     }
     if ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
         $modeFill = true;
     }
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $groupTree = CRM_Core_BAO_CustomGroup::getTree($params['contact_type'], CRM_Core_DAO::$_nullObject, $cid, 0, null);
     CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults, false, false);
     $contact = get_object_vars($contactObj);
     $location = null;
     foreach ($params as $key => $value) {
         if ($key == 'id' || $key == 'contact_type') {
             continue;
         }
         if ($key == 'location') {
             $location = true;
         } else {
             if (in_array($key, array('email_greeting', 'postal_greeting', 'addressee'))) {
                 // CRM-4575, need to null custom
                 if ($params["{$key}_id"] != 4) {
                     $params["{$key}_custom"] = 'null';
                 }
                 unset($params[$key]);
             } else {
                 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key)) {
                     $custom = true;
                 } else {
                     $getValue = CRM_Utils_Array::retrieveValueRecursive($contact, $key);
                     if ($key == 'contact_source') {
                         $params['source'] = $params[$key];
                         unset($params[$key]);
                     }
                     if ($modeFill && isset($getValue)) {
                         unset($params[$key]);
                     }
                 }
             }
         }
     }
     if ($location) {
         for ($loc = 1; $loc <= count($params['location']); $loc++) {
             //if location block is already present for the contact
             //then do not fill any data for that location type, CRM-4424
             if ($modeFill) {
                 foreach ($contact['location'] as $location => $locationDetails) {
                     $getValue = CRM_Utils_Array::value('location_type_id', $locationDetails);
                     if (isset($getValue) && $getValue == $params['location'][$loc]['location_type_id']) {
                         unset($params['location'][$loc]);
                         break;
                     }
                 }
             }
             if (array_key_exists('address', $contact['location'][$loc])) {
                 $fields = array('street_address', 'city', 'state_province_id', 'postal_code', 'postal_code_suffix', 'country_id');
                 foreach ($fields as $field) {
                     $getValue = CRM_Utils_Array::retrieveValueRecursive($contact['location'][$loc]['address'], $field);
                     if ($modeFill && isset($getValue)) {
                         unset($params['location'][$loc]['address'][$field]);
                     }
                 }
             }
             $fields = array('email' => 'email', 'phone' => 'phone', 'im' => 'name');
             foreach ($fields as $key => $field) {
                 if (array_key_exists($key, $contact['location'][$loc])) {
                     for ($c = 1; $c <= count($params['location'][$loc][$key]); $c++) {
                         $getValue = CRM_Utils_Array::retrieveValueRecursive($contact['location'][$loc][$key][$c], $field);
                         if ($modeFill && isset($getValue)) {
                             unset($params['location'][$loc][$key][$c][$field]);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:93,代码来源:Contact.php

示例6: setDefaultValues

 /**
  * Set the default form values.
  *
  *
  * @return array
  *   the default array reference
  */
 public function setDefaultValues()
 {
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
         if ($this->_copyValueId) {
             // cached tree is fetched
             $groupTree = CRM_Core_BAO_CustomGroup::getTree($this->_type, $this, $this->_entityId, $this->_groupID);
             $valueIdDefaults = array();
             $groupTreeValueId = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, $this->_copyValueId, $this);
             CRM_Core_BAO_CustomGroup::setDefaults($groupTreeValueId, $valueIdDefaults, FALSE, FALSE, $this->get('action'));
             $tableId = $groupTreeValueId[$this->_groupID]['table_id'];
             foreach ($valueIdDefaults as $valueIdElementName => $value) {
                 // build defaults for COPY action for new record saving
                 $valueIdElementNamePieces = explode('_', $valueIdElementName);
                 $valueIdElementNamePieces[2] = "-{$this->_groupCount}";
                 $elementName = implode('_', $valueIdElementNamePieces);
                 $customDefaultValue[$elementName] = $value;
             }
         } else {
             $customDefaultValue = CRM_Custom_Form_CustomData::setDefaultValues($this);
         }
         return $customDefaultValue;
     }
     $groupTree = CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this, $this->_tableID, $this->_groupID, $this->_contactSubType);
     if (empty($_POST['hidden_custom_group_count'])) {
         // custom data building in edit mode (required to handle multi-value)
         $groupTree = CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this, $this->_tableID, $this->_groupID, $this->_contactSubType);
         $customValueCount = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, TRUE, $this->_groupID, NULL, NULL, $this->_tableID);
     } else {
         $customValueCount = $_POST['hidden_custom_group_count'][$this->_groupID];
     }
     $this->assign('customValueCount', $customValueCount);
     $defaults = array();
     return $defaults;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:41,代码来源:CustomData.php

示例7: setComponentDefaults

 /**
  * setDefault componet specific profile fields.
  *
  * @param array $fields
  *   Profile fields.
  * @param int $componentId
  *   ComponetID.
  * @param string $component
  *   Component name.
  * @param array $defaults
  *   An array of default values.
  *
  * @param bool $isStandalone
  */
 public static function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE)
 {
     if (!$componentId || !in_array($component, array('Contribute', 'Membership', 'Event', 'Activity'))) {
         return;
     }
     $componentBAO = $componentSubType = NULL;
     switch ($component) {
         case 'Membership':
             $componentBAO = 'CRM_Member_BAO_Membership';
             $componentBAOName = 'Membership';
             $componentSubType = array('membership_type_id');
             break;
         case 'Contribute':
             $componentBAO = 'CRM_Contribute_BAO_Contribution';
             $componentBAOName = 'Contribution';
             $componentSubType = array('financial_type_id');
             break;
         case 'Event':
             $componentBAO = 'CRM_Event_BAO_Participant';
             $componentBAOName = 'Participant';
             $componentSubType = array('role_id', 'event_id', 'event_type_id');
             break;
         case 'Activity':
             $componentBAO = 'CRM_Activity_BAO_Activity';
             $componentBAOName = 'Activity';
             $componentSubType = array('activity_type_id');
             break;
     }
     $values = array();
     $params = array('id' => $componentId);
     //get the component values.
     CRM_Core_DAO::commonRetrieve($componentBAO, $params, $values);
     if ($componentBAOName == 'Participant') {
         $values += array('event_type_id' => CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values['event_id'], 'event_type_id'));
     }
     $formattedGroupTree = array();
     $dateTimeFields = array('participant_register_date', 'activity_date_time', 'receive_date', 'receipt_date', 'cancel_date', 'thankyou_date', 'membership_start_date', 'membership_end_date', 'join_date');
     foreach ($fields as $name => $field) {
         $fldName = $isStandalone ? $name : "field[{$componentId}][{$name}]";
         if (in_array($name, $dateTimeFields)) {
             $timefldName = $isStandalone ? "{$name}_time" : "field[{$componentId}][{$name}_time]";
             if (!empty($values[$name])) {
                 list($defaults[$fldName], $defaults[$timefldName]) = CRM_Utils_Date::setDateDefaults($values[$name]);
             }
         } elseif (array_key_exists($name, $values)) {
             $defaults[$fldName] = $values[$name];
         } elseif ($name == 'participant_note') {
             $noteDetails = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant');
             $defaults[$fldName] = array_pop($noteDetails);
         } elseif (in_array($name, array('financial_type', 'payment_instrument', 'participant_status', 'participant_role'))) {
             $defaults[$fldName] = $values["{$name}_id"];
         } elseif ($name == 'membership_type') {
             // since membership_type field is a hierselect -
             $defaults[$fldName][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values['membership_type_id'], 'member_of_contact_id', 'id');
             $defaults[$fldName][1] = $values['membership_type_id'];
         } elseif ($name == 'membership_status') {
             $defaults[$fldName] = $values['status_id'];
         } elseif ($customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($name, TRUE)) {
             if (empty($formattedGroupTree)) {
                 //get the groupTree as per subTypes.
                 $groupTree = array();
                 foreach ($componentSubType as $subType) {
                     $subTree = CRM_Core_BAO_CustomGroup::getTree($componentBAOName, CRM_Core_DAO::$_nullObject, $componentId, 0, $values[$subType]);
                     $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $subTree);
                 }
                 $formattedGroupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
                 CRM_Core_BAO_CustomGroup::setDefaults($formattedGroupTree, $defaults);
             }
             //FIX ME: We need to loop defaults, but once we move to custom_1_x convention this code can be simplified.
             foreach ($defaults as $customKey => $customValue) {
                 if ($customFieldDetails = CRM_Core_BAO_CustomField::getKeyID($customKey, TRUE)) {
                     if ($name == 'custom_' . $customFieldDetails[0]) {
                         //hack to set default for checkbox
                         //basically this is for weired field name like field[33][custom_19]
                         //we are converting this field name to array structure and assign value.
                         $skipValue = FALSE;
                         foreach ($formattedGroupTree as $tree) {
                             if (!empty($tree['fields'][$customFieldDetails[0]])) {
                                 if ('CheckBox' == CRM_Utils_Array::value('html_type', $tree['fields'][$customFieldDetails[0]])) {
                                     $skipValue = TRUE;
                                     $defaults['field'][$componentId][$name] = $customValue;
                                     break;
                                 } elseif (CRM_Utils_Array::value('data_type', $tree['fields'][$customFieldDetails[0]]) == 'Date') {
                                     $skipValue = TRUE;
                                     // CRM-6681, $default contains formatted date, time values.
                                     $defaults[$fldName] = $customValue;
//.........这里部分代码省略.........
开发者ID:rollox,项目名称:civicrm-core,代码行数:101,代码来源:UFGroup.php

示例8: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     $defaults = array();
     $params = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         require_once str_replace('_', DIRECTORY_SEPARATOR, $this->_BAOName) . ".php";
         eval($this->_BAOName . '::retrieve( $params, $defaults );');
         $sourceName = CRM_Contact_BAO_Contact::displayName($defaults['source_contact_id']);
         $targetName = CRM_Contact_BAO_Contact::displayName($defaults['target_entity_id']);
         $this->assign('sourceName', $sourceName);
         $this->assign('targetName', $targetName);
     }
     if ($this->_action == CRM_CORE_ACTION_DELETE) {
         $this->assign('delName', $defaults['subject']);
     }
     if ($this->_log) {
         $defaults['status'] = 'Completed';
     }
     // set the default date if we are creating a new meeting/call or
     // marking one as complete
     if ($this->_log || !isset($this->_id)) {
         // rounding of minutes
         $min = (int) (date("i") / 15) * 15;
         $defaults['scheduled_date_time'] = array('Y' => date('Y'), 'M' => date('m'), 'd' => date('d'), 'h' => date('h'), 'i' => $min, 'A' => date('A'));
     }
     if ($this->_action & (CRM_CORE_ACTION_VIEW | CRM_CORE_ACTION_BROWSE)) {
         $inactiveNeeded = true;
         $viewMode = true;
     } else {
         $viewMode = false;
         $inactiveNeeded = false;
     }
     if (isset($this->_groupTree)) {
         CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, $viewMode, $inactiveNeeded);
     }
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:45,代码来源:Form.php

示例9: civicrm_contact_relationship_get

/**
 * Function to get the relationship
 *
 * @param array   $contact_a          (reference ) input parameters.
 * @param array   $contact_b          (reference ) input parameters.
 * @param array   $relationshipTypes  an array of Relationship Type Name.
 * @param string  $sort               sort all relationship by relationshipId (eg asc/desc)
 *
 * @return        Array of all relationship.
 *
 * @access  public
 */
function civicrm_contact_relationship_get($contact_a, $contact_b = NULL, $relationshipTypes = NULL, $sort = NULL)
{
    if (!is_array($contact_a)) {
        return civicrm_create_error(ts('Input parameter is not an array'));
    }
    if (!isset($contact_a['contact_id'])) {
        return civicrm_create_error(ts('Could not find contact_id in input parameters.'));
    }
    require_once 'CRM/Contact/BAO/Relationship.php';
    $contactID = $contact_a['contact_id'];
    $relationships = CRM_Contact_BAO_Relationship::getRelationship($contactID);
    if (!empty($relationshipTypes)) {
        $result = array();
        foreach ($relationshipTypes as $relationshipName) {
            foreach ($relationships as $key => $relationship) {
                if ($relationship['relation'] == $relationshipName) {
                    $result[$key] = $relationship;
                }
            }
        }
        $relationships = $result;
    }
    if (isset($contact_b['contact_id'])) {
        $cid = $contact_b['contact_id'];
        $result = array();
        foreach ($relationships as $key => $relationship) {
            if ($relationship['cid'] == $cid) {
                $result[$key] = $relationship;
            }
        }
        $relationships = $result;
    }
    //sort by relationship id
    if ($sort) {
        if (strtolower($sort) == 'asc') {
            ksort($relationships);
        } elseif (strtolower($sort) == 'desc') {
            krsort($relationships);
        }
    }
    //handle custom data.
    require_once 'CRM/Core/BAO/CustomGroup.php';
    foreach ($relationships as $relationshipId => $values) {
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', CRM_Core_DAO::$_nullObject, $relationshipId, FALSE, $values['civicrm_relationship_type_id']);
        $formatTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($formatTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                $relationships[$relationshipId][$key] = $val;
            }
        }
    }
    if ($relationships) {
        return civicrm_create_success($relationships);
    } else {
        return civicrm_create_error(ts('Invalid Data'));
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:71,代码来源:Relationship.php

示例10: civicrm_event_search

/**
 * Get Event record.
 * 
 *
 * @param  array  $params     an associative array of name/value property values of civicrm_event
 *
 * @return  Array of all found event property values.
 * @access public
 */
function civicrm_event_search(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameters is not an array.'));
    }
    $inputParams = array();
    $returnProperties = array();
    $returnCustomProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount');
    $sort = false;
    // don't check if empty, more meaningful error for API user instead of siletn defaults
    $offset = array_key_exists('return.offset', $params) ? $params['return.offset'] : 0;
    $rowCount = array_key_exists('return.max_results', $params) ? $params['return.max_results'] : 25;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            if (substr($n, 0, 14) == 'return.custom_') {
                //take custom return properties separate
                $returnCustomProperties[] = substr($n, 7);
            } elseif (!in_array(substr($n, 7), array('offset', 'max_results'))) {
                $returnProperties[] = substr($n, 7);
            }
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    if (!empty($returnProperties)) {
        $returnProperties[] = 'id';
        $returnProperties[] = 'event_type_id';
    }
    $returnProperties[] = 'is_template';
    require_once 'CRM/Core/BAO/CustomGroup.php';
    require_once 'CRM/Event/BAO/Event.php';
    $eventDAO = new CRM_Event_BAO_Event();
    $eventDAO->copyValues($inputParams);
    $event = array();
    if (!empty($returnProperties)) {
        $eventDAO->selectAdd();
        $eventDAO->selectAdd(implode(',', $returnProperties));
    }
    $eventDAO->orderBy($sort);
    $eventDAO->limit((int) $offset, (int) $rowCount);
    $eventDAO->find();
    while ($eventDAO->fetch()) {
        // ignore event templates
        // ideally need to put this in the query, but not sure how to do this with the below
        // ( ( is_template IS NULL ) OR ( is_template = 0 ) )
        // hence doing this here for now, please fix on a future rewrite
        if ($eventDAO->is_template) {
            continue;
        }
        $event[$eventDAO->id] = array();
        CRM_Core_DAO::storeValues($eventDAO, $event[$eventDAO->id]);
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Event', CRM_Core_DAO::$_nullObject, $eventDAO->id, false, $eventDAO->event_type_id);
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                if (!empty($returnCustomProperties)) {
                    $customKey = explode('_', $key);
                    //show only return properties
                    if (in_array('custom_' . $customKey['1'], $returnCustomProperties)) {
                        $event[$eventDAO->id][$key] = $val;
                    }
                } else {
                    $event[$eventDAO->id][$key] = $val;
                }
            }
        }
    }
    //end of the loop
    $eventDAO->free();
    return $event;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:85,代码来源:Event.php

示例11: setDefaultValues

 static function setDefaultValues(&$form)
 {
     $defaults = array();
     CRM_Core_BAO_CustomGroup::setDefaults($form->_groupTree, $defaults);
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:6,代码来源:CustomData.php

示例12: setDefaultValues

 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     $defaults = array();
     $params = array();
     if ($this->_action & CRM_CORE_ACTION_ADD) {
         // set group and tag defaults if any
         if ($this->_gid) {
             $defaults['group'][$this->_gid] = 1;
         }
         if ($this->_tid) {
             $defaults['tag'][$this->_tid] = 1;
         }
         if (CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS >= 1) {
             // set the is_primary location for the first location
             $defaults['location'] = array();
             $locationTypeKeys = array_filter(array_keys(CRM_Core_PseudoConstant::locationType()), 'is_int');
             sort($locationTypeKeys);
             // also set the location types for each location block
             for ($i = 0; $i < CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS; $i++) {
                 $defaults['location'][$i + 1] = array();
                 //$defaults['location'][$i+1]['location_type_id'] = $locationTypeKeys[$i];
                 if ($i == 0) {
                     $defaultLocation =& new CRM_Core_BAO_LocationType();
                     $locationType = $defaultLocation->getDefault();
                     $defaults['location'][$i + 1]['location_type_id'] = $locationType->id;
                 } else {
                     $defaults['location'][$i + 1]['location_type_id'] = $locationTypeKeys[$i];
                 }
                 $defaults['location'][$i + 1]['address'] = array();
                 $config =& CRM_Core_Config::singleton();
                 $countryIsoCodes =& CRM_Core_PseudoConstant::countryIsoCode();
                 $defaultCountryId = array_search($config->defaultContactCountry, $countryIsoCodes);
                 $defaults['location'][$i + 1]['address']['country_id'] = $defaultCountryId;
             }
             $defaults['location'][1]['is_primary'] = true;
         }
     } else {
         // this is update mode
         // get values from contact table
         $params['id'] = $params['contact_id'] = $this->_contactId;
         $ids = array();
         $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids);
         $this->set('ids', $ids);
         $this->assign('contactId', $this->_contactId);
         // also set contact_type, since this is used in showHide routines
         // to decide whether to display certain blocks (demographics)
         $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults);
         // set the group and tag ids
         CRM_Contact_Form_GroupTag::setDefaults($this->_contactId, $defaults, CRM_CONTACT_FORM_GROUPTAG_ALL);
     }
     // use most recently posted values if any to display show hide blocks
     $params = $this->controller->exportValues($this->_name);
     if (!empty($params)) {
         $this->setShowHide($params, true);
     } else {
         $this->setShowHide($defaults, false);
     }
     // do we need inactive options ?
     if ($this->_action & (CRM_CORE_ACTION_VIEW | CRM_CORE_ACTION_BROWSE)) {
         $inactiveNeeded = true;
         $viewMode = true;
     } else {
         $viewMode = false;
         $inactiveNeeded = false;
     }
     CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, $viewMode, $inactiveNeeded);
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:75,代码来源:Edit.php

示例13: civicrm_event_search

/**
 * Get Event record.
 *
 *
 * @param  array  $params     an associative array of name/value property values of civicrm_event
 *
 * @return  Array of all found event property values.
 * @access public
 */
function civicrm_event_search(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameters is not an array.'));
    }
    $inputParams = array();
    $returnProperties = array();
    $returnCustomProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount', 'isCurrent');
    $sort = array_key_exists('return.sort', $params) ? $params['return.sort'] : FALSE;
    // don't check if empty, more meaningful error for API user instead of silent defaults
    $offset = array_key_exists('return.offset', $params) ? $params['return.offset'] : 0;
    $rowCount = array_key_exists('return.max_results', $params) ? $params['return.max_results'] : 25;
    $isCurrent = array_key_exists('isCurrent', $params) ? $params['isCurrent'] : 0;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            if (substr($n, 0, 14) == 'return.custom_') {
                //take custom return properties separate
                $returnCustomProperties[] = substr($n, 7);
            } elseif (!in_array(substr($n, 7), array('sort', 'offset', 'max_results'))) {
                $returnProperties[] = substr($n, 7);
            }
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    if (!empty($returnProperties)) {
        $returnProperties[] = 'id';
        $returnProperties[] = 'event_type_id';
    }
    require_once 'CRM/Core/BAO/CustomGroup.php';
    require_once 'CRM/Event/BAO/Event.php';
    $eventDAO = new CRM_Event_BAO_Event();
    $eventDAO->copyValues($inputParams);
    $event = array();
    if (!empty($returnProperties)) {
        $eventDAO->selectAdd();
        $eventDAO->selectAdd(implode(',', $returnProperties));
    }
    $eventDAO->whereAdd('( is_template IS NULL ) OR ( is_template = 0 )');
    if ($isCurrent) {
        $eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
    }
    $eventDAO->orderBy($sort);
    $eventDAO->limit((int) $offset, (int) $rowCount);
    $eventDAO->find();
    while ($eventDAO->fetch()) {
        $event[$eventDAO->id] = array();
        CRM_Core_DAO::storeValues($eventDAO, $event[$eventDAO->id]);
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Event', CRM_Core_DAO::$_nullObject, $eventDAO->id, FALSE, $eventDAO->event_type_id);
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                if (!empty($returnCustomProperties)) {
                    $customKey = explode('_', $key);
                    //show only return properties
                    if (in_array('custom_' . $customKey['1'], $returnCustomProperties)) {
                        $event[$eventDAO->id][$key] = $val;
                    }
                } else {
                    $event[$eventDAO->id][$key] = $val;
                }
            }
        }
    }
    //end of the loop
    $eventDAO->free();
    return $event;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:82,代码来源:Event.php

示例14: buildQuickForm

 /**
  * build form for address input fields 
  *
  * @param object $form - CRM_Core_Form (or subclass)
  * @param array reference $location - location array
  * @param int $locationId - location id whose block needs to be built.
  * @return none
  *
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $addressBlockCount = null)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Address_Block_Count') ? $form->get('Address_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $config = CRM_Core_Config::singleton();
     $countryDefault = $config->defaultContactCountry;
     $form->applyFilter('__ALL__', 'trim');
     $js = array('onChange' => 'checkLocation( this.id );');
     $form->addElement('select', "address[{$blockId}][location_type_id]", ts('Location Type'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::locationType(), $js);
     $js = array('id' => "Address_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );');
     $form->addElement('checkbox', "address[{$blockId}][is_primary]", ts('Primary location for this contact'), ts('Primary location for this contact'), $js);
     $js = array('id' => "Address_" . $blockId . "_IsBilling", 'onClick' => 'singleSelect( this.id );');
     $form->addElement('checkbox', "address[{$blockId}][is_billing]", ts('Billing location for this contact'), ts('Billing location for this contact'), $js);
     // hidden element to store master address id
     $form->addElement('hidden', "address[{$blockId}][master_id]");
     require_once 'CRM/Core/BAO/Preferences.php';
     $addressOptions = CRM_Core_BAO_Preferences::valueOptions('address_options', true, null, true);
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
     $elements = array('address_name' => array(ts('Address Name'), $attributes['address_name'], null), 'street_address' => array(ts('Street Address'), $attributes['street_address'], null), 'supplemental_address_1' => array(ts('Addt\'l Address 1'), $attributes['supplemental_address_1'], null), 'supplemental_address_2' => array(ts('Addt\'l Address 2'), $attributes['supplemental_address_2'], null), 'city' => array(ts('City'), $attributes['city'], null), 'postal_code' => array(ts('Zip / Postal Code'), $attributes['postal_code'], null), 'postal_code_suffix' => array(ts('Postal Code Suffix'), array('size' => 4, 'maxlength' => 12), null), 'county_id' => array(ts('County'), $attributes['county_id'], 'county'), 'state_province_id' => array(ts('State / Province'), $attributes['state_province_id'], null), 'country_id' => array(ts('Country'), $attributes['country_id'], null), 'geo_code_1' => array(ts('Latitude'), array('size' => 9, 'maxlength' => 10), null), 'geo_code_2' => array(ts('Longitude'), array('size' => 9, 'maxlength' => 10), null), 'street_number' => array(ts('Street Number'), $attributes['street_number'], null), 'street_name' => array(ts('Street Name'), $attributes['street_name'], null), 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], null));
     $stateCountryMap = array();
     foreach ($elements as $name => $v) {
         list($title, $attributes, $select) = $v;
         $nameWithoutID = strpos($name, '_id') !== false ? substr($name, 0, -3) : $name;
         if (!CRM_Utils_Array::value($nameWithoutID, $addressOptions)) {
             $continue = true;
             if (in_array($nameWithoutID, array('street_number', 'street_name', 'street_unit')) && CRM_Utils_Array::value('street_address_parsing', $addressOptions)) {
                 $continue = false;
             }
             if ($continue) {
                 continue;
             }
         }
         if (!$attributes) {
             $attributes = $attributes[$name];
         }
         //build normal select if country is not present in address block
         if ($name == 'state_province_id' && !$addressOptions['country']) {
             $select = 'stateProvince';
         }
         if (!$select) {
             if ($name == 'country_id' || $name == 'state_province_id') {
                 if ($name == 'country_id') {
                     $stateCountryMap[$blockId]['country'] = "address_{$blockId}_{$name}";
                     $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
                 } else {
                     $stateCountryMap[$blockId]['state_province'] = "address_{$blockId}_{$name}";
                     if ($countryDefault) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
                     } else {
                         $selectOptions = array('' => ts('- select a country -'));
                     }
                 }
                 $form->addElement('select', "address[{$blockId}][{$name}]", $title, $selectOptions);
             } else {
                 if ($name == 'address_name') {
                     $name = "name";
                 }
                 $form->addElement('text', "address[{$blockId}][{$name}]", $title, $attributes);
             }
         } else {
             $form->addElement('select', "address[{$blockId}][{$name}]", $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select());
         }
     }
     require_once 'CRM/Core/BAO/Address.php';
     require_once 'CRM/Core/BAO/CustomGroup.php';
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
     $entityId = null;
     if (!empty($form->_values['address'])) {
         $entityId = $form->_values['address'][$blockId]['id'];
     }
     // Process any address custom data -
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $form, $entityId);
     if (isset($groupTree) && is_array($groupTree)) {
         // use simplified formatted groupTree
         $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form);
         // make sure custom fields are added /w element-name in the format - 'address[$blockId][custom-X]'
         foreach ($groupTree as $id => $group) {
             foreach ($group['fields'] as $fldId => $field) {
                 $groupTree[$id]['fields'][$fldId]['element_custom_name'] = $field['element_name'];
                 $groupTree[$id]['fields'][$fldId]['element_name'] = "address[{$blockId}][{$field['element_name']}]";
             }
         }
         $defaults = array();
         CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
         // For some of the custom fields like checkboxes, the defaults doesn't populate
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Address.php

示例15: setComponentDefaults

 /**
  * This function is used to setDefault componet specific profile fields.
  * 
  * @param array  $fields      profile fields.
  * @param int    $componentId componetID
  * @param string $component   component name
  * @param array  $defaults    an array of default values.
  *
  * @return void.
  */
 function setComponentDefaults(&$fields, $componentId, $component, &$defaults)
 {
     if (!$componentId || !in_array($component, array('Contribute', 'Membership', 'Event'))) {
         return;
     }
     $componentBAO = $componentSubType = null;
     switch ($component) {
         case 'Membership':
             $componentBAO = 'CRM_Member_BAO_Membership';
             $componentBAOName = 'Membership';
             $componentSubType = array('membership_type_id');
             break;
         case 'Contribute':
             $componentBAO = 'CRM_Contribute_BAO_Contribution';
             $componentBAOName = 'Contribution';
             $componentSubType = array('contribution_type_id');
             break;
         case 'Event':
             $componentBAO = 'CRM_Event_BAO_Participant';
             $componentBAOName = 'Participant';
             $componentSubType = array('role_id', 'event_id');
             break;
     }
     $values = array();
     $params = array('id' => $componentId);
     //get the component values.
     CRM_Core_DAO::commonRetrieve($componentBAO, $params, $values);
     $formattedGroupTree = array();
     foreach ($fields as $name => $field) {
         $fldName = "field[{$componentId}][{$name}]";
         if ($name == 'participant_register_date') {
             $timefldName = "field[{$componentId}][{$name}_time]";
             list($defaults[$fldName], $defaults[$timefldName]) = CRM_Utils_Date::setDateDefaults($values[$name]);
         } else {
             if (array_key_exists($name, $values)) {
                 $defaults[$fldName] = $values[$name];
             } else {
                 if ($name == 'participant_note') {
                     require_once "CRM/Core/BAO/Note.php";
                     $noteDetails = array();
                     $noteDetails = CRM_Core_BAO_Note::getNote($componentId, 'civicrm_participant');
                     $defaults[$fldName] = array_pop($noteDetails);
                 } else {
                     if (in_array($name, array('contribution_type', 'payment_instrument'))) {
                         $defaults[$fldName] = $values["{$name}_id"];
                     } else {
                         if ($customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($name, true)) {
                             if (empty($formattedGroupTree)) {
                                 //get the groupTree as per subTypes.
                                 $groupTree = array();
                                 require_once 'CRM/Core/BAO/CustomGroup.php';
                                 foreach ($componentSubType as $subType) {
                                     $subTree = CRM_Core_BAO_CustomGroup::getTree($componentBAOName, CRM_Core_DAO::$_nullObject, $componentId, 0, $values[$subType]);
                                     $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $subTree);
                                 }
                                 $formattedGroupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
                                 CRM_Core_BAO_CustomGroup::setDefaults($formattedGroupTree, $defaults);
                             }
                             //FIX ME: We need to loop defaults, but once we move to custom_1_x convention this code can be simplified.
                             foreach ($defaults as $customKey => $customValue) {
                                 if ($customFieldDetails = CRM_Core_BAO_CustomField::getKeyID($customKey, true)) {
                                     if ($name == 'custom_' . $customFieldDetails[0]) {
                                         //hack to set default for checkbox
                                         //basically this is for weired field name like field[33][custom_19]
                                         //we are converting this field name to array structure and assign value.
                                         $skipValue = false;
                                         foreach ($formattedGroupTree as $tree) {
                                             if ('CheckBox' == CRM_Utils_Array::value('html_type', $tree['fields'][$customFieldDetails[0]])) {
                                                 $skipValue = true;
                                                 $defaults['field'][$componentId][$name] = $customValue;
                                                 break;
                                             } else {
                                                 if (CRM_Utils_Array::value('data_type', $tree['fields'][$customFieldDetails[0]]) == 'Date') {
                                                     $skipValue = true;
                                                     $customValue = $tree['fields'][$customFieldDetails[0]]['element_value'];
                                                     list($defaults['field'][$componentId][$name], $defaults['field'][$componentId][$name . '_time']) = CRM_Utils_Date::setDateDefaults($customValue);
                                                 }
                                             }
                                         }
                                         if (!$skipValue) {
                                             $defaults[$fldName] = $customValue;
                                         }
                                         unset($defaults[$customKey]);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:UFGroup.php


注:本文中的CRM_Core_BAO_CustomGroup::setDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。