本文整理汇总了PHP中CRM_Core_BAO_File::filePostProcess方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::filePostProcess方法的具体用法?PHP CRM_Core_BAO_File::filePostProcess怎么用?PHP CRM_Core_BAO_File::filePostProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_File
的用法示例。
在下文中一共展示了CRM_Core_BAO_File::filePostProcess方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* PostProcess function.
*
* @param array $groupTree
* @param array $params
* @param bool $skipFile
*/
public static function postProcess(&$groupTree, &$params, $skipFile = FALSE)
{
// Get the Custom form values and groupTree
// first reset all checkbox and radio data
foreach ($groupTree as $groupID => $group) {
if ($groupID === 'info') {
continue;
}
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
//added Multi-Select option in the below if-statement
if ($field['html_type'] == 'CheckBox' || $field['html_type'] == 'Radio' || $field['html_type'] == 'AdvMulti-Select' || $field['html_type'] == 'Multi-Select') {
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = 'NULL';
}
$v = NULL;
foreach ($params as $key => $val) {
if (preg_match('/^custom_(\\d+)_?(-?\\d+)?$/', $key, $match) && $match[1] == $field['id']) {
$v = $val;
}
}
if (!isset($groupTree[$groupID]['fields'][$fieldId]['customValue'])) {
// field exists in db so populate value from "form".
$groupTree[$groupID]['fields'][$fieldId]['customValue'] = array();
}
switch ($groupTree[$groupID]['fields'][$fieldId]['html_type']) {
//added for CheckBox
case 'CheckBox':
if (!empty($v)) {
$customValue = array_keys($v);
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue) . CRM_Core_DAO::VALUE_SEPARATOR;
} else {
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = NULL;
}
break;
//added for Advanced Multi-Select
//added for Advanced Multi-Select
case 'AdvMulti-Select':
//added for Multi-Select
//added for Multi-Select
case 'Multi-Select':
if (!empty($v)) {
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $v) . CRM_Core_DAO::VALUE_SEPARATOR;
} else {
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = NULL;
}
break;
case 'Select Date':
$date = CRM_Utils_Date::processDate($v);
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = $date;
break;
case 'File':
if ($skipFile) {
continue;
}
//store the file in d/b
$entityId = explode('=', $groupTree['info']['where'][0]);
$fileParams = array('upload_date' => date('Ymdhis'));
if ($groupTree[$groupID]['fields'][$fieldId]['customValue']['fid']) {
$fileParams['id'] = $groupTree[$groupID]['fields'][$fieldId]['customValue']['fid'];
}
if (!empty($v)) {
$fileParams['uri'] = $v['name'];
$fileParams['mime_type'] = $v['type'];
CRM_Core_BAO_File::filePostProcess($v['name'], $groupTree[$groupID]['fields'][$fieldId]['customValue']['fid'], $groupTree[$groupID]['table_name'], trim($entityId[1]), FALSE, TRUE, $fileParams, 'custom_' . $fieldId, $v['type']);
}
$defaults = array();
$paramsFile = array('entity_table' => $groupTree[$groupID]['table_name'], 'entity_id' => $entityId[1]);
CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_EntityFile', $paramsFile, $defaults);
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = $defaults['file_id'];
break;
default:
$groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = $v;
break;
}
}
}
}
示例2: crm_add_file_by_entity
/**
* Attach a file to a given entity
*
* @param string $name filename
* @param object $entityID id of the supported entity.
* @param string $entity_table
*
* @access public
*/
function crm_add_file_by_entity($name, $entityID, $entityTable = 'civicrm_contact', $params)
{
require_once 'CRM/Core/BAO/File.php';
CRM_Core_BAO_File::filePostProcess($name, null, $entityTable, $entityID, null, false, $params);
}
示例3: add
/**
* Add the Message Templates.
*
* @param array $params
* Reference array contains the values submitted by the form.
*
*
* @return object
*/
public static function add(&$params)
{
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'MessageTemplate', CRM_Utils_Array::value('id', $params), $params);
if (!empty($params['file_id']) && is_array($params['file_id']) && count($params['file_id'])) {
$fileParams = $params['file_id'];
unset($params['file_id']);
}
$messageTemplates = new CRM_Core_DAO_MessageTemplate();
$messageTemplates->copyValues($params);
$messageTemplates->save();
if (!empty($fileParams)) {
$params['file_id'] = $fileParams;
CRM_Core_BAO_File::filePostProcess($params['file_id']['location'], NULL, 'civicrm_msg_template', $messageTemplates->id, NULL, TRUE, $params['file_id'], 'file_id', $params['file_id']['type']);
}
CRM_Utils_Hook::post($hook, 'MessageTemplate', $messageTemplates->id, $messageTemplates);
return $messageTemplates;
}
示例4: civicrm_file_by_entity_add
/**
* Attach a file to a given entity
*
* @param string $name filename
* @param object $entityID id of the supported entity.
* @param string $entity_table
*
* @access public
*/
function civicrm_file_by_entity_add($name, $entityID, $entityTable = 'civicrm_contact', $params)
{
require_once 'CRM/Core/BAO/File.php';
CRM_Core_BAO_File::filePostProcess($name, NULL, $entityTable, $entityID, NULL, FALSE, $params);
}