當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BP_Groups_Member::prime_group_admins_mods_cache方法代碼示例

本文整理匯總了PHP中BP_Groups_Member::prime_group_admins_mods_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP BP_Groups_Member::prime_group_admins_mods_cache方法的具體用法?PHP BP_Groups_Member::prime_group_admins_mods_cache怎麽用?PHP BP_Groups_Member::prime_group_admins_mods_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BP_Groups_Member的用法示例。


在下文中一共展示了BP_Groups_Member::prime_group_admins_mods_cache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get


//.........這裏部分代碼省略.........
         $sql['from'] .= " JOIN {$bp->groups->table_name_groupmeta} gm_last_activity on ( g.id = gm_last_activity.group_id )";
         $where_conditions['last_activity'] = "gm_last_activity.meta_key = 'last_activity'";
     }
     // Sanitize 'order'.
     $order = bp_esc_sql_order($order);
     /**
      * Filters the converted 'orderby' term.
      *
      * @since 2.1.0
      *
      * @param string $value   Converted 'orderby' term.
      * @param string $orderby Original orderby value.
      * @param string $value   Parsed 'type' value for the get method.
      */
     $orderby = apply_filters('bp_groups_get_orderby_converted_by_term', self::convert_orderby_to_order_by_term($orderby), $orderby, $r['type']);
     // Random order is a special case.
     if ('rand()' === $orderby) {
         $sql['orderby'] = "ORDER BY rand()";
     } else {
         $sql['orderby'] = "ORDER BY {$orderby} {$order}";
     }
     if (!empty($r['per_page']) && !empty($r['page']) && $r['per_page'] != -1) {
         $sql['pagination'] = $wpdb->prepare("LIMIT %d, %d", intval(($r['page'] - 1) * $r['per_page']), intval($r['per_page']));
     }
     $where = '';
     if (!empty($where_conditions)) {
         $sql['where'] = implode(' AND ', $where_conditions);
         $where = "WHERE {$sql['where']}";
     }
     $paged_groups_sql = "{$sql['select']} FROM {$sql['from']} {$where} {$sql['orderby']} {$sql['pagination']}";
     /**
      * Filters the pagination SQL statement.
      *
      * @since 1.5.0
      *
      * @param string $value Concatenated SQL statement.
      * @param array  $sql   Array of SQL parts before concatenation.
      * @param array  $r     Array of parsed arguments for the get method.
      */
     $paged_groups_sql = apply_filters('bp_groups_get_paged_groups_sql', $paged_groups_sql, $sql, $r);
     $cached = bp_core_get_incremented_cache($paged_groups_sql, 'bp_groups');
     if (false === $cached) {
         $paged_group_ids = $wpdb->get_col($paged_groups_sql);
         bp_core_set_incremented_cache($paged_groups_sql, 'bp_groups', $paged_group_ids);
     } else {
         $paged_group_ids = $cached;
     }
     $uncached_group_ids = bp_get_non_cached_ids($paged_group_ids, 'bp_groups');
     if ($uncached_group_ids) {
         $group_ids_sql = implode(',', array_map('intval', $uncached_group_ids));
         $group_data_objects = $wpdb->get_results("SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id IN ({$group_ids_sql})");
         foreach ($group_data_objects as $group_data_object) {
             wp_cache_set($group_data_object->id, $group_data_object, 'bp_groups');
         }
     }
     $paged_groups = array();
     foreach ($paged_group_ids as $paged_group_id) {
         $paged_groups[] = new BP_Groups_Group($paged_group_id);
     }
     $total_groups_sql = "SELECT COUNT(DISTINCT g.id) FROM {$sql['from']} {$where}";
     /**
      * Filters the SQL used to retrieve total group results.
      *
      * @since 1.5.0
      *
      * @param string $t_sql     Concatenated SQL statement used for retrieving total group results.
      * @param array  $total_sql Array of SQL parts for the query.
      * @param array  $r         Array of parsed arguments for the get method.
      */
     $total_groups_sql = apply_filters('bp_groups_get_total_groups_sql', $total_groups_sql, $sql, $r);
     $cached = bp_core_get_incremented_cache($total_groups_sql, 'bp_groups');
     if (false === $cached) {
         $total_groups = (int) $wpdb->get_var($total_groups_sql);
         bp_core_set_incremented_cache($total_groups_sql, 'bp_groups', $total_groups);
     } else {
         $total_groups = (int) $cached;
     }
     $group_ids = array();
     foreach ((array) $paged_groups as $group) {
         $group_ids[] = $group->id;
     }
     // Grab all groupmeta.
     if (!empty($r['update_meta_cache'])) {
         bp_groups_update_meta_cache($group_ids);
     }
     // Prefetch all administrator IDs, if requested.
     if ($r['update_admin_cache']) {
         BP_Groups_Member::prime_group_admins_mods_cache($group_ids);
     }
     // Set up integer properties needing casting.
     $int_props = array('id', 'creator_id', 'enable_forum');
     // Integer casting.
     foreach ($paged_groups as $key => $g) {
         foreach ($int_props as $int_prop) {
             $paged_groups[$key]->{$int_prop} = (int) $paged_groups[$key]->{$int_prop};
         }
     }
     unset($sql, $total_sql);
     return array('groups' => $paged_groups, 'total' => $total_groups);
 }
開發者ID:CompositeUK,項目名稱:clone.BuddyPress,代碼行數:101,代碼來源:class-bp-groups-group.php


注:本文中的BP_Groups_Member::prime_group_admins_mods_cache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。