Plugin Directory

Changeset 729295


Ignore:
Timestamp:
06/21/2013 08:27:21 AM (13 years ago)
Author:
atvdev
Message:

Upversion

Location:
amazon-s3-uploads/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • amazon-s3-uploads/trunk/asssu.php

    r728976 r729295  
    66Author URI: https://profiles.google.com/117859515361389646005
    77Description: Moves your uploads to Amazon S3 via cron jobs.
    8 Version: 1.9.1
     8Version: 1.9.2
    99*/
    1010
     
    1414register_activation_hook(__FILE__, 'activation_hook');
    1515function activation_hook() {
    16     global $asssu;
     16    $asssu = new \asssu\Asssu();
    1717    $asssu->activation_hook();
    1818}
     
    2020register_deactivation_hook(__FILE__, 'deactivation_hook');
    2121function deactivation_hook() {
    22     global $asssu;
     22    $asssu = new \asssu\Asssu();
    2323    $asssu->deactivation_hook();
    2424}
  • amazon-s3-uploads/trunk/plugin/asssu/__init.php

    r728997 r729295  
    4242   
    4343    public static
    44         $version = '1.9.1';
     44        $version = '1.9.2';
    4545       
    4646    public
     
    6868        # na kano prepare
    6969        $this->config = $this->db->wpdb->get_row('SELECT * FROM '.$this->db->table.' WHERE site_url like "'.$this->site_url.'"', ARRAY_A);
     70        $this->config['is_active'] = $this->config['is_active'] === '1';
    7071        ob_end_clean();
    7172        $this->check_version();
     
    7475            $this->cron_integration = new AsssuCronIntegration($this);
    7576            $this->file_managment_integration = new AsssuFileManagmentIntegration($this);
     77            $this->file_plugins_integration = new AsssuPluginsManagmentIntegration($this);
    7678        }
    7779    }
     
    126128
    127129        $this->db->create();
     130        $this->config['version'] = '1.9.1';
    128131        $this->config['access_key'] = $old_config['asssu_access_key'];
    129132        $this->config['secret_key'] = $old_config['asssu_secret_key'];
     
    136139    }
    137140   
    138     // function upgrade_1_9_1() {
    139     //     $this->config['version'] = '1.9.2';
    140     //     $this->db->save_config();
    141     //     return $this->config['version'];
    142     // }
     141    function upgrade_1_9_1() {
     142        $this->config['version'] = '1.9.2';
     143        $this->db->save_config();
     144        return $this->config['version'];
     145    }
    143146
    144147    function convert_to_s3_path($path, $stream_wrapper_format=true) {
    145         $s3_path = $this->config['bucket_subdir'].'/'.trim(str_replace($this->wp_upload_dir['basedir'], '', $path), '/');
     148        if (strpos($path, 's3://') === 0)
     149            return $path;
     150        $s3_path = trim(str_replace($this->wp_upload_dir['basedir'], '', $path), '/');
     151        if (!empty($this->config['bucket_subdir']))
     152            $s3_path = trim($this->config['bucket_subdir'].'/'.$s3_path, '/');
    146153        if ($stream_wrapper_format)
    147154            $s3_path = sprintf('s3://%s/%s', $this->config['bucket_name'], $s3_path);
     
    277284    function __construct($asssu) {
    278285        $this->asssu = $asssu;
     286        // add_filter('upload_dir', array($this, 'upload_dir'));
    279287        add_filter('wp_handle_upload_prefilter', array($this, 'wp_handle_upload_prefilter'));
    280288        add_filter('wp_delete_file', array($this, 'wp_delete_file'));
     289    }
     290
     291    function upload_dir($args) {
     292        $client = $this->asssu->get_s3_client();
     293        $args['path'] = $this->asssu->convert_to_s3_path($args['path']);
     294        $args['basedir'] = $this->asssu->convert_to_s3_path($args['basedir']);
     295        return $args;
    281296    }
    282297
     
    340355            @ unlink($s3_path);
    341356        return $file;
     357    }
     358}
     359
     360class AsssuPluginsManagmentIntegration {
     361
     362    function __construct($asssu) {
     363        $this->asssu = $asssu;
     364        // add_filter('bp_core_avatar_upload_path', array($this, 'bp_core_avatar_upload_path'));
     365        // add_filter('bp_core_avatar_folder_dir', array($this, 'bp_core_avatar_folder_dir'));
     366    }
     367
     368    function bp_core_avatar_upload_path($basedir) {
     369        $client = $this->asssu->get_s3_client();
     370        return $this->asssu->convert_to_s3_path($basedir);
     371    }
     372
     373    function bp_core_avatar_folder_dir($avatar_folder_dir) {
     374        $client = $this->asssu->get_s3_client();
     375        return $this->asssu->convert_to_s3_path($avatar_folder_dir);
    342376    }
    343377}
  • amazon-s3-uploads/trunk/plugin/asssu/forms.php

    r728976 r729295  
    1616                $options = array();
    1717            $options['initial'] = $this->asssu->config;
    18             unset($options['initial']['is_active']);
    1918        }
    2019        parent::__construct($data, $files, $options);
     
    3736        require_once __DIR__.'/../../lib/aws-sdk-php/aws-autoloader.php';
    3837       
    39         // the connection
    4038        // for some reason this does not throw exception
    4139        // when you try to connect with wrong credentials
  • amazon-s3-uploads/trunk/readme.txt

    r728762 r729295  
    55Requires at least: 3.5.1
    66Tested up to: 3.5.1
    7 Stable tag: 1.9.1
     7Stable tag: 1.9.2
    88License: GPLv2.1
    99
Note: See TracChangeset for help on using the changeset viewer.