Plugin Directory

Changeset 2793340


Ignore:
Timestamp:
10/03/2022 09:23:20 AM (3 years ago)
Author:
andreadegiovine
Message:

1.1.9

Location:
cloud-customer-area
Files:
18 added
6 edited

Legend:

Unmodified
Added
Removed
  • cloud-customer-area/trunk/assets/frontend.css

    r2310114 r2793340  
    123123    border-bottom: 0;
    124124}
     125
     126.cloud-customer-area-icon {
     127    height: 16px;
     128    width: 16px;
     129    display: inline-block;
     130    margin: 0 5px;
     131    vertical-align: text-bottom;
     132}
  • cloud-customer-area/trunk/assets/frontend.js

    r2310114 r2793340  
    1717                load_el.remove();
    1818                $.each( data, function( key, value ) {
    19                     $(table_el).append( '<tr><td>'+ value.name +'</td><td>'+ value.date +'</td><td>'+ value.ext +'</td><td>'+ value.download_link +'</td></tr>' );
     19                    var icon = value.icon.length > 0 ? '<span class="cloud-customer-area-icon" style="background-image: url('+ value.icon +')"></span>' : '';
     20                    $(table_el).append( '<tr><td>'+ value.name +'</td><td>'+ value.date +'</td><td>'+ icon + value.ext +'</td><td>'+ value.download_link +'</td></tr>' );
    2021                });
    2122            },
  • cloud-customer-area/trunk/cloud-customer-area.php

    r2585315 r2793340  
    88Text Domain: cloud-customer-area
    99Domain Path: /languages/
    10 Version: 1.1.8
     10Version: 1.1.9
    1111*/
    1212
     
    168168
    169169            if (isset($_GET['action']) && $_GET['action'] == 'download' && isset($_GET['download_name']) && isset($_GET['download_id']) && isset($_GET['token']) && (!in_array('guest', $customer_roles) ? wp_verify_nonce($_GET['token'], CCA_SLUG . '_download') : true)) {
    170                 CCA_googleApi_downloadFile($_GET['download_name'], $_GET['download_id']);
     170                CCA_googleApi_downloadFile($_GET['download_name'], $_GET['download_id'], (!empty($_GET['export']) ? $_GET['export'] : false));
    171171                exit;
    172172            } else {
     
    224224                        $time = explode('T', $file->modifiedTime)[1];
    225225                        $time = explode(':', $time)[0] . ':' . explode(':', $time)[1];
    226 
     226                        $download_args = [
     227                            'action' => 'download',
     228                            'download_name' => urlencode($file->name),
     229                            'download_id' => $file->id,
     230                            'token' => wp_create_nonce(CCA_SLUG . '_download')
     231                        ];
     232                        if(strpos($file->mimeType, 'application/vnd.google-apps') !== false){
     233                            $download_args['export'] = str_replace('application/vnd.google-apps.', '', $file->mimeType);
     234                        }
     235                        $download_link = add_query_arg($download_args, site_url());
    227236                        $return_output[] = array(
    228237                            'name' => $file->name,
    229238                            'date' => $date,
    230                             'ext' => $file->fileExtension,
    231                             'download_link' => '<a href="' . site_url() . '/?action=download&download_name=' . urlencode($file->name) . '&download_id=' . $file->id . '&token=' . wp_create_nonce(CCA_SLUG . '_download') . '" target="_blank">' . __(CCA_getSetting('label_download', 'customize'), 'cloud-customer-area') . '</a>',
     239                            'ext' => !empty($file->fileExtension) ? $file->fileExtension : '',
     240                            'icon' => !empty($file->iconLink) ? $file->iconLink : '',
     241                            'download_link' => '<a href="' . $download_link . '" target="_blank">' . __(CCA_getSetting('label_download', 'customize'), 'cloud-customer-area') . '</a>',
    232242                        );
    233243                    }
  • cloud-customer-area/trunk/inc/functions.php

    r2539690 r2793340  
    210210}
    211211
    212 function CCA_googleApi_downloadFile($fileName, $fileId)
    213 {
    214     $google_api = CCA_googleApi_init();
    215     $access_token = CCA_getSetting('access_token', 'oauth');
    216     $get_file = $google_api->getFile($access_token, $fileId);
     212function CCA_googleApi_downloadFile($fileName, $fileId, $export = false)
     213{
     214    $google_api = CCA_googleApi_init();
     215    $access_token = CCA_getSetting('access_token', 'oauth');
     216    $get_file = $google_api->getFile($access_token, $fileId, $export);
     217    $fileExportTypeMap = [
     218        'audio' => '.mp3',
     219        'document' => '.docx',
     220        'drawing' => '.pdf',
     221        'file' => '',
     222        'presentation' => '.pptx',
     223        'spreadsheet' => '.xlsx'
     224    ];
     225    if($export && !empty($fileExportTypeMap[$export])){
     226        $fileName .= $fileExportTypeMap[$export];
     227    }
    217228    header('Content-Type: application/octet-stream');
    218229    header("Content-Transfer-Encoding: Binary");
  • cloud-customer-area/trunk/inc/google-api.php

    r2539690 r2793340  
    124124            $args = array(
    125125                'key' => $this->client_id,
    126                 'fields' => 'nextPageToken, files(id, name, thumbnailLink, fileExtension, modifiedTime)',
     126                'fields' => 'nextPageToken, files(id, name, thumbnailLink, fileExtension, modifiedTime, mimeType, iconLink, properties)',
    127127            );
    128128            if (!empty($q)) {
     
    154154        }
    155155
    156         public function getFile($token = '', $fileID = false)
     156        public function getFile($token = '', $fileID = false, $export = false)
    157157        {
    158158            if (!isset($token->access_token)) {
    159159                return false;
    160160            }
     161            $fileExportTypeMap = [
     162                'audio' => 'audio/mpeg',
     163                'document' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
     164                'drawing' => 'application/pdf',
     165                'file' => 'application/octet-stream',
     166                'presentation' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
     167                'spreadsheet' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
     168            ];
    161169            $headers = array(
    162170                'Authorization' => 'Bearer "' . $token->access_token . '"',
    163171            );
    164             $response = $this->sendAPIRequest('https://www.googleapis.com/drive/v3/files/' . $fileID . '/?alt=media', '', 'GET', $headers);
     172            if($export){
     173                if(empty($fileExportTypeMap[$export])){
     174                    return 'Error';
     175                }
     176                $response = $this->sendAPIRequest('https://www.googleapis.com/drive/v3/files/' . $fileID . '/export?mimeType=' . $fileExportTypeMap[$export], '', 'GET', $headers);
     177            } else {
     178                $response = $this->sendAPIRequest('https://www.googleapis.com/drive/v3/files/' . $fileID . '/?alt=media', '', 'GET', $headers);
     179            }
    165180            return $response;
    166181        }
  • cloud-customer-area/trunk/readme.txt

    r2585315 r2793340  
    44Donate link: https://totalpress.org/donate?utm_source=wordpress_org&utm_medium=plugin_page&utm_campaign=cloud_customer_area
    55Requires at least: 4.0
    6 Tested up to: 5.8
    7 Stable tag: 1.1.8
     6Tested up to: 6.0
     7Stable tag: 1.1.9
    88Requires PHP: 5.6
    99License: GPLv2 or later
     
    4040This plugin is written using only **functions included in the WordPress core**, so it does **not reduce the performance of your website** and does **not cause compatibility problems**.
    4141You can use the "Cloud Customer Area" plugin with **any theme builder**, with any theme and with **any plugin**. It's perfect!
     42
     43**Files created with Google apps can be downloaded via the plugin only if the size does not exceed 10mb.**
    4244
    4345== Cloud Customer Area features ==
     
    99101== Changelog ==
    100102
     103= 1.1.9 =
     104* WP 6.0 compatibility;
     105* Export Google apps file;
     106
    101107= 1.1.8 =
    102108* WP 5.8 compatibility.
     
    127133
    128134== Upgrade Notice ==
     135
     136= 1.1.9 =
     137WP 6.0 compatibility;
     138Export Google apps file;
    129139
    130140= 1.1.8 =
Note: See TracChangeset for help on using the changeset viewer.