News:

Join the Facebook Fan Page.

Main Menu

GuestBook

Started by NiXnAx, December 07, 2004, 11:58:23 PM

Previous topic - Next topic

NiXnAx

Hey guys, I need some help with the mod I'm writing, cant make it work when it gets more than one post in the guestbook :-/

The code I already have, is located here. And I have a testforum here. Just go into the profile to view the guestbook.

I would be happy if you could come with suggestions and other ways to write the code on :-/

CapriSkye

guestbook in a forum? that's an interesting idea, hope you'll get some help here.

NiXnAx

Could someone tell me what is wrong with this code? I only get one entry into the array, I'm not sure if I have done it correct, but I know that the SQL is correct.
function loadGuestBook($user)
{
global $gbookLoaded, $db_prefix;
  // Getting the guestbook enties from the database
$request = db_query("
  SELECT guestpostid, Owner_ID, Guest_ID, memberName, realName, signtime, body
    FROM {$db_prefix}guestbooks, {$db_prefix}members
   WHERE Owner_ID=$user
     AND ID_MEMBER=Guest_ID
   ORDER BY signtime DESC", __FILE__, __LINE__);
$i = 0;
while ($grow = mysql_fetch_assoc($request))
{
// Censor....
censorText($grow['body']);

// Do the code.
  $gbookLoaded = array(
    '$i' => array(
'gbookid' => $grow['guestpostid'],
'Guest_ID' => $grow['Guest_ID'],
'Owner_ID' => $grow['Owner_ID'],
'username' => $grow['memberName'],
'guestname' => $grow['realName'],
'signtime' => timeformat($grow['signtime']),
'body' => doUBBC($grow['body'], 1)));
$i++;
}
  return;

}


Here is the code located in the Profile.template.php

  // GuestBook for the member.
$usernumber = $context['member']['id'];
if ($modSettings['gbook_enable'] == '1')
{
global $gbookLoaded;
loadGuestBook($usernumber);
$gbook = $gbookLoaded;
echo '
<tr>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr>
<tr>
<td colspan="2">
<div style="position: relative; top: 0px; left: 0px; width: 95%; height: 140px; margin: 2px; padding: 7px; border-style: inset; border-left-width: 2px; border-right-width: 2px; border-top-width: 2px; border-bottom-width: 2px; overflow: auto;" class="quote">';
if ( $context['user']['id'] != '0' && $gbook[ sizeof($gbook)-1 ]['Guest_ID'] != $context['user']['id'] )
  echo '
<form action="' . $scripturl . '?action=profile;u=', $usernumber, '" method="post" name="postmodify">
<input type="hidden" name="Guest_ID" value="' . $context['user']['id'] . '">
<input type="hidden" name="Owner_ID" value="' . $usernumber . '">
<center>
<textarea style="font-size: 10px; width: 90%; margin: 2px" name="message" cols="57" rows="4" wrap="soft" ONCLICK="javascript:storeCaret(this);" ONKEYUP="javascript:storeCaret(this);" ONCHANGE="javascript:storeCaret(this);"></textarea>

<br>
<input value="200" name="msgCL" style="width:33px; font-size: 12px" disabled>
<input type="submit" value="Add" style="width:35px; font-size: 12px">
</center>
<script language="JavaScript">
<!--
var supportsKeys = false
function tick() {
calcCharLeft(document.forms[0])
if (!supportsKeys) timerID = setTimeout("tick()",200)
}

function calcCharLeft(sig) {
clipped = false
maxLength = ' , $modSettings['gbook_lenght'] , '
if (document.postmodify.message.value.length > maxLength) {
document.postmodify.message.value = document.postmodify.message.value.substring(0,maxLength)
charleft = 0
clipped = true
}
else {
charleft = maxLength - document.postmodify.message.value.length
}
document.postmodify.msgCL.value = charleft
return clipped
}
tick();
//-->
</script>';
echo '
<hr size="1" width="100%" class="hr">
<font size="1"><b>Posts:</b> ' . sizeof($gbook) . '</font>

<hr size="1" width="100%" class="hr">
<br>';
for($i=0;$i < count($gbook); $i++ ) {
echo '
<b><a href="', $scripturl, '?action=profile;u=', $gbook[$i]['Guest_ID'] , '" title="' . $gbook[$i]['username'] . '">' . $gbook[$i]['guestname'] . '</a> - ', $gbook[$i]['signtime'], '</b><br><br>
' . $gbook[$i]['body'] . '<br><br>Post: ', (count($gbook)-$i);
if ( $gbook[$i]['Owner_ID'] == $context['member']['id'] ) {
echo ' 
- <a href="', $scripturl, '?action=profile;u=', $usernumber, ';delete=', $gbook[$i]['gbookid'], '" title="Delete post from guestbook">Delete post</a>';
}
}
echo '
<hr size="1" width="100%" class="hr"><br><br>';

  echo '
</div>
</td>
</tr>';
}

[Unknown]

'$i' => array(

Don't quote your variables!  In this case, you want:

$gBookLoaded[] = array(
   'gbookid' => ...
);

-[Unknown]

NiXnAx

#4
Okay, the guestbook mod works as a charm now :D (for now)
The things that are missing is:
  • the admin functions to controll the size of the posts and how many entries there can be in a guestbook, if the guestbook is enabled, if guests can post in it (now they can't)
  • The message in the top to say how many new guestbook entries you have Done
  • User configuration
  • Delete a series of entiries
  • Clear the guestbook of all the members or just one member
  • The guestbook itselfe with delete and add entries Done

thanks a lot [Unknown] for the help.

But I were wondering if there was a quick way to test if the user viewing the guestbook has admin priviliges? (so that he could delete inappropriate entries)

(the link in the first post have been updated and it should now be set up with the package installer I think, if it works correctly  :-X)

zillion

Just curious why you want a "Guest Book"!  What advantages does this have over (say) just another Board, where Guests can post?

ANARCH¥

lol, its exactly the idea i got....open a new thread. call him: Introduce Yourself!

NiXnAx

It is more personal getting a message in the guestbook, and it is not a message to all the members of the board, but everyone can read it. And there is a larger posibility that the member will read it ;)

CapriSkye

i think the idea is pretty cool. forum is like talking to everybody where guestbook is just toward one person. hope you'll release the mod soon.

CapriSkye


NiXnAx

I havn't had much time to do anything on it, and I wish there were someone to help me with making the permissions, and configuration of the plugin.

Advertisement: