Topic: Repetitive code...
I've noticed that there isn't really a lot of repetitive code in punbb, however there is one thing that sticks out, as being in (almost) every file, but not being a function.
$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
This would work much better for modifications (and hooks) if this was put into a function.
eg
//functions.php
is_admmod($user,$mods_array) {
return ($$user['g_id'] == PUN_ADMIN || ($$user['g_moderator'] == '1' && array_key_exists($$user['username'], $mods_array))) ? true : false;
}
or
//functions.php
is_admmod($user,$mods_array) {
$is_admmod = ($$user['g_id'] == PUN_ADMIN || ($$user['g_moderator'] == '1' && array_key_exists($$user['username'], $mods_array))) ? true : false;
($hook = get_hook('fn_adnmod')) ? eval($hook) : null;
return $is_admmod;
}
and
//Some generic file (post.php, moderator.php, etc)
$mods_array = ($cur_posting['moderators'] != '') ? unserialize($cur_posting['moderators']) : array();
$is_admmod = is_admmod($pun_user,$mods_array);
Meh...
I enjoy pie :)