/** * BuddyPress settings fields helper. */ function _wds_get_buddypress_fields() { // BuddyPress Groups if (function_exists('groups_get_groups')) { // We have BuddyPress groups, so let's get some settings $opts = array('title' => __('BuddyPress', 'wds'), 'intro' => __('BuddyPress sitemaps integration.', 'wds'), 'options' => array(array('type' => 'radio', 'name' => 'sitemap-buddypress-groups', 'title' => __('Include BuddyPress groups in my sitemaps', 'wds'), 'description' => __('Enabling this option will add all your BuddyPress groups to your sitemap.', 'wds'), 'items' => array(__('No', 'wds'), __('Yes', 'wds'))))); $groups = groups_get_groups(array('per_page' => WDS_BP_GROUPS_LIMIT)); $groups = @$groups['groups'] ? $groups['groups'] : array(); $exclude = array(); foreach ($groups as $group) { $exclude["exclude-buddypress-group-{$group->slug}"] = $group->name; } if ($exclude) { $opts['options'][] = array('type' => 'checkbox', 'name' => 'sitemap-buddypress', 'title' => __('Exclude these groups from my sitemap', 'wds'), 'items' => $exclude); } } // BuddyPress profiles $opts['options'][] = array('type' => 'radio', 'name' => 'sitemap-buddypress-profiles', 'title' => __('Include BuddyPress profiles in my sitemaps', 'wds'), 'description' => __('Enabling this option will add all your BuddyPress profiles to your sitemap.', 'wds'), 'items' => array(__('No', 'wds'), __('Yes', 'wds'))); $wp_roles = new WP_Roles(); $wp_roles = $wp_roles->get_names(); $wp_roles = $wp_roles ? $wp_roles : array(); $exclude = array(); foreach ($wp_roles as $key => $label) { $exclude["exclude-profile-role-{$key}"] = $label; } if ($exclude) { $opts['options'][] = array('type' => 'checkbox', 'name' => 'sitemap-buddypress-roles', 'title' => __('Exclude profiles with these roles from my sitemap', 'wds'), 'items' => $exclude); } return $opts; }
/** * Cleans up all the groups and groupings in a course (it does this best-effort * i.e. if one deletion fails, it still attempts further deletions). * IMPORTANT: Note that if the groups and groupings are used by other courses * somehow, they will still be deleted - it doesn't protect against this. * @param int $courseid The id of the course * @return boolean True if the clean up was successful, false otherwise. */ function groups_cleanup_groups($courseid) { $success = true; // Delete all the groupings $groupings = groups_get_groupings($courseid); if ($groupings != false) { foreach ($groupings as $groupingid) { $groupingdeleted = groups_delete_grouping($groupingid); if (!$groupingdeleted) { $success = false; } } } // Delete all the groups $groupids = groups_get_groups($courseid); if ($groupids != false) { foreach ($groupids as $groupid) { $groupdeleted = groups_delete_group($groupid); if (!$groupdeleted) { $success = false; } } } return $success; }
function process_groups_shortcode($args = array(), $content = false) { $groups_args = wp_parse_args($args, array('exclude' => false, 'show_members' => false, 'group_marker' => 'icon')); $exclude = !empty($groups_args['exclude']) ? array_filter(array_map('intval', array_map('trim', explode(',', $groups_args['exclude'])))) : array(); $rpl = new AgmMarkerReplacer(); $overrides = $rpl->arguments_to_overrides($args); $raw = groups_get_groups(array('user_id' => false, 'exclude' => $exclude)); if (empty($raw['groups'])) { return $content; } $maps = array(); foreach ($raw['groups'] as $group) { if (empty($group->id)) { continue; } $map = $this->_get_group_map($group->id, array('show_members' => $groups_args['show_members'], 'group_marker' => $groups_args['group_marker'])); if (!$map) { continue; } $maps[] = $map; } if (empty($maps)) { return $content; } return $rpl->create_overlay_tag($maps, $overrides); }
function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras ) { global $bp; $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page; $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; if ( 'invites' == $type ) { $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page ); } else if ( 'single-group' == $type ) { $group = new stdClass; $group->group_id = BP_Groups_Group::get_id_from_slug($slug); $this->groups = array( $group ); } else { $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' =>$this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) ); } if ( 'invites' == $type ) { $this->total_group_count = (int)$this->groups['total']; $this->group_count = (int)$this->groups['total']; $this->groups = $this->groups['groups']; } else if ( 'single-group' == $type ) { $this->single_group = true; $this->total_group_count = 1; $this->group_count = 1; } else { if ( !$max || $max >= (int)$this->groups['total'] ) { $this->total_group_count = (int)$this->groups['total']; } else { $this->total_group_count = (int)$max; } $this->groups = $this->groups['groups']; if ( $max ) { if ( $max >= count($this->groups) ) { $this->group_count = count( $this->groups ); } else { $this->group_count = (int)$max; } } else { $this->group_count = count( $this->groups ); } } // Build pagination links if ( (int)$this->total_group_count && (int)$this->pag_num ) { $this->pag_links = paginate_links( array( 'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ), 'format' => '', 'total' => ceil( (int)$this->total_group_count / (int)$this->pag_num ), 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1 ) ); } }
/** * Returns an array of group objects that the user is a member of * in the given course. If userid isn't specified, then return a * list of all groups in the course. * * @uses $CFG * @param int $courseid The id of the course in question. * @param int $userid The id of the user in question as found in the 'user' * table 'id' field. * @return object */ function get_groups($courseid, $userid = 0) { if ($userid) { $groupids = groups_get_groups_for_user($userid, $courseid); } else { $groupids = groups_get_groups($courseid); } return groups_groupids_to_groups($groupids, $courseid, $alldata = true); }
function sp_assignments_dashboard_widget_configuration() { //get old settings or default to empty array $options = get_option("assignments_dashboard_widget_options", array()); //saving options? if (isset($_POST['assignments_dashboard_options_save'])) { //get course_id $options['course_id'] = intval($_POST['assignments_dashboard_course_id']); //save it update_option("assignments_dashboard_widget_options", $options); } //show options form $groups = groups_get_groups(array('orderby' => 'name', 'order' => 'ASC')); ?> <p>Choose a class/group to show assignments from.</p> <div class="feature_post_class_wrap"> <label>Class</label> <select name="assignments_dashboard_course_id"> <option value="" <?php selected($options['course_id'], ""); ?> > All Classes </option> <?php $groups = groups_get_groups(array('orderby' => 'name', 'order' => 'ASC')); if (!empty($groups) && !empty($groups['groups'])) { foreach ($groups['groups'] as $group) { ?> <option value="<?php echo intval($group->id); ?> " <?php selected($options['course_id'], $group->id); ?> > <?php echo $group->name; ?> </option> <?php } } ?> </select> </div> <input type="hidden" name="assignments_dashboard_options_save" value="1" /> <?php }
function test_create_group() { $this->assertTrue($this->groupid = groups_create_group($this->courseid)); $this->assertTrue(groups_group_exists($this->groupid)); $this->assertTrue(groups_group_belongs_to_course($this->groupid, $this->courseid)); $this->assertTrue($groupids = groups_get_groups($this->courseid)); //array... $this->assertTrue($groupinfo = groups_set_default_group_settings()); $groupinfo->name = 'Group ' . $this->getLabel(); //'Temporary Group Name' $this->assertTrue(groups_set_group_settings($this->groupid, $groupinfo)); $this->assertTrue($groupinfo->name == groups_get_group_name($this->groupid)); $this->assertTrue($this->courseid == groups_get_course($this->groupid)); }
public function is_comment_visible($comment) { if ($this->ace_role == self::CORE_TEACHER) { return TRUE; } $comment_user_id = is_array($comment) ? $comment['user_id'] : $comment->user_id; if ($this->user->ID == $comment_user_id) { return TRUE; // own comment } if ($this->is_teacher()) { if (function_exists("groups_get_groups")) { // Check if teacher shares one or more groups with comment owner. $common_bp_groups = groups_get_groups(array('user_id' => $comment_user_id, 'include' => $this->get_bp_group_ids(), 'show_hidden' => TRUE, 'populate_extras' => FALSE, 'update_meta_cache' => FALSE)); return $common_bp_groups['total'] > 0; } else { return TRUE; // BuddyPress not installed } } return FALSE; }
/** * Loads BuddyPress Group items. */ private function _load_buddypress_group_items() { if (!function_exists('groups_get_groups')) { return false; } // No BuddyPress Groups, bail out. global $wds_options; if (!defined('BP_VERSION')) { return false; } // Nothing to do if (!(int) @$wds_options['sitemap-buddypress-groups']) { return false; } // Nothing to do $groups = groups_get_groups(array('per_page' => WDS_BP_GROUPS_LIMIT)); $groups = @$groups['groups'] ? $groups['groups'] : array(); //$total_users = (int)count_users(); //$total_users = $total_users ? $total_users : 1; foreach ($groups as $group) { if (@$wds_options["exclude-buddypress-group-{$group->slug}"]) { continue; } //$priority = sprintf("%.1f", ($group->total_member_count / $total_users)); $link = bp_get_group_permalink($group); $this->_add_item($link, 0.2, 'weekly', strtotime($group->last_activity), $group->description); } return true; }
/** * Display the Group delete confirmation screen. * * We include a separate confirmation because group deletion is truly * irreversible. * * @since 1.7.0 */ function bp_groups_admin_delete() { if (!bp_current_user_can('bp_moderate')) { die('-1'); } $group_ids = isset($_REQUEST['gid']) ? $_REQUEST['gid'] : 0; if (!is_array($group_ids)) { $group_ids = explode(',', $group_ids); } $group_ids = wp_parse_id_list($group_ids); $groups = groups_get_groups(array('include' => $group_ids, 'show_hidden' => true, 'per_page' => null)); // Create a new list of group ids, based on those that actually exist $gids = array(); foreach ($groups['groups'] as $group) { $gids[] = $group->id; } $base_url = remove_query_arg(array('action', 'action2', 'paged', 's', '_wpnonce', 'gid'), $_SERVER['REQUEST_URI']); ?> <div class="wrap"> <?php screen_icon('buddypress-groups'); ?> <h2><?php _e('Delete Groups', 'buddypress'); ?> </h2> <p><?php _e('You are about to delete the following groups:', 'buddypress'); ?> </p> <ul class="bp-group-delete-list"> <?php foreach ($groups['groups'] as $group) { ?> <li><?php echo esc_html($group->name); ?> </li> <?php } ?> </ul> <p><strong><?php _e('This action cannot be undone.', 'buddypress'); ?> </strong></p> <a class="button-primary" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'do_delete', 'gid' => implode(',', $gids)), $base_url), 'bp-groups-delete')); ?> "><?php _e('Delete Permanently', 'buddypress'); ?> </a> <a class="button" href="<?php echo esc_attr($base_url); ?> "><?php _e('Cancel', 'buddypress'); ?> </a> </div> <?php }
function __construct($user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false) { global $bp; $this->pag_page = isset($_REQUEST['grpage']) ? intval($_REQUEST['grpage']) : $page; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; if (bp_current_user_can('bp_moderate') || is_user_logged_in() && $user_id == bp_loggedin_user_id()) { $show_hidden = true; } if ('invites' == $type) { $this->groups = groups_get_invites_for_user($user_id, $this->pag_num, $this->pag_page, $exclude); } else { if ('single-group' == $type) { $group = new stdClass(); $group->group_id = BP_Groups_Group::get_id_from_slug($slug); $this->groups = array($group); } else { $this->groups = groups_get_groups(array('type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, 'show_hidden' => $show_hidden)); } } if ('invites' == $type) { $this->total_group_count = (int) $this->groups['total']; $this->group_count = (int) $this->groups['total']; $this->groups = $this->groups['groups']; } else { if ('single-group' == $type) { $this->single_group = true; $this->total_group_count = 1; $this->group_count = 1; } else { if (empty($max) || $max >= (int) $this->groups['total']) { $this->total_group_count = (int) $this->groups['total']; } else { $this->total_group_count = (int) $max; } $this->groups = $this->groups['groups']; if (!empty($max)) { if ($max >= count($this->groups)) { $this->group_count = count($this->groups); } else { $this->group_count = (int) $max; } } else { $this->group_count = count($this->groups); } } } // Build pagination links if ((int) $this->total_group_count && (int) $this->pag_num) { $this->pag_links = paginate_links(array('base' => add_query_arg(array('grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Group pagination next text', 'buddypress'), 'mid_size' => 1)); } }
/** * Builds the select box to choose the group to attach the BuddyDrive Item to * @param int $user_id the user id * @param int $selected the group id in case of edit form * @param string $name the name of the select box * @uses bp_loggedin_user_id() to get current user id * @uses groups_get_groups() to list the groups of the user * @uses groups_get_groupmeta() to check group enabled BuddyDrive * @uses selected() to eventually activate a group * @return string the select box */ function buddydrive_get_select_user_group($user_id = false, $selected = false, $name = false) { if (empty($user_id)) { $user_id = bp_loggedin_user_id(); } $name = !empty($name) ? ' name="' . $name . '"' : false; $output = __('No group available for BuddyDrive', 'buddydrive'); if (!bp_is_active('groups')) { return $output; } $user_groups = groups_get_groups(array('user_id' => $user_id, 'show_hidden' => true, 'per_page' => false)); $buddydrive_groups = false; // checking for available buddydrive groups if (!empty($user_groups['groups'])) { foreach ($user_groups['groups'] as $group) { if (1 == groups_get_groupmeta($group->id, '_buddydrive_enabled')) { $buddydrive_groups[] = array('group_id' => $group->id, 'group_name' => $group->name); } } } // building the select box if (!empty($buddydrive_groups) && is_array($buddydrive_groups)) { $output = '<select id="buddygroup"' . $name . '>'; foreach ($buddydrive_groups as $buddydrive_group) { $output .= '<option value="' . $buddydrive_group['group_id'] . '" ' . selected($selected, $buddydrive_group['group_id'], false) . '>' . $buddydrive_group['group_name'] . '</option>'; } $output .= '</select>'; } return apply_filters('buddydrive_get_select_user_group', $output); }
function admin_main($data) { if (!$data) { $data = array(); } ?> <div class='level-operation' id='main-bpgroups'> <h2 class='sidebar-name'><?php _e('Groups', 'membership'); ?> <span><a href='#remove' id='remove-bpgroups' class='removelink' title='<?php _e("Remove Groups from this rules area.", 'membership'); ?> '><?php _e('Remove', 'membership'); ?> </a></span></h2> <div class='inner-operation'> <p><?php _e('Select the groups to be covered by this rule by checking the box next to the relevant groups title.', 'membership'); ?> </p> <?php if (function_exists('groups_get_groups')) { $groups = groups_get_groups(array('per_page' => MEMBERSHIP_GROUP_COUNT)); } if ($groups) { ?> <table cellspacing="0" class="widefat fixed"> <thead> <tr> <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> <th style="" class="manage-column column-name" id="name" scope="col"><?php _e('Group title', 'membership'); ?> </th> <th style="" class="manage-column column-date" id="date" scope="col"><?php _e('Group created', 'membership'); ?> </th> </tr> </thead> <tfoot> <tr> <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> <th style="" class="manage-column column-name" id="name" scope="col"><?php _e('Group title', 'membership'); ?> </th> <th style="" class="manage-column column-date" id="date" scope="col"><?php _e('Group created', 'membership'); ?> </th> </tr> </tfoot> <tbody> <?php foreach ($groups['groups'] as $key => $group) { ?> <tr valign="middle" class="alternate" id="bpgroup-<?php echo $group->id; ?> "> <th class="check-column" scope="row"> <input type="checkbox" value="<?php echo $group->id; ?> " name="bpgroups[]" <?php if (in_array($group->id, $data)) { echo 'checked="checked"'; } ?> > </th> <td class="column-name"> <strong><?php echo esc_html($group->name); ?> </strong> </td> <td class="column-date"> <?php echo date("Y/m/d", strtotime($group->date_created)); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } if ($groups['total'] > MEMBERSHIP_GROUP_COUNT) { ?> <p class='description'><?php echo __("Only the most recent ", 'membership') . MEMBERSHIP_GROUP_COUNT . __(" groups are shown above.", 'membership'); ?> </p> <?php } ?> </div> </div> <?php }
function process_group_archives_shortcode($args = array(), $content = false) { $args = $this->_preparse_arguments($args, array('date' => false, 'lookahead' => false, 'weeks' => false, 'category' => false, 'limit' => false, 'order' => false, 'groups' => false, 'user' => false, 'class' => 'eab-group_events', 'template' => 'get_shortcode_archive_output', 'override_styles' => false, 'override_scripts' => false)); if (is_numeric($args['user'])) { $args['user'] = $this->_arg_to_int($args['user']); } else { if ('current' == trim($args['user'])) { $user = wp_get_current_user(); $args['user'] = $user->ID; } else { $args['user'] = false; } } if (is_numeric($args['groups'])) { // Single group ID $args['groups'] = $this->_arg_to_int($args['groups']); } else { if (strstr($args['groups'], ',')) { // Comma-separated list of group IDs $ids = array_map('intval', array_map('trim', explode(',', $args['groups']))); if (!empty($ids)) { $args['groups'] = $ids; } } else { // Keyword if (in_array(trim($args['groups']), array('my', 'my-groups', 'my_groups')) && $args['user']) { if (!function_exists('groups_get_groups')) { return $content; } $groups = groups_get_groups(array('user_id' => $args['user'])); $args['groups'] = array_map('intval', wp_list_pluck($groups['groups'], 'id')); } else { if ('all' == trim($args['groups'])) { if (!function_exists('groups_get_groups')) { return $content; } $groups = groups_get_groups(); $args['groups'] = array_map('intval', wp_list_pluck($groups['groups'], 'id')); } else { $args['groups'] = false; } } } } if (!$args['groups']) { return $content; } $events = array(); $query = $this->_to_query_args($args); $query['meta_query'][] = array('key' => 'eab_event-bp-group_event', 'value' => $args['groups'], 'compare' => is_array($args['groups']) ? 'IN' : '='); $order_method = $args['order'] ? create_function('', 'return "' . $args['order'] . '";') : false; if ($order_method) { add_filter('eab-collection-date_ordering_direction', $order_method); } // Lookahead - depending on presence, use regular upcoming query, or poll week count if ($args['lookahead']) { $method = $args['weeks'] ? create_function('', 'return ' . $args['weeks'] . ';') : false; if ($method) { add_filter('eab-collection-upcoming_weeks-week_number', $method); } $collection = new Eab_BuddyPress_GroupEventsWeeksCollection($args['groups'], $args['date'], $query); if ($method) { remove_filter('eab-collection-upcoming_weeks-week_number', $method); } } else { // No lookahead, get the full month only $collection = new Eab_BuddyPress_GroupEventsCollection($args['groups'], $args['date'], $query); } if ($order_method) { remove_filter('eab-collection-date_ordering_direction', $order_method); } $events = $collection->to_collection(); $output = eab_call_template('util_apply_shortcode_template', $events, $args); $output = $output ? $output : $content; if (!$args['override_styles']) { wp_enqueue_style('eab_front'); } if (!$args['override_scripts']) { wp_enqueue_script('eab_event_js'); } return $output; }
/** * This function will empty a course of USER data as much as /// possible. It will retain the activities and the structure /// of the course. * * @uses $USER * @uses $SESSION * @uses $CFG * @param object $data an object containing all the boolean settings and courseid * @param bool $showfeedback if false then do it all silently * @return bool * @todo Finish documenting this function */ function reset_course_userdata($data, $showfeedback = true) { global $CFG, $USER, $SESSION; $result = true; $strdeleted = get_string('deleted'); // Look in every instance of every module for data to delete if ($allmods = get_records('modules')) { foreach ($allmods as $mod) { $modname = $mod->name; $modfile = $CFG->dirroot . '/mod/' . $modname . '/lib.php'; $moddeleteuserdata = $modname . '_delete_userdata'; // Function to delete user data if (file_exists($modfile)) { @(include_once $modfile); if (function_exists($moddeleteuserdata)) { $moddeleteuserdata($data, $showfeedback); } } } } else { error('No modules are installed!'); } // Delete other stuff $coursecontext = get_context_instance(CONTEXT_COURSE, $data->courseid); if (!empty($data->reset_students) or !empty($data->reset_teachers)) { $teachers = array_keys(get_users_by_capability($coursecontext, 'moodle/course:update')); $participants = array_keys(get_users_by_capability($coursecontext, 'moodle/course:view')); $students = array_diff($participants, $teachers); if (!empty($data->reset_students)) { foreach ($students as $studentid) { role_unassign(0, $studentid, 0, $coursecontext->id); } if ($showfeedback) { notify($strdeleted . ' ' . get_string('students'), 'notifysuccess'); } /// Delete group members (but keep the groups) TODO:check. if ($groupids = groups_get_groups($data->courseid)) { foreach ($groupids as $groupid) { if (groups_remove_all_group_members($groupid)) { if ($showfeedback) { notify($strdeleted . ' groups_members', 'notifysuccess'); } } else { $result = false; } } } } if (!empty($data->reset_teachers)) { foreach ($teachers as $teacherid) { role_unassign(0, $teacherid, 0, $coursecontext->id); } if ($showfeedback) { notify($strdeleted . ' ' . get_string('teachers'), 'notifysuccess'); } } } if (!empty($data->reset_groups)) { if ($groupids = groups_get_groups($data->courseid)) { foreach ($groupids as $groupid) { if (groups_delete_group($groupid)) { if ($showfeedback) { notify($strdeleted . ' groups', 'notifysuccess'); } } else { $result = false; } } } } if (!empty($data->reset_events)) { if (delete_records('event', 'courseid', $data->courseid)) { if ($showfeedback) { notify($strdeleted . ' event', 'notifysuccess'); } } else { $result = false; } } if (!empty($data->reset_logs)) { if (delete_records('log', 'course', $data->courseid)) { if ($showfeedback) { notify($strdeleted . ' log', 'notifysuccess'); } } else { $result = false; } } // deletes all role assignments, and local override, these have no courseid in table and needs separate process $context = get_context_instance(CONTEXT_COURSE, $data->courseid); delete_records('role_capabilities', 'contextid', $context->id); return $result; }
/** * Process the repair tool * * In case something went wrong with group activities (visibility, component...), * this tool should repair the problematic activities. * * @package WP Idea Stream * @subpackage buddypress/activity * * @since 2.0.0 * * @global $wpdb * @uses bp_is_active() to check if a component is active * @uses wp_list_pluck() to pluck a certain field out of each object in a list. * @uses bp_activity_get() to get all ideastream activities * @uses wp_filter_object_list() to filter a list of objects, based on a set of key => value arguments. * @uses wp_parse_id_list() to sanitize a list of ids * @uses get_post_meta() to get the group id the idea is attached to * @uses groups_get_groups() to get the needed groups * @uses WP_Idea_Stream_Activity::bulk_edit_activity() to update the activities (component/item_id/visibility) * @return array the result of the repair operation. */ public function repair_activities() { global $wpdb; $buddypress = buddypress(); $blog_id = get_current_blog_id(); // Description of this tool, displayed to the user $statement = __('Making sure IdeaStream activities are consistent: %s', 'wp-idea-stream'); // Default to failure text $result = __('No activity needs to be repaired.', 'wp-idea-stream'); // Default to unrepaired $repair = 0; if (!bp_is_active('groups')) { return; } $ideastream_types = wp_list_pluck($this->activity_actions, 'type'); // Get all activities $ideastream_activities = bp_activity_get(array('filter' => array('action' => $ideastream_types), 'show_hidden' => true, 'spam' => 'all', 'per_page' => false)); if (is_array($ideastream_activities['activities'])) { $idea_comments = array(); $idea_posts = array(); $to_repair = array(); $attached_component = array('comment' => array($buddypress->groups->id => array(), $buddypress->blogs->id => array()), 'post' => array($buddypress->groups->id => array(), $buddypress->blogs->id => array())); foreach ($ideastream_activities['activities'] as $activity) { if (false !== strpos($activity->type, 'comment')) { $idea_comments[$activity->id] = $activity->secondary_item_id; $attached_component['comment'][$activity->component][] = $activity->id; } else { $idea_posts[$activity->id] = $activity->secondary_item_id; $attached_component['post'][$activity->component][] = $activity->id; } } // Gets the comment activities to repair if (!empty($idea_comments)) { // I don't think get_comments() allow us to get comments // using a list of comment ids.. $in = implode(',', wp_parse_id_list($idea_comments)); $sql = array('select' => "SELECT c.comment_ID, m.meta_value as group_id", 'from' => "FROM {$wpdb->comments} c LEFT JOIN {$wpdb->postmeta} m", 'on' => "ON (c.comment_post_ID = m.post_id )", 'where' => $wpdb->prepare("WHERE comment_ID IN ({$in}) AND m.meta_key = %s", '_ideastream_group_id')); $idea_comments_check = $wpdb->get_results(join(' ', $sql), OBJECT_K); foreach ($idea_comments as $activity_comment_id => $comment_secondary_id) { if (!empty($idea_comments_check[$comment_secondary_id]) && !in_array($activity_comment_id, $attached_component['comment'][$buddypress->groups->id])) { $to_repair['groups'][$idea_comments_check[$comment_secondary_id]->group_id][] = $activity_comment_id; } else { if (empty($idea_comments_check[$comment_secondary_id]) && in_array($activity_comment_id, $attached_component['comment'][$buddypress->groups->id])) { $to_repair['blogs'][] = $activity_comment_id; } } } } // Gets the idea activities to repair if (!empty($idea_posts)) { add_filter('wp_idea_stream_ideas_get_status', 'wp_idea_stream_ideas_get_all_status', 10, 1); // Get user's ideas posted in the group $idea_posts_check = wp_idea_stream_ideas_get_ideas(array('per_page' => -1, 'include' => $idea_posts, 'meta_query' => array(array('key' => '_ideastream_group_id', 'compare' => 'EXIST')))); $idea_posts_check = wp_list_pluck($idea_posts_check['ideas'], 'ID'); remove_filter('wp_idea_stream_ideas_get_status', 'wp_idea_stream_ideas_get_all_status', 10, 1); foreach ($idea_posts as $activity_post_id => $post_secondary_id) { if (in_array($post_secondary_id, $idea_posts_check) && !in_array($activity_post_id, $attached_component['post'][$buddypress->groups->id])) { $group_id = get_post_meta($post_secondary_id, '_ideastream_group_id', true); if (!empty($group_id)) { $to_repair['groups'][$group_id][] = $activity_post_id; } } else { if (!in_array($post_secondary_id, $idea_posts_check) && in_array($activity_post_id, $attached_component['post'][$buddypress->groups->id])) { $to_repair['blogs'][] = $activity_post_id; } } } } } if (!empty($to_repair['groups'])) { // Get the groups to have their status $groups = groups_get_groups(array('show_hidden' => true, 'populate_extras' => false, 'include' => join(',', array_keys($to_repair['groups'])), 'per_page' => false)); if (!empty($groups['groups'])) { $public_groups = wp_filter_object_list($groups['groups'], array('status' => 'public'), 'and', 'id'); foreach ($to_repair['groups'] as $item_id => $repair_activities) { $hide_sitewide = 0; if (!in_array($item_id, $public_groups)) { $hide_sitewide = 1; } self::bulk_edit_activity($repair_activities, $hide_sitewide, $buddypress->groups->id, $item_id); $repair += count($repair_activities); } } } if (!empty($to_repair['blogs'])) { self::bulk_edit_activity($to_repair['blogs'], 0, $buddypress->blogs->id, $blog_id); $repair += count($to_repair['blogs']); } // Setup success/fail messaging if (!empty($repair)) { $result = sprintf(__('%d repared', 'wp-idea-stream'), $repair); } // All done! return array(0, sprintf($statement, $result)); }
global $EM_Event; if (!function_exists('bp_is_active') || !bp_is_active('groups')) { return false; } $user_groups = array(); $group_data = groups_get_user_groups(get_current_user_id()); if (!is_super_admin()) { foreach ($group_data['groups'] as $group_id) { if (groups_is_user_admin(get_current_user_id(), $group_id)) { $user_groups[] = groups_get_group(array('group_id' => $group_id)); } } $group_count = count($user_groups); } else { $groups = groups_get_groups(array('show_hidden' => true)); $user_groups = $groups['groups']; $group_count = $groups['total']; } if (count($user_groups) > 0) { ?> <p> <select name="group_id"> <option value="<?php echo $BP_Group->id; ?> "><?php _e('Not a Group Event', 'dbem'); ?> </option>
function format_value($value, $post_id, $field) { // bail early if no value if (empty($value)) { return $value; } // force value to array $value = acf_get_array($value); // convert values to int $value = array_map('intval', $value); // load groups if needed if ($field['return_format'] == 'object') { // get groups $value = groups_get_groups(array('include' => $value)); } // convert back from array if neccessary if (!$field['multiple']) { $value = array_shift($value); } // return return $value; }
/** * extended_search( $groups, $params ) * * Hooks into groups_get_groups filter and extends search to include Courseware used post types */ function extended_search($groups, $params) { // Don't bother searching if nothing queried if (empty($params['search_terms'])) { return $groups; } // A hack to make WordPress believe the taxonomy is registered if (!taxonomy_exists('group_id')) { global $wp_taxonomies; $wp_taxonomies['group_id'] = ''; } $all_groups = groups_get_groups(array('type' => 'alphabetical')); foreach ($all_groups['groups'] as $group) { // Search posts from current $group $results = get_posts(array('group_id' => $group->id, 'post_type' => array('assignment', 'course', 'schedule', 'lecture'), 's' => $params['search_terms'])); // Merge posts to $groups if new found if (!empty($results)) { if (!in_array($group, $groups['groups'])) { $groups['groups'][] = $group; $groups['total']++; } } } return $groups; }
/** * If the user doesn't have any place to create a new group, don't let him create a group * @param boolean Return control behavior if user cannot create groups - if TRUE, return FALSE; if FALSE, die * TODO: this parameter is poorly named / implemented */ function bp_group_hierarchy_assert_parent_available($return = false) { global $bp; if (is_super_admin()) { return true; } if ($cache_result = wp_cache_get($bp->loggedin_user->id, 'bpgh_has_available_parent_group')) { if ($cache_result == 'true') { return true; } if ($return) { return false; } else { wp_die(__('Sorry, you are not allowed to create groups.', 'buddypress'), __('Sorry, you are not allowed to create groups.', 'buddypress')); } } $group_permission = get_site_option('bpgh_extension_toplevel_group_permission'); if ($group_permission == 'anyone' || has_filter('bp_group_hierarchy_enforce_subgroup_permission_' . $group_permission) && apply_filters('bp_group_hierarchy_enforce_subgroup_permission_' . $group_permission, false, $bp->loggedin_user->id, 0)) { /** If the user can create top-level groups, we're done looking */ wp_cache_set($bp->loggedin_user->id, 'true', 'bpgh_has_available_parent_group'); return true; } $user_groups = groups_get_groups(array('user_id' => $bp->loggedin_user->id)); foreach ($user_groups['groups'] as $group) { if (bp_group_hierarchy_can_create_subgroups($bp->loggedin_user->id, $group->id)) { /** If the user can create subgroups here, we're done looking */ wp_cache_set($bp->loggedin_user->id, 'true', 'bpgh_has_available_parent_group'); return true; } } wp_cache_set($bp->loggedin_user->id, 'false', 'bpgh_has_available_parent_group'); if ($return) { return false; } else { wp_die(__('Sorry, you are not allowed to create groups.', 'buddypress'), __('Sorry, you are not allowed to create groups.', 'buddypress')); } }
$nch++; } //} //nom�s els del curs echo "<li><a href=\"javascript:reloadiframegroup('&eid=search_res&pop=si&group=0&cid=0')\">" . get_string('allusersincourse', 'email') . "</a></li>"; echo '</li></ul></div>'; //---posem el formulari de cerca echo '<div onclick="switchMenu(\'srch\')">' . '<img id="srch_icon" src="' . $CFG->pixpath . '/t/switch_plus.gif"/>' . get_string('searchcontact', 'email') . '</div>'; echo '<div id="srch" style="display:none;"><ul>'; echo '<form method="post" action="search.php?id=' . $id . '&pop=si&group=' . $selgroup . '" target="bssearch">' . '<input id="sfield" type="text" name="search" value="" />' . '<input type="submit" name="doit" value="' . get_string('search') . '"/>' . '</form>'; echo '</ul></div>'; // Prints group selector for users with a viewallgroups capability if course groupmode is separate if ($course->groupmode == 1 || $course->groupmode == 2) { // Prints all groups if user can see them all if (has_capability('block/email_list:viewallgroups', $context) || $course->groupmode == 2) { $groups = groups_groupids_to_groups(groups_get_groups($course->id), $course->id); $groupsmode = $course->groupmode; $currentgroup = $selgroup; $urlroot = $CFG->wwwroot . '/email/contacts/list.php?id=' . $course->id; $showall = 1; echo '<br/>'; print_group_menu($groups, $groupsmode, $currentgroup, $urlroot, $showall); } else { // Prints only groups current user is a participant of $usergroups = groups_get_groups_for_user($USER->id, $course->id); // Shows a Show all users to users in multiple groups $showall = 0; if (count($usergroups) > 1) { $showall = 1; } $usergroups = groups_groupids_to_groups($usergroups, $course->id);
/** * Find and return a list of groups suggestions that match the query. * * @package WP Idea Stream * @subpackage buddypress/groups * * @since 2.0.0 * * @uses groups_get_groups() to get the groups suggestions * @uses bp_get_group_permalink() to build each group permalink * @uses apply_filters() Calls 'wp_idea_stream_groups_suggestions_query_args' to override the groups query args * Calls 'wp_idea_stream_groups_suggestions_get_suggestions' to override the found suggestions * @return array|WP_Error Array of results. If there were problems, returns a WP_Error object. */ public function get_suggestions() { $groups_query = array('show_hidden' => $this->args['show_hidden'], 'populate_extras' => $this->args['populate_extras'], 'type' => 'alphabetical', 'page' => 1, 'per_page' => $this->args['limit'], 'search_terms' => $this->args['term'], 'user_id' => $this->args['author']); // Only return matches for this meta query. if (!empty($this->args['meta_key']) && !empty($this->args['meta_value'])) { $groups_query['meta_query'] = array(array('key' => $this->args['meta_key'], 'value' => $this->args['meta_value'], 'compare' => '=')); } /** * @param array $groups_query the groups query arguments * @param WP_Idea_Stream_Groups_Suggestions $this the current class */ $groups_query = apply_filters('wp_idea_stream_groups_suggestions_query_args', $groups_query, $this); if (is_wp_error($groups_query)) { return $group_query; } $groups_results = groups_get_groups($groups_query); if (empty($groups_results['groups'])) { return false; } foreach ($groups_results['groups'] as $group) { $result = new stdClass(); $result->id = $group->id; $result->name = $group->name; $result->link = bp_get_group_permalink($group); $results[] = $result; } /** * @param array $results the groups suggestions * @param WP_Idea_Stream_Groups_Suggestions $this the current class */ return apply_filters('wp_idea_stream_groups_suggestions_get_suggestions', $results, $this); }
global $EM_Event; if (!function_exists('bp_is_active') || !bp_is_active('groups')) { return false; } $user_groups = array(); $group_data = groups_get_user_groups(get_current_user_id()); if (!is_super_admin()) { foreach ($group_data['groups'] as $group_id) { if (groups_is_user_admin(get_current_user_id(), $group_id)) { $user_groups[] = groups_get_group(array('group_id' => $group_id)); } } $group_count = count($user_groups); } else { $groups = groups_get_groups(array('show_hidden' => true, 'per_page' => 0)); $user_groups = $groups['groups']; $group_count = $groups['total']; } if (count($user_groups) > 0) { ?> <p> <select name="group_id"> <option value=""><?php _e('Not a Group Event', 'dbem'); ?> </option> <?php //in case user isn't a group mod, but can edit other users' events if (!empty($EM_Event->group_id) && !in_array($EM_Event->group_id, $group_data['groups'])) { $other_group = groups_get_group(array('group_id' => $EM_Event->group_id));
global $EM_Event; if (!function_exists('bp_is_active') || !bp_is_active('groups')) { return false; } $user_groups = array(); $group_data = groups_get_user_groups(get_current_user_id()); if (!is_super_admin()) { foreach ($group_data['groups'] as $group_id) { if (groups_is_user_admin(get_current_user_id(), $group_id)) { $user_groups[] = groups_get_group(array('group_id' => $group_id)); } } $group_count = count($user_groups); } else { $groups = groups_get_groups(); $user_groups = $groups['groups']; $group_count = $groups['total']; } if (count($user_groups) > 0) { ?> <p> <select name="group_id"> <option value="<?php echo $BP_Group->id; ?> "><?php _e('Not a Group Event', 'dbem'); ?> </option> <?php
/** * Gets a list of the groups not in a specified grouping * @param int $groupingid The grouping specified * @return array An array of the group ids */ function groups_get_groups_not_in_grouping($groupingid, $courseid) { $allgroupids = groups_get_groups($courseid); $groupids = array(); foreach ($allgroupids as $groupid) { if (!groups_belongs_to_grouping($groupid, $groupingid)) { array_push($groupids, $groupid); } } return $groupids; }
function groups_action_redirect_to_random_group() { global $bp, $wpdb; if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) { $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) ); bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug . '/' ); } }
function __construct($args = array()) { // Backward compatibility with old method of passing arguments if (!is_array($args) || func_num_args() > 1) { _deprecated_argument(__METHOD__, '1.7', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__)); $old_args_keys = array(0 => 'user_id', 1 => 'type', 2 => 'page', 3 => 'per_page', 4 => 'max', 5 => 'slug', 6 => 'search_terms', 7 => 'populate_extras', 8 => 'include', 9 => 'exclude', 10 => 'show_hidden', 11 => 'page_arg'); $func_args = func_get_args(); $args = bp_core_parse_args_array($old_args_keys, $func_args); } $defaults = array('type' => 'active', 'page' => 1, 'per_page' => 20, 'max' => false, 'show_hidden' => false, 'page_arg' => 'grpage', 'user_id' => 0, 'slug' => false, 'include' => false, 'exclude' => false, 'search_terms' => '', 'meta_query' => false, 'populate_extras' => true, 'update_meta_cache' => true); $r = wp_parse_args($args, $defaults); extract($r); $this->pag_page = isset($_REQUEST[$page_arg]) ? intval($_REQUEST[$page_arg]) : $page; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; if (bp_current_user_can('bp_moderate') || is_user_logged_in() && $user_id == bp_loggedin_user_id()) { $show_hidden = true; } if ('invites' == $type) { $this->groups = groups_get_invites_for_user($user_id, $this->pag_num, $this->pag_page, $exclude); } else { if ('single-group' == $type) { $this->single_group = true; if (groups_get_current_group()) { $group = groups_get_current_group(); } else { $group = groups_get_group(array('group_id' => BP_Groups_Group::get_id_from_slug($r['slug']), 'populate_extras' => $r['populate_extras'])); } // backwards compatibility - the 'group_id' variable is not part of the // BP_Groups_Group object, but we add it here for devs doing checks against it // // @see https://buddypress.trac.wordpress.org/changeset/3540 // // this is subject to removal in a future release; devs should check against // $group->id instead $group->group_id = $group->id; $this->groups = array($group); } else { $this->groups = groups_get_groups(array('type' => $type, 'order' => $order, 'orderby' => $orderby, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, 'update_meta_cache' => $update_meta_cache, 'show_hidden' => $show_hidden)); } } if ('invites' == $type) { $this->total_group_count = (int) $this->groups['total']; $this->group_count = (int) $this->groups['total']; $this->groups = $this->groups['groups']; } else { if ('single-group' == $type) { if (empty($group->id)) { $this->total_group_count = 0; $this->group_count = 0; } else { $this->total_group_count = 1; $this->group_count = 1; } } else { if (empty($max) || $max >= (int) $this->groups['total']) { $this->total_group_count = (int) $this->groups['total']; } else { $this->total_group_count = (int) $max; } $this->groups = $this->groups['groups']; if (!empty($max)) { if ($max >= count($this->groups)) { $this->group_count = count($this->groups); } else { $this->group_count = (int) $max; } } else { $this->group_count = count($this->groups); } } } // Build pagination links if ((int) $this->total_group_count && (int) $this->pag_num) { $this->pag_links = paginate_links(array('base' => add_query_arg(array($page_arg => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Group pagination next text', 'buddypress'), 'mid_size' => 1)); } }
/** * Cached wrapper for fetching IDs of groups that a user is a member of. * * @param int $user_id * @return array */ function cacsp_get_groups_of_user($user_id) { $group_ids = wp_cache_get($user_id, 'cacsp_groups_of_user'); if (false === $group_ids) { $user_groups = groups_get_groups(array('user_id' => bp_loggedin_user_id(), 'update_meta_cache' => false, 'show_hidden' => true, 'populate_extras' => false)); $group_ids = array(); if (!empty($user_groups['groups'])) { $group_ids = array_map('intval', wp_list_pluck($user_groups['groups'], 'id')); } wp_cache_add($user_id, $group_ids, 'cacsp_groups_of_user'); } return array_map('intval', $group_ids); }
function kleo_ajax_search() { //if "s" input is missing exit if (empty($_REQUEST['s']) && empty($_REQUEST['bbp_search'])) { die; } if (!empty($_REQUEST['bbp_search'])) { $search_string = $_REQUEST['bbp_search']; } else { $search_string = $_REQUEST['s']; } $output = ""; $context = "any"; $defaults = array('numberposts' => 4, 'posts_per_page' => 20, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false, 's' => $_REQUEST['s']); if (isset($_REQUEST['context']) && $_REQUEST['context'] != '') { $context = explode(",", $_REQUEST['context']); $defaults['post_type'] = $context; } $defaults = apply_filters('kleo_ajax_query_args', $defaults); $the_query = new WP_Query($defaults); $posts = $the_query->get_posts(); $members = array(); $members['total'] = 0; $groups = array(); $groups['total'] = 0; $forums = FALSE; if (function_exists('bp_is_active') && ($context == "any" || in_array("members", $context))) { $members = bp_core_get_users(array('search_terms' => $search_string, 'per_page' => $defaults['numberposts'], 'populate_extras' => false)); } if (function_exists('bp_is_active') && bp_is_active("groups") && ($context == "any" || in_array("groups", $context))) { $groups = groups_get_groups(array('search_terms' => $search_string, 'per_page' => $defaults['numberposts'], 'populate_extras' => false)); } if (class_exists('bbPress') && ($context == "any" || in_array("forum", $context))) { $forums = kleo_bbp_get_replies($search_string); } //if there are no posts, groups nor members if (empty($posts) && $members['total'] == 0 && $groups['total'] == 0 && !$forums) { $output = "<div class='kleo_ajax_entry ajax_not_found'>"; $output .= "<div class='ajax_search_content'>"; $output .= "<i class='icon icon-exclamation-sign'></i> "; $output .= __("Sorry, we haven't found anything based on your criteria.", 'kleo_framework'); $output .= "<br>"; $output .= __("Please try searching by different terms.", 'kleo_framework'); $output .= "</div>"; $output .= "</div>"; echo $output; die; } //if there are members if ($members['total'] != 0) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-members">'; $output .= '<h4><span>' . __("Members", 'kleo_framework') . '</span></h4>'; foreach ((array) $members['users'] as $member) { $image = '<img src="' . bp_core_fetch_avatar(array('item_id' => $member->ID, 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">'; if ($update = bp_get_user_meta($member->ID, 'bp_latest_update', true)) { $latest_activity = char_trim(trim(strip_tags(bp_create_excerpt($update['content'], 50, "...")))); } else { $latest_activity = ''; } $output .= "<div class ='kleo_ajax_entry'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='" . bp_core_get_user_domain($member->ID) . "' class='search_title'>"; $output .= $member->display_name; $output .= "</a>"; $output .= "<span class='search_excerpt'>"; $output .= $latest_activity; $output .= "</span>"; $output .= "</div>"; $output .= "</div>"; } $output .= "<a class='ajax_view_all' href='" . bp_get_members_directory_permalink() . "?s=" . $search_string . "'>" . __('View member results', 'kleo_framework') . "</a>"; $output .= "</div>"; } //if there are groups if ($groups['total'] != 0) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-groups">'; $output .= '<h4><span>' . __("Groups", 'kleo_framework') . '</span></h4>'; foreach ((array) $groups['groups'] as $group) { $image = '<img src="' . bp_core_fetch_avatar(array('item_id' => $group->id, 'object' => 'group', 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">'; $output .= "<div class ='kleo_ajax_entry'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='" . bp_get_group_permalink($group) . "' class='search_title'>"; $output .= $group->name; $output .= "</a>"; $output .= "</div>"; $output .= "</div>"; } $output .= "<a class='ajax_view_all' href='" . bp_get_groups_directory_permalink() . "?s=" . $search_string . "'>" . __('View group results', 'kleo_framework') . "</a>"; $output .= "</div>"; } //if there are posts if (!empty($posts)) { $post_types = array(); $post_type_obj = array(); foreach ($posts as $post) { $post_types[$post->post_type][] = $post; if (empty($post_type_obj[$post->post_type])) { $post_type_obj[$post->post_type] = get_post_type_object($post->post_type); } } foreach ($post_types as $ptype => $post_type) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-' . esc_attr($post_type_obj[$ptype]->name) . '">'; if (isset($post_type_obj[$ptype]->labels->name)) { $output .= "<h4><span>" . $post_type_obj[$ptype]->labels->name . "</span></h4>"; } else { $output .= "<hr>"; } $count = 0; foreach ($post_type as $post) { $count++; if ($count > 4) { continue; } $format = get_post_format($post->ID); if ($img_url = kleo_get_post_thumbnail_url($post->ID)) { $image = aq_resize($img_url, 44, 44, true, true, true); if (!$image) { $image = $img_url; } $image = '<img src="' . $image . '" class="kleo-rounded">'; } else { if ($format == 'video') { $image = "<i class='icon icon-video'></i>"; } elseif ($format == 'image' || $format == 'gallery') { $image = "<i class='icon icon-picture'></i>"; } else { $image = "<i class='icon icon-link'></i>"; } } $excerpt = ""; if (!empty($post->post_content)) { $excerpt = char_trim(trim(strip_tags(strip_shortcodes($post->post_content))), 40, "..."); } $link = apply_filters('kleo_custom_url', get_permalink($post->ID)); $classes = "format-" . $format; $output .= "<div class ='kleo_ajax_entry {$classes}'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='{$link}' class='search_title'>"; $output .= get_the_title($post->ID); $output .= "</a>"; $output .= "<span class='search_excerpt'>"; $output .= $excerpt; $output .= "</span>"; $output .= "</div>"; $output .= "</div>"; } $output .= '</div>'; } $output .= "<a class='ajax_view_all' href='" . home_url('/') . '?s=' . $search_string . "'>" . __('View all results', 'kleo_framework') . "</a>"; } /* Forums topics search */ if (!empty($forums)) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-forums">'; $output .= '<h4><span>' . __("Forums", 'kleo_framework') . '</span></h4>'; $i = 0; foreach ($forums as $fk => $forum) { $i++; if ($i <= 4) { $image = "<i class='icon icon-chat-1'></i>"; $output .= "<div class ='kleo_ajax_entry'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='" . $forum['url'] . "' class='search_title'>"; $output .= $forum['name']; $output .= "</a>"; //$output .= "<span class='search_excerpt'>"; //$output .= $latest_activity; //$output .= "</span>"; $output .= "</div>"; $output .= "</div>"; } } $output .= "<a class='ajax_view_all' href='" . bbp_get_search_url() . "?bbp_search=" . $search_string . "'>" . __('View forum results', 'kleo_framework') . "</a>"; $output .= "</div>"; } echo $output; die; }
function groups_action_redirect_to_random_group() { global $bp, $wpdb; if (bp_is_groups_component() && isset($_GET['random-group'])) { $group = groups_get_groups(array('type' => 'random', 'per_page' => 1)); bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group['groups'][0]->slug . '/'); } }