/**
 * Fetches a random social group
 *
 * @param boolean $force_rebuild				Force the cache to be rebuilt
 * @param boolean $without_icon					Fetch groups that have no icon
 * @return array								Array of groupinfos
 */
function fetch_socialgroup_random_group($without_icon = false)
{
    global $vbulletin;
    $total = $vbulletin->db->query_first("\n\t\tSELECT COUNT(*) AS total\n\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup\n\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupicon AS sgicon ON (sgicon.groupid = socialgroup.groupid)\n\t");
    if (!$total['total']) {
        return false;
    }
    $hook_query_fields = $hook_query_joins = $hook_query_where = '';
    ($hook = vBulletinHook::fetch_hook('group_fetch_random')) ? eval($hook) : false;
    $sql = "SELECT socialgroup.*, sgicon.dateline AS icondateline,\n\t\t\t\t\tsgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height,\n\t\t\t\t\tsocialgroup.socialgroupcategoryid AS categoryid, sgc.title AS categoryname\n\t\t\t\t\t{$hook_query_fields}\n\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup " . ($without_icon ? 'LEFT' : 'INNER') . " JOIN " . TABLE_PREFIX . "socialgroupicon AS sgicon ON (sgicon.groupid = socialgroup.groupid)\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)\n\t\t\t{$hook_query_joins}\n\t\t\t{$hook_query_where}\n\t\t\tLIMIT " . vbrand(0, max(--$total['total'], 1)) . ", 1\n\t";
    $result = $vbulletin->db->query_first($sql);
    if (!$result and !$without_icon) {
        return fetch_socialgroup_random_group(true);
    }
    return $result;
}
Example #2
0
}
// #######################################################################
if ($_REQUEST['do'] == 'overview') {
    $show['sgicons'] = $vbulletin->options['sg_enablesocialgroupicons'];
    ($hook = vBulletinHook::fetch_hook('group_prepareinfo')) ? eval($hook) : false;
    $vbulletin->input->clean_array_gpc('r', array('owngrouppage' => TYPE_UINT));
    $show['messageinfo'] = $vbulletin->options['socnet_groups_msg_enabled'] ? true : false;
    $show['pictureinfo'] = ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_albums'] and $vbulletin->options['socnet_groups_albums_enabled']);
    // Get categories
    $categories = fetch_socialgroup_category_cloud();
    $categorybits = '';
    foreach ($categories as $category) {
        eval('$categorybits .= "' . fetch_template('socialgroups_category_cloud_bit') . '";');
    }
    // Fetch a random group
    if ($randomgroup = fetch_socialgroup_random_group()) {
        $randomgroup = prepare_socialgroup($randomgroup);
    }
    // Get newest groups
    $newgroups = fetch_socialgroup_newest_groups(false, false, !$vbulletin->options['sg_enablesocialgroupicons']);
    $newgroupbits = '';
    foreach ($newgroups as $group) {
        $group = prepare_socialgroup($group);
        ($hook = vBulletinHook::fetch_hook('group_newgroup_bit')) ? eval($hook) : false;
        eval('$newgroupbits .= "' . fetch_template('socialgroups_newgroup_' . ($vbulletin->options['sg_enablesocialgroupicons'] ? '' : 'listview_') . 'bit') . '";');
    }
    // Display groups that the current user created
    if ($owngroup = fetch_owner_socialgroup($vbulletin->userinfo['userid'], $vbulletin->GPC['owngrouppage'])) {
        $owngroup = prepare_socialgroup($owngroup);
        ($hook = vBulletinHook::fetch_hook('group_newgroup_bit')) ? eval($hook) : false;
        eval('$owngroup = "' . fetch_template('socialgroups_owngroup_bit') . '";');