function refresh_counts($user_id, $where) { $model = new RTMediaModel(); $counts = $model->get_counts($user_id, $where); $media_count = array(); foreach ($counts as $count) { if (!isset($count->privacy)) { $count->privacy = 0; } if (isset($media_count[strval($count->privacy)])) { foreach ($media_count[strval($count->privacy)] as $key => $val) { $media_count[strval($count->privacy)]->{$key} = intval($count->{$key}) + intval($val); } } else { $media_count[strval($count->privacy)] = $count; } unset($media_count[strval($count->privacy)]->privacy); } if (isset($where["context"])) { if ($where["context"] == "profile") { update_user_meta($user_id, 'rtmedia_counts_' . get_current_blog_id(), $media_count); } else { if ($where["context"] == "group" && function_exists("groups_update_groupmeta")) { groups_update_groupmeta($user_id, 'rtmedia_counts_' . get_current_blog_id(), $media_count); } } } return $media_count; }