/** * Function to remove the file from the server * @param string $name */ public static function remove_thumb($name) { if ($name != '') { $avatar_path = $GLOBALS['AVATAR_PATH']; $do_files_and_attachment = new CRMFilesAndAttachments(); $do_files_and_attachment->get_file_details_by_name($name); $file_extension = ''; if ($do_files_and_attachment->getNumRows() > 0) { $do_files_and_attachment->next(); $file_extension = $do_files_and_attachment->file_extension; $do_files_and_attachment->delete_record($do_files_and_attachment->idfile_uploads); $thumb_large_name = 'thl_' . $name . '.' . $file_extension; $thumb_medium_name = 'thm_' . $name . '.' . $file_extension; $thumb_small_name = 'ths_' . $name . '.' . $file_extension; if (is_file($avatar_path . '/' . $thumb_large_name)) { unlink($avatar_path . '/' . $thumb_large_name); } if (is_file($avatar_path . '/' . $thumb_medium_name)) { unlink($avatar_path . '/' . $thumb_medium_name); } if (is_file($avatar_path . '/' . $thumb_small_name)) { unlink($avatar_path . '/' . $thumb_small_name); } } } }
/** * event function to delete the notes * @param object $evctl * first it will delete the note and then check if there are some document attached with it. * if documents are attached then delete from the database and then from physical location * @see class/core/CRMFilesAndAttachments.class.php * @see class/fields/fieldtypes/FieldType21.class.php */ function eventAjaxDeleteNotes(\EventControler $evctl) { if ((int) $evctl->idnotes > 0) { $this->getId($evctl->idnotes); if ($_SESSION["do_cpaneluser"]->idcpanel_user === $this->idcpanel_user) { $qry = "\n\t\t\t\tdelete from `" . $this->getTable() . "`\n\t\t\t\twhere \n\t\t\t\t`idnotes` = ?\n\t\t\t\t"; $this->query($qry, array((int) $evctl->idnotes)); $do_files_and_attachment = new \CRMFilesAndAttachments(); $do_files_and_attachment->get_uploaded_files(8, (int) $evctl->idnotes); if ($do_files_and_attachment->getNumRows() > 0) { while ($do_files_and_attachment->next()) { $file_name = $do_files_and_attachment->file_name; $file_extension = $do_files_and_attachment->file_extension; $do_files_and_attachment->delete_record($do_files_and_attachment->idfile_uploads); \FieldType21::remove_file($file_name, $file_extension); } } echo '1'; } else { echo '0'; } } }