function fileDelete() { // delete file $postParams = $_POST; $fileId = $postParams['fileID']; CRM_Core_BAO_File::deleteEntityFile($postParams['entityTable'], $postParams['entityID'], $fileTypeID = NULL, $fileId); CRM_Utils_System::civiExit(); }
/** * function to delete a file attachment from an entity table / entity ID * * @static * @access public */ static function deleteAttachment() { $params = array(); $params['entityTable'] = CRM_Utils_Request::retrieve('entityTable', 'String', CRM_Core_DAO::$_nullObject, TRUE); $params['entityID'] = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $params['fileID'] = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $signature = CRM_Utils_Request::retrieve('_sgn', 'String', CRM_Core_DAO::$_nullObject, TRUE); $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$_signableFields); if (!$signer->validate($signature, $params)) { CRM_Core_Error::fatal('Request signature is invalid'); } CRM_Core_BAO_File::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']); }
/** * Delete Mails and all its associated records. * * @param int $id * Id of the mail to delete. * * @return void */ public static function del($id) { if (empty($id)) { CRM_Core_Error::fatal(); } CRM_Utils_Hook::pre('delete', 'Mailing', $id, CRM_Core_DAO::$_nullArray); // delete all file attachments CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing', $id); $dao = new CRM_Mailing_DAO_Mailing(); $dao->id = $id; $dao->delete(); CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success'); CRM_Utils_Hook::post('delete', 'Mailing', $id, $dao); }
static function formatAttachment(&$formValues, &$params, $entityTable, $entityID = NULL) { // delete current attachments if applicable if ($entityID && CRM_Utils_Array::value('is_delete_attachment', $formValues)) { CRM_Core_BAO_File::deleteEntityFile($entityTable, $entityID); } $config = CRM_Core_Config::singleton(); $numAttachments = $config->maxAttachments; $now = date('Ymdhis'); // setup all attachments for ($i = 1; $i <= $numAttachments; $i++) { $attachName = "attachFile_{$i}"; if (isset($formValues[$attachName]) && !empty($formValues[$attachName])) { // we dont care if the file is empty or not // CRM-7448 $fileParams = array('uri' => $formValues[$attachName]['name'], 'type' => $formValues[$attachName]['type'], 'location' => $formValues[$attachName]['name'], 'upload_date' => $now); $params[$attachName] = $fileParams; } } }
/** * Delete Mails and all its associated records * * @param int $id id of the mail to delete * * @return void * @access public * @static */ public static function del($id) { if (empty($id)) { CRM_Core_Error::fatal(); } // delete all file attachments CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing', $id); $dao = new CRM_Mailing_DAO_Mailing(); $dao->id = $id; $dao->delete(); CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.')); }
static function formatAttachment(&$formValues, &$params, $entityTable, $entityID = null) { // delete current attachments if applicable if ($entityID && CRM_Utils_Array::value('is_delete_attachment', $formValues)) { CRM_Core_BAO_File::deleteEntityFile($entityTable, $entityID); } $config =& CRM_Core_Config::singleton(); $numAttachments = $config->maxAttachments; // setup all attachments for ($i = 1; $i <= $numAttachments; $i++) { $attachName = "attachFile_{$i}"; if (isset($formValues[$attachName]) && !empty($formValues[$attachName])) { // ensure file is not empty $contents = file_get_contents($formValues[$attachName]['name']); if ($contents) { $fileParams = array('uri' => $formValues[$attachName]['name'], 'type' => $formValues[$attachName]['type'], 'upload_date' => date('Ymdhis'), 'location' => $formValues[$attachName]['name']); $params[$attachName] = $fileParams; } } } }
/** * Delete an existing File. * * @param array $params * Array per getfields metadata. * * @return array * API Result Array */ function civicrm_api3_file_delete($params) { civicrm_api3_verify_mandatory($params, NULL, array('id')); if (CRM_Core_BAO_File::deleteEntityFile('*', $params['id'])) { return civicrm_api3_create_success(); } else { throw new API_Exception('Error while deleting a file.'); } }
public static function fileDelete() { $postParams = $_GET; $fileId = $postParams['fileID']; $result = 0; CRM_Core_BAO_File::deleteEntityFile($postParams['entityTable'], $postParams['entityID'], $fileTypeID = NULL, $fileId); list($path) = CRM_Core_BAO_File::path($fileId, $postParams['entityID'], NULL, NULL); if ($path === null) { $result = 1; } echo html_entity_decode(stripcslashes(json_encode(array('values' => array(array('result' => $result))), true))); CRM_Utils_System::civiExit(); }