Esempio n. 1
0
 /**
  * return formated files and delete updated files
  */
 public function filter_images($entries_files = null, $field_files = null)
 {
     $this->CI->load->library('files/files');
     if ($entries_files) {
         $entries_parts = explode('|', $entries_files);
         $field_parts = explode('|', $field_files);
         if (is_array($entries_parts) && count($entries_parts) > 0) {
             foreach ($entries_parts as $field) {
                 if (!in_array($field, (array) $field_parts)) {
                     Files::delete_file($field);
                 }
             }
             return $field_parts;
         }
         return null;
     } else {
         return null;
     }
 }
Esempio n. 2
0
 /**
  * Delete a file
  *
  * @access	public
  * @return	void
  */
 public function delete_file()
 {
     // this is just a safeguard if they circumvent the JS permissions
     if (!in_array('delete_file', Files::allowed_actions())) {
         show_error(lang('files:no_permissions'));
     }
     if ($id = $this->input->post('file_id')) {
         $result = Files::delete_file($id);
         $result['status'] and Events::trigger('file_deleted', $id);
         echo json_encode($result);
     }
 }
Esempio n. 3
0
 /**
  * Deletes a product, the images and Files folder related to it.
  *
  * @param integer $id The Product ID to delete
  * @return boolean TRUE or FALSE on success of failure
  * @access public
  */
 public function delete_product($id)
 {
     $product = $this->get_product($id);
     if ($this->db->delete('firesale_products', array('id' => $id))) {
         // Remove files folder
         if ($product !== FALSE) {
             $folder = $this->get_file_folder_by_slug($product->slug);
             if ($folder != FALSE) {
                 $images = Files::folder_contents($folder->id);
                 $images = $images['data']['file'];
                 foreach ($images as $image) {
                     Files::delete_file($image->id);
                 }
                 Files::delete_folder($folder->id);
             }
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
Esempio n. 4
0
 /**
  * Save / Upload gallery images
  * 
  * @param string $type insert|update
  * @param int $gallery_id 
  * @return bool
  */
 private function save_gallery_images($type = 'insert', $gallery_id)
 {
     if (!is_numeric($gallery_id)) {
         return FALSE;
     }
     $folder_id = $this->gallery_m->get($gallery_id)->folder_id;
     $max_images = $this->input->post('max_images');
     $image_name = $this->current_user->username . "Image ";
     $img_data = NULL;
     $img_id = array();
     for ($i = 1; $i <= $max_images; $i++) {
         $img = Files::upload($folder_id, $image_name . $i, $field = 'image' . $i, $width = 800, $height = 800, $ratio = TRUE);
         if ($img['status'] === TRUE) {
             $img_data = array('gallery_id' => $gallery_id, 'file_id' => $img['data']['id']);
             if ($file_id = $this->input->post('image' . $i)) {
                 Files::delete_file($file_id);
                 $img_id[] = $this->gallery_image_m->update_by('file_id', $file_id, $img_data);
             } else {
                 $img_id[] = $this->gallery_image_m->insert($img_data);
             }
         }
     }
     return count($img_id);
 }
Esempio n. 5
0
<?php

require 'checkallowed.php';
// No direct access
$url_id = $GPXIN['id'];
$url_do = $GPXIN['do'];
$file_name = $GPXIN['file'];
require DOCROOT . '/includes/classes/files.php';
$Files = new Files();
// Delete a file
if ($url_do == 'delete') {
    echo $Files->delete_file($url_id, $file_name);
} elseif ($url_do == 'delete_dir') {
    echo $Files->delete_dir($url_id, $file_name);
} elseif ($url_do == 'savecontent') {
    if (empty($url_id) || empty($file_name)) {
        die('No ID or filename given!');
    }
    $file_content = $GPXIN['content'];
    echo $Files->save_file($url_id, $file_name, $file_content);
    exit;
} elseif ($url_do == 'show_addfile') {
    echo '<b>' . $lang['new_filename'] . ':</b> <input type="text" class="inputs" id="newfilename" /><br />
    <textarea id="filecontent" class="txteditor" style="width:715px;height:370px;white-space:pre;"></textarea><br />
    <div align="center"><div class="button" onClick="javascript:file_savenewfile(' . $url_id . ');">' . $lang['save'] . '</div></div>';
    exit;
} elseif ($url_do == 'show_add_dir') {
    echo '<b>' . $lang['new_dirname'] . ':</b> <input type="text" class="inputs" id="new_dirname" /><br />
    <div align="center"><div class="button" onClick="javascript:file_add_newdir(' . $url_id . ');">' . $lang['save'] . '</div></div>';
    exit;
} elseif ($url_do == 'create_newdir') {
Esempio n. 6
0
 /**
  * Delete a file
  *
  * @access	public
  * @return	void
  */
 public function delete_file()
 {
     // this is just a safeguard if they circumvent the JS permissions
     if (!in_array('delete_file', Files::allowed_actions())) {
         show_error(lang('files:no_permissions'));
     }
     if ($id = $this->input->post('file_id')) {
         echo json_encode(Files::delete_file($id));
     }
 }
 /**
  * Deletes the table and clean files
  * @param type $field
  * @param type $stream
  */
 public function field_assignment_destruct($field, $stream)
 {
     $this->CI->load->library('files/files');
     $table_data = $this->_table_data($field, $stream);
     /** first lets get the images that we need to delete * */
     $rows = $this->CI->db->get($table_data->table)->result();
     /** lets remove the files * */
     foreach ($rows as $r) {
         Files::delete_file($r->{$table_data->file_id_column});
     }
     /** Drop the table! * */
     $this->CI->dbforge->drop_table($table_data->table);
 }