本文整理汇总了PHP中CRM_Utils_File::cleanFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File::cleanFileName方法的具体用法?PHP CRM_Utils_File::cleanFileName怎么用?PHP CRM_Utils_File::cleanFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_File
的用法示例。
在下文中一共展示了CRM_Utils_File::cleanFileName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
require_once 'CRM/Utils/Request.php';
require_once 'CRM/Core/DAO.php';
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
require_once 'CRM/Core/BAO/File.php';
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::delete($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
} else {
$wrapper = new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
}
} else {
require_once 'CRM/Utils/File.php';
CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
}
}
示例2: run
public function run()
{
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
}
} else {
CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
}
}
示例3: putFile
/**
* @param $out
*
* @return string
*/
function putFile($out)
{
$config = CRM_Core_Config::singleton();
$fileName = $config->uploadDir . 'Financial_Transactions_' . $this->_batchIds . '_' . date('YmdHis') . '.' . $this->getFileExtension();
$this->_downloadFile[] = $config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($fileName));
$buffer = fopen($fileName, 'w');
fwrite($buffer, $out);
fclose($buffer);
return $fileName;
}
示例4: putFile
function putFile($export)
{
$config = CRM_Core_Config::singleton();
$fileName = $config->uploadDir . 'Financial_Transactions_' . $this->_batchIds . '_' . date('YmdHis') . '.' . $this->getFileExtension();
$this->_downloadFile[] = $config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($fileName));
$out = fopen($fileName, 'w');
fputcsv($out, $export['headers']);
unset($export['headers']);
if (!empty($export)) {
foreach ($export as $fields) {
fputcsv($out, $fields);
}
fclose($out);
}
return $fileName;
}
示例5: createZip
/**
* @param array $files
* @param null $destination
* @param bool $overwrite
*
* @return bool
*/
public function createZip($files = array(), $destination = NULL, $overwrite = FALSE)
{
//if the zip file already exists and overwrite is false, return false
if (file_exists($destination) && !$overwrite) {
return FALSE;
}
$valid_files = array();
if (is_array($files)) {
foreach ($files as $file) {
//make sure the file exists
if (file_exists($file)) {
$validFiles[] = $file;
}
}
}
if (count($validFiles)) {
$zip = new ZipArchive();
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
return FALSE;
}
foreach ($validFiles as $file) {
$zip->addFile($file, CRM_Utils_File::cleanFileName(basename($file)));
}
$zip->close();
return file_exists($destination);
} else {
return FALSE;
}
}
示例6: getEntityFile
/**
* get all the files and associated object associated with this
* combination
*/
static function getEntityFile($entityTable, $entityID, $addDeleteArgs = false)
{
if (empty($entityTable) || !$entityID) {
$results = NULL;
return $results;
}
$config = CRM_Core_Config::singleton();
list($sql, $params) = self::sql($entityTable, $entityID, NULL);
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$results = array();
while ($dao->fetch()) {
$result['fileID'] = $dao->cfID;
$result['entityID'] = $dao->cefID;
$result['mime_type'] = $dao->mime_type;
$result['fileName'] = $dao->uri;
$result['description'] = $dao->description;
$result['cleanName'] = CRM_Utils_File::cleanFileName($dao->uri);
$result['fullPath'] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
$result['url'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$dao->cfID}&eid={$entityID}");
$result['href'] = "<a href=\"{$result['url']}\">{$result['cleanName']}</a>";
$result['tag'] = CRM_Core_BAO_EntityTag::getTag($dao->cfID, 'civicrm_file');
if ($addDeleteArgs) {
$result['deleteURLArgs'] = self::deleteURLArgs($entityTable, $entityID, $dao->cfID);
}
$results[$dao->cfID] = $result;
}
//fix tag names
$tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
foreach ($results as &$values) {
if (!empty($values['tag'])) {
$tagNames = array();
foreach ($values['tag'] as $tid) {
$tagNames[] = $tags[$tid];
}
$values['tag'] = implode(', ', $tagNames);
} else {
$values['tag'] = '';
}
}
$dao->free();
return $results;
}
示例7: list
/**
* get all the files and associated object associated with this
* combination
*/
public function &getEntityFile($entityTable, $entityID)
{
$config = CRM_Core_Config::singleton();
list($sql, $params) = self::sql($entityTable, $entityID, NULL);
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$results = array();
while ($dao->fetch()) {
$result['fileID'] = $dao->cfID;
$result['entityID'] = $dao->cefID;
$result['mime_type'] = $dao->mime_type;
$result['fileName'] = $dao->uri;
$result['cleanName'] = CRM_Utils_File::cleanFileName($dao->uri);
$result['fullPath'] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
$result['url'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$dao->cfID}&eid={$entityID}");
$result['href'] = "<a href=\"{$result['url']}\">{$result['cleanName']}</a>";
$results[$dao->cfID] = $result;
}
$dao->free();
return $results;
}
示例8: buildCustomFieldData
/**
* Build the entity-specific custom data into the group tree on a per-field basis
*
* @param object $dao
* Object representing the custom field to be populated into the groupTree.
* @param array $groupTree
* (reference) the group tree being build.
* @param string $table
* Table name.
* @param int $groupID
* Custom group ID.
* @param int $fieldID
* Custom field ID.
*/
public static function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID)
{
$column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
$idName = "{$table}_id";
$fieldName = "{$table}_{$column}";
$dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type'];
if ($dataType == 'File') {
if (isset($dao->{$fieldName})) {
$config = CRM_Core_Config::singleton();
$fileDAO = new CRM_Core_DAO_File();
$fileDAO->id = $dao->{$fieldName};
if ($fileDAO->find(TRUE)) {
$entityIDName = "{$table}_entity_id";
$customValue['id'] = $dao->{$idName};
$customValue['data'] = $fileDAO->uri;
$customValue['fid'] = $fileDAO->id;
$customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->{$entityIDName}}");
$customValue['displayURL'] = NULL;
$deleteExtra = ts('Are you sure you want to delete attached file.');
$deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"'));
$customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $fileDAO->id, 'eid' => $dao->{$entityIDName}, 'fid' => $fieldID), ts('more'), FALSE, 'file.manage.delete', 'File', $fileDAO->id);
$customValue['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs($table, $dao->{$entityIDName}, $fileDAO->id);
$customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
if ($fileDAO->mime_type == "image/jpeg" || $fileDAO->mime_type == "image/pjpeg" || $fileDAO->mime_type == "image/gif" || $fileDAO->mime_type == "image/x-png" || $fileDAO->mime_type == "image/png") {
$customValue['displayURL'] = $customValue['fileURL'];
$entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileDAO->id, 'entity_id', 'file_id');
$customValue['imageURL'] = str_replace('persist/contribute', 'custom', $config->imageUploadURL) . $fileDAO->uri;
list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, NULL, NULL);
if ($path && file_exists($path)) {
list($imageWidth, $imageHeight) = getimagesize($path);
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$customValue['imageThumbWidth'] = $imageThumbWidth;
$customValue['imageThumbHeight'] = $imageThumbHeight;
}
}
}
} else {
$customValue = array('id' => $dao->{$idName}, 'data' => '');
}
} else {
$customValue = array('id' => $dao->{$idName}, 'data' => $dao->{$fieldName});
}
if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
}
if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
} else {
$groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue;
}
}
示例9: array
//.........这里部分代码省略.........
$select = $from = $where = array();
foreach ($groupTree['info']['tables'] as $table => $fields) {
$from[] = $table;
$select[] = "{$table}.id as {$table}_id";
$select[] = "{$table}.entity_id as {$table}_entity_id";
foreach ($fields as $column => $dontCare) {
$select[] = "{$table}.{$column} as {$table}_{$column}";
}
if ($entityID) {
$where[] = "{$table}.entity_id = {$entityID}";
}
}
$groupTree['info']['select'] = $select;
$groupTree['info']['from'] = $from;
$groupTree['info']['where'] = null;
if ($entityID) {
$groupTree['info']['where'] = $where;
$select = implode(', ', $select);
// this is a hack to find a table that has some values for this
// entityID to make the below LEFT JOIN work (CRM-2518)
$firstTable = null;
foreach ($from as $table) {
$query = "\nSELECT id\nFROM {$table}\nWHERE entity_id = {$entityID}\n";
$recordExists = CRM_Core_DAO::singleValueQuery($query);
if ($recordExists) {
$firstTable = $table;
break;
}
}
if ($firstTable) {
$fromSQL = $firstTable;
foreach ($from as $table) {
if ($table != $firstTable) {
$fromSQL .= "\nLEFT JOIN {$table} USING (entity_id)";
}
}
$query = "\nSELECT {$select}\n FROM {$fromSQL}\n WHERE {$firstTable}.entity_id = {$entityID}\n";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
foreach ($groupTree as $groupID => $group) {
if ($groupID === 'info') {
continue;
}
$table = $groupTree[$groupID]['table_name'];
foreach ($group['fields'] as $fieldID => $dontCare) {
$column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
$idName = "{$table}_id";
$fieldName = "{$table}_{$column}";
$dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type'];
if ($dataType == 'File') {
if (isset($dao->{$fieldName})) {
require_once 'CRM/Core/DAO/File.php';
$config = CRM_Core_Config::singleton();
$fileDAO = new CRM_Core_DAO_File();
$fileDAO->id = $dao->{$fieldName};
if ($fileDAO->find(true)) {
$entityIDName = "{$table}_entity_id";
$customValue['id'] = $dao->{$idName};
$customValue['data'] = $fileDAO->uri;
$customValue['fid'] = $fileDAO->id;
$customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->{$entityIDName}}");
$customValue['displayURL'] = null;
$deleteExtra = ts('Are you sure you want to delete attached file.');
$deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"'));
$customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $fileDAO->id, 'eid' => $dao->{$entityIDName}, 'fid' => $fieldID));
$customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
if ($fileDAO->mime_type == "image/jpeg" || $fileDAO->mime_type == "image/pjpeg" || $fileDAO->mime_type == "image/gif" || $fileDAO->mime_type == "image/x-png" || $fileDAO->mime_type == "image/png") {
$customValue['displayURL'] = $customValue['fileURL'];
$entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileDAO->id, 'entity_id', 'id');
require_once 'CRM/Core/BAO/File.php';
list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, null, null);
list($imageWidth, $imageHeight) = getimagesize($path);
require_once 'CRM/Contact/BAO/Contact.php';
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$customValue['imageThumbWidth'] = $imageThumbWidth;
$customValue['imageThumbHeight'] = $imageThumbHeight;
}
}
} else {
$customValue = array('id' => $dao->{$idName}, 'data' => '');
}
} else {
$customValue = array('id' => $dao->{$idName}, 'data' => $dao->{$fieldName});
}
if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
}
if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
} else {
$groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue;
}
}
}
}
}
}
}
return $groupTree;
}
示例10: _civicrm_api3_attachment_format_result
/**
* Attachment result formatting helper.
*
* @param CRM_Core_DAO_File $fileDao
* Maybe "File" or "File JOIN EntityFile".
* @param CRM_Core_DAO_EntityFile $entityFileDao
* Maybe "EntityFile" or "File JOIN EntityFile".
* @param bool $returnContent
* Whether to return the full content of the file.
* @param bool $isTrusted
* Whether the current request is trusted to perform file-specific operations.
*
* @return array
*/
function _civicrm_api3_attachment_format_result($fileDao, $entityFileDao, $returnContent, $isTrusted)
{
$config = CRM_Core_Config::singleton();
$path = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $fileDao->uri;
$result = array('id' => $fileDao->id, 'name' => CRM_Utils_File::cleanFileName($fileDao->uri), 'mime_type' => $fileDao->mime_type, 'description' => $fileDao->description, 'upload_date' => is_numeric($fileDao->upload_date) ? CRM_Utils_Date::mysqlToIso($fileDao->upload_date) : $fileDao->upload_date, 'entity_table' => $entityFileDao->entity_table, 'entity_id' => $entityFileDao->entity_id);
$result['url'] = CRM_Utils_System::url('civicrm/file', 'reset=1&id=' . $result['id'] . '&eid=' . $result['entity_id'], TRUE, NULL, FALSE, TRUE);
if ($isTrusted) {
$result['path'] = $path;
}
if ($returnContent) {
$result['content'] = file_get_contents($path);
}
return $result;
}
示例11: wordmailmerge_civicrm_buildForm
function wordmailmerge_civicrm_buildForm($formName, &$form)
{
require_once 'CRM/Core/DAO/MessageTemplate.php';
require_once 'CRM/Core/BAO/File.php';
require_once 'CRM/Core/DAO.php';
if ($formName == 'CRM_Admin_Form_MessageTemplates') {
$action = $form->getVar('_action');
$template = CRM_Core_Smarty::singleton();
$form->assign('action', $action);
$templatePath = realpath(dirname(__FILE__) . "/templates");
$config = CRM_Core_Config::singleton();
if ($action == CRM_Core_Action::UPDATE) {
$msgTemplateId = $form->getVar('_defaultValues')['id'];
$sql = "SELECT * FROM veda_civicrm_wordmailmerge WHERE msg_template_id = %1";
$params = array(1 => array($msgTemplateId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) {
$fileId = $dao->file_id;
}
if (!empty($fileId)) {
$mysql = "SELECT * FROM civicrm_file WHERE id = %1";
$params = array(1 => array($fileId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($mysql, $params);
while ($dao->fetch()) {
$default['fileID'] = $dao->id;
$default['mime_type'] = $dao->mime_type;
$default['fileName'] = $dao->uri;
$default['cleanName'] = CRM_Utils_File::cleanFileName($dao->uri);
$default['fullPath'] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
$default['url'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$dao->id}&eid={$msgTemplateId}");
$default['href'] = "<a href=\"{$default['url']}\">{$default['cleanName']}</a>";
$default['tag'] = CRM_Core_BAO_EntityTag::getTag($dao->id, 'civicrm_file');
$default['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs('civicrm_msg_template', $msgTemplateId, $dao->id);
}
$defaults[$dao->id] = $default;
$form->assign('defaults', $defaults);
}
}
CRM_Core_BAO_File::buildAttachment($form, 'civicrm_msg_template', '', 1);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'reset=1'));
CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/CRM/Wordmailmerge/testfield.tpl"));
}
}
示例12: postProcess
function postProcess()
{
$values = $this->_contactIds;
$config = CRM_Core_Config::singleton();
$msg_id = $this->_submitValues['message_template'];
if (!empty($msg_id)) {
$mysql = " SELECT * FROM veda_civicrm_wordmailmerge WHERE msg_template_id = %1";
$params = array(1 => array($msg_id, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($mysql, $params);
//$dao = CRM_Core_DAO::executeQuery($mysql);
while ($dao->fetch()) {
$fileId = $dao->file_id;
}
$sql = "SELECT * FROM civicrm_file WHERE id = %1";
$params = array(1 => array($fileId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
//$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$default['fileID'] = $dao->id;
$default['mime_type'] = $dao->mime_type;
$default['fileName'] = $dao->uri;
$default['cleanName'] = CRM_Utils_File::cleanFileName($dao->uri);
$default['fullPath'] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
$default['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs('civicrm_file', $msg_id, $dao->id);
}
$defaults[$dao->id] = $default;
$this->assign('defaults', $defaults);
$noofContact = count($this->_contactIds);
require_once $config->extensionsDir . '/uk.co.vedaconsulting.module.wordmailmerge/tinybutstrong/tbs_class.php';
require_once $config->extensionsDir . '/uk.co.vedaconsulting.module.wordmailmerge/tinybutstrong-opentbs/tbs_plugin_opentbs.php';
$TBS = new clsTinyButStrong();
// new instance of TBS
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
// load the OpenTBS plugin
$template = $default['fullPath'];
// contactrows to check for duplicate address
$contactrows = array();
foreach ($values as $key => $value) {
$SelectedcontactID = $values[$key];
// get the details for all selected contacts
list($contactDetails) = CRM_Utils_Token::getTokenDetails(array($SelectedcontactID), $this->_returnProperties, NULL, NULL, FALSE, $this->_allTokens);
// populate contactrows array to check dupliacte address
$contactrows[$SelectedcontactID] = $contactDetails[$SelectedcontactID];
}
// if merge_letter_for_same_address selected check for duplicate address
if (isset($this->_submitValues['merge_letter_for_same_address']) && $this->_submitValues['merge_letter_for_same_address']) {
CRM_Core_BAO_Address::mergeSameAddress($contactrows);
}
foreach ($values as $key => $value) {
if ($key < $noofContact) {
$selectedCID = $values[$key];
$contactFormatted = array();
// if contact_id found in filtered contactrows array get contact details from contactrows
if (array_key_exists($selectedCID, $contactrows)) {
$contactFormatted[$selectedCID] = $contactrows[$selectedCID];
$membershipFormatted = array();
if ($this->_searchFrom == 'member' && isset($contactFormatted[$selectedCID]['membership_id'])) {
$membershipFormatted = CRM_Utils_Token::getMembershipTokenDetails($contactFormatted[$selectedCID]['membership_id']);
}
foreach ($this->_tokenMerge as $atKey => $atValue) {
// Replace hook tokens
$explodedTokenName = explode('.', $atValue['token_name']);
// this is fixed by assigning 'address_block' token into 'contact' token array // gopi@vedaconsulting.co.uk
//need to do proper fix seems token named as contact.address_block
// $atValue['token_name'] = ($atValue['token_name'] == 'address_block') ? 'contact.'.$atValue['token_name'] : $atValue['token_name'];
if (array_key_exists($atValue['token_name'], $contactFormatted[$selectedCID])) {
if (!empty($explodedTokenName[1]) && $explodedTokenName[0] != 'contact') {
$vars[$key][$explodedTokenName[0]][$explodedTokenName[1]] = $contactFormatted[$selectedCID][$atValue['token_name']];
} else {
$vars[$key][$atValue['token_name']] = $contactFormatted[$selectedCID][$atValue['token_name']];
}
} else {
if ($explodedTokenName[0] == 'membership') {
$explodedTokenName[1] = $explodedTokenName[1] == 'membership_id' ? 'id' : $explodedTokenName[1];
$vars[$key][$explodedTokenName[0]][$explodedTokenName[1]] = CRM_Utils_Token::getMembershipTokenReplacement($explodedTokenName[1], $membershipFormatted[$contactFormatted[$selectedCID]['membership_id']]);
} else {
$vars[$key][$atValue['token_name']] = CRM_Utils_Token::getContactTokenReplacement($atValue['token_name'], $contactFormatted[$selectedCID], FALSE, FALSE);
}
}
//need to do proper fix, token_name.date seems not returning null value if not found
if ($explodedTokenName[0] == 'token_name' && !is_array($vars[$key]['token_name'])) {
$vars[$key][$atValue['token_name']] = '';
}
}
//to skip error, if by chance using membership token in 'find contact' search
if ($this->_searchFrom != 'member') {
foreach (CRM_Core_SelectValues::membershipTokens() as $token => $label) {
$token = str_replace(array('{', '}'), "", $token);
$tokenNames = explode('.', $token);
$vars[$key]['membership'][$tokenNames[1]] = $label;
}
}
foreach ($vars[$key] as $varKey => $varValue) {
$explodeValues = explode('.', $varKey);
if (isset($explodeValues[1]) && !empty($explodeValues[1])) {
$vars[$key][$explodeValues[0]][$explodeValues[1]] = $vars[$key][$varKey];
unset($vars[$key][$varKey]);
}
}
// blank lines removed while creating the address_block - gopi@vedaconsulting.co.uk
//.........这里部分代码省略.........