本文整理汇总了PHP中CRM_Core_BAO_File::deleteFileReferences方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::deleteFileReferences方法的具体用法?PHP CRM_Core_BAO_File::deleteFileReferences怎么用?PHP CRM_Core_BAO_File::deleteFileReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_File
的用法示例。
在下文中一共展示了CRM_Core_BAO_File::deleteFileReferences方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: moveAllBelongings
//.........这里部分代码省略.........
foreach ($mergeValueArray as $k => $v) {
if ($v != '') {
$mergeValue[] = $v;
}
}
$submitted[$key] = $mergeValue;
}
}
break;
default:
break;
}
}
}
// **** Do file custom fields related migrations
// FIXME: move this someplace else (one of the BAOs) after discussing
// where to, and whether CRM_Core_BAO_File::deleteFileReferences() shouldn't actually,
// like, delete a file...
if (!isset($customFiles)) {
$customFiles = array();
}
foreach ($customFiles as $customId) {
list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($customId);
// get the contact_id -> file_id mapping
$fileIds = array();
$sql = "SELECT entity_id, {$columnName} AS file_id FROM {$tableName} WHERE entity_id IN ({$mainId}, {$otherId})";
$dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
while ($dao->fetch()) {
$fileIds[$dao->entity_id] = $dao->file_id;
}
$dao->free();
// delete the main contact's file
if (!empty($fileIds[$mainId])) {
CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
}
// move the other contact's file to main contact
//NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
$sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
} else {
$sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
}
CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
if (CRM_Core_DAO::singleValueQuery("\n SELECT id\n FROM civicrm_entity_file\n WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")) {
$sql = "\n UPDATE civicrm_entity_file\n SET entity_id = {$mainId}\n WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}";
} else {
$sql = "\n INSERT INTO civicrm_entity_file ( entity_table, entity_id, file_id )\n VALUES ( '{$tableName}', {$mainId}, {$fileIds[$otherId]} )";
}
CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
}
// move view only custom fields CRM-5362
$viewOnlyCustomFields = array();
foreach ($submitted as $key => $value) {
$fid = (int) substr($key, 7);
if (array_key_exists($fid, $cFields) && !empty($cFields[$fid]['attributes']['is_view'])) {
$viewOnlyCustomFields[$key] = $value;
}
}
// special case to set values for view only, CRM-5362
if (!empty($viewOnlyCustomFields)) {
$viewOnlyCustomFields['entityID'] = $mainId;
CRM_Core_BAO_CustomValueTable::setValues($viewOnlyCustomFields);
}
// **** Delete other contact & update prev-next caching
$otherParams = array('contact_id' => $otherId, 'id' => $otherId, 'version' => 3);
if (CRM_Core_Permission::check('merge duplicate contacts') && CRM_Core_Permission::check('delete contacts')) {
示例3: moveAllBelongings
//.........这里部分代码省略.........
foreach ($mergeValueArray as $k => $v) {
if ($v != '') {
$mergeValue[] = $v;
}
}
$submitted[$key] = $mergeValue;
}
}
break;
default:
break;
}
}
}
// **** Do file custom fields related migrations
// FIXME: move this someplace else (one of the BAOs) after discussing
// where to, and whether CRM_Core_BAO_File::deleteFileReferences() shouldn't actually,
// like, delete a file...
if (!isset($customFiles)) {
$customFiles = array();
}
foreach ($customFiles as $customId) {
list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($customId);
// get the contact_id -> file_id mapping
$fileIds = array();
$sql = "SELECT entity_id, {$columnName} AS file_id FROM {$tableName} WHERE entity_id IN ({$mainId}, {$otherId})";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$fileIds[$dao->entity_id] = $dao->file_id;
}
$dao->free();
// delete the main contact's file
if (!empty($fileIds[$mainId])) {
CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
}
// move the other contact's file to main contact
//NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
$sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
} else {
$sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
}
CRM_Core_DAO::executeQuery($sql);
if (CRM_Core_DAO::singleValueQuery("\n SELECT id\n FROM civicrm_entity_file\n WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")) {
$sql = "\n UPDATE civicrm_entity_file\n SET entity_id = {$mainId}\n WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}";
} else {
$sql = "\n INSERT INTO civicrm_entity_file ( entity_table, entity_id, file_id )\n VALUES ( '{$tableName}', {$mainId}, {$fileIds[$otherId]} )";
}
CRM_Core_DAO::executeQuery($sql);
}
// move view only custom fields CRM-5362
$viewOnlyCustomFields = array();
foreach ($submitted as $key => $value) {
$fid = (int) substr($key, 7);
if (array_key_exists($fid, $cFields) && !empty($cFields[$fid]['attributes']['is_view'])) {
$viewOnlyCustomFields[$key] = $value;
}
}
// special case to set values for view only, CRM-5362
if (!empty($viewOnlyCustomFields)) {
$viewOnlyCustomFields['entityID'] = $mainId;
CRM_Core_BAO_CustomValueTable::setValues($viewOnlyCustomFields);
}
if (!$checkPermissions || CRM_Core_Permission::check('merge duplicate contacts') && CRM_Core_Permission::check('delete contacts')) {
// if ext id is submitted then set it null for contact to be deleted
if (!empty($submitted['external_identifier'])) {