Plugin Directory

Changeset 3043713


Ignore:
Timestamp:
03/01/2024 03:00:56 PM (2 years ago)
Author:
arstudios
Message:

Release 1.8.0.

Location:
constellation-client-portal
Files:
131 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • constellation-client-portal/trunk/README.txt

    r3030228 r3043713  
    55Requires at least: 5.0.0
    66Tested up to: 6.4
    7 Stable tag: 1.7.6
     7Stable tag: 1.8.0
    88Requires PHP: 7.4
    99License: GPLv3 or later
     
    1212== Description ==
    1313
    14 Turn your WordPress site into a professional client portal and streamline your operation.  Create private pages for your clients, customers, and team members.  Create private posts and attach private files (example: pdf, jpg, docx, xlsx, etc).
     14Turn your WordPress site into a professional client portal. Create private pages and posts, and attach private files (example: pdf, jpg, docx, xlsx, etc.) for secure collaboration and document management.
    1515
    1616Upgrade to the [Pro version](https://adrianrodriguezstudios.com/constellation-client-portal/?utm_source=wporg "Get Constellation Client Portal Pro") and integrate with WooCommerce to accept payments for invoices and services.
     17
     18Streamline your operation and improve client satisfaction with Constellation Client Portal.
    1719
    1820== Features ==
     
    4244* Export file and invoice lists to CSV.
    4345* Create [global client pages](https://adrianrodriguezstudios.com/2023/05/16/how-to-utilize-global-pages/ "Client Portal Global Pages").
     46* Create global client files that can be accessed by more than one company.
    4447
    4548== Use Cases ==
     
    124127* **class** Accepted Values: any valid HTML class attribute name or names (separate multiple class names with a space). Default: null.
    125128
     129= Global Files (Pro) =
     130
     131`[accp_global_files]`
    126132
    127133= Company Menu (Pro) =
     
    200206
    201207== Changelog ==
     208= 1.8.0 (Pro) - 2024-3-1 =
     209* Update: Updated the CSV import functionality to add warnings to import logs if company id or file attachment data is missing or malformed.
     210* Update: Added new Global Files section to the plugin settings.
     211* Update: Updated the list shortcode settings to account for the new global files.
     212* Feature: Added functionality that allows for global file posts to be created and displayed via a new accp_global_files shortcode.
     213* Update: Updated the global page functionality to deny access if any published company that a user is assigned to contains a status other than "active."
     214* Fix: Fixed issue preventing notes from being deleted.
     215* Update: Updated the WP list table delete page permanent delete admin notice text.
     216* Update: Updated the functionality that generates taxonomy list column content to improve organization and maintainability.
     217* Update: Updated the WP list table filter query functionality for better organization and maintainability.
     218* Update: Updated the functionality that generates the post WP list table Category column content to improve organization and maintainability.
     219* Update: Updated the functionality that generates the post WP list table Company column content to improve organization and maintainability.
     220* Update: Updated the excluded user and excluded role WP list table column content functionality for better organization and maintainability.
     221* Update: Added new global file post type and associated taxonomies.
     222* Improvement: Improved the client page, client invoice, and client file meta save functionality.
     223* Improvement: Improved capability checks and sanitization for the excluded user and excluded role sections for pages and posts.
     224* Improvement: Updated the functionality that saves the accp_client_file_categories, accp_client_invoice_categories, and accp_client_page_categories exclude user and exclude role taxonomy meta data better organization and maintainability.
     225* Improvement: Updated the functionality that adds the exclude user and exclude role sections to the accp_client_file_categories, accp_client_invoice_categories, and accp_client_page_categories edit taxonomy page for better organization and maintainability.
     226* Improvement: Updated the functionality that adds the exclude user and exclude role sections to the accp_client_file_categories, accp_client_invoice_categories, and accp_client_page_categories add taxonomy form for better organization and maintainability.
     227
     228= 1.8.0 (Core) - 2024-3-1 =
     229* Improvement: Improved the assign company directory settings instructions.
     230* Update: Updated the assign company dir functionality to prevent assigning the reserved "global-files" dir.
     231* Update: Updated the WP list table delete page permanent delete admin notice UI.
     232* Improvement: Updated the post bulk edit UI to provide better user feedback on button click.
     233* Fix: Removed functionality that automatically saves an 'unpaid' status to file posts if no value is saved.
     234
    202235= 1.7.6 (Pro) - 2024-2-1 =
    203236* Update: Minor code formatting updates.
     
    561594* Fix: Fixed issue preventing download of new files in the list after the recent code updates caused malformed paths.
    562595* Update: Added functionality to flush the rewrite rules on plugin upgrade.
    563 * New Feature: Added excerpt support and functionality to the clientfile and accp_clientinvoice post types.
     596* Feature: Added excerpt support and functionality to the clientfile and accp_clientinvoice post types.
    564597* Update: Updated the the file and invoice shortcodes to pull from the excerpt field, instead of the content field, if excerpts are enabled.
    565598* Improvement: Updated static references to WP dirs and updated functionality to get this data dynamically.
     
    578611* Change: Updated the file output functionality.
    579612* Change: Updated the file and invoice list shortcode CSS classes.
    580 * New Feature: Updated the invoice add-to-cart functionality to support simple and variable subscription products.
     613* Feature: Updated the invoice add-to-cart functionality to support simple and variable subscription products.
    581614* Improvement: Updated the admin invoice product select options to exclude variable products and subscriptions (not variations) since top-level variable products cannot be added to the cart.
    582615* Improvement: Added additional options to the invoice status select field.
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-admin.php

    r3030228 r3043713  
    4848        $this->plugin_name = $plugin_name;
    4949        $this->version = $version;
    50         $this->accp_utility_functions = new ACCP_Utility_Functions();       
     50        $this->accp_utility_functions = new ACCP_Utility_Functions();
     51        $this->is_pro = $this->accp_utility_functions->is_pro_plugin($this->plugin_name);
    5152
    5253        /**
     
    205206             * If this is the Basic tier, serve the file here if the base checks passed.
    206207             */
    207             if( $this->plugin_name != 'ars-constellation-client-portal-pro' ){
     208            if( true !== $this->is_pro ){
    208209               
    209210                if($base_checks == true){
     
    230231
    231232                /**
    232                  * Proceed through Pro checks
     233                 * Proceed through Pro checks.
    233234                 */
    234235               
     
    241242                }
    242243
     244                $pro_admin = new ARS_Constellation_Client_Portal_Pro_Admin($this->plugin_name, $this->version);
     245                $is_global_files_dir = $pro_admin->check_if_uri_is_global_files_dir($request_uri);
    243246                $pro_check_class = new ARS_Constellation_Client_Portal_Pro_File_Checks();
    244                 $pro_checks = $pro_check_class->accp_direct_file_access_pro_checks($request_uri);           
    245 
    246                 if($base_checks == true && $pro_checks == true){
    247 
    248                     $checks_passed = true;
     247                $pro_checks = $pro_check_class->accp_direct_file_access_pro_checks($request_uri);
     248               
     249                if( true === $is_global_files_dir ){
    249250
    250251                    /**
    251                      * Serve the requested file.
     252                     * Global file checks.
    252253                     */
    253                     $this->accp_load_requested_file($request_uri, $checks_passed);
    254                     exit();
     254                    $global_file_authorized = $pro_check_class->accp_direct_global_file_access_pro_checks($request_uri);
     255
     256                    if( true === $global_file_authorized ){
     257
     258                        $checks_passed = true;
     259
     260                        /**
     261                         * Serve the requested file.
     262                         */
     263                        $this->accp_load_requested_file($request_uri, $checks_passed);
     264                        exit();
     265
     266                    }else{
     267
     268                        /**
     269                         * Redirect to the home page.
     270                         */
     271                        wp_redirect('/');
     272                        exit;
     273
     274                    }
    255275
    256276                }else{
    257277
    258278                    /**
    259                      * Redirect to the home page.
     279                     * Standard client file checks.
    260280                     */
    261                     wp_redirect('/');
    262                     exit;
     281                    if($base_checks == true && $pro_checks == true){
     282
     283                        $checks_passed = true;
     284   
     285                        /**
     286                         * Serve the requested file.
     287                         */
     288                        $this->accp_load_requested_file($request_uri, $checks_passed);
     289                        exit();
     290   
     291                    }else{
     292   
     293                        /**
     294                         * Redirect to the home page.
     295                         */
     296                        wp_redirect('/');
     297                        exit;
     298   
     299                    }
    263300
    264301                }
     
    505542        $post_type = $post->post_type;
    506543        $accp_file = get_post_meta($post_id, 'accp_file', true);
    507 
    508         if($post_type != 'accp_clientcompany'){
     544        $included_post_types = array( 'accp_clientinvoice', 'accp_clientfile', 'accp_global_file' );
     545
     546        if( in_array($post_type, $included_post_types) ){
    509547
    510548            /**
     
    545583
    546584                /**
    547                  * If the post doesn't have file just delete the post.
     585                 * If the post doesn't have a file just delete the post.
    548586                 */
    549587                wp_delete_post($post_id, true);
     
    557595       
    558596        /**
    559          * Remove any associated post notes if this if
    560          * this is the Pro version.
     597         * Remove any associated post notes if this is the Pro version.
    561598         */
    562599        $this->accp_delete_post_notes_on_post_delete($post_id);
     
    634671       
    635672        $file_ids = json_decode(stripslashes($_POST['del_file_post_id_json'])); // Sanitize in loop.
     673        $included_post_types = array( 'accp_clientinvoice', 'accp_clientfile', 'accp_global_file' );
    636674       
    637675        if($file_ids != null && !empty($file_ids)){
     
    643681                $post_type = $post->post_type;
    644682                $accp_file = get_post_meta($post_id, 'accp_file', true);
    645 
    646                 if($post_type !== 'accp_clientcompany'){
     683               
     684
     685                if( in_array($post_id, $included_post_types) ){
    647686
    648687                    /**
     
    816855
    817856    /**
    818      * Restrict access to Client Pages Client File and
    819      * Client Invoice Posts on front-end.
     857     * Restrict access to Client Pages, Client File and
     858     * Client Invoice, and Global File posts on front-end.
    820859     */
    821860    function accp_restrict_client_page_access(){
     
    834873
    835874        /**
    836          * Exit if this is not a Client Page, Client File,
     875         * Exit if this is not a Client Page, Client File, Global File
    837876         * or Client Invoice post type.
    838877         */
    839         if( $post_type !== 'accp_client_pages' && $post_type !== 'accp_clientfile' && $post_type !== 'accp_clientinvoice' )
     878        if( $post_type !== 'accp_client_pages' &&
     879            $post_type !== 'accp_clientfile' &&
     880            $post_type !== 'accp_clientinvoice' &&
     881            $post_type !== 'accp_global_file'
     882        )
    840883            return;
    841884
     
    872915         * Check if pro access checks need to be instantiated.
    873916         */       
    874         if ( $this->plugin_name == 'ars-constellation-client-portal-pro' ){         
     917        if ( $this->plugin_name == 'ars-constellation-client-portal-pro' ){
    875918           
    876919            $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );
    877             $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     920           
     921            if( 'accp_global_file' !== $post_type ){
     922
     923                $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);
     924
     925            }else{
     926
     927                $check_authorization = $authorization->verify_global_file_post_authorization_pro($post_id, $user_id);
     928
     929            }
    878930
    879931        }else{                     
     
    9941046       
    9951047        global $post;
    996        
    997         if( (get_post_type($post->ID) != 'accp_clientfile' && get_post_type($post->ID) != 'accp_clientinvoice') || !$post ) return;
     1048
     1049        if( !$post )
     1050            return;
     1051
     1052        $post_type = get_post_type($post->ID);     
     1053
     1054        if( 'accp_clientfile' != $post_type && 'accp_clientinvoice' != $post_type && 'accp_global_file' != $post_type )
     1055            return;     
    9981056       
    9991057        $enctype = ' enctype=multipart/form-data'; // No need for double quotes.
     
    10101068       
    10111069        $screens = array( 'accp_clientfile', 'accp_clientinvoice' );
     1070       
     1071        $is_pro = $this->accp_utility_functions->is_pro_plugin($this->plugin_name);
     1072
     1073        if( true === $is_pro ){     
     1074
     1075            $screens[] = 'accp_global_file';
     1076
     1077        }       
    10121078       
    10131079        foreach ( $screens as $screen ) {
    10141080
    1015             add_meta_box('clientfile', __('Client File', 'ars-constellation-client-portal'), array($this, 'accp_client_file_meta_fields'), $screen, 'normal', 'high');     
     1081            add_meta_box('clientfile', __('Client File', 'constellation-client-portal'), array($this, 'accp_client_file_meta_fields'), $screen, 'normal', 'high');     
    10161082
    10171083        }
     
    10211087
    10221088    /**
    1023      * Client File meta boxes.
     1089     * Client file meta boxes.
     1090     *
     1091     * Adds the file upload and current file UI.
    10241092     */
    10251093    public function accp_client_file_meta_fields() {
     
    10281096
    10291097        $file_save_nonce = wp_create_nonce('accp_file_save_nonce');
    1030         $curr_post_id = get_the_id();
    1031         $accp_file = get_post_meta($curr_post_id, 'accp_file', true);       
    1032         $post_company = get_post_meta($curr_post_id, 'accp_user', true);       
    1033         $accp_clientfiles_full_dir_path = $this->accp_utility_functions->accp_get_clientfiles_path();   
     1098        $post_id = $post->ID;
     1099        $post_type = get_post_type($post_id);
     1100        $accp_file = get_post_meta($post_id, 'accp_file', true);       
     1101        $post_company = get_post_meta($post_id, 'accp_user', true) ? get_post_meta($post_id, 'accp_user', true) : '';       
     1102        $accp_clientfiles_full_dir_path = $this->accp_utility_functions->accp_get_clientfiles_path();       
    10341103       
    10351104        ?>
     
    10371106        <?php
    10381107       
    1039         if ( !empty($accp_file) ):
    1040 
    1041             $company_dir = $this->accp_get_company_dir($post_company);
    1042             $accp_file_path = parse_url($accp_file['url'], PHP_URL_PATH);                   
    1043             $accp_file_full_path = $accp_clientfiles_full_dir_path . '/' . $company_dir . '/' . basename($accp_file_path);
     1108        if ( $accp_file && !empty($accp_file) ):
     1109
     1110            $company_dir = $post_company ? $this->accp_get_company_dir($post_company) : '';
     1111            $accp_file_path = parse_url($accp_file['url'], PHP_URL_PATH);
     1112           
     1113            if( 'accp_clientinvoice' === $post_type || 'accp_clientfile' === $post_type ){
     1114
     1115                $accp_file_full_path = $accp_clientfiles_full_dir_path . '/' . $company_dir . '/' . basename($accp_file_path);
     1116
     1117            }else{
     1118
     1119                $accp_file_full_path = $accp_clientfiles_full_dir_path . '/global-files/' . basename($accp_file_path);
     1120
     1121            }
     1122           
    10441123           
    10451124            /**
     
    10511130            ?> 
    10521131
    1053                 <div id="curr_file_container" data-post-id="<?php echo esc_attr($curr_post_id); ?>" data-file-path="<?php echo esc_attr($accp_file_full_path); ?>" data-assigned-company="<?php echo esc_attr($post_company); ?>">
     1132                <div id="curr_file_container" data-post-id="<?php echo esc_attr($post_id); ?>" data-file-path="<?php echo esc_attr($accp_file_full_path); ?>" data-assigned-company="<?php echo $post_company ? esc_attr($post_company) : 'global'; ?>">
    10541133
    10551134                    <p>Current File</p>
     
    11111190       
    11121191        <?php
    1113         if(!empty($post_company)){
     1192        /**
     1193         * Exit if this is not a client invoice or
     1194         * client file post type.
     1195         */
     1196        if( 'accp_clientinvoice' != $post_type && 'accp_clientfile' != $post_type )
     1197            return;
     1198
     1199        if( !empty($post_company) ){
    11141200
    11151201            echo '<p>Assigned Company</p>';         
     
    11771263        <?php
    11781264       
    1179     }   
     1265    }
    11801266
    11811267
     
    16911777
    16921778        if(empty($new_company_dir))
    1693             die();                 
     1779            die();
     1780       
     1781        /**
     1782         * Check for use of reserved "global-file" dir name.
     1783         */
     1784        if( 'global-files' === strtolower($new_company_dir) ||
     1785            'global_files' === strtolower($new_company_dir) ||
     1786            'globalfiles' === strtolower($new_company_dir) ||
     1787            'global.files' === strtolower($new_company_dir)
     1788        ){
     1789
     1790            $note_content = 'The '.esc_html( strtolower($new_company_dir) ).' directory name is reserved and cannot be used.  Please enter a different name.';
     1791
     1792            $this->accp_add_directory_update_note($company_id, $note_content);
     1793
     1794            die();
     1795
     1796        }
    16941797           
    16951798        $new_company_path = $accp_clientfiles_full_dir_path . DIRECTORY_SEPARATOR . $new_company_dir;
     
    18711974            return $post_id;
    18721975
    1873         }
     1976        }       
    18741977   
    1875         if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
     1978        if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
    18761979            return $post_id;
    18771980       
    1878         if( $post_type !== 'accp_clientfile' && $post_type !== 'accp_clientinvoice')
     1981        if( $post_type !== 'accp_clientfile' && $post_type !== 'accp_clientinvoice' && $post_type !== 'accp_global_file')
    18791982            return $post_id;
    18801983       
    1881         if(!is_user_logged_in())
     1984        if( !is_user_logged_in() )
    18821985            return wp_die('Invalid command.');
    18831986       
    1884         if(!current_user_can('upload_files'))
    1885             return $post_id;       
    1886        
    1887         /**
    1888          * Add the company ID to the file post meta.
    1889          */
    1890         if(!$_POST['accp_user']) return $post_id;
    1891 
    1892         $company_post_data = $this->accp_utility_functions->accp_sanitize_integers($_POST['accp_user']);
    1893         $company = get_post( $company_post_data );   
    1894         $company_id = $company->ID;
    1895 
    1896         update_post_meta($post_id, 'accp_user', $company_id);
    1897 
    18981987        if( !current_user_can('upload_files') )
    18991988            return $post_id;
    1900 
     1989       
     1990       
     1991        /**
     1992         * Add the company ID to the file post meta.
     1993         */
     1994        if( 'accp_clientfile' === $post_type || 'accp_clientinvoice' === $post_type ){
     1995
     1996            if( !$_POST['accp_user'] )
     1997                return $post_id;
     1998
     1999            $company_post_data = $this->accp_utility_functions->accp_sanitize_integers($_POST['accp_user']);
     2000            $company = get_post( $company_post_data );   
     2001            $company_id = $company->ID;
     2002
     2003            update_post_meta($post_id, 'accp_user', $company_id);
     2004
     2005        }
     2006               
    19012007   
    19022008        /**
     
    19252031
    19262032            }
     2033           
    19272034           
    19282035            /**
     
    19492056                 * Prep upload.
    19502057                 */             
    1951                 if(!empty($file_type_array['type'])){
     2058                if( !empty($file_type_array['type']) ){
    19522059                    $upload = wp_handle_upload( $_FILES['accp_file'], array( 'test_form' => false ) );
    19532060                }
     
    20222129    /**
    20232130     * Configure custom upload directory for the
    2024      * 'clientfile' and 'accp_clientinvoice' post types.
     2131     * 'accp_clientfile' and 'accp_clientinvoice' post types.
     2132     *
     2133     * This sets the company-specific upload dir, and not
     2134     * the global file upload dir.
     2135     *
     2136     * @param array $default_dir - Default uploads directory array.
    20252137     *
    2026      * Uses the 'upload_dir' WP filter.
     2138     * @return array $custom_dir|$default_dir - Custom dir if customized, else $default_dir.
     2139     *
     2140     * @hooked upload_dir.
    20272141     */
    20282142    function accp_set_upload_dir($default_dir){
     
    27652879            $screen->parent_file === 'edit.php?post_type=accp_clientfile' ||
    27662880            $screen->parent_file === 'edit.php?post_type=accp_clientinvoice' ||
    2767             $screen->parent_file === 'admin.php?page=accp-settings.php'
     2881            $screen->parent_file === 'edit.php?post_type=accp_global_file'         
    27682882        ){     
    27692883
     2884            /**
     2885             * Add content to the clientfile trash page.
     2886             */
     2887            if (strpos($_SERVER['REQUEST_URI'],'post_status=trash') !== false) {                   
     2888               
    27702889                /**
    2771                  * Add content to the clientfile trash page.
     2890                 * Add a nonce to the accp_clientfile trash header that can be used for ajax calls.
    27722891                 */
    2773                 if (strpos($_SERVER['REQUEST_URI'],'post_status=trash') !== false) {                   
    2774                    
    2775                     /**
    2776                      * Add a nonce to the accp_clientfile trash header that can be used for ajax calls.
    2777                      */
    2778                     $clientfile_admin_nonce = wp_create_nonce('clientfile_admin_nonce');
    2779 
    2780                     echo '<span id="clientfile-admin-nonce" data-nonce="' . esc_attr($clientfile_admin_nonce) . '" class="hidden"> </span>';
    2781                    
    2782                     /**
    2783                      * Add an admin notice on the trash page.
    2784                      */
    2785                     if($screen->parent_file !== 'admin.php?page=accp-settings.php'){
    2786                         echo '<span class="delete-screen-notice">Deleting posts on this screen will also delete any file attached to the post.</span>';
    2787                     }
     2892                $clientfile_admin_nonce = wp_create_nonce('clientfile_admin_nonce');
     2893
     2894                echo wp_kses_post('<span id="clientfile-admin-nonce" data-nonce="' . esc_attr($clientfile_admin_nonce) . '" class="hidden"> </span>');
    27882895               
    2789                 } 
     2896                /**
     2897                 * Add an admin notice on the trash page.
     2898                 */
     2899                $permanent_delete_notice = 'Deleting posts on this screen will also delete any file attached to the post.';
     2900                $permanent_delete_notice = apply_filters('accp_update_permanent_post_delete_notice', $permanent_delete_notice);
     2901
     2902                echo wp_kses_post('<div class="notice notice-error"><p>'.esc_html($permanent_delete_notice).'</p></div>');                 
     2903           
     2904            } 
    27902905
    27912906        }
     
    33473462    }
    33483463
     3464
     3465    /**
     3466     * Get the Company column content html.
     3467     *
     3468     * This generates the Company column content for post
     3469     * (file, invoice, global file) WP list tables, and
     3470     * not for taxonomy lists.
     3471     *
     3472     * @param string $column_name - The column name slug.
     3473     * @param int $post_id - The post ID.
     3474     *
     3475     * @return string $html - The column content html.
     3476     */
     3477    function get_company_column_content_for_post_lists($column_name, $post_id){
     3478
     3479        if( !is_admin() || !is_user_logged_in() || !current_user_can('manage_options') )
     3480            return;
     3481       
     3482        if ( 'company' != $column_name )
     3483            return;
     3484
     3485        $company_id = get_post_meta($post_id, 'accp_user', true) ? get_post_meta($post_id, 'accp_user', true) : '';         
     3486
     3487        if( !$company_id || empty($company_id) )
     3488            return;         
     3489
     3490        $company_name = get_the_title($company_id) ? get_the_title($company_id) : '';
     3491
     3492        $html = '';
     3493
     3494        $html .= $company_name;
     3495       
     3496        /**
     3497         * If a file exists, output the file path data that
     3498         * is used when deleting posts.
     3499         */
     3500        $accp_file = get_post_meta($post_id, 'accp_file', true);
     3501
     3502        if ( !empty($accp_file) && isset($accp_file['url']) ) {
     3503
     3504            $accp_file_path = parse_url($accp_file['url'], PHP_URL_PATH);
     3505            $accp_file_full_path = untrailingslashit( get_home_path() ) . $accp_file_path;
     3506            $accp_del_nonce = wp_create_nonce('post_delete_file_nonce');
     3507
     3508            $html .= '<span class="data-path-container hidden" data-file-path="' . esc_url($accp_file_full_path) . '" data-nonce="' . esc_attr($accp_del_nonce) . '"></span>';
     3509
     3510        }
     3511
     3512        echo wp_kses_post($html);
     3513
     3514    }
     3515
     3516
     3517    /**
     3518     * Get the Category column content html.
     3519     *
     3520     * This generates the Category column content for post
     3521     * (file, invoice, client page, global file, etc) WP list tables,
     3522     * and not for taxonomy lists.
     3523     *
     3524     * @param string $column_name - The column name slug.
     3525     * @param int $post_id - The post ID.
     3526     *
     3527     * @return string $html - The column content html.
     3528     */
     3529    function get_category_column_content_for_post_lists($column_name, $post_id){
     3530
     3531        if( !is_admin() || !is_user_logged_in() || !current_user_can('manage_options') )
     3532            return;
     3533
     3534        if ( 'file_category' != $column_name )
     3535            return;
     3536
     3537        $post_type = get_post_type($post_id);
     3538
     3539        if(!$post_type)
     3540            return;
     3541
     3542        $category_slug = '';
     3543
     3544        if( 'accp_clientinvoice' === $post_type ){
     3545
     3546            $category_slug = 'accp_invoice_categories';
     3547
     3548        }
     3549
     3550        if( 'accp_clientfile' === $post_type ){
     3551
     3552            $category_slug = 'accp_file_categories';
     3553
     3554        }
     3555
     3556        if( 'accp_client_pages' === $post_type ){
     3557
     3558            $category_slug = 'accp_client_page_categories';
     3559
     3560        }
     3561
     3562        if( 'accp_global_file' === $post_type ){
     3563
     3564            $category_slug = 'accp_global_file_categories';
     3565
     3566        }
     3567
     3568        if(empty($category_slug))
     3569            return;         
     3570       
     3571        $terms = get_the_terms( $post_id, $category_slug );
     3572                           
     3573        if ( $terms && !is_wp_error( $terms ) ){
     3574   
     3575            $categories = array();
     3576       
     3577            foreach ( $terms as $term ) {
     3578
     3579                $categories[] = $term->name;
     3580
     3581            }
     3582                               
     3583            $category_list = join( ", ", $categories );
     3584       
     3585            echo esc_html($category_list);
     3586
     3587        }
     3588
     3589    }
     3590
    33493591} //End ARS_Constellation_Client_Portal_Admin Class
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-client-pages.php

    r3004306 r3043713  
    4747        $this->version = $version;     
    4848        $this->utilities = new ACCP_Utility_Functions($this->plugin_name, $this->version);
     49        $this->admin = new ARS_Constellation_Client_Portal_Admin($this->plugin_name, $this->version);
    4950
    5051        if( class_exists('ARS_Constellation_Client_Portal_Pro_Admin') ){
     
    294295     * @param int $post_id - The post ID of the Client Page.
    295296     */
    296     public function accp_client_pages_column_display_company_name( $column_name, $post_id ) {   
     297    public function accp_client_pages_column_display_company_name( $column_name, $post_id ) {
     298       
     299        if( !is_admin() || !is_user_logged_in() || !current_user_can('manage_options') )
     300            return;
    297301       
    298302        /**
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-company.php

    r3030228 r3043713  
    967967                $generate_dir_text = 'Uploading a new file and selecting this company will also automatically generate a company directory.  So creating a directory here is <strong>not required</strong>.';
    968968
    969                 $specify_dir_text = 'If you have already created a directory for this company on the server, you can specify the directory name here. Uploading a new file and selecting this company will also automatically generate a company directory.  So specifying a directory here is <strong>not required</strong>.';
     969                $specify_dir_text = 'If you have already manually created a directory for this company on the server, you can specify the directory name here. Uploading a new file and selecting this company will also automatically generate a company directory.  So specifying a directory here is <strong>not required</strong>.';
    970970
    971971                $dir_assigned_class = '';
     
    10511051                    ?>
    10521052
    1053                     <?php echo esc_html($truncated_path . '/'); ?><input type="text" id="accp-specify-dir-name" name="accp_specify_dir_name" value=""> <span class="accp-field-note">Letters, numbers, underscores, or hyphens only.</span>
     1053                    <?php echo esc_html($truncated_path . '/'); ?><input type="text" id="accp-specify-dir-name" name="accp_specify_dir_name" value=""> <span class="accp-field-note">Letters, numbers, underscores, or hyphens only.  The "global-files" name is reserved and cannot be used.</span>
    10541054
    10551055                    <input class="button" data-nonce="<?php echo esc_attr($generate_nonce); ?>" data-post-id="<?php echo esc_attr($id); ?>" type="submit" value="Assign Directory" id="accp-assign-dir-btn" />
     
    10651065               
    10661066    }
     1067   
    10671068
    10681069    /**
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-core-authorization.php

    r2920206 r3043713  
    421421
    422422
     423    /**
     424     * Check if this is a Global File post
     425     * (Global File posts only), and return authorization.
     426     *
     427     * @param int $post_id - the ID of the Client File post.
     428     *
     429     * @return bool $is_global_file - true if this is a global file.
     430     */
     431    function is_global_file_post($post_id){
     432
     433        if(!$post_id)
     434            return false;
     435           
     436        $post = get_post($post_id);
     437
     438        if(!$post)
     439            return false;
     440
     441        $post_type = $post->post_type;
     442
     443        /**
     444         * Return false if the post type is not "accp_client_pages."
     445         */
     446        if( !$post_type || $post_type != 'accp_global_file' )
     447            return false;
     448       
     449        if( 'accp_global_file' === $post_type )
     450            return true;
     451
     452        return false;
     453   
     454    }
     455
     456
    423457} // END ARS_Constellation_Client_Portal_Core_Authorization
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-file.php

    r3004306 r3043713  
    4747        $this->version = $version;
    4848        $this->utilities = new ACCP_Utility_Functions($this->plugin_name, $this->version);
     49        $this->admin = new ARS_Constellation_Client_Portal_Admin($this->plugin_name, $this->version);
    4950
    5051        if( class_exists('ARS_Constellation_Client_Portal_Pro_Admin') ){
     
    272273     * Display the Company column content in the Client File WP List Table.
    273274     */
    274     function clientfile_column_display_company_name( $column_name, $post_id ) {         
    275        
    276         if ( 'company' != $column_name )
    277             return;
    278        
    279         if( get_post_meta($post_id, 'accp_user', true) ){
    280        
    281             $company_id = get_post_meta($post_id, 'accp_user', true);
    282            
    283             if($company_id != $post_id){
    284                
    285                 $company = get_the_title($company_id);
    286 
    287             }else{
    288 
    289                 $company = null;
    290 
    291             }
    292            
    293             if($company != null){
    294 
    295                 /**
    296                  * Display the company name.
    297                  */
    298                 echo esc_html($company);
    299 
    300                 /**
    301                  * If a file exists, output the file path data that
    302                  * is used when deleting posts.
    303                  */
    304                 $accp_file = get_post_meta($post_id, 'accp_file', true);
    305 
    306                 if ( !empty($accp_file) && isset($accp_file['url']) ) {
    307 
    308                     $accp_file_path = parse_url($accp_file['url'], PHP_URL_PATH);
    309                     $accp_file_full_path = untrailingslashit( get_home_path() ) . $accp_file_path;
    310                     $accp_del_nonce = wp_create_nonce('post_delete_file_nonce');
    311 
    312                     echo '<span class="data-path-container hidden" data-file-path="' . esc_url($accp_file_full_path) . '" data-nonce="' . esc_attr($accp_del_nonce) . '"></span>';
    313 
    314                 }
    315 
    316                
    317             }
    318 
    319         }   
     275    function clientfile_column_display_company_name( $column_name, $post_id ) {                 
     276       
     277        $this->admin->get_company_column_content_for_post_lists($column_name, $post_id);
    320278       
    321279    }
     
    359317    function clientfile_column_display_category( $column_name, $post_id ) {         
    360318       
    361         if ( 'file_category' != $column_name )
    362             return;
    363        
    364         $id = get_the_ID();     
    365        
    366         $terms = get_the_terms( $id, 'accp_file_categories' );
    367                            
    368         if ( $terms && ! is_wp_error( $terms ) ){
    369    
    370             $file_cats = array();
    371        
    372             foreach ( $terms as $term ) {
    373                 $file_cats[] = $term->name;
    374             }
    375                                
    376             $file_cat_list = join( ", ", $file_cats );
    377        
    378             echo esc_html($file_cat_list);
    379 
    380         }
     319        $this->admin->get_category_column_content_for_post_lists($column_name, $post_id);
    381320       
    382321    }
     
    501440         * Company Filter
    502441         */
    503         if ( $pagenow=='edit.php' && isset($_GET['accp_file_company_filter']) && $_GET['accp_file_company_filter'] != '' && $query->is_main_query() ) {
     442        if ( $pagenow == 'edit.php' && isset($_GET['accp_file_company_filter']) && $_GET['accp_file_company_filter'] != '' && $query->is_main_query() ) {
    504443           
    505444            $query->query_vars['meta_key'] = 'accp_user';
     
    573512        global $post;
    574513
    575         $saved_status = get_post_meta($post->ID, 'file_status', true);
    576 
    577         /**
    578          * If there is no saved status, set the invoice
    579          * status to the default - 'unpaid.'
    580          */
    581         if(is_object($post) && !$saved_status){
    582             update_post_meta($post->ID, 'invoice_status', 'unpaid');   
    583         }       
    584        
     514        $saved_status = get_post_meta($post->ID, 'file_status', true);     
    585515        $defined_statuses = $this->accp_get_defined_file_statuses();       
    586516       
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-invoice.php

    r3004306 r3043713  
    4747        $this->version = $version;
    4848        $this->utilities = new ACCP_Utility_Functions($this->plugin_name, $this->version);
     49        $this->admin = new ARS_Constellation_Client_Portal_Admin($this->plugin_name, $this->version);
    4950
    5051        if( class_exists('ARS_Constellation_Client_Portal_Pro_Admin') ){
     
    276277    function accp_clientinvoice_column_display_company_name( $column_name, $post_id ) {         
    277278       
    278         if ( 'company' != $column_name )
    279             return;
    280        
    281         if( get_post_meta($post_id, 'accp_user', true) ){
    282        
    283             $company_id = get_post_meta($post_id, 'accp_user', true);
    284            
    285             if($company_id != $post_id){
    286                
    287                 $company = get_the_title($company_id);
    288 
    289             }else{
    290 
    291                 $company = null;
    292 
    293             }
    294            
    295             if($company != null){
    296 
    297                 /**
    298                  * Display the company name.
    299                  */
    300                 echo esc_html($company);
    301 
    302                 /**
    303                  * If a file exists, output the file path data that
    304                  * is used when deleting posts.
    305                  */
    306                 $accp_file = get_post_meta($post_id, 'accp_file', true);
    307 
    308                 if ( !empty($accp_file) && isset($accp_file['url']) ) {
    309 
    310                     $accp_file_path = parse_url($accp_file['url'], PHP_URL_PATH);
    311                     $accp_file_full_path = untrailingslashit( get_home_path() ) . $accp_file_path;
    312                     $accp_del_nonce = wp_create_nonce('post_delete_file_nonce');
    313 
    314                     echo '<span class="data-path-container hidden" data-file-path="' . esc_url($accp_file_full_path) . '" data-nonce="' . esc_attr($accp_del_nonce) . '"></span>';
    315 
    316                 }
    317 
    318                
    319             }
    320 
    321         }   
     279        $this->admin->get_company_column_content_for_post_lists($column_name, $post_id);   
    322280       
    323281    }
     
    360318    function accp_clientinvoice_column_display_categories( $column_name, $post_id ) {           
    361319       
    362         if ( 'file_category' != $column_name )
    363             return;
    364        
    365         $id = get_the_ID();     
    366        
    367         $terms = get_the_terms( $id, 'accp_invoice_categories' );   
    368                            
    369         if ( $terms && ! is_wp_error( $terms ) ){
    370    
    371             $file_cats = array();
    372        
    373             foreach ( $terms as $term ) {
    374                 $file_cats[] = $term->name;
    375             }
    376                                
    377             $file_cat_list = join( ", ", $file_cats );
    378        
    379             echo esc_html($file_cat_list);
    380 
    381         }
     320        $this->admin->get_category_column_content_for_post_lists($column_name, $post_id);
    382321       
    383322    }
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-settings.php

    r3004306 r3043713  
    358358
    359359
     360    /**
     361     * File settings page content.
     362     */
    360363    function get_file_settings_page_content(){
    361364
     
    388391
    389392
     393    /**
     394     * Global File settings page content.
     395     */
     396    function get_global_file_settings_page_content(){
     397
     398        if( !is_admin() || !is_user_logged_in() || !current_user_can('manage_options') )
     399            return;
     400
     401        $allowed_html = $this->get_customized_allowed_html_for_wp_kses();
     402        $is_pro = $this->utilities->is_pro_plugin($this->plugin_name);
     403        $html = '';             
     404       
     405        /**
     406         * Section html filter.
     407         */
     408        if( true === $is_pro ){
     409
     410            $html = apply_filters('accp_global_file_settings_page_section_html', $html);
     411
     412        }
     413
     414        if( !empty($html) ){
     415
     416            $form_action = 'options.php';
     417            $instatiate_wp_settings = 'accp-global-file-settings-group';
     418
     419            echo wp_kses( $this->generate_settings_page_html($html, true, true, $form_action, $instatiate_wp_settings), $allowed_html );
     420
     421        }
     422
     423    }
     424
     425
     426    /**
     427     * Client Page settings page content.
     428     */
    390429    function get_client_page_settings_page_content(){
    391430
     
    785824                $p_class = 'accp-function-error';
    786825                $dir_writable_message = 'Error: Your file directory is not writable.  Your file uploads will not work until this issue is resolved.  If you have not yet created a File or Invoice post and uploaded a file, this may be the problem.   Create a test File post and attach a file to it.  This will create the accp-clientfiles upload directory. If this notice is still visable after you have done that, please contact your administrator for more information.';
     826               
    787827            }
    788828           
     
    898938            $page_list['accp-invoice-settings'] = 'Invoices';
    899939            $page_list['accp-file-settings'] = 'Files';
     940            $page_list['accp-global-file-settings'] = 'Global Files';
    900941            $page_list['accp-client-page-settings'] = 'Client Pages';
    901942            $page_list['accp-company-settings'] = 'Companies';
     
    11541195            'data-term-slug' => array(),
    11551196            'step'        => array(),
    1156             'maxlength'   => array(),           
     1197            'maxlength'   => array(),
     1198            'data-post-type' => array(),           
    11571199        );
    11581200
  • constellation-client-portal/trunk/admin/css/ars-constellation-client-portal-admin.css

    r2973972 r3043713  
    106106}
    107107
     108.tax-company-exclude{
     109    margin-bottom: 15px;
     110}
     111
    108112.tax-user-exclude .select2,
    109113.tax-role-exclude .select2,
     114.tax-company-exclude .select2,
    110115.tax-custom-select .select2 {
    111116    width: 95% !important;
     
    730735}
    731736
    732 .accp-spinner.spinner {
     737.accp-spinner.spinner{
    733738    margin-top: 20px;
     739}
     740
     741.accp-spinner.spinner.accp-spinner-after-bulk-edit{
     742    margin-top: 0px;
    734743}
    735744
  • constellation-client-portal/trunk/admin/js/ars-constellation-client-portal-admin.js

    r3004306 r3043713  
    1111        $('table a.submitdelete').click(function (e) {
    1212           
    13             if (window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1 || window.location.href.indexOf("post_status=trash&post_type=accp_clientinvoice") > -1 ) {         
     13            if( window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1 ||
     14                window.location.href.indexOf("post_status=trash&post_type=accp_clientinvoice") > -1 ||
     15                window.location.href.indexOf("post_status=trash&post_type=accp_global_file") > -1
     16            ){         
    1417               
    1518                var file_del_nonce = $('#clientfile-admin-nonce').attr('data-nonce');   
     
    4750
    4851        });
    49 
    50         // Add a notice to the accp_clientfile delete WP List Table
    51         /* if (window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1) {
    52             $('<span class="delete-screen-notice">Deleting posts on this screen will also delete any file attached to the post</span>').insertAfter('input#delete_all');
    53         } */
     52               
    5453
    5554        /**
     
    6463                (
    6564                window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1 ||
    66                 window.location.href.indexOf("post_status=trash&post_type=accp_clientinvoice") > -1
     65                window.location.href.indexOf("post_status=trash&post_type=accp_clientinvoice") > -1 ||
     66                window.location.href.indexOf("post_status=trash&post_type=accp_global_file") > -1
    6767                ) &&
    6868                $('#bulk-action-selector-top').val() == 'delete'
     
    116116         $('#delete_all').click(function (e) {     
    117117           
    118             if (window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1 || window.location.href.indexOf("post_status=trash&post_type=accp_clientinvoice") > -1 ) {
     118            if (window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1 || window.location.href.indexOf("post_status=trash&post_type=accp_clientinvoice") > -1 || window.location.href.indexOf("post_status=trash&post_type=accp_global_file") > -1 ) {   
    119119
    120120                e.preventDefault();
     
    124124                if(window.location.href.indexOf("post_status=trash&post_type=accp_clientfile") > -1){
    125125                    var post_type = 'accp_clientfile';
     126                }
     127
     128                if(window.location.href.indexOf("post_status=trash&post_type=accp_global_file") > -1){
     129                    var post_type = 'accp_global_file';
    126130                }
    127131
     
    291295                var generate_nonce = $('#accp-generate-dir-btn').attr('data-nonce');
    292296                var dir_name = $('#accp-specify-dir-name').val();
     297
     298                if( 'global-files' === dir_name.toLowerCase().replace(/\s/g, '') ||
     299                    'globalfiles' === dir_name.toLowerCase().replace(/\s/g, '') ||
     300                    'global_files' === dir_name.toLowerCase().replace(/\s/g, '') ||
     301                    'global.files' === dir_name.toLowerCase().replace(/\s/g, '')
     302                 ){
     303
     304                    alert('The '+dir_name.toLowerCase().replace(/\s/g, '')+' directory name is reserved and cannot be used.  Please enter a different name.');
     305
     306                    return;
     307
     308                }
     309
    293310                var spinner_elem = '<span class="accp-dir-assign-spinner spinner" style="float: none;"></span>';
    294 
    295311                var move_files = '';
    296312                var update_links = '';
     
    512528
    513529                    },
    514                     success: function(data){
    515 
    516                         //dev
    517                         console.log(data);
     530                    success: function(data){                   
    518531
    519532                        try {
     
    717730        });
    718731
    719         $('#bulk_edit').on( 'click', function() {       
    720 
    721             if( $('#invoice-status-bulk-edit-select').length ){         
    722                
    723                 var post_ids = new Array();
    724                 var invoice_status = $('#invoice-status-bulk-edit-select').val();
    725                 var nonce = $('#accp-invoice-bulk-edit-section').attr('data-nonce');
    726 
    727                 $( 'tr#bulk-edit ul#bulk-titles-list li button' ).each( function() {
    728                     post_ids.push( $( this ).attr( 'id' ).replace( /^(_)/i, '' ) );
    729                 });     
    730                
    731                 if(invoice_status != "-1"){
    732                
    733                     $.ajax({
    734                         url: ajaxurl,
    735                         type: 'POST',
    736                         async: false,                       
    737                         data: {
    738                             action: 'accp_save_invoice_bulk_edit',
    739                             post_ids: post_ids,
    740                             invoice_status: invoice_status,
    741                             nonce: nonce
    742                         },
    743                         success: function(data){               
    744                                        
    745                            
    746                         },
    747                         error: function(jqXHR, textStatus, errorThrown){
    748                             console.log(textStatus, errorThrown);
    749                             console.log(jqXHR);
    750                         },
    751 
    752                     });
    753 
    754                 }
    755 
    756 
    757             }
    758                        
    759         });
    760 
    761 
    762         $('#bulk_edit').on( 'click', function() {       
    763 
    764             if( $('#file-status-bulk-edit-select').length ){       
     732        $('#bulk_edit').on( 'click', function(e) {     
     733
     734            accp_save_invoice_bulk_edit(e);
     735
     736            accp_save_file_bulk_edit(e);
     737
     738            accp_save_global_file_bulk_edit(e);
     739                       
     740        });
     741
     742
     743    }); // End document ready
     744
     745
     746    function accp_save_invoice_bulk_edit(e){
     747
     748        if( $('#invoice-status-bulk-edit-select').length ){
     749           
     750            /**
     751             * Disable pointer events instead of setting
     752             * a "disabled" property to allow native WP
     753             * post data to be saved normally.
     754             */
     755            accp_disable_pointer_events_by_event_target(e);
     756            accp_add_and_show_status_spinner_after_bulk_add_buttons(e);
     757               
     758            var post_ids = new Array();
     759            var invoice_status = $('#invoice-status-bulk-edit-select').val();
     760            var nonce = $('#accp-invoice-bulk-edit-section').attr('data-nonce');
     761
     762            $( 'tr#bulk-edit ul#bulk-titles-list li button' ).each( function() {
     763                post_ids.push( $( this ).attr( 'id' ).replace( /^(_)/i, '' ) );
     764            });     
     765           
     766            if(invoice_status != "-1"){
     767           
     768                $.ajax({
     769                    url: ajaxurl,
     770                    type: 'POST',
     771                    async: false,                       
     772                    data: {
     773                        action: 'accp_save_invoice_bulk_edit',
     774                        post_ids: post_ids,
     775                        invoice_status: invoice_status,
     776                        nonce: nonce
     777                    },
     778                    success: function(data){               
     779                                   
     780                       
     781                    },
     782                    error: function(jqXHR, textStatus, errorThrown){
     783
     784                        accp_reset_pointer_events_by_selector('#bulk-edit');
     785                        $('.accp-spinner-after-bulk-edit').remove();
     786
     787                        console.log(textStatus, errorThrown);
     788                        console.log(jqXHR);
     789                    },
     790
     791                });
     792
     793            }
     794
     795        }
     796
     797    }
     798
     799    function accp_save_file_bulk_edit(e){
     800
     801        if( $('#file-status-bulk-edit-select').length ){
     802
     803            /**
     804             * Disable pointer events instead of setting
     805             * a "disabled" property to allow native WP
     806             * post data to be saved normally.
     807             */
     808            accp_disable_pointer_events_by_event_target(e);
     809            accp_add_and_show_status_spinner_after_bulk_add_buttons(e);
    765810                               
    766                 var post_ids = new Array();
    767                 var file_status = $('#file-status-bulk-edit-select').val();
    768                 var nonce = $('#accp-file-bulk-edit-section').attr('data-nonce');
    769 
    770                 $( 'tr#bulk-edit ul#bulk-titles-list li button' ).each( function() {
    771                     post_ids.push( $( this ).attr( 'id' ).replace( /^(_)/i, '' ) );
    772                 });
    773 
    774                 console.log(post_ids);
    775                
    776                 if(file_status != "-1"){
    777                
    778                     $.ajax({
    779                         url: ajaxurl,
    780                         type: 'POST',
    781                         async: false,                       
    782                         data: {
    783                             action: 'accp_save_file_bulk_edit',
    784                             post_ids: post_ids,
    785                             file_status: file_status,
    786                             nonce: nonce
    787                         },
    788                         success: function(data){               
    789                                        
    790                             console.log(data);
    791                         },
    792                         error: function(jqXHR, textStatus, errorThrown){
    793                             console.log(textStatus, errorThrown);
    794                             console.log(jqXHR);
    795                         },
    796 
    797                     });
    798 
    799                 }
    800 
    801 
    802             }
    803                        
    804         });
    805 
    806     }); // End document ready
     811            var post_ids = new Array();
     812            var file_status = $('#file-status-bulk-edit-select').val();
     813            var nonce = $('#accp-file-bulk-edit-section').attr('data-nonce');
     814
     815            $( 'tr#bulk-edit ul#bulk-titles-list li button' ).each( function() {
     816                post_ids.push( $( this ).attr( 'id' ).replace( /^(_)/i, '' ) );
     817            });                 
     818           
     819            if(file_status != "-1"){
     820           
     821                $.ajax({
     822                    url: ajaxurl,
     823                    type: 'POST',
     824                    async: false,                       
     825                    data: {
     826                        action: 'accp_save_file_bulk_edit',
     827                        post_ids: post_ids,
     828                        file_status: file_status,
     829                        nonce: nonce
     830                    },
     831                    success: function(data){                                                   
     832                       
     833
     834                    },
     835                    error: function(jqXHR, textStatus, errorThrown){
     836
     837                        accp_reset_pointer_events_by_selector('#bulk-edit');
     838                        $('.accp-spinner-after-bulk-edit').remove();                       
     839
     840                        console.log(textStatus, errorThrown);
     841                        console.log(jqXHR);
     842                    },
     843
     844                });
     845
     846            }
     847
     848        }
     849
     850    }
     851
     852
     853    function accp_save_global_file_bulk_edit(e){
     854
     855        if( $('#global-file-status-bulk-edit-select').length ){
     856
     857            /**
     858             * Disable pointer events instead of setting
     859             * a "disabled" property to allow native WP
     860             * post data to be saved normally.
     861             */
     862            accp_disable_pointer_events_by_event_target(e);
     863            accp_add_and_show_status_spinner_after_bulk_add_buttons(e);             
     864                               
     865            var post_ids = new Array();
     866            var file_status = $('#global-file-status-bulk-edit-select').val();
     867            var nonce = $('#accp-file-bulk-edit-section').attr('data-nonce');
     868
     869            $( 'tr#bulk-edit ul#bulk-titles-list li button' ).each( function() {
     870                post_ids.push( $( this ).attr( 'id' ).replace( /^(_)/i, '' ) );
     871            });         
     872           
     873            if(file_status != "-1"){
     874           
     875                $.ajax({
     876                    url: ajaxurl,
     877                    type: 'POST',
     878                    async: false,                       
     879                    data: {
     880                        action: 'accp_save_global_file_bulk_edit',
     881                        post_ids: post_ids,
     882                        file_status: file_status,
     883                        nonce: nonce
     884                    },
     885                    success: function(data){                                                                       
     886                       
     887                       
     888
     889                    },
     890                    error: function(jqXHR, textStatus, errorThrown){
     891
     892                        accp_reset_pointer_events_by_selector('#bulk-edit');
     893                        $('.accp-spinner-after-bulk-edit').remove();
     894
     895                        console.log(textStatus, errorThrown);
     896                        console.log(jqXHR);
     897                    },
     898
     899                });
     900
     901            }
     902
     903        }
     904
     905    }
    807906   
    808907
     
    860959
    861960
    862     function accp_admin_tab_click_actions(){
    863        
    864         $(document).on('click','ul.accp-settings-tabs li', function() {
    865 
    866             // Change the tab menu display
    867             $('ul.accp-settings-tabs li').removeAttr('data-tab-status');
    868             $(this).attr('data-tab-status', 'active');
    869 
    870             // Display the active tab
    871             var active_id = $(this).attr('data-tab-id');
    872             var active_tab = $('.accp-settings-tab[data-tab-id="' + active_id  + '"]');
    873 
    874             // Remove active status from all other tabs
    875             $('.accp-settings-tab').removeAttr('data-tab-content-status');
    876 
    877             // Make the new tab active
    878             $(active_tab).attr('data-tab-content-status', 'active');
    879 
    880         });
    881 
    882     }
    883 
    884     function accp_admin_load_last_active_tab_on_load(){
    885 
    886         if($('ul.accp-settings-tabs li').length > -1){     
    887 
    888             var url = document.location.toString();
    889 
    890             if (url.match('#')) {
    891                
    892                 var active_id = url.split('#')[1];
    893 
    894                 // Change the tab menu display
    895                 $('ul.accp-settings-tabs li').removeAttr('data-tab-status');
    896                 $('[data-tab-id = '+ active_id +' ]').attr('data-tab-status', 'active');
    897                
    898                 var active_id = $('[data-tab-id = '+ active_id +' ]').attr('data-tab-id');
    899                 var active_tab = $('.accp-settings-tab[data-tab-id="' + active_id  + '"]');
    900 
    901                 // Remove active status from all other tabs
    902                 $('.accp-settings-tab').removeAttr('data-tab-content-status');
    903 
    904                 // Make the new tab active
    905                 $(active_tab).attr('data-tab-content-status', 'active');
    906 
    907             }
    908 
    909         }
    910 
    911     }
    912 
    913961    function accp_add_and_show_status_spinner(e){
    914962
     
    922970       
    923971        return new_spinner_class;
     972
     973    }
     974
     975
     976    function accp_add_and_show_status_spinner_after_bulk_add_buttons(e){
     977
     978        var target_elem = e.target.closest('.submit.inline-edit-save');
     979        var unique_class = 'accp-' + Math.random().toString(36).slice(2) + '-spinner';
     980        var spinner_elem = '<span class="'+unique_class+' accp-spinner spinner accp-spinner-after-bulk-edit" style="float: none;"></span>';
     981        var new_spinner_class = '.' + unique_class + '.accp-spinner.spinner';
     982
     983        $(spinner_elem).appendTo(target_elem);
     984        $(new_spinner_class).css('visibility', 'visible');
     985       
     986        return new_spinner_class;
     987
     988    }
     989
     990
     991    function accp_disable_element_by_event_target(e){
     992
     993        var target_elem = e.target;
     994
     995        $(target_elem).prop('disabled', true);
     996
     997    }
     998
     999
     1000    function accp_disable_pointer_events_by_event_target(e){
     1001
     1002        var target_elem = e.target;
     1003
     1004        $(target_elem).attr('style', 'pointer-events: none;');
     1005
     1006    }
     1007
     1008    function accp_reset_pointer_events_by_selector(selector){
     1009
     1010        $(selector).attr('style', 'pointer-events: all;');
     1011
     1012    }
     1013
     1014
     1015    function accp_remove_disabled_prop_from_element(selector){
     1016
     1017        $(selector).prop('disabled', false);       
    9241018
    9251019    }
  • constellation-client-portal/trunk/ars-constellation-client-portal.php

    r3030228 r3043713  
    55 * Plugin URI:        https://adrianrodriguezstudios.com/constellation-client-portal/
    66 * Description:       Create private pages for each of your clients, post private files, and protect your client files from unauthorized users and search engines.  <strong>Important:</strong> All Site-level File Protection features will cease to function if the plugin is disabled or uninstalled.
    7  * Version:           1.7.6
     7 * Version:           1.8.0
    88 * Author:            ARS
    99 * Author URI:        https://adrianrodriguezstudios.com
     
    5555     */
    5656    define('ACCP_PLUGIN_NAME', 'ARS_CONSTELLATION_CLIENT_PORTAL');
    57     define('ACCP_PLUGIN_VERSION', '1.7.6'); // Change the version in the header as well.
     57    define('ACCP_PLUGIN_VERSION', '1.8.0'); // Change the version in the header as well.
    5858    define( ACCP_PLUGIN_NAME, ACCP_PLUGIN_VERSION );
    5959    define('ACCP_PLUGIN_FILE_NAME', __FILE__);
  • constellation-client-portal/trunk/public/shortcodes/class-ars-constellation-client-portal-list-shortcodes.php

    r3018869 r3043713  
    113113
    114114    /**
    115      * Generate the shortcode content.
     115     * Generate the shortcode content (for non-global shortcodes).
    116116     *
    117117     * @param array $atts - array of atts passed in via the shortcode.
     
    150150        if( false === $authorized_company_id || !$authorized_company_id )
    151151            return;
    152        
     152
    153153
    154154        /**
     
    163163            $atts = shortcode_atts( $this->get_clientfile_core_shortcode_atts(), $atts );
    164164
    165         }                
     165        }       
    166166
    167167
     
    452452        return apply_filters( 'accp_update_invoice_atts_array', $atts );
    453453
    454     }   
     454    }
     455   
     456   
     457    /**
     458     * Get the core atts for the global_file shortcode.
     459     *
     460     * @return array $atts - array of defined shortcode atts.
     461     */
     462    function get_global_file_core_shortcode_atts(){
     463
     464        $atts = array(
     465            'id' => '', // This is reserved and is for internal use only.
     466            'css_id' => '', // Optional ID for the accp_documents_filelist list div.  Defaults to null.
     467            'class' => '', // Optional additional class(es) for the accp_documents_filelist list div.  Defaults to null.
     468            'categories' => '', // Category atts can be entered as the Slug or ID in the shortcode
     469            'file_status' => '', // File status to show - file status slug or null. Defaults to null.
     470            'display_number' => '', // This is the number of posts per page
     471            'order_by' => '', // This allows ordering by post title - default is post date - options "title" or "date"
     472            'order' => '', // This can be set as ASC or DESC - default is DESC     
     473            'show_excerpt' => '', // Displays truncated text from the post content field
     474            'show_thumbnail' => '', // Displays the posts featured image in the loop
     475            'excerpt_length' => '', // Accepts the number of words for the excerpt
     476            'thumbnail_size' => '', // Enter the thumbnail slug defined in the theme
     477            'align_thumbnail' => '', // center, left, right, float-left, float-right
     478            'show_post_date' => '', // Display the post date - default is false     
     479            'list_id' => '', // Integer - Useful when there are multiple shortcode lists on the same page - default is null
     480            'link_title' => '' // nolink or empty.  Used to disable post link titles - default is null.
     481        );
     482
     483        return apply_filters( 'accp_update_global_file_atts_array', $atts );
     484
     485    }
    455486
    456487
     
    17491780     * @return string $html - The section html.
    17501781     */
    1751     private function get_list_item_title_html($post_id, $user_id, $link_title){
     1782    function get_list_item_title_html($post_id, $user_id, $link_title){
    17521783
    17531784        if( !is_user_logged_in() || is_admin() )
     
    17591790        /**
    17601791         * Verify Authorization.
    1761          */       
     1792         */
     1793        $core_authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
     1794
    17621795        if ( true === $this->is_pro ){                 
    17631796           
    1764             $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );
    1765             $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     1797            $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );           
     1798            $is_global_file = $core_authorization->is_global_file_post($post_id);
     1799
     1800            if( true === $is_global_file ){
     1801
     1802                $check_authorization = $authorization->verify_global_file_post_authorization_pro($post_id, $user_id);
     1803
     1804            }else{
     1805
     1806                $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     1807
     1808            }
    17661809
    17671810        }else{                     
     
    17701813             * Use the default file check if this is the Core version
    17711814             * to determine if access should be granted.
    1772              */
    1773             $authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
    1774             $check_authorization = $authorization->verify_page_or_post_authorization($post_id, $user_id);
     1815             */           
     1816            $check_authorization = $core_authorization->verify_page_or_post_authorization($post_id, $user_id);
    17751817
    17761818        }
     
    18111853     * @return string $html - The section html.
    18121854     */
    1813     private function get_list_item_meta_html($post_id, $user_id, $atts, $due_date, $past_due_notice){
     1855    function get_list_item_meta_html($post_id, $user_id, $atts, $due_date, $past_due_notice){
    18141856
    18151857        if( !is_user_logged_in() || is_admin() )
     
    18211863        /**
    18221864         * Verify Authorization.
    1823          */       
     1865         */
     1866        $core_authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
     1867
    18241868        if ( true === $this->is_pro ){                 
    18251869           
    1826             $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );
    1827             $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     1870            $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );           
     1871            $is_global_file = $core_authorization->is_global_file_post($post_id);
     1872
     1873            if( true === $is_global_file ){
     1874
     1875                $check_authorization = $authorization->verify_global_file_post_authorization_pro($post_id, $user_id);
     1876
     1877            }else{
     1878
     1879                $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     1880
     1881            }
    18281882
    18291883        }else{                     
     
    18321886             * Use the default file check if this is the Core version
    18331887             * to determine if access should be granted.
    1834              */
    1835             $authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
    1836             $check_authorization = $authorization->verify_page_or_post_authorization($post_id, $user_id);
     1888             */           
     1889            $check_authorization = $core_authorization->verify_page_or_post_authorization($post_id, $user_id);
    18371890
    18381891        }
     
    18801933     * @return string $html - The section html.
    18811934     */
    1882     private function get_list_item_thumbnail_html($post_id, $user_id, $atts){
     1935    function get_list_item_thumbnail_html($post_id, $user_id, $atts){
    18831936
    18841937        if( !is_user_logged_in() || is_admin() )
     
    18901943        /**
    18911944         * Verify Authorization.
    1892          */       
     1945         */
     1946        $core_authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
     1947
    18931948        if ( true === $this->is_pro ){                 
    18941949           
    1895             $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );
    1896             $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     1950            $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );           
     1951            $is_global_file = $core_authorization->is_global_file_post($post_id);
     1952
     1953            if( true === $is_global_file ){
     1954
     1955                $check_authorization = $authorization->verify_global_file_post_authorization_pro($post_id, $user_id);
     1956
     1957            }else{
     1958
     1959                $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     1960
     1961            }
    18971962
    18981963        }else{                     
     
    19011966             * Use the default file check if this is the Core version
    19021967             * to determine if access should be granted.
    1903              */
    1904             $authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
    1905             $check_authorization = $authorization->verify_page_or_post_authorization($post_id, $user_id);
     1968             */           
     1969            $check_authorization = $core_authorization->verify_page_or_post_authorization($post_id, $user_id);
    19061970
    19071971        }
     
    19412005     * @return string $html - The section html.
    19422006     */
    1943     private function get_list_item_excerpt_html($post_id, $user_id, $atts){
     2007    function get_list_item_excerpt_html($post_id, $user_id, $atts){
    19442008
    19452009        if( !is_user_logged_in() || is_admin() )
     
    19512015        /**
    19522016         * Verify Authorization.
    1953          */       
     2017         */
     2018        $core_authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
     2019
    19542020        if ( true === $this->is_pro ){                 
    19552021           
    1956             $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );
    1957             $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     2022            $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );           
     2023            $is_global_file = $core_authorization->is_global_file_post($post_id);
     2024
     2025            if( true === $is_global_file ){
     2026
     2027                $check_authorization = $authorization->verify_global_file_post_authorization_pro($post_id, $user_id);
     2028
     2029            }else{
     2030
     2031                $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     2032
     2033            }
    19582034
    19592035        }else{                     
     
    19622038             * Use the default file check if this is the Core version
    19632039             * to determine if access should be granted.
    1964              */
    1965             $authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
    1966             $check_authorization = $authorization->verify_page_or_post_authorization($post_id, $user_id);
     2040             */           
     2041            $check_authorization = $core_authorization->verify_page_or_post_authorization($post_id, $user_id);
    19672042
    19682043        }
     
    20042079     * @return string $html - The section html.
    20052080     */
    2006     private function get_list_item_download_section_html($post_id, $user_id, $attached_file, $atts){
     2081    function get_list_item_download_section_html($post_id, $user_id, $attached_file, $atts){
    20072082
    20082083        if( !is_user_logged_in() || is_admin() )
     
    20142089        /**
    20152090         * Verify Authorization.
    2016          */       
     2091         */
     2092        $core_authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
     2093
    20172094        if ( true === $this->is_pro ){                 
    20182095           
    2019             $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );
    2020             $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     2096            $authorization = new ARS_Constellation_Client_Portal_Pro_Authorization( $this->plugin_name, $this->version );           
     2097            $is_global_file = $core_authorization->is_global_file_post($post_id);
     2098
     2099            if( true === $is_global_file ){
     2100
     2101                $check_authorization = $authorization->verify_global_file_post_authorization_pro($post_id, $user_id);
     2102
     2103            }else{
     2104
     2105                $check_authorization = $authorization->verify_page_or_post_authorization_pro($post_id, $user_id);                       
     2106
     2107            }
    20212108
    20222109        }else{                     
     
    20252112             * Use the default file check if this is the Core version
    20262113             * to determine if access should be granted.
    2027              */
    2028             $authorization = new ARS_Constellation_Client_Portal_Core_Authorization( $this->plugin_name, $this->version );
    2029             $check_authorization = $authorization->verify_page_or_post_authorization($post_id, $user_id);
     2114             */           
     2115            $check_authorization = $core_authorization->verify_page_or_post_authorization($post_id, $user_id);
    20302116
    20312117        }
Note: See TracChangeset for help on using the changeset viewer.