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


PHP CRM_Core_BAO_CustomField::getFileURL方法代码示例

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


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

示例1: setDefaultsValues

 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultsValues()
 {
     $this->_defaults = array();
     if ($this->_multiRecordProfile && $this->_multiRecord == CRM_Core_Action::DELETE) {
         return;
     }
     if ($this->_mode != self::MODE_SEARCH) {
         // set default values for country / state to start with
         CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $this->_defaults);
     }
     if ($this->_id && !$this->_multiRecordProfile) {
         if ($this->_isContactActivityProfile) {
             $contactFields = $activityFields = array();
             foreach ($this->_fields as $fieldName => $field) {
                 if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
                     $activityFields[$fieldName] = $field;
                 } else {
                     $contactFields[$fieldName] = $field;
                 }
             }
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $contactFields, $this->_defaults, TRUE);
             if ($this->_activityId) {
                 CRM_Core_BAO_UFGroup::setComponentDefaults($activityFields, $this->_activityId, 'Activity', $this->_defaults, TRUE);
             }
         } else {
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, TRUE);
         }
     }
     //set custom field defaults
     if ($this->_multiRecordProfile) {
         foreach ($this->_multiRecordFields as $key => $field) {
             $fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key);
         }
         $defaultValues = array();
         if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) {
             $defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE);
             if ($this->_recordExists == TRUE) {
                 $defaultValues = $defaultValues[$this->_recordId];
             } else {
                 $defaultValues = NULL;
             }
         }
         if (!empty($defaultValues)) {
             foreach ($defaultValues as $key => $value) {
                 $name = "custom_{$key}";
                 $htmlType = $this->_multiRecordFields[$name]['html_type'];
                 if ($htmlType != 'File') {
                     if (isset($value)) {
                         CRM_Core_BAO_CustomField::setProfileDefaults($key, $name, $this->_defaults, $this->_id, $this->_mode, $value);
                     } else {
                         $this->_defaults[$name] = "";
                     }
                 }
                 if ($htmlType == 'File') {
                     $entityId = $this->_id;
                     if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
                         $entityId = $this->_activityId;
                     }
                     $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $key);
                     if ($url) {
                         $customFiles[$name]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                         $deleteExtra = ts("Are you sure you want to delete attached file?");
                         $fileId = $url['file_id'];
                         $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$key}&action=delete");
                         $text = ts("Delete Attached File");
                         $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                         // also delete the required rule that we've set on the form element
                         $this->removeFileRequiredRules($name);
                     }
                 }
             }
         }
     } else {
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $htmlType = $field['html_type'];
                 if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && CRM_Utils_Array::value('field_type', $field) != 'Activity') {
                     CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
                 }
                 if ($htmlType == 'File') {
                     $entityId = $this->_id;
                     if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
                         $entityId = $this->_activityId;
                     }
                     $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
                     if ($url) {
                         $customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                         $deleteExtra = ts("Are you sure you want to delete attached file?");
                         $fileId = $url['file_id'];
                         $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
                         $text = ts("Delete Attached File");
                         $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                         // also delete the required rule that we've set on the form element
//.........这里部分代码省略.........
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Form.php

示例2: getValues


//.........这里部分代码省略.........
                 $params[$index] = $details->{$name};
             } elseif ($name == 'contact_sub_type') {
                 $contactSubTypeNames = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name});
                 if (!empty($contactSubTypeNames)) {
                     $contactSubTypeLabels = array();
                     // get all contact subtypes
                     $allContactSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
                     // build contact subtype labels array
                     foreach ($contactSubTypeNames as $cstName) {
                         if ($cstName) {
                             $contactSubTypeLabels[] = $allContactSubTypes[$cstName]['label'];
                         }
                     }
                     $values[$index] = implode(',', $contactSubTypeLabels);
                 }
                 $params[$index] = $details->{$name};
             } else {
                 if (substr($name, 0, 7) === 'do_not_' || substr($name, 0, 3) === 'is_') {
                     if ($details->{$name}) {
                         $values[$index] = '[ x ]';
                     }
                 } else {
                     if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                         $htmlType = $field['html_type'];
                         // field_type is only set when we are retrieving profile values
                         // when sending email, we call the same function to get custom field
                         // values etc, i.e. emulating a profile
                         $fieldType = CRM_Utils_Array::value('field_type', $field);
                         if ($htmlType == 'File') {
                             $entityId = $cid;
                             if (!$cid && $fieldType == 'Activity' && !empty($componentWhere[0][2])) {
                                 $entityId = $componentWhere[0][2];
                             }
                             $fileURL = CRM_Core_BAO_CustomField::getFileURL($entityId, $cfID, NULL, $absolute, $additionalWhereClause);
                             $params[$index] = $values[$index] = $fileURL['file_url'];
                         } else {
                             $customVal = NULL;
                             if (isset($dao) && property_exists($dao, 'data_type') && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
                                 $customVal = (int) $details->{$name};
                             } elseif (isset($dao) && property_exists($dao, 'data_type') && $dao->data_type == 'Float') {
                                 $customVal = (double) $details->{$name};
                             } elseif (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) {
                                 $customVal = $details->{$name};
                             }
                             //CRM-4582
                             if (CRM_Utils_System::isNull($customVal)) {
                                 continue;
                             }
                             $params[$index] = $customVal;
                             $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
                             if ($field['data_type'] == 'ContactReference') {
                                 $params[$index] = $values[$index];
                             }
                             if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) {
                                 $customFieldName = "{$name}_from";
                             }
                         }
                     } elseif ($name == 'image_URL') {
                         list($width, $height) = getimagesize(CRM_Utils_String::unstupifyUrl($details->{$name}));
                         list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height);
                         $image_URL = '<img src="' . $details->{$name} . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . '  />';
                         $values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->{$name}}\", {$width}, {$height});'>{$image_URL}</a>";
                     } elseif (in_array($name, array('birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) {
                         $values[$index] = CRM_Utils_Date::customFormat($details->{$name});
                         $params[$index] = CRM_Utils_Date::isoToMysql($details->{$name});
                     } else {
开发者ID:rollox,项目名称:civicrm-core,代码行数:67,代码来源:UFGroup.php

示例3: getValues


//.........这里部分代码省略.........
                                     if (array_key_exists($name, $studentFields)) {
                                         require_once 'CRM/Core/OptionGroup.php';
                                         $paramsNew = array($name => $details->{$name});
                                         if ($name == 'test_tutoring') {
                                             $names = array($name => array('newName' => $index, 'groupName' => 'test'));
                                         } else {
                                             if (substr($name, 0, 4) == 'cmr_') {
                                                 //for  readers group
                                                 $names = array($name => array('newName' => $index, 'groupName' => substr($name, 0, -3)));
                                             } else {
                                                 $names = array($name => array('newName' => $index, 'groupName' => $name));
                                             }
                                         }
                                         CRM_Core_OptionGroup::lookupValues($paramsNew, $names, false);
                                         $values[$index] = $paramsNew[$index];
                                         $params[$index] = $paramsNew[$name];
                                     } else {
                                         $processed = false;
                                         if (CRM_Core_Permission::access('Quest', false)) {
                                             require_once 'CRM/Quest/BAO/Student.php';
                                             $processed = CRM_Quest_BAO_Student::buildStudentForm($this, $field);
                                         }
                                         if (!$processed) {
                                             if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') {
                                                 if ($details->{$name}) {
                                                     $values[$index] = '[ x ]';
                                                 }
                                             } else {
                                                 require_once 'CRM/Core/BAO/CustomField.php';
                                                 if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                                                     $htmlType = $field['html_type'];
                                                     $dataType = $field['data_type'];
                                                     if ($htmlType == 'File') {
                                                         $fileURL = CRM_Core_BAO_CustomField::getFileURL($cid, $cfID);
                                                         $params[$index] = $values[$index] = $fileURL['file_url'];
                                                     } else {
                                                         $customVal = null;
                                                         if (isset($dao) && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
                                                             $customVal = (int) $details->{$name};
                                                         } else {
                                                             if (isset($dao) && $dao->data_type == 'Float') {
                                                                 $customVal = (double) $details->{$name};
                                                             } else {
                                                                 if (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) {
                                                                     $customVal = $details->{$name};
                                                                 }
                                                             }
                                                         }
                                                         //CRM-4582
                                                         if (CRM_Utils_System::isNull($customVal)) {
                                                             continue;
                                                         }
                                                         $params[$index] = $customVal;
                                                         $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
                                                         if ($htmlType == 'Autocomplete-Select') {
                                                             $params[$index] = $values[$index];
                                                         }
                                                         if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) {
                                                             $customFieldName = "{$name}_from";
                                                         }
                                                     }
                                                 } else {
                                                     if ($name == 'home_URL' && !empty($details->{$name})) {
                                                         $url = CRM_Utils_System::fixURL($details->{$name});
                                                         $values[$index] = "<a href=\"{$url}\">{$details->{$name}}</a>";
                                                     } else {
开发者ID:bhirsch,项目名称:voipdev,代码行数:67,代码来源:UFGroup.php

示例4: setDefaultsValues

 /** 
  * 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 void 
  */
 function setDefaultsValues()
 {
     $this->_defaults = array();
     if ($this->_id) {
         CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, true);
     }
     //set custom field defaults
     require_once "CRM/Core/BAO/CustomField.php";
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
             $htmlType = $field['html_type'];
             if (!CRM_Utils_Array::value($name, $this->_defaults) || $htmlType == 'File') {
                 CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
             }
             if ($htmlType == 'File') {
                 $url = CRM_Core_BAO_CustomField::getFileURL($this->_id, $customFieldID);
                 if ($url) {
                     $customFiles[$field['name']]['displayURL'] = "Attached File : {$url['file_url']}";
                     $deleteExtra = "Are you sure you want to delete attached file ?";
                     $fileId = $url['file_id'];
                     $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$this->_id}&fid={$customFieldID}&action=delete");
                     $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">Delete Attached File</a>";
                 }
             }
         }
     }
     if (isset($customFiles)) {
         $this->assign('customFiles', $customFiles);
     }
     $this->setDefaults($this->_defaults);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:38,代码来源:Form.php

示例5: setDefaultValues

 function setDefaultValues()
 {
     $defaults = array();
     $profileFields = CRM_Core_BAO_UFGroup::getFields($this->_profileID);
     $contactID = $this->_contactID;
     $entityCaseID = NULL;
     $cases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($contactID, FALSE, 'Application');
     $entityCaseID = end($cases);
     if ($contactID) {
         $options = array();
         $fields = array();
         foreach ($profileFields as $name => $field) {
             if (substr($name, 0, 7) == 'custom_') {
                 $id = substr($name, 7);
                 if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                     if ($entityCaseID) {
                         CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, $entityCaseID, CRM_Profile_Form::MODE_REGISTER);
                     }
                     if (!isset($defaults[$name])) {
                         CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, $contactID, CRM_Profile_Form::MODE_REGISTER);
                     }
                     $htmlType = $field['html_type'];
                     if ($htmlType == 'File') {
                         $this->assign('customname', $name);
                         $entityId = $entityCaseID;
                         $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
                         if ($url) {
                             $customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                             $deleteExtra = ts("Are you sure you want to delete attached file?");
                             $fileId = $url['file_id'];
                             $session = CRM_Core_Session::singleton();
                             $session->pushUserContext(CRM_Utils_System::url('civicrm/vacancy/apply', "reset=1&id={$this->_id}&cid={$contactID}"));
                             $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
                             $text = ts("Delete Attached File");
                             $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                             $this->assign('customFiles', $customFiles);
                         }
                     }
                 }
             } else {
                 $fields[$name] = 1;
             }
         }
         CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $defaults);
     }
     return $defaults;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:47,代码来源:Application.php

示例6: setDefaultsValues

 /**
  * 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 void
  */
 function setDefaultsValues()
 {
     $this->_defaults = array();
     if ($this->_id) {
         if ($this->_isContactActivityProfile) {
             $contactFields = $activityFields = array();
             foreach ($this->_fields as $fieldName => $field) {
                 if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
                     $activityFields[$fieldName] = $field;
                 } else {
                     $contactFields[$fieldName] = $field;
                 }
             }
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $contactFields, $this->_defaults, TRUE);
             if ($this->_activityId) {
                 CRM_Core_BAO_UFGroup::setComponentDefaults($activityFields, $this->_activityId, 'Activity', $this->_defaults, TRUE);
             }
         } else {
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, TRUE);
         }
     }
     //set custom field defaults
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
             $htmlType = $field['html_type'];
             if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && CRM_Utils_Array::value('field_type', $field) != 'Activity') {
                 CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
             }
             if ($htmlType == 'File') {
                 $entityId = $this->_id;
                 if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
                     $entityId = $this->_activityId;
                 }
                 $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
                 if ($url) {
                     $customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                     $deleteExtra = ts("Are you sure you want to delete attached file?");
                     $fileId = $url['file_id'];
                     $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
                     $text = ts("Delete Attached File");
                     $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                     // also delete the required rule that we've set on the form element
                     $this->removeFileRequiredRules($field['name']);
                 }
             }
         }
     }
     if (isset($customFiles)) {
         $this->assign('customFiles', $customFiles);
     }
     if (CRM_Utils_Array::value('image_URL', $this->_defaults)) {
         list($imageWidth, $imageHeight) = getimagesize($this->_defaults['image_URL']);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $this->_defaults['image_URL']);
     }
     if (array_key_exists('contact_sub_type', $this->_defaults) && !empty($this->_defaults['contact_sub_type'])) {
         $this->_defaults['contact_sub_type'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_defaults['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR));
     }
     $this->setDefaults($this->_defaults);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:72,代码来源:Form.php


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