2013-01-03, 06:48 PM
(2013-01-03, 06:39 PM)pavemen Wrote: [ -> ]here is my Patches export that makes the edits to the groups page in the ACP. it adds the group id and the group's formatting
btw, the functions you are asking for are already in the ACP. Not useful for front-end plugins, but i the ACP you can use these
edit: as part of the $form object
/** * Generate a forum selection box. * * @param string The name of the selection box. * @param mixed Array/string of the selected items. * @param array Array of options (pid, main_option, multiple) * @param boolean Is this our first iteration of this function? * @return string The built select box. */ function generate_forum_select($name, $selected, $options=array(), $is_first=1) { global $fselectcache, $forum_cache, $selectoptions; if(!$selectoptions) { $selectoptions = ''; } if(!$options['depth']) { $options['depth'] = 0; } $options['depth'] = intval($options['depth']); if(!$options['pid']) { $pid = 0; } $pid = intval($options['pid']); if(!is_array($fselectcache)) { if(!is_array($forum_cache)) { $forum_cache = cache_forums(); } foreach($forum_cache as $fid => $forum) { $fselectcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; } } if($options['main_option'] && $is_first) { $select_add = ''; if($selected == -1) { $select_add = " selected=\"selected\""; } $selectoptions .= "<option value=\"-1\"{$select_add}>{$options['main_option']}</option>\n"; } if(is_array($fselectcache[$pid])) { foreach($fselectcache[$pid] as $main) { foreach($main as $forum) { if($forum['fid'] != "0" && $forum['linkto'] == '') { $select_add = ''; if(!empty($selected) && ($forum['fid'] == $selected || (is_array($selected) && in_array($forum['fid'], $selected)))) { $select_add = " selected=\"selected\""; } $sep = ''; if(isset($options['depth'])) { $sep = str_repeat(" ", $options['depth']); } $style = ""; if($forum['active'] == 0) { $style = " style=\"font-style: italic;\""; } $selectoptions .= "<option value=\"{$forum['fid']}\"{$style}{$select_add}>".$sep.htmlspecialchars_uni(strip_tags($forum['name']))."</option>\n"; if($forum_cache[$forum['fid']]) { $options['depth'] += 5; $options['pid'] = $forum['fid']; $this->generate_forum_select($forum['fid'], $selected, $options, 0); $options['depth'] -= 5; } } } } } if($is_first == 1) { if(!isset($options['multiple'])) { $select = "<select name=\"{$name}\""; } else { $select = "<select name=\"{$name}\" multiple=\"multiple\""; } if(isset($options['class'])) { $select .= " class=\"{$options['class']}\""; } if(isset($options['id'])) { $select .= " id=\"{$options['id']}\""; } if(isset($options['size'])) { $select .= " size=\"{$options['size']}\""; } $select .= ">\n".$selectoptions."</select>\n"; $selectoptions = ''; return $select; } } /** * Generate a group selection box. * * @param string The name of the selection box. * @param mixed Array/string of the selected items. * @param array Array of options (class, id, multiple) * @return string The built select box. */ function generate_group_select($name, $selected=array(), $options=array()) { global $cache; $select = "<select name=\"{$name}\""; if(isset($options['multiple'])) { $select .= " multiple=\"multiple\""; } if(isset($options['class'])) { $select .= " class=\"{$options['class']}\""; } if(isset($options['id'])) { $select .= " id=\"{$options['id']}\""; } if(isset($options['size'])) { $select .= " size=\"{$options['size']}\""; } $select .= ">\n"; $groups_cache = $cache->read('usergroups'); foreach($groups_cache as $group) { $selected_add = ""; if(is_array($selected)) { if(in_array($group['gid'], $selected)) { $selected_add = " selected=\"selected\""; } } $select .= "<option value=\"{$group['gid']}\"{$selected_add}>".htmlspecialchars_uni(strip_tags($group['title']))."</option>"; } $select .= "</select>"; return $select; }
Thank you for this, I would really like this to be built into myBB in a future version. Or something that makes it this easy.