Code:
INSERT INTO `LocalizationStrings` VALUES (10001, 1, 'Profile Comments');
INSERT INTO `LocalizationStrings` VALUES (10002, 1, 'Comment');
INSERT INTO `LocalizationStrings` VALUES (10003, 1, 'Write comment');
INSERT INTO `LocalizationStrings` VALUES (10004, 1, 'Read Comments');
INSERT INTO `LocalizationStrings` VALUES (10005, 1, 'Read New Comments');
INSERT INTO `LocalizationStrings` VALUES (10006, 1, 'comment added successfully');
INSERT INTO `LocalizationStrings` VALUES (10007, 1, 'failed to add comment');
INSERT INTO `GlParams` (`Name`, `VALUE`, `kateg`, `desc`, `Type`, `check`, `err_text`) VALUES ('enable_profileComments',
'on', '1', 'Enable Comments for profiles', 'checkbox', '', '7');
CREATE TABLE `ProfilesComments` (
`ID` bigint(20) NOT NULL auto_increment,
`Date` datetime NOT NULL default '0000-00-00 00:00:00',
`IP` varchar(16) default NULL,
`Sender` bigint(8) unsigned NOT NULL default '0',
`Recipient` bigint(8) unsigned NOT NULL default '0',
`Text` mediumtext NOT NULL,
`New` enum('0','1') NOT NULL default '1',
`date` datetime default '0000-00-00 00:00:00',
`ReplyTO` int(11) unsigned default NULL,
PRIMARY KEY (`ID`),
KEY `Pair` (`Sender`,`Recipient`)
) TYPE=MyISAM;
#
#
#
//--------------------------
in your styles_ae???css
find
/*
*
* End Blog Styles
add above
/*###############################################*/
div#profileComments
{
position:relative;
border:0px solid red;
}
div.comment_row
{
position:relative;
border-bottom:1px solid #cecece;
margin-bottom:10px;
}
div.comment_caption
{
position:relative;
font-weight:bold;
margin-bottom:5px;
}
div.comment_text
{
position:relative;
margin-bottom:5px;
border:1px solid #cecece;
background-color:#F3F5FF;
padding:3px;
}
/*###############################################*/
div.block_menu
{
position: absolute;
right: 5px;
font-weight: bold;
cursor: pointer;
text-transform: uppercase;
}
div.db_2_block div.block_menu
{
top: 7px;
color: #FFFFFF;
}
div.design_box_border div.block_menu
{
top: 0px;
color: #3F3F3F;
}
/*###############################################*/
div.add_comment, div.addcomment_submit, div.addcomment_textarea
{
position:relative;
text-align:right;
margin-bottom:5px;
}
textarea.comment_textarea
{
width:543px;
height:70px;
}
div.comment_menu
{
position:relative;
border:0px solid red;
height:16px;
margin-bottom:5px;
background-color:#EFF0F4;
}
div.comment_menu div.for_all
{
position:absolute;
top:0px;
right:10px;
border:0px solid green;
}
div.comment_menu div.for_all span
{
margin:0px 5px;
}
div.comment_menu div.for_edit
{
position:absolute;
top:0px;
left:10px;
border:0px solid blue;
}
div.addcomment_submit
{
border:0px solid red;
}
div.answer_smiles
{
position:relative;
text-align:center;
border:0px solid red;
}
div.commentNew
{
position:absolute;
top:4px;
right:0px;
color:green;
}
/*###############################################*/
//-----------------------------------------
in your profile.php
find:
$vote_count = get_vote_member_count($ID);
}
add below
/* Vars */
/* ID of Logged member */
$memberID = (int)$member['ID'];
/* ID of profile */
$profileID = (int)$ID;
$owner = ($profileID == $memberID ) ? 1 : 0;
$period = 1; // time period before user can add another record (in minutes)
$records_on_page = 16; // number of records at the page
$record_maxlength = 1600; // max length of record
$record_limit = 100; // maximum number of records in the guest book
$iPerPage = 5;
$show = 6;
/* Vars */
find
$enable_couple = getParam("enable_couple") == "on" ? 1 : 0;
add below
$enable_profileComments = ( 'on' == getParam("enable_profileComments") ) ? 1 : 0;
$_page_cont[$_ni]['profile_comments'] = $enable_profileComments ? getMemberProfileComments() : '';
find
$ret .= print_row_area2( $arrpd, process_smiles( $text ), "table", $rd, 2 );
break;
}
}
return $ret;
}
add below
// Profile Comments BEGIN ------------------------------------------------------
function getMemberProfileComments()
{
global $site;
global $logged;
global $oTemplConfig;
global $profileID;
global $memberID;
global $owner;
$ret = '';
if( $logged['member'] )
{
$ret .= '<div class="add_comment">';
$ret .= '<a href="javascript:void(0);" onclick="z = document.getElementById(\'addCommentArea\');
z.style.display=\'block\'">' . _t("_Add comment") . '</a>';
$ret .= '</div>';
}
if( $_POST['commentsubmit'] )
{
$ret .= addComment($profileID);
}
if( $_GET['action'] == 'commentdelete' )
{
$commentID = (int)$_GET['commentID'];
$ret .= deleteComment($commentID);
}
if ( $_GET['page'] )
{
$sFormAdd = '&page=' . (int)$_GET['page'];
}
$ret .= '<div id="profileComments">';
$ret .= '<div style="display:none;" class="addcomment_textarea" id="addCommentArea">' . "\n";
$ret .= '<form method="post" action="' . $site['url'] . 'profile.php?ID=' . $profileID . $sFormAdd
. '">';
$ret .= '<textarea name="commenttext" class="comment_textarea"
id="commenttext"></textarea>';
$ret .= '<div class="answer_smiles">';
$ret .= put_smiles( 'commenttext', 120);
$ret .= '</div>';
$ret .= '<div class="addcomment_submit">';
$ret .= '<input type="hidden" name="ID" value="' . $profileID . '" />';
$ret .= '<input type="hidden" name="member" value="' . $memberID . '" />';
$ret .= '<input type="hidden" name="commentsubmit" value="true" />';
$ret .= '<input type="submit" value="add comment" />';
$ret .= '</div>';
$ret .= '</form>';
$ret .= '</div>' . "\n";
$ret .= getCommentList( '', 1 );
$ret .= '<div style="text-align:center;"> ';
$ret .= getCommentNavigation();
$ret .= '</div>';
$ret .= '</div>';
$langShow = _t('_Show');
$langHide = _t('_Hide');
$menu = '<div class="block_menu"
onclick="javascript: if ( \'none\' == document.getElementById(\'profileComments\').style.display ) {
document.getElementById(\'profileComments\').style.display=\'block\'; this.innerHTML=\''. $langHide .'\'; } else {
document.getElementById(\'profileComments\').style.display=\'none\'; this.innerHTML=\''. $langShow .'\'; }" >'. $langHide
.'</div>';
return $ret;
// return DesignBoxContent( _t("_profile_comments"), $ret, $oTemplConfig -> getMemberProfileComments_db_num, $menu );
}
function getCommentList( $commentID = '', $sql_limit = 0)
{
global $cont;
global $logged;
global $site;
global $iPerPage;
global $profileID;
global $memberID;
global $owner;
global $ID_PIC_URL;
global $ID_PIC_DIR;
$ret = '';
if( $commentID )
{
$add = ' AND `ReplyTO` = \'' . $commentID . '\' ';
}
else
{
$add = ' AND `ReplyTO` is null ';
}
if ( 1 == $sql_limit )
{
if( !$_GET['page'] )
{
$page = 0;
}
else
{
$page = ((int)$_GET['page']-1) * $iPerPage;
}
$query_limit = " LIMIT {$page}, {$iPerPage} ";
}
else
{
$query_limit = "";
}
if ( $_GET['page'] )
{
$sFormAdd = '&page=' . (int)$_GET['page'];
}
$comment_query = "SELECT
`ProfilesComments`.`ID` AS gID,
`ProfilesComments`.`Date`,
`ProfilesComments`.`IP`,
`ProfilesComments`.`Sender`,
`ProfilesComments`.`Recipient`,
`ProfilesComments`.`Text`,
`ProfilesComments`.`New`,
`ProfilesComments`.`Date`,
`ProfilesComments`.`ReplyTO`,
`Profiles`.`Pic_0_addon`,
`Profiles`.`ID` AS pID,
`Profiles`.`NickName` AS pNick
FROM
`ProfilesComments`
LEFT JOIN `Profiles` ON `ProfilesComments`.`Sender` = `Profiles`.`ID`
WHERE
`ProfilesComments`.`Recipient` = '" . $profileID . "'
" . $add . "
ORDER BY `Date` DESC $query_limit ;";
//echo $comment_query;
$comment_res = db_res($comment_query);
while( $comment_arr = mysql_fetch_assoc($comment_res))
{
$ret .= '<div class="comment_row" style="margin-left:' . ( 10*$cont) . 'px;">';
$ret .= '<div class="comment_caption">';
$ret .= '<a href="' . $site['url'] . 'profile.php?ID=' . $comment_arr['pID'] . '">';
$ret .= process_line_output($comment_arr['pNick']);
// Add posters Photo - Thumbnail to post IN DEVELOPMENT
// $id = $comment_arr['pID'];
// $thumb_name = "$ID_PIC_URL" . $id . "_" . "0_{$comment_arr['Pic_0_addon']}" . ".jpg";
// $ret .= $thumb_name;
// add time of comment to comment in correct order display ex. 00-00-00 time 01:10:10
$ret .= '</a>';
$ret .= '<div class="comment_caption">';
$ret .= process_line_output (date("m-d-Y - h:ia", strtotime($comment_arr['Date'])));
$ret .= '</div>';
if( $owner && $comment_arr['New'] )
{
$ret .= '<div class="commentNew">' . _t("_new") . '</div>';
db_res("UPDATE `ProfilesComments` SET `New` = '0' WHERE `ID` =
'{$comment_arr['gID']}';");
}
elseif( $logged['admin'] )
{
$ret .= '<div class="commentNew">' . _t("_new") . '</div>';
}
$ret .= '</div>';
$ret .= '<div class="comment_text">';
$ret .= process_smiles(process_text_withlinks_output($comment_arr['Text']));
$ret .= '</div>' . "\n";
$ret .= '<div class="comment_menu" id="menu' . $comment_arr['gID'] . '" style="display:block;">';
$ret .= '<div class="for_all">';
$ret .= ( $owner || $logged['admin'] ) ? '<span><a href="' . $site['url'] .
'profile.php?ID=' . $profileID . '&action=commentdelete&commentID=' . $comment_arr['gID'] . '">delete</a></span>' :
'';
$ret .= ( $logged['member'] ) ? '<span><a href="javascript:void(0);" onclick="z =
document.getElementById(\'comm' . $comment_arr['gID'] . '\'); y = document.getElementById(\'menu' . $comment_arr['gID'] .
'\'); z.style.display=\'block\'; y.style.display=\'none\';">answer</a></span>' : '';
$ret .= '</div>';
$ret .= '</div>';
$cont ++;
$ret .= '</div>';
$ret .= '<div style="display:none;" class="addcomment_textarea" id="comm' . $comment_arr['gID'] .
'">' . "\n";
$ret .= '<form method="post" action="' . $site['url'] . 'profile.php?ID=' . $profileID .
$sFormAdd . '">';
$ret .= '<textarea name="commenttext" class="comment_textarea" id="answer_text' .
$comment_arr['gID'] . '"></textarea>';
$ret .= '<div class="answer_smiles">';
$ret .= put_smiles( 'answer_text' . $comment_arr['gID'], 120);
$ret .= '</div>';
$ret .= '<div class="addcomment_submit">';
$ret .= '<input type="hidden" name="replyTO" value="' . $comment_arr['gID']
. '" />';
$ret .= '<input type="hidden" name="ID" value="' . $profileID . '" />';
$ret .= '<input type="hidden" name="member" value="' . $memberID . '" />';
$ret .= '<input type="hidden" name="commentsubmit" value="true" />';
$ret .= '<input type="submit" value="add comment" />';
$ret .= '</div>';
$ret .= '</form>';
$ret .= '</div>' . "\n";
$ret .= getCommentList( $comment_arr['gID'] );
$cont --;
}
return $ret;
}
function addComment( $profileID )
{
global $record_maxlength;
global $period;
global $record_limit;
global $logged;
$ret = "";
$record_text = process_db_input(strmaxtextlen( $_POST['commenttext'], $record_maxlength ));
$record_sender = strlen($_COOKIE['memberID']) ? (int)$_COOKIE['memberID'] : "";
$record_recipient = (int)$profileID;
$ip = ( getenv('HTTP_CLIENT_IP') ? getenv('HTTP_CLIENT_IP') : getenv('REMOTE_ADDR') );
if($_POST['replyTO'] > 0 )
{
$replyTO = (int)$_POST['replyTO'];
}
else
{
$replyTO = 'NULL';
}
if ( !$record_recipient )
return $ret;
if( !$record_sender )
{
return $ret;
}
if( strlen($record_text) < 2 )
{
$ret .= _t_err("_enter_message_text");
return $ret;
}
// Test if IP is defined
if ( !$ip )
{
$ret .= _t_err("_sorry, i can not define you ip adress. IT'S TIME TO COME OUT !");
return $ret;
}
// Test if last message is old enough
$last_count = db_arr( "SELECT COUNT( * ) AS `last_count` FROM `ProfilesComments` WHERE `IP` = '{$ip}' AND
(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`Date`) < {$period}*60)" );
if ( $last_count['last_count'] != 0 )
{
$ret .= _t_err("_You have to wait for PERIOD minutes before you can write another message!", $period);
return $ret;
}
// Perform insertion
db_res( "INSERT INTO `ProfilesComments` SET `Date` = NOW(), `IP` = '{$ip}', `Sender` = '{$record_sender}',
`Recipient` = '{$record_recipient}', `Text` = '{$record_text}', `New` = '1', `ReplyTO` = {$replyTO};" );
//echo "INSERT INTO `ProfilesComments` SET `Date` = NOW(), `IP` = '{$ip}', `Sender` = '{$record_sender}',
`Recipient` = '{$record_recipient}', `Text` = '{$record_text}', `New` = '1', `ReplyTO` = {$replyTO};" . '<hr>';
return $ret;
}
function deleteComment( $commentID )
{
global $logged;
global $profileID;
global $memberID;
global $owner;
$commentID = (int)$commentID;
if( $owner || $logged['admin'] )
{
$del = db_res( "SELECT `ID` FROM `ProfilesComments` WHERE `ReplyTO` = '$commentID' ");
while ( $del_arr = mysql_fetch_array($del))
{
deleteComment( $del_arr['ID'] );
}
db_res("DELETE FROM `ProfilesComments` WHERE `ID` = '$commentID'");
}
else
{
$ret = '';
return $ret;
}
}
function getCommentNavigation()
{
global $site;
global $iPerPage;
global $show;
global $profileID;
global $memberID;
global $owner;
$page = $_GET['page'] ? $_GET['page'] : 1;
$ret = '';
$nav_query = "
SELECT
COUNT(*)
FROM
`ProfilesComments`
LEFT JOIN `Profiles` ON `ProfilesComments`.`Sender` = `Profiles`.`ID`
WHERE
`ProfilesComments`.`Recipient` = '" . $profileID . "'
AND `Profiles`.`Status` = 'Active'
AND `ReplyTO` is NULL;";
$nav_arr = db_arr($nav_query);
$pages = ceil( $nav_arr['0'] / $iPerPage );
$around = (int)($show / 2);
if( $page < $show )
{
$start = 1;
}
elseif( $page > $pages - $show )
{
$start = max(1, $pages - $show);
}
else
{
$start = $page - $around;
}
if ( $page < $show )
{
$end = min($show, $pages);
}
elseif ( $page > $pages - $show )
{
$end = $pages;
}
else
{
$end = $page + $around;
}
$ret .= '<div style="margin-bottom:5px;"> ';
for( $i = $start; $i <= $end; $i++ )
{
if( $page == $i )
{
$ret .= '<span>[ ' . $i . ' ]</span> ';
}
else
{
$ret .= ' <span>[ <a href="' . $site['url'] . 'profile.php?ID=' . $profileID . '&page=' .
$i . '">' . $i . '</a> ]</span>';
}
}
$ret .= '</div>';
$ret .= '<div> ';
if( 1 < $page )
{
$ret .= ' <a href="' . $site['url'] . 'profile.php?ID=' . $profileID . '">First</a> | ';
$ret .= ' <a href="' . $site['url'] . 'profile.php?ID=' . $profileID . '&page=' . ( $page - 1 ) .
'"><< Previous</a> ';
}
if( $page < $pages)
{
$ret .= ' <a href="' . $site['url'] . 'profile.php?ID=' . $profileID . '&page=' . ( $page + 1 ) .
'">Next >></a> | ';
$ret .= ' <a href="' . $site['url'] . 'profile.php?ID=' . $profileID . '&page=' . ($pages) .
'">Last</a>';
}
$ret .= '</div>';
return $ret;
}
// - END
//---------------------------------
in your tmpl_???_page_7.html
add below (where ever you want the comments hack to be displayed)
<div class="clear_both" align="center">__profile_comments__</div>
// ------------------------------
open member.php
find:
// new messages attention
$new_mess_arr = db_arr( "SELECT ID FROM `Messages` WHERE Recipient = $p_arr[ID] AND New = '1' ORDER BY Date DESC
LIMIT 1" );
if ( $new_mess_arr )
$mess = $new_mess_arr[ID];
after add
// new profile comments member
$new_com_arr = db_arr ("SELECT ID FROM `ProfilesComments` WHERE Recipient = $p_arr[ID] AND New = '1' LIMIT 1");
if ( $new_com_arr )
$vcomm = 1;
// end new profile comments member
find:
else
echo _t( "_ATT_MESSAGE_NONE", $site['url'] );?>
</td>
</tr>
after add:
<tr class=table>
<td class=control_panel_td_1 valign=top align="left"><? echo _t( "_profile_comments" ); ?>:</td>
<td class=control_panel_td_2 valign=top align="left">
<a href="<?= $site['url'] ?>profile.php?ID=<?= $p_arr[ID] ?>" style="font-weight: bold;"> <?= _t('_view_comments')
?>
</a><br />
<?
if ( $vcomm )
echo _t( "_ATT_PCOMMENTSNOTIFY", $site['url'] );
else
echo _t( "_ATT_PC_NONENOTIFY", $site['url'] );?>
</td>
</tr>
// ---- add to lang file BEGIN
'_profile_comments' => 'Profile Comments',
'_view_comments' => 'View Comments',
'_ATT_PC_NONENOTIFY' => 'No new Comments<br>',
'_ATT_PCOMMENTSNOTIFY' =>' <b><font color=#00ff00>New Comment</b></font><br>',
// ---- add to lang file End
Bookmarks