Hi,
there's this extension that needs some tweaking....
Rich Pedley wrote:Group Images
Adds images for user groups based on number of posts. Several images are included, but you can easily add more.
[code=xml]<?xml version="1.0" encoding="UTF-8"?>
<extension engine="1.0">
<id>egroups_imgs</id>
<title>Group Images Beta</title>
<version>0.5</version>
<description>WARNING: use at your own risk (written for 1.3 beta) Adds images for user groups based on number of posts. Set images on the Users > Groups page. Set number to display on the Users > Ranks page.</description>
<author>Rich Pedley</author>
<minversion>1.3 Beta</minversion>
<maxtestedon>1.3 Beta</maxtestedon>
<install><![CDATA[
if (!array_key_exists('o_egroup_imgs', $forum_config)){
$forum_db->query("INSERT INTO ".$forum_db->prefix."config (conf_name, conf_value) VALUES ('o_egroup_imgs', '1')");
$forum_db->add_field('groups', 'g_img', 'VARCHAR(255)', '');
$forum_db->add_field('ranks', 'img', 'VARCHAR(2)', '');
}
]]>
</install>
<uninstall><![CDATA[
$forum_db->query("DELETE FROM ".$forum_db->prefix."config WHERE conf_name = 'o_egroup_imgs'");
$forum_db->drop_field($forum_db->prefix.'groups', 'g_img');
$forum_db->drop_field($forum_db->prefix.'ranks', 'img');
]]>
</uninstall>
<hooks>
<hook id="agr_start, ark_start"><![CDATA[
if(file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
else
require $ext_info['path'].'/lang/English.php';
]]>
</hook>
<hook id="ark_add_rank_qr_add_rank"><![CDATA[
$group_image=$_POST['new_group_image'];
$query['INSERT'].=', img';
$query['VALUES'].=',\''.$forum_db->escape($group_image).'\'';
]]>
</hook>
<hook id="ark_update_qr_update_rank"><![CDATA[
$group_image=$_POST['group_image'][$id];
$query['SET'].=",img='".$forum_db->escape($group_image)."'";
]]>
</hook>
<hook id="ark_pre_add_rank_submit"><![CDATA[
?>
<div class="mf-field select">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span class="fld-label"><?php echo $lang_eg_imgs['Rank Images']; ?></span></label><br />
<span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="new_group_image">
<option value="">0</option>
<?php
for($i=1;$i<=10;$i++){
echo '<option value="'.$i.'">'.$i.'</option>'."\n";
}
?>
</select>
</span>
</div>
<?php
]]>
</hook>
<hook id="ark_pre_edit_cur_rank_submit"><![CDATA[
?>
<div class="mf-field select">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span class="fld-label"><?php echo $lang_eg_imgs['Group Image']; ?></span></label><br />
<span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="group_image[<?php echo $cur_rank['id'] ?>]">
<option value="">0</option>
<?php
for($i=1;$i<=10;$i++){
$sel='';
if($cur_rank['img']==$i) $sel=' selected="selected"';
echo '<option value="'.$i.'"'.$sel.'>'.$i.'</option>'."\n";
}
?>
</select>
</span>
</div>
<?php
]]>
</hook>
<hook id="agr_add_end_qr_add_group"><![CDATA[
$group_image=$_POST['group_image'];
$query['INSERT'].=', g_img';
$query['VALUES'].=',\''.$forum_db->escape($group_image).'\'';
]]>
</hook>
<hook id="agr_edit_end_qr_update_group"><![CDATA[
$group_image=$_POST['group_image'];
$query['SET'].=",g_img='".$forum_db->escape($group_image)."'";
]]>
</hook>
<hook id="agr_add_edit_group_pre_basic_details_fieldset_end"><![CDATA[
function get_group_icons(){
global $ext_info;
$eranks = array();
if($handle = opendir($ext_info['path'].'/icons/')){
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if($file!='.' && $file!='..')
$eranks[]=$file;
}
closedir($handle);
}
return $eranks;
}
$group_icons=get_group_icons();
?>
<div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box select">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span class="fld-label"><?php echo $lang_eg_imgs['Group Image']; ?></span></label><br />
<span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="group_image">
<option value=""><?php echo $lang_eg_imgs['None']; ?></option>
<?php
$group_icon_options='';
foreach ($group_icons as $k){
$sel='';
if($group['g_img']==$k) $sel=' selected="selected"';
$group_icon_options.='<option value="'.$k.'"'.$sel.' style="background: url('.$ext_info['url'].'/icons/'.$k.') no-repeat center left;padding-left:12px;">'.$k.'</option>'."\n";
}
echo $group_icon_options;
?>
</select>
</span>
</div>
</div>
<?php
]]>
</hook>
<hook id="vt_qr_get_posts"><![CDATA[
$query['SELECT'].=', g.g_img AS groupimage';
$gresult=$forum_db->query("SELECT min_posts, img FROM ".$forum_db->prefix."ranks ORDER BY min_posts DESC");
]]></hook>
<hook id="vt_row_pre_post_actions_merge"><![CDATA[
if ($cur_post['poster_id'] > 1 && $cur_post['groupimage']!='' && !isset($groupicon[$cur_post['poster_id']])){
while ($granks = $forum_db->fetch_assoc($gresult)){
//reset just in case..
$rank_markup='';
if(intval($cur_post['num_posts']) >= intval($granks['min_posts'])){
for($i=1;$i<=intval($granks['img']);$i++){
$rank_markup.='<img src="'.$ext_info['url'].'/icons/'.$cur_post['groupimage'].'" height="10" width="10" style="margin-left:1px;" alt="" />';
}
$rank_icon_splice = array('rankicon'=>'<li class="userrankicon">'.$rank_markup.'</li>');
if (isset($forum_page['author_ident']['avatar'])){
array_splice($forum_page['author_ident'], 3, 0, $rank_icon_splice);
}else{
array_splice($forum_page['author_ident'], 2, 0, $rank_icon_splice);
}
break;
}
}
//reset array and set this user as being parsed
mysql_data_seek($gresult,0);
$groupicon[$cur_post['poster_id']]='set';
}
]]></hook>
</hooks>
</extension>
[/code]