Plugin Directory

Changeset 1163814


Ignore:
Timestamp:
05/20/2015 05:17:00 AM (11 years ago)
Author:
themeavenue
Message:

Update files to 3.1.10

Location:
awesome-support/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • awesome-support/trunk/awesome-support.php

    r1163297 r1163814  
    1111 * Plugin URI:        http://getawesomesupport.com
    1212 * Description:       Awesome Support is a great ticketing system that will help you improve your customer satisfaction by providing a unique customer support experience.
    13  * Version:           3.1.8
     13 * Version:           3.1.10
    1414 * Author:            ThemeAvenue
    1515 * Author URI:        http://themeavenue.net
     
    2929 *----------------------------------------------------------------------------*/
    3030
    31 define( 'WPAS_VERSION',           '3.1.8' );
     31define( 'WPAS_VERSION',           '3.1.10' );
    3232define( 'WPAS_DB_VERSION',        '1' );
    3333define( 'WPAS_URL',               trailingslashit( plugin_dir_url( __FILE__ ) ) );
  • awesome-support/trunk/includes/admin/settings/settings-general.php

    r1163772 r1163814  
    2828                    'type'    => 'select',
    2929                    'desc'    => __( 'Who to assign tickets to by default (if auto-assignment is enabled, this will only be used in case an assignment rule is incorrect).', 'wpas' ),
    30                     'options' => wpas_list_users( 'edit_ticket' ),
     30                    'options' => isset( $_GET['post_type'] ) && 'ticket' === $_GET['post_type'] && isset( $_GET['page'] ) && 'settings' === $_GET['page'] ? wpas_list_users( 'edit_ticket' ) : array(),
    3131                    'default' => ''
    3232                ),
  • awesome-support/trunk/includes/functions-general.php

    r1160923 r1163814  
    568568
    569569}
     570
     571/**
     572 * Shuffle an associative array.
     573 *
     574 * @param array $list The array to shuffle
     575 *
     576 * @return array Shuffled array
     577 *
     578 * @link  http://php.net/manual/en/function.shuffle.php#99624
     579 * @since 3.1.10
     580 */
     581function shuffle_assoc( $list ) {
     582
     583    if ( ! is_array( $list ) ) {
     584        return $list;
     585    }
     586
     587    $keys   = array_keys( $list );
     588    $random = array();
     589
     590    shuffle( $keys );
     591
     592    foreach ( $keys as $key ) {
     593        $random[ $key ] = $list[ $key ];
     594    }
     595
     596    return $random;
     597
     598}
  • awesome-support/trunk/includes/functions-post.php

    r1163297 r1163814  
    733733    }
    734734
    735     $users = get_transient( 'wpas_list_agents' );
    736 
    737     if ( false === $users ) {
    738         $users = get_users( array( 'orderby' => 'wpas_random' ) ); // We use a unique and non-existing orderby parameter so that we can identify the query in pre_user_query
    739         set_transient( 'wpas_list_agents', $users, 24 * 60 * 60 );
    740     }
    741 
     735    $users = shuffle_assoc( wpas_get_users( array( 'cap' => 'edit_ticket' ) ) );
    742736    $agent = array();
    743737
    744738    foreach ( $users as $user ) {
    745739
    746         if ( array_key_exists( 'edit_ticket', $user->allcaps ) ) {
    747 
    748             $posts_args = array(
    749                 'post_type'              => 'ticket',
    750                 'post_status'            => 'any',
    751                 'posts_per_page'         => -1,
    752                 'no_found_rows'          => true,
    753                 'cache_results'          => false,
    754                 'update_post_term_cache' => false,
    755                 'update_post_meta_cache' => false,
    756                 'meta_query'             => array(
    757                     array(
    758                         'key'     => '_wpas_status',
    759                         'value'   => 'open',
    760                         'type'    => 'CHAR',
    761                         'compare' => '='
    762                     ),
    763                     array(
    764                         'key'     => '_wpas_assignee',
    765                         'value'   => $user->ID,
    766                         'type'    => 'NUMERIC',
    767                         'compare' => '='
    768                     ),
    769                 )
    770             );
    771 
    772             $open_tickets = new WP_Query( $posts_args );
    773             $count        = count( $open_tickets->posts ); // Total number of open tickets for this agent
    774 
    775             if ( empty( $agent ) ) {
     740        $posts_args = array(
     741            'post_type'              => 'ticket',
     742            'post_status'            => 'any',
     743            'posts_per_page'         => - 1,
     744            'no_found_rows'          => true,
     745            'cache_results'          => false,
     746            'update_post_term_cache' => false,
     747            'update_post_meta_cache' => false,
     748            'meta_query'             => array(
     749                array(
     750                    'key'     => '_wpas_status',
     751                    'value'   => 'open',
     752                    'type'    => 'CHAR',
     753                    'compare' => '='
     754                ),
     755                array(
     756                    'key'     => '_wpas_assignee',
     757                    'value'   => $user->ID,
     758                    'type'    => 'NUMERIC',
     759                    'compare' => '='
     760                ),
     761            )
     762        );
     763
     764        $open_tickets = new WP_Query( $posts_args );
     765        $count        = count( $open_tickets->posts ); // Total number of open tickets for this agent
     766
     767        if ( empty( $agent ) ) {
     768            $agent = array( 'tickets' => $count, 'user_id' => $user->ID );
     769        } else {
     770
     771            if ( $count < $agent['tickets'] ) {
    776772                $agent = array( 'tickets' => $count, 'user_id' => $user->ID );
    777             } else {
    778 
    779                 if ( $count < $agent['tickets'] ) {
    780                     $agent = array( 'tickets' => $count, 'user_id' => $user->ID );
    781                 }
    782 
    783773            }
    784774
     
    10771067    );
    10781068
    1079     $editor = wp_editor( $editor_content, $editor_id, $settings );
    1080 
    1081     echo $editor;
     1069    wp_editor( $editor_content, $editor_id, $settings );
     1070
    10821071    die();
    10831072
  • awesome-support/trunk/includes/functions-user.php

    r1163297 r1163814  
    357357
    358358    /* Get the hash of the arguments that's used for caching the result. */
    359     $hash = md5( serialize( $args ) );
     359    $hash = substr( md5( serialize( $args ) ), 0, 10 ); // Limit the length of the hash in order to avoid issues with option_name being too long in the database (https://core.trac.wordpress.org/ticket/15058)
    360360
    361361    /* Check if we have a result already cached. */
     
    364364    /* If there is a cached result we return it and don't run the expensive query. */
    365365    if ( false !== $result ) {
    366         return apply_filters( 'wpas_get_users', $result );
     366        if ( is_object( $result[0] ) && is_a( $result[0], 'WP_User' ) ) {
     367            delete_transient( "wpas_list_users_$hash" ); // Invalidate the previous cache
     368        } else {
     369            return apply_filters( 'wpas_get_users', get_users( array( 'include' => (array) $result ) ) );
     370        }
    367371    }
    368372
     
    370374    $all_users = get_users();
    371375
     376    /**
     377     * Store the selected user IDs for caching.
     378     *
     379     * On database with a lot of users, storing the entire WP_User
     380     * object causes issues (eg. "Got a packet bigger than ‘max_allowed_packet’ bytes").
     381     * In order to avoid that we only store the user IDs and then get the users list
     382     * later on only including those IDs.
     383     *
     384     * @since 3.1.10
     385     */
     386    $users_ids = array();
     387
    372388    /* Loop through the users list and filter them */
    373389    foreach ( $all_users as $user ) {
    374390
    375391        /* Check for required capability */
    376         if ( ! empty( $cap ) ) {
    377             if ( ! $user->has_cap( $args['cap'] ) ) {
     392        if ( ! empty( $args['cap'] ) ) {
     393            if ( ! array_key_exists( $args['cap'], $user->allcaps ) ) {
    378394                continue;
    379395            }
     
    381397
    382398        /* Check for excluded capability */
    383         if ( ! empty( $cap_exclude ) ) {
    384             if ( $user->has_cap( $args['cap_exclude'] ) ) {
     399        if ( ! empty( $args['cap_exclude'] ) ) {
     400            if ( array_key_exists( $args['cap_exclude'], $user->allcaps ) ) {
    385401                continue;
    386402            }
     
    394410        /* Now we add this user to our final list. */
    395411        array_push( $list, $user );
     412        array_push( $users_ids, $user->ID );
    396413
    397414    }
    398415
    399416    /* Let's cache the result so that we can avoid running this query too many times. */
    400     set_transient( "wpas_list_users_$hash", $list, apply_filters( 'wpas_list_users_cache_expiration', 60 * 60 * 24 ) );
     417    set_transient( "wpas_list_users_$hash", $users_ids, apply_filters( 'wpas_list_users_cache_expiration', 60 * 60 * 24 ) );
    401418
    402419    return apply_filters( 'wpas_get_users', $list );
     
    543560function wpas_support_users_dropdown( $args = array() ) {
    544561    $args['cap_exclude'] = 'edit_ticket';
     562    $args['cap']         = 'create_ticket';
    545563    echo wpas_users_dropdown( $args );
    546564}
  • awesome-support/trunk/readme.txt

    r1163773 r1163814  
    66Requires at least: 3.5.1
    77Tested up to: 4.3
    8 Stable tag: 3.1.9
     8Stable tag: 3.1.10
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    152152
    153153== Changelog ==
     154
     155= 3.1.10 - 2015-05-20 =
     156
     157* More performance improvements
     158* Fixes "Got a packet bigger than ‘max_allowed_packet’ bytes" issue on sites with lots of users
    154159
    155160= 3.1.9 - 2015-05-20 =
Note: See TracChangeset for help on using the changeset viewer.