PDA

View Full Version : radiPanel Staff Emails Help!



:Pringles,
30-07-2012, 08:08 PM
Hey!

I need a bit of assistance with my radiPanel staff emails page.

As you all know, it shows up all of the contacts on your panel in their usergroups, but i would like my usergroups to be in heirachy order, meaning i would love my staff emails list to be in a paritcular ID order.

Admin - admin.addUsergroup?id=5
Radio Manager - admin.addUsergroup?id=4
Senior Presenter - admin.addUsergroup?id=11
Radio Presenter - admin.addUsergroup?id=2
Regular User - admin.addUsergroup?id=1

And here is the code of the radiPanel emails page which i would like ordered by ID number, and not just generically.


<?php

if( !preg_match( "/index.php/i", $_SERVER['PHP_SELF'] ) ) { die(); }

?>
<div class="box">

<div class="square title">
<strong>Staff Contact Details</strong>
</div>

<?php

$query = $db->query( "SELECT * FROM users ORDER BY displaygroup DESC" );

$j = "a";

while( $array = $db->assoc( $query ) ) {

$query2 = $db->query( "SELECT * FROM usergroups WHERE id = '{$array['displaygroup']}'" );
$array2 = $db->assoc( $query2 );

echo "<div class=\"row {$j}\">";

echo "<span style=\"float: right;\">";
echo $array['email'] ? $array['email'] : 'N/A';
echo "</span>";

echo "<span style=\"font-weight: bold; color: #{$array2['colour']};\">";
echo $array['username'];
echo "</span> ";

echo "(" . ( $array['habbo'] ? $array['habbo'] : 'N/A' ) . ")";

echo "</div>";

$j++;

if( $j == "c" ) {

$j = "a";

}

}

?>

</div>

Slopure
31-07-2012, 02:05 AM
I believe you do not need to code that, you can go into admin on radipanel, and go to manage user groups, and you can change ranking order by clicking the green arrows.

:Pringles,
31-07-2012, 04:10 AM
Gumy15; All that does is move about the menu order, it doesn't do anything for the staff email page, any new groups show up right at the top. The only groups in order is infact the groups which matthew gall coded himself into the panel.

Tomm
31-07-2012, 03:08 PM
The whole thing needs a cleanup from looking at that code. Why on earth would you put the query in the loop like that? Such a terrible idea and a waste of resources. You could just have one single query at the top and loop through that rather than potentially executing hundreds of stupid queries. Something like this:


SELECT * FROM users INNER JOIN usersgroups ON users.displaygroup = usergroups.id ORDER BY users.displaygroup DESC;

(also why do we need to do select * we don't appear to be using that many fields from each table)

Although without access to the schema I can't validate the accuracy of the query so I don't recommend you use it.

Anyway, you could get the ordering sorted by adding some kind of displayorder field in the usergroups table which specifies the order in which you want them to be displayed. Then you'd change the query to order by the display order rather than the group id. Although that would not be possible with the current code you posted as it first fetches the users than does the silly thing where it fetches the usergroup information over and over. You'd need to implement the kind of query I posted.

Want to hide these adverts? Register an account for free!