/** * vBForum_Search_Type_SocialGroupMessage::showGroupSelect() * This function generates the select scrolling list for groups, * which is used in search for groupmessages * * @param string $name : name for the select element * @param string $style_string : something like "style=XXXX" or "class=XXX". Or empty * @return $html: complete html for the select element */ private function showGroupOptions($selected) { global $vbulletin, $vbphrase; if (!is_array($selected)) { $selected = array($selected); } //get rid of any invalid entries. $selected = array_filter($selected); //get groups to display. This is any group that we are a member of //and any groups that are on our "tosearch" list $mygroups = fetch_socialgroups_mygroups(false); $searchgroups = array(); foreach ($mygroups as $group) { $searchgroups[$group['groupid']] = $group['name']; } //if we have groups selected that aren't in the members groups, //account for them. $extra = array(); $extraids = array_diff($selected, array_keys($searchgroups)); if (count($extraids)) { $rst = $vbulletin->db->query_read("\n\t\t\t\tSELECT socialgroup.groupid, socialgroup.name\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup\n\t\t\t\tWHERE socialgroup.groupid IN (" . implode(', ', array_map('intval', $extraids)) . ")"); while ($row = $vbulletin->db->fetch_array($rst)) { $extra[$row['groupid']] = $row['name']; } } if (count($searchgroups) > 0 or count($extra) > 0) { $select = render_option_template($vbphrase['any_group'], '', !count($selected) ? 'selected="selected"' : ''); //make the extra items display first -- prepending keyed items //to the searchgroups array proved surprisingly cumbersome foreach ($extra as $id => $name) { $select .= render_option_template(htmlspecialchars_uni($name), $id, in_array($id, $selected) ? 'selected="selected"' : ''); } foreach ($searchgroups as $id => $name) { $select .= render_option_template(htmlspecialchars_uni($name), $id, in_array($id, $selected) ? 'selected="selected"' : ''); } return $select; } else { return false; } }
$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') . '";'); } // Display groups the current user is in if ($vbulletin->userinfo['userid']) { $mygroups = fetch_socialgroups_mygroups($vbulletin->options['sg_enablesocialgroupicons']); // Render bits $mygroup_bits = ''; foreach ($mygroups as $mygroup) { ($hook = vBulletinHook::fetch_hook('group_list_mygroupsbit')) ? eval($hook) : false; eval('$mygroup_bits .= "' . fetch_template('socialgroups_mygroups_' . ($vbulletin->options['sg_enablesocialgroupicons'] ? '' : 'listview_') . 'bit') . '";'); } } ($hook = vBulletinHook::fetch_hook('group_overview')) ? eval($hook) : false; $navbits[''] = $vbphrase['social_groups']; $show['creategroup'] = $vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['cancreategroups']; $templatename = 'socialgroups_overview'; } // ####################################################################### if ($_REQUEST['do'] == 'categorylist') { $vbulletin->input->clean_array_gpc('r', array('perpage' => TYPE_UINT, 'pagenumber' => TYPE_UINT, 'sort' => TYPE_NOHTML, 'order' => TYPE_NOHTML));
foreach ($newgroups as $group) { $group = prepare_socialgroup($group); $group['canjoin'] = can_join_group($group); $group['canleave'] = can_leave_group($group); ($hook = vBulletinHook::fetch_hook('group_newgroup_bit')) ? eval($hook) : false; $templater = vB_Template::create('socialgroups_newgroup_bit'); $templater->register('group', $group); $templater->register('template_hook', $template_hook); $newgroupbits .= $templater->render(); } unset($newgroups); // Get recently updated groups $updatedgroups = fetch_socialgroups_updatedgroups(); if ($vbulletin->userinfo['userid']) { // Display groups the current user is in $mygroups = fetch_socialgroups_mygroups(true); } else { // Random groups $mygroups = fetch_socialgroup_random_groups(); } // Get groupids to be displayed $groupids = array(); if (!empty($updatedgroups)) { foreach ((array) $updatedgroups as $group) { $groupids[] = $group['groupid']; } } if (!empty($mygroups)) { foreach ((array) $mygroups as $group) { $groupids[] = $group['groupid']; }