Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
--- a/includes/clientside/static/comments.js Tue Aug 28 19:00:20 2007 -0400
+++ b/includes/clientside/static/comments.js Wed Aug 29 18:23:37 2007 -0400
@@ -181,14 +181,14 @@
// User level
tplvars.USER_LEVEL = 'Guest';
if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member';
- if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator';
- if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator';
+ if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator';
+ if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator';
// Send PM link
tplvars.SEND_PM_LINK=(this_comment.user_id>1 && data.logged_in)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">Send private message</a><br />':'';
// Add buddy link
- tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1 && data.logged_in)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':'';
+ tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1 && data.logged_in && this_comment.is_buddy != 1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':'';
// Edit link
tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</a>';
@@ -208,6 +208,13 @@
tplbool.signature = ( this_comment.signature == '' ) ? false : true;
tplbool.can_edit = ( data.auth_edit_comments && ( ( this_comment.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) );
tplbool.auth_mod = data.auth_mod_comments;
+ tplbool.is_friend = ( this_comment.is_buddy == 1 && this_comment.is_friend == 1 );
+ tplbool.is_foe = ( this_comment.is_buddy == 1 && this_comment.is_friend == 0 );
+
+ if ( tplbool.is_friend )
+ tplvars.USER_LEVEL += '<br /><b>On your friend list</b>';
+ else if ( tplbool.is_foe )
+ tplvars.USER_LEVEL += '<br /><b>On your foe list</b>';
parser.assign_vars(tplvars);
parser.assign_bool(tplbool);
--- a/includes/comment.php Tue Aug 28 19:00:20 2007 -0400
+++ b/includes/comment.php Wed Aug 29 18:23:37 2007 -0400
@@ -106,11 +106,15 @@
{
$ret['template'] = file_get_contents(ENANO_ROOT . '/themes/' . $template->theme . '/comment.tpl');
}
- $q = $db->sql_query('SELECT c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,u.user_level,u.user_id,u.signature FROM '.table_prefix.'comments AS c
+ $q = $db->sql_query('SELECT c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,u.user_level,u.user_id,u.signature, b.buddy_id IS NOT NULL AS is_buddy, ( b.is_friend IS NOT NULL AND b.is_friend=1 ) AS is_friend FROM '.table_prefix.'comments AS c
LEFT JOIN '.table_prefix.'users AS u
ON (u.user_id=c.user_id)
+ LEFT JOIN '.table_prefix.'buddies AS b
+ ON ( ( b.user_id=' . $session->user_id.' AND b.buddy_user_id=c.user_id ) OR b.user_id IS NULL)
WHERE page_id=\'' . $this->page_id . '\'
- AND namespace=\'' . $this->namespace . '\';');
+ AND namespace=\'' . $this->namespace . '\'
+ GROUP BY c.comment_id
+ ORDER BY c.time ASC;');
$count_appr = 0;
$count_total = 0;
$count_unappr = 0;
@@ -134,6 +138,18 @@
// Format text
$row['comment_data'] = RenderMan::render($row['comment_data']);
+ if ( $row['is_buddy'] == 1 && $row['is_friend'] == 0 )
+ {
+ $seed = md5(sha1(mt_rand() . microtime()));
+ $wrapper = '
+ <div id="posthide_'.$seed.'" style="display: none;">
+ ' . $row['comment_data'] . '
+ </div>
+ <p><span style="opacity: 0.4; filter: alpha(opacity=40);">Post from foe hidden.</span> <span style="text-align: right;"><a href="#showpost" onclick="document.getElementById(\'posthide_'.$seed.'\').style.display=\'block\'; this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;">Display post</a></span></p>
+ ';
+ $row['comment_data'] = $wrapper;
+ }
+
// Format date
$row['time'] = date('F d, Y h:i a', $row['time']);
--- a/includes/pageprocess.php Tue Aug 28 19:00:20 2007 -0400
+++ b/includes/pageprocess.php Wed Aug 29 18:23:37 2007 -0400
@@ -709,6 +709,13 @@
echo '<tr><td class="row3">Real name: ' . $userdata['real_name'] . '</td></tr>';
}
+ // Administer user button
+
+ if ( $session->user_level >= USER_LEVEL_ADMIN )
+ {
+ echo '<tr><td class="row1"><a href="' . makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'UserManager&src=get&user=' . urlencode($target_username), true) . '" onclick="ajaxAdminUser(\'' . addslashes($target_username) . '\'); return false;">Administer user</a></td></tr>';
+ }
+
// Comments
echo '<tr><th class="subhead">' . htmlspecialchars($target_username) . '\'s latest comments</th></tr>';
--- a/includes/stats.php Tue Aug 28 19:00:20 2007 -0400
+++ b/includes/stats.php Wed Aug 29 18:23:37 2007 -0400
@@ -60,7 +60,7 @@
}
$data = array();
- $q = $db->sql_query('SELECT COUNT(hit_id) AS num_hits, page_id, namespace FROM hits GROUP BY page_id, namespace ORDER BY num_hits DESC LIMIT ' . $num . ';');
+ $q = $db->sql_query('SELECT COUNT(hit_id) AS num_hits, page_id, namespace FROM '.table_prefix.'hits GROUP BY page_id, namespace ORDER BY num_hits DESC LIMIT ' . $num . ';');
while ( $row = $db->fetchrow() )
{
--- a/themes/oxygen/comment.tpl Tue Aug 28 19:00:20 2007 -0400
+++ b/themes/oxygen/comment.tpl Wed Aug 29 18:23:37 2007 -0400
@@ -4,16 +4,16 @@
<th colspan="2" style="text-align: left;">{DATETIME}</th>
</tr>
<tr>
- <td style="width: 120px; height: 100%;" rowspan="4" valign="top" class="row1">
+ <td style="width: 120px; height: 100%;" rowspan="4" valign="top" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
<table border="0" width="100%" style="height: 100%;" cellspacing="0" cellpadding="0">
<tr>
- <td valign="top" class="row1">
+ <td valign="top" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
<b>{NAME}</b><br />
<small>{USER_LEVEL}</small>
</td>
</tr>
<tr>
- <td valign="bottom" class="row1">
+ <td valign="bottom" class="row1<!-- BEGIN is_friend --> row1_green<!-- END is_friend --><!-- BEGIN is_foe --> row1_red<!-- END is_foe -->">
{SEND_PM_LINK} {ADD_BUDDY_LINK}
</td>
</tr>
--- a/themes/oxygen/css/bleu.css Tue Aug 28 19:00:20 2007 -0400
+++ b/themes/oxygen/css/bleu.css Wed Aug 29 18:23:37 2007 -0400
@@ -71,6 +71,14 @@
div.tblholder th.subhead { padding: 4px; background-color: #90A0B0; font-weight: bold; text-align: center; color: #FFFFFF; }
div.tblholder table { background-color: #FFFFFF; width: 100%; }
+/* Colored table cells */
+div.tblholder td.row1_red { padding: 4px; background-color: #F8E0E0; }
+div.tblholder td.row2_red { padding: 4px; background-color: #FFF0F0; }
+div.tblholder td.row3_red { padding: 4px; background-color: #FFE8E8; }
+div.tblholder td.row1_green { padding: 4px; background-color: #E0F8E0; }
+div.tblholder td.row2_green { padding: 4px; background-color: #F0FFF0; }
+div.tblholder td.row3_green { padding: 4px; background-color: #E8FFE8; }
+
div.tblholder th a {
color: #FFFFFF !important;
text-decoration: underline !important;