Changeset 1163814
- Timestamp:
- 05/20/2015 05:17:00 AM (11 years ago)
- Location:
- awesome-support/trunk
- Files:
-
- 6 edited
-
awesome-support.php (modified) (2 diffs)
-
includes/admin/settings/settings-general.php (modified) (1 diff)
-
includes/functions-general.php (modified) (1 diff)
-
includes/functions-post.php (modified) (2 diffs)
-
includes/functions-user.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
awesome-support/trunk/awesome-support.php
r1163297 r1163814 11 11 * Plugin URI: http://getawesomesupport.com 12 12 * 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. 813 * Version: 3.1.10 14 14 * Author: ThemeAvenue 15 15 * Author URI: http://themeavenue.net … … 29 29 *----------------------------------------------------------------------------*/ 30 30 31 define( 'WPAS_VERSION', '3.1. 8' );31 define( 'WPAS_VERSION', '3.1.10' ); 32 32 define( 'WPAS_DB_VERSION', '1' ); 33 33 define( 'WPAS_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); -
awesome-support/trunk/includes/admin/settings/settings-general.php
r1163772 r1163814 28 28 'type' => 'select', 29 29 '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(), 31 31 'default' => '' 32 32 ), -
awesome-support/trunk/includes/functions-general.php
r1160923 r1163814 568 568 569 569 } 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 */ 581 function 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 733 733 } 734 734 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' ) ) ); 742 736 $agent = array(); 743 737 744 738 foreach ( $users as $user ) { 745 739 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'] ) { 776 772 $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 783 773 } 784 774 … … 1077 1067 ); 1078 1068 1079 $editor = wp_editor( $editor_content, $editor_id, $settings ); 1080 1081 echo $editor; 1069 wp_editor( $editor_content, $editor_id, $settings ); 1070 1082 1071 die(); 1083 1072 -
awesome-support/trunk/includes/functions-user.php
r1163297 r1163814 357 357 358 358 /* 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) 360 360 361 361 /* Check if we have a result already cached. */ … … 364 364 /* If there is a cached result we return it and don't run the expensive query. */ 365 365 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 } 367 371 } 368 372 … … 370 374 $all_users = get_users(); 371 375 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 372 388 /* Loop through the users list and filter them */ 373 389 foreach ( $all_users as $user ) { 374 390 375 391 /* 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 ) ) { 378 394 continue; 379 395 } … … 381 397 382 398 /* 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 ) ) { 385 401 continue; 386 402 } … … 394 410 /* Now we add this user to our final list. */ 395 411 array_push( $list, $user ); 412 array_push( $users_ids, $user->ID ); 396 413 397 414 } 398 415 399 416 /* 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 ) ); 401 418 402 419 return apply_filters( 'wpas_get_users', $list ); … … 543 560 function wpas_support_users_dropdown( $args = array() ) { 544 561 $args['cap_exclude'] = 'edit_ticket'; 562 $args['cap'] = 'create_ticket'; 545 563 echo wpas_users_dropdown( $args ); 546 564 } -
awesome-support/trunk/readme.txt
r1163773 r1163814 6 6 Requires at least: 3.5.1 7 7 Tested up to: 4.3 8 Stable tag: 3.1. 98 Stable tag: 3.1.10 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 152 152 153 153 == 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 154 159 155 160 = 3.1.9 - 2015-05-20 =
Note: See TracChangeset
for help on using the changeset viewer.