本文整理汇总了PHP中CRM_Core_BAO_File::deleteAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::deleteAttachment方法的具体用法?PHP CRM_Core_BAO_File::deleteAttachment怎么用?PHP CRM_Core_BAO_File::deleteAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_File
的用法示例。
在下文中一共展示了CRM_Core_BAO_File::deleteAttachment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$fileID = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$file = false;
if (is_numeric($fileID)) {
$file = civicrm_api3('File', 'getsingle', array('id' => $fileID));
}
try {
CRM_Core_BAO_File::deleteAttachment();
} catch (Exception $e) {
return null;
}
//Do the backend-service delete
if ($file && !empty($file['description'])) {
$details = json_decode($file['description']);
if ($details && property_exists($details, "source") && $details->source == "securefiles") {
//Check extension level permissions
CRM_Securefiles_Permission::checkFilePerms(CRM_Core_Action::DELETE, $fileID, $entityID);
$backendService = CRM_Securefiles_Backend::getBackendService();
if ($backendService) {
//Check backend service permissions
if ($backendService->checkPermissions(CRM_Core_Action::DELETE, $fileID, $entityID) !== false) {
$backendService->deleteFile($file['uri'], $entityID);
}
}
}
}
}