Exemple #1
0
 public function __construct($source_id, $filedir_prefs, $ignore_restrictions)
 {
     parent::__construct();
     $filedir_prefs = self::apply_filedir_overrides($filedir_prefs);
     $banned_or_guest = !$this->EE->session->userdata('member_id') or $this->EE->session->userdata('is_banned');
     $filedir_denied = in_array($source_id, self::get_denied_filedirs());
     $assets_action = in_array($this->EE->input->get_post('ACT'), Assets_helper::get_asset_action_ids());
     // Enforce restrictions, if needed
     if (!$ignore_restrictions && (REQ == 'ACTION' && $assets_action && ($banned_or_guest or $filedir_denied))) {
         header('HTTP/1.1 403 Forbidden');
         exit;
     }
     $this->_ignore_restrictions = $ignore_restrictions;
     $this->_source_id = $source_id;
     $filedir_prefs->server_path = self::resolve_server_path($filedir_prefs->server_path);
     $this->_source_settings = $filedir_prefs;
 }
 /**
  * Returns TRUE if the other source is an S3 source and shares the same credentials
  * @param Assets_base_source $source
  * @return mixed
  */
 public function can_move_files_from(Assets_base_source $source)
 {
     return $source instanceof Assets_s3_source && $this->settings()->access_key_id == $source->settings()->access_key_id && $this->settings()->secret_access_key == $source->settings()->secret_access_key;
 }
Exemple #3
0
 /**
  * Returns TRUE if source is capable from performing the file move from another source as if the file being moved was
  * inside the new source already. For example - all EE operations and S3 operations, that take place on the same AWS account.
  *
  * @param Assets_base_source $source
  * @return boolean
  */
 public function can_move_files_from(Assets_base_source $source)
 {
     return $source instanceof Assets_rs_source && $this->settings()->username == $source->settings()->username && $this->settings()->api_key == $source->settings()->api_key;
 }
 /**
  * Move a file between sources
  *
  * @param Assets_base_source $old_source
  * @param Assets_base_source $new_source
  * @param $file_id
  * @param $folder_id
  * @param string $action to take if conflict exists
  * @return array
  * @throws Exception
  */
 private function _move_file_between_sources(Assets_base_source $old_source, Assets_base_source $new_source, $file_id, $folder_id, $action)
 {
     $file_to_move = $old_source->get_file($file_id);
     $local_file = $file_to_move->get_local_copy();
     $result = $new_source->transfer_file_into_source($local_file, $folder_id, $file_to_move, $action);
     if (isset($result['success'])) {
         if ($old_source->finalize_outgoing_transfer($file_to_move)) {
             if (Assets_helper::get_kind($result['path']) == 'image') {
                 $new_source->post_upload_image_actions($file_id, $local_file);
             }
             @unlink($local_file);
             return array('success' => TRUE, 'new_path' => $file_id);
         } else {
             throw new Exception(lang('invalid_source_path'));
         }
     } else {
         return $result;
     }
 }