Exemplo n.º 1
0
 public function delete()
 {
     if ($this->file_id && module_file::can_i('delete', 'Files')) {
         $file_data = $this->get_data();
         if ($this->can_i_access()) {
             // delete any sub files of buckets first.
             // todo: recurisive testing.
             if ($file_data['bucket']) {
                 $sub_files = module_file::get_files(array('bucket_parent_file_id' => $file_data['file_id']));
                 foreach ($sub_files as $sub_file) {
                     if ($sub_file['file_id'] && $sub_file['bucket_parent_file_id'] == $this->file_id) {
                         $sub_file_ucm = new ucm_file($sub_file['file_id']);
                         $sub_file_ucm->delete();
                     }
                 }
             }
             // delete the physical file.
             if ($file_data['file_path'] && is_file($file_data['file_path'])) {
                 unlink($file_data['file_path']);
             }
             // delete the db entry.
             delete_from_db('file', 'file_id', $this->file_id);
             // delete any comments.
             delete_from_db('file_comment', 'file_id', $this->file_id);
             // delete any staff rel.
             delete_from_db('file_user_rel', 'file_id', $this->file_id);
             // delete any notifications
             delete_from_db('file_notification', 'file_id', $this->file_id);
         }
     }
 }
Exemplo n.º 2
0
/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!$file_safe) {
    die('wrong page');
}
if (!module_file::can_i('edit', 'File Approval')) {
    die('no perms');
}
$ucm_file = new ucm_file($file_id);
$ucm_file->check_page_permissions();
$file = $ucm_file->get_data();
$file_id = (int) $file['file_id'];
// sanatisation/permission check
module_template::init_template('file_approval_email', 'Dear {CUSTOMER_NAME},<br>
<br>
This email is regarding your file <strong>{FILE_NAME}</strong>{if:JOB_LINK} related to the job <a href="{JOB_LINK}">{JOB_NAME}</a>{endif:JOB_LINK}.<br><br>
Please view this file and comments online by <a href="{FILE_URL}">clicking here</a>.<br><br>
Thank you,<br><br>
{FROM_NAME}
', 'File for Approval: {FILE_NAME}', array('CUSTOMER_NAME' => 'Customers Name', 'FILE_NAME' => 'File Name', 'JOB_NAME' => 'Job Name', 'FROM_NAME' => 'Your name', 'FILE_URL' => 'Link to file for customer'));
// template for sending emails.
// are we sending the paid one? or the dueone.
//$template_name = 'file_email';
$template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'file_approval_email';