Welcome to Geeklog, Anonymous Monday, December 30 2024 @ 01:22 pm EST

Geeklog Forums

Saving comments in Journal Plugin


Nomood

Anonymous
Journal plugin --- when comments saved leads to the index page of the site instead of the comment or article

The code seems to be correct. Any one having any idea / corrective measure ?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
As discussed here: The plugin API for comments has changed in Geeklog 1.4.0 and the plugin has to be updated.

bye, Dirk
 Quote

Nomood

Anonymous
well, according to Vinny's article, there is nothing much wrong in the journal plugin - also I am speaking of GL versions prior to 1.4

The code seems perfectly ok , for example

echo "hello"; should show "hello" whatever be the version or modifications. Thus the code is quite simple in this case - what is bugging me is where is the bug ...

I have to dig deeper I guess
 Quote

Status: offline

zaurav

Forum User
Chatty
Registered: 01/07/06
Posts: 57
keep us posted with the code, if you can get it to work. I am having the same problem and its really frustrating.
 Quote

Nomood

Anonymous
well .... zaurav, this is funny and Dirk will frown and could be angry BUT
this is what works for me with the 1.3.11 series

This will , instead of taking to home page, will take you to the comment page where you made the comment in the journal
[ BTW - do u know how many comments per page / can that be paginated ?? ?? ]

Here are the necessary changes .... please give feedback whether this *works* for you

Go to the file comment.php ---

Find the following line ---

require_once('lib-common.php');

Add after this ---

// changes for near normal behavior of journal plugin after a comment
// is saved - remove these lines if any roblem

$rurl = getenv("HTTP_REFERER");
$uurl = str_replace("&pid=0&type=journal","",$turl);
$uurl = str_replace("sid","type=journal&cid",$uurl);

if((preg_match("/pid/i", "$rurl"))&&(preg_match("/sid/i", "$rurl"))&&(preg_match("/journal/i", "$rurl")))
{
echo"";
}

//end of change --- wish you good luck Smile

 Quote

Nomood

Anonymous
certain parts did not come so let me try again ....
ok DONE .... ignore the upper one , read THIS

Text Formatted Code

Go to the file comment.php ---

Find the following line ---

require_once('lib-common.php');

Add after this ---

// changes for near normal behavior of journal plugin after a comment
// is saved - remove these lines if any roblem

$rurl = getenv("HTTP_REFERER");
$uurl = str_replace("&pid=0&type=journal","",$turl);
$uurl = str_replace("sid","type=journal&cid",$uurl);

if((preg_match("/pid/i", "$rurl"))&&(preg_match("/sid/i", "$rurl"))&&(preg_match("/journal/i", "$rurl")))
{
echo"<meta http-equiv=refresh content="0; url=$uurl">";
}

//end of change --- wish you good luck :)

 
 Quote

Nomood

Anonymous
A small corretion, so things finally (hopefully) are

Text Formatted Code
Go to the file comment.php ---

Find the following line ---

require_once('lib-common.php');

Add after this ---

// changes for near normal behavior of journal plugin after a comment
// is saved - remove these lines if any problem

$rurl = getenv("HTTP_REFERER");
$uurl = str_replace("&pid=0&type=journal","",$rurl);
$uurl = str_replace("sid","type=journal&cid",$uurl);

if((preg_match("/pid/i", "$rurl"))&&(preg_match("/sid/i", "$rurl"))&&(preg_match("/journal/i", "$rurl")))
{
echo"<meta http-equiv=refresh content=\"0; url=$uurl\">";
}

//end of change --- wish you good luck :)


 
 Quote

Status: offline

zaurav

Forum User
Chatty
Registered: 01/07/06
Posts: 57
determined
Hey nomood,
It didn't work!Sad. I followed ure instructions per se and heres what I got in my comments.php.
Text Formatted Code
* Geeklog common function library
*/
require_once('lib-common.php');
// changes for near normal behavior of journal plugin after a comment
// is saved - remove these lines if any problem

$rurl = getenv("HTTP_REFERER");
$uurl = str_replace("&pid=0&type=journal","",$rurl);
$uurl = str_replace("sid","type=journal&cid",$uurl);

if((preg_match("/pid/i", "$rurl"))&&(preg_match("/sid/i", "$rurl"))&&(preg_match("/journal/i", "$rurl")))
{
echo"<meta http-equiv=refresh content="0; url=$uurl">";
}

//end of change
/**
 

It takes me to the main page when I click on the comment link in the journals menu.
The first code
Text Formatted Code
// changes for near normal behavior of journal plugin after a comment
// is saved - remove these lines if any roblem

$rurl = getenv("HTTP_REFERER");
$uurl = str_replace("&pid=0&type=journal","",$turl);
$uurl = str_replace("sid","type=journal&cid",$uurl);

if((preg_match("/pid/i", "$rurl"))&&(preg_match("/sid/i", "$rurl"))&&(preg_match("/journal/i", "$rurl")))
{
echo"";
}

//end of change
 
though did give me some technical gibberish on the screen. If you want that I can give it to you. Let me know . peace
 Quote

Nomood

Anonymous
The above solution will work with 1.3. series not 1.4

For 1.4

a dirty non-db workaround will be


step 1
======

to each of the entry you make in journal add at the end

Text Formatted Code
<a href="comment.php?comment_id=subject_of_the _article" target=new>Comments</a>
 


** ENABLE SUFFICIENT HTML SO THAT THIS IS SEEN AS A LINK IN THE JOURNAL ENTRY

The comment id will be different for different entries

step 2
======

create a file named comments.dat with proper write perm and keep it where your kournal/index.php is

step 3
=======

under the same location keep a file named comment.php

comment.php will be as follows :


Text Formatted Code


<?
// Settings:

// File in which the entries will be saved (requires CHMOD 666):
$comment_settings['comment_file'] = "comments.dat";

// Admin E-mail for notifications (optional):
$comment_settings['admin_email'] = "";

// Add new comments at the top or at the bottom?
$comment_settings['add_comments'] = "bottom";

// How many comments per page?
$comment_settings['comments_per_page'] = 10;

// Make links clickable:
$comment_settings['auto_link'] = true;

// Length limitations:
$comment_settings['text_maxlength'] = 500;
$comment_settings['word_maxlength'] = 50;

// If no name is entered:
$comment_settings['anonym'] = "Anonym";

// Time format:
$comment_settings['time_format'] = "%d.%m.%Y, %H:%M";

// Anker, where the comments are on your pages:
$comment_settings['anker'] = "#comments";

// replace wordwrap? (if no ""):
$comment_settings['wordwrap'] = " - ";

// Language settings:
$comment_lang['language'] =           "en";
$comment_lang['title'] =              "Comments";
$comment_lang['email_title'] =        "E-mail to [name]";
$comment_lang['hp_title'] =           "Homepage: [homepage]";
$comment_lang['no_comments_yet'] =    "No comments yet.";
$comment_lang['comments_shown'] =     "[comments] of [comments_total] comments (part [part])";
$comment_lang['previous'] =           "Previous part";
$comment_lang['next'] =               "Next part";
$comment_lang['show_all'] =           "Show all comments";
$comment_lang['add_comment'] =        "Your comment:";
$comment_lang['name'] =               "Name:";
$comment_lang['email_hp'] =           "E-mail or homepage:";
$comment_lang['ok'] =                 "OK";
$comment_lang['no_comments'] =        "No comments";
$comment_lang['one_comment'] =        "1 comment";
$comment_lang['several_comments'] =   "[comments] comments";
$comment_lang['comment_link_title'] = "Read or write comments";
$comment_lang['email_subject'] =      "Comment to [comment_to]";
$comment_lang['email_text'] =         "Comment to [comment_to] by [name]:\n\n[comment]\n\n\nLink to the comment:\n[link]";
$comment_lang['error'] =              "Error:";
$comment_lang['err_text_too_long'] =  "the text is too long ([characters] characters - maximum is [characters_max] characters)";
$comment_lang['err_word_too_long'] =  "the word [word] is too long";

// End of settings

function comment_make_link($string)
 {
  $string = ' ' . $string;
  $string = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\">\\2</a>", $string);
  $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1<a href=\"http://\\2\">\\2</a>", $string);
  $string = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $string);
  $string = substr($string, 1);
  return $string;
 }

function count_comments($comment_id, $text=0)
 {
  global $comment_settings, $comment_lang;
  $data = file($comment_settings['comment_file']);
  $comment_total_entries = count($data);
  // count entries:
  $comment_count = 0;
  for ($i = 0; $i < $comment_total_entries; $i++)
  {
   $parts = explode("|", $data[$i]);
   if ($parts[3] == $comment_id) $comment_count++;
  }
  if ($text == 0) return $comment_count;
  else
   {
    if ($comment_count == 0) $count_text = $comment_lang['no_comments'];
    elseif ($comment_count == 1) $count_text = $comment_lang['one_comment'];
    else $count_text = str_replace("[comments]", $comment_count, $comment_lang['several_comments']);
    return $count_text;
   }
 }

if (isset($_GET['comment_id'])) $comment_id = $_GET['comment_id'];
if (isset($_POST['comment_id'])) $comment_id = $_POST['comment_id'];
if (isset($_GET['comment_popup'])) $comment_popup = $_GET['comment_popup'];
if (isset($_POST['comment_popup'])) $comment_popup = $_POST['comment_popup'];

if (empty($comment_popup) && empty($comment_id) && empty($_GET['comment_popup_link'])) $comment_id = basename($_SERVER["PHP_SELF"]);

if (isset($comment_id))
 {
  if (isset($_GET['comment_page'])) $comment_page = $_GET['comment_page']; else $comment_page = 1;

// if comment entered::
if (isset($_POST['comment_text']) && trim($_POST['comment_text']) != "")
  {
   // check posted data:
   unset($errors);
   if (strlen($_POST['comment_text']) > $comment_settings['text_maxlength']) { $err_txt_too_lng = str_replace("[characters]", strlen($_POST['comment_text']), $comment_lang['err_text_too_long']); $err_txt_too_lng = str_replace("[characters_max]", $comment_settings['text_maxlength'], $err_txt_too_lng); $errors[] = $err_txt_too_lng; }
   $text_arr = str_replace("\n", " ", $_POST['comment_text']);
   $text_arr = explode(" ",$text_arr); for ($i=0;$i<count($text_arr);$i++) { trim($text_arr[$i]); $laenge = strlen($text_arr[$i]); if ($laenge > $comment_settings['word_maxlength']) { $errors[] = str_replace("[word]", "\"".htmlentities(stripslashes(substr($text_arr[$i],0,$comment_settings['word_maxlength'])))."...\"", $comment_lang['err_word_too_long']); } }

   // look if double:
   $data = file($comment_settings['comment_file']);
   $row_count = count($data);
   for ($row = 0; $row < $row_count; $row++)
     {
      $parts = explode("|", $data[$row]);
      if ($parts[3] == $_POST['comment_id'] && urldecode($parts[4]) == trim($_POST['name']) && trim(urldecode($parts[6])) == trim($_POST['comment_text'])) { $double_entry = true; break; }
     }

   // save if no errors:
   if (empty($errors) && empty($double_entry))
    {
      $comment_text = urlencode(trim($_POST['comment_text']));
      $name = urlencode(trim($_POST['name']));
      $email_hp = trim($_POST['email_hp']);
      if (substr($email_hp,0,7) == "http://") $email_hp = substr($email_hp,7);
      $email_hp = urlencode(base64_encode($email_hp));

      $uniqid = uniqid("");
      if ($comment_settings['add_comments'] == "top")
      {
       $data = file($comment_settings['comment_file']);
       $c = count($data);
       $datei = fopen($comment_settings['comment_file'], 'w+');
       flock($datei, 2);
       fwrite($datei, $uniqid."|".time()."|".$_SERVER["REMOTE_ADDR"]."|".$_POST['comment_id']."|".$name."|".$email_hp."|".$comment_text."\n");
       for ($i = 0; $i < $c; $i++) { fwrite($datei, trim($data[$i])."\n"); }
       flock($datei, 3);
       fclose($datei);
      }
      else
      {
       $datei = fopen($comment_settings['comment_file'], "a");
       flock($datei, 2);
       fwrite($datei, $uniqid."|".time()."|".$_SERVER["REMOTE_ADDR"]."|".$_POST['comment_id']."|".$name."|".$email_hp."|".$comment_text."\n");
       flock($datei, 3);
       fclose($datei);
      }

     // E-mail notification to admin:
     if (isset($comment_settings['admin_email']) && $comment_settings['admin_email'] !="")
      {
       if (isset($comment_popup)) { $acid1="?comment_id=".$comment_id."&ampcomment_popup=true"; $acid2="&comment_id=".$comment_id."&comment_popup=true"; } else { $acid1 = ""; $acid2 = ""; }
       $sender_name = trim($_POST['name']);
       if ($sender_name=="") $sender_name = $comment_settings['anonym'];
       if (preg_match("/^[^@]+@.+\.\D{2,5}$/", base64_decode(urldecode($email_hp)))) $sender_email = base64_decode(urldecode($email_hp)); else $sender_email = "no@email.xx";
       $comment_subject = str_replace("[comment_to]", $_POST['comment_id'], $comment_lang['email_subject']);
       $comment_email_text = str_replace("[comment_to]",$_POST['comment_id'],$comment_lang['email_text']);
       $comment_email_text = str_replace("[name]",stripslashes($sender_name),$comment_email_text);
       $comment_email_text = str_replace("[comment]",stripslashes($_POST['comment_text']),$comment_email_text);
       $emailbody = str_replace("[link]","http://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'].$acid1.$comment_settings['anker'],$comment_email_text);
       $header= "From: ".stripslashes($sender_name)." <".stripslashes($sender_email).">\n";
       $header .= "X-Mailer: PHP/" . phpversion(). "\n";
       $header .= "X-Sender-IP: ".$_SERVER["REMOTE_ADDR"]."\n";
       $header .= "Content-Type: text/plain";
       @mail($comment_settings['admin_email'], $comment_subject, $emailbody, $header);
      }
     }
   }

  // count:
  $data = file($comment_settings['comment_file']);
  $comment_total_entries = count($data);
  $comment_count = count_comments($comment_id);

  // Header for popup window:
  if (isset($comment_popup))
   {
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $comment_lang['language']; ?>"><head><title><?php echo $comment_lang['title']; ?></title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /><style type="text/css"><!-- body { color: #000000; background: #ffffff; margin: 15px; padding: 0px; font-family: verdana, arial, sans-serif; font-size: 13px; } p { font-family: verdana, arial, sans-serif; font-size: 13px; line-height: 19px; } h1 { font-family: verdana, arial, sans-serif; font-size: 18px; font-weight: bold; } --></style></head><body><h1><?php echo $comment_lang['title']; ?></h1><?php
   }

  // show comments:
  if (isset($_GET['show_comments'])) $show_comments = $_GET['show_comments'];
  if (isset($_POST['show_comments'])) $show_comments = $_POST['show_comments'];
  if (isset($show_comments) && isset($hide_comments)) unset($hide_comments);
  if (empty($hide_comments))
  {
  $comment_k = 0;
  $comment_a = 0;
  for ($i = 0; $i < $comment_total_entries; $i++)
    {
     $parts = explode("|", $data[$i]);
     if ($parts[3] == $comment_id)
      {
       $comment_k++;
       if ($parts[4] != "") $name = htmlentities(stripslashes(urldecode($parts[4]))); else $name = $comment_settings['anonym'];
       if ($parts[5] != "")
        {
         $email_hp = htmlentities(stripslashes(base64_decode(urldecode($parts[5]))));
         if (preg_match("/^[^@]+@.+\.\D{2,5}$/", $email_hp))
             {
              $email_parts = explode("@", $email_hp);
              $email_name = $email_parts[0];
              $email_domain_tld = $email_parts[1];
              $domain_parts = explode(".", $email_domain_tld);
              $email_domain = "";
              for ($x = 0; $x < count($domain_parts)-1; $x++)
               {
                $email_domain .= $domain_parts[$x].".";
               }
              $email_tld = $domain_parts[$x];
              $email_title = str_replace("[name]",$name,$comment_lang['email_title']);
              $name = "<script type=\"text/javascript\">
              <!--
              document.write('<a href=\"mailto:');
              document.write('".$email_name."');
              document.write('@');
              document.write('".$email_domain."');
              document.write('".$email_tld."');
              document.write('\" title=\"".$email_title."\">');
              //-->
              </script>".$name."<script type=\"text/javascript\">
              <!--
              document.write('</a>');
              //-->
              </script>";
             }
          else
          {
           $hp_title = str_replace("[homepage]",$email_hp,$comment_lang['hp_title']);
           if (isset($comment_popup)) $name = '<a href="http://'.$email_hp.'" title="'.$hp_title.'" target="_blank">'.$name.'</a>';
           else $name = '<a href="http://'.$email_hp.'" title="'.$hp_title.'">'.$name.'</a>';
          }
        }
       $comment = htmlentities(stripslashes(urldecode($parts[6])));
       if (isset($comment_settings['wordwrap']) && $comment_settings['wordwrap'] != "") $comment = str_replace("\n", $comment_settings['wordwrap'], trim($comment));
       if (isset($comment_settings['auto_link']) && $comment_settings['auto_link']==true) $comment = comment_make_link($comment);
       $zeit = $parts[1];

       if ($comment_settings['add_comments'] == "top")
        {
         if ($comment_page=="show_all" || ($comment_k>($comment_page-1)*$comment_settings['comments_per_page'] && $comment_k<$comment_page*$comment_settings['comments_per_page']+1)) { ?><p style="margin:0px 0px 5px 0px;"><b><?php echo $name; ?>:</b> <?php echo $comment; ?><span style="font-size: 10px; color: #808080;">(<?php echo strftime($comment_settings['time_format'], $parts[1]); ?>)</span></p><?php $comment_a++; }
        }
       else
        {
         if ($comment_page=="show_all" || ($comment_k > ( ($comment_count-$comment_settings['comments_per_page']) - ( ($comment_page-1) * $comment_settings['comments_per_page'] ) ) && $comment_k < (($comment_count-$comment_settings['comments_per_page'])-(($comment_page-1)*$comment_settings['comments_per_page']))+($comment_settings['comments_per_page']+1))) { ?><p style="margin:0px 0px 5px 0px;"><b><?php echo $name; ?>:</b> <?php echo $comment; ?><span style="font-size: 10px; color: #808080;">(<?php echo strftime($comment_settings['time_format'], $parts[1]); ?>)</span></p><?php $comment_a++; }
        }
      }
    }

 $comments_shown = str_replace("[comments]", $comment_a, $comment_lang['comments_shown']);
 $comments_shown = str_replace("[comments_total]", $comment_count, $comments_shown);
 $comments_shown = str_replace("[part]", $comment_page, $comments_shown);
 if ($comment_k == 0) echo "<p><i>".$comment_lang['no_comments_yet']."</i></p>";
 if ($comment_settings['comments_per_page'] < $comment_count && $comment_page != "show_all") { ?><p style="margin:10px 0px 3px 0px; font-family: verdana, arial, sans-serif; font-size: 11px;"><?php echo $comments_shown; ?> <?php
 if ($comment_settings['comments_per_page'] < $comment_count && $comment_page > 1) { ?>[ <a href="<?php echo basename($_SERVER["PHP_SELF"]); ?>?comment_id=<?php echo $comment_id; ?>&comment_page=<?php echo $comment_page-1; if (isset($comment_popup)) echo "&comment_popup=true"; if (isset($show_comments)) echo "&show_comments=true"; echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['previous']; ?>">«</a> ] <?php }
 if ($comment_settings['comments_per_page'] < $comment_count && $comment_page < (($comment_count/$comment_settings['comments_per_page']))) { ?>[ <a href="<?php echo basename($_SERVER["PHP_SELF"]); ?>?comment_id=<?php echo $comment_id; ?>&comment_page=<?php echo $comment_page+1; if (isset($comment_popup)) echo "&comment_popup=true"; if (isset($show_comments)) echo "&show_comments=true"; echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['next']; ?>">»</a> ] <?php }
 ?>
 [ <a href="<?php echo basename($_SERVER["PHP_SELF"]); ?>?comment_id=<?php echo $comment_id; ?>&comment_page=show_all<?php if (isset($comment_popup)) echo "&comment_popup=true"; if (isset($show_comments)) echo "&show_comments=true"; echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['show_all']; ?>">*</a> ]</p><?php }
 if(isset($errors))
  {
   ?><p style="color:red; font-weight:bold;"><?php echo $comment_lang['error']; ?></p><ul><?php foreach($errors as $f) { ?><li><?php echo $f; ?></li><?php } ?></ul><?php
  }
 ?>
 <form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>"><div>
 <?php if (isset($comment_popup)) { ?><input type="hidden" name="comment_popup" value="true" /><?php } ?>
 <input type="hidden" name="comment_id" value="<?php echo $comment_id; ?>" />
 <input type="hidden" name="show_comments" value="true" />
 <table style="margin-top: 10px;" border="0" cellpadding="1" cellspacing="0">
  <tr>
   <td colspan="3">
   <b><?php echo $comment_lang['add_comment']; ?></b>
   <textarea style="width: 400px;" name="comment_text" cols="45" rows="4"><?php if (isset($errors) && isset($_POST['comment_text'])) echo htmlentities(stripslashes($_POST['comment_text'])); ?></textarea>
   </td>
  </tr>
  <tr>
   <td style="font-family: verdana, arial, sans-serif; font-size: 11px; vertical-align: bottom;"><?php echo $comment_lang['name']; ?><input type="text" name="name" value="<?php if (isset($errors) && isset($_POST['name'])) echo htmlentities(stripslashes($_POST['name'])); else echo ""; ?>" size="23" maxlength="25" /></td>
   <td style="font-family: verdana, arial, sans-serif; font-size: 11px; vertical-align: bottom;"><?php echo $comment_lang['email_hp']; ?><br/><input type="text" name="email_hp" value="<?php if (isset($errors) && isset($_POST['email_hp'])) echo htmlentities(stripslashes($_POST['email_hp'])); else echo ""; ?>" size="23" maxlength="60" /></td>
   <td style="font-family: verdana, arial, sans-serif; font-size: 11px; vertical-align: bottom;"><input type="submit" value="  <?php echo $comment_lang['ok']; ?>  " /></td>
  </tr>
 </table>
 </div></form>
   <?php
 }
 else
 {

  ?><p>[ <a href="<?php echo basename($_SERVER['PHP_SELF']); ?>?show_comments=true<?php echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['comment_link_title']; ?>"><?php echo count_comments($comment_id, 1); ?></a> ]</p>
  <?php
 }
 // Footer for popup window:
 if (isset($comment_popup))
  {
   ?></body></html><?php
  }
}
// JavaScript for popup window and link:
if (isset($_GET['comment_popup_link']))
 {
 ?>function comment(id)
 {
 var page = "<?php echo $_SERVER['PHP_SELF']; ?>?comment_id=" + id + "&comment_popup=true";
 popwin = window.open(page,"","width=460,height=500,scrollbars,resizable")
 popwin.focus();
 }
 document.open();
 document.write("[ <a href=\"javascript:comment('<?php echo $_GET['comment_popup_link']; ?>')\" title=\"<?php echo $comment_lang['comment_link_title']; ?>\"><?php echo count_comments($_GET['comment_popup_link'], 1); ?></a> ]");
 document.close();
 <?php
 }
?>

 
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
Quote by Nomood: Any one having any idea / corrective measure ?

I went for corrective measure Wink
I read through the suggested by Dirk docs and updated the function responsible for saving comments in Journal Plugin. So all you have to do is to edit functions.inc and replace the current function plugin_savecomment_journal
with this
Text Formatted Code
function plugin_savecomment_journal($title, $body, $je_id, $pid, $postmode)
{
    global $_CONF, $_TABLES, $LANG03, $_USER;

    $retval = '';


    $ret = CMT_saveComment ($title, $body, $je_id, $pid, 'journal', $postmode);
    if ($ret > 0) { // failure //FIXME: some failures should not return to comment form
        $retval .= COM_siteHeader()
            . CMT_commentForm ($_USER['uid'], $title, $comment, $je_id, $pid,
                    'journal', $LANG03[14], $postmode)
            . COM_siteFooter();
    } else { // success
        $retval = COM_refresh ($_CONF['site_url']
                                . "/journal/index.php?mode=read&je_id=$je_id");
    }

    return $retval;
}
 

Works for me Smile
I've learnt something today because there is great documentation available Its a deal - shaking hands
Geeklog Polish Support Team
 Quote

Status: offline

zaurav

Forum User
Chatty
Registered: 01/07/06
Posts: 57
ALthough I didnt do it the way robin did it, it still worked for me. I had edited my comment.php file so all i did was recopy the original (that came with the 1.4.0 distro) and it all fell into place.
The only disturbing thing is - when I click on public journals I can only see my personal journal. Whereas in the Journal block there are all the public journals there.
I think its a problem with public_html/journal/index.php. Maybe something is missing. here it is anyways
Text Formatted Code
require_once ('../lib-common.php');

if (DB_getItem ($_TABLES['plugins'], 'pi_enabled', "pi_name = 'journal'") == 0) {
    $display .= COM_siteHeader();
    $display .= 'Sorry, the journal plugin is not enabled';
    $display .= COM_siteFooter();
    echo $display;
    exit;
}

// Initialize and clean up post/request id fields:
if ($_REQUEST['jrn_id'] != '')
{
    $jrn_id = COM_applyFilter($_REQUEST['jrn_id'], true);
}
if ($_REQUEST['je_id'] != '')
{
    $je_id = COM_applyFilter($_REQUEST['je_id'], true);
} else if ($_REQUEST['id'] != '') {
    // for comment api
    $je_id = COM_applyFilter($_REQUEST['id'], true);
}
$mode = COM_applyFilter($_REQUEST['mode']);

if ($_REQUEST['uid'] != '')
{
    $uid = COM_applyFilter($_REQUEST['uid'], true);
} else {
    $uid = $_USER['uid'];
}


if (($mode <> "changejournal") AND ($_REQUEST['verified'] <> 1) AND ($mode <> "save") AND ($mode <> 'doexport')) {
    $display .= COM_siteHeader();
}

// if not anonymous, get current journal
if ($_USER['uid'] > 1) {
    $result = DB_query ("SELECT jrn_id FROM {$_TABLES['journal']} WHERE jrn_uid = {$_USER['uid']} ORDER BY jrn_iscurrent DESC");
    if (DB_numRows ($result) > 0) {
        $C = DB_fetchArray ($result);
        $cur_journal = $C['jrn_id'];
    }

}

switch ($mode) {
    case $LANG_JOURNAL['cancel']:
        // note: I purpose don't have anything in this so that when a user
        //       clicks cancel on a form they route to the user page
    case 'user':
        if (!empty($jrn_id)) {
            // viewing someone elses public journal
            $display .= shownavigation($mode, $jrn_id);
            $display .= showjournalentries($jrn_id,$_REQUEST['offset'],$mode);
        } else {
            // viewing private journal
            $display .= shownavigation($mode,$cur_journal);
            $display .= showjournalentries($cur_journal,$_REQUEST['offset'],$mode);
        }
        break;
    case 'edit':
        if ($_REQUEST['type'] == 'entry') {
            $display .= shownavigation($mode,$cur_journal);
            $display .= editjournalentry($je_id);
        } else if ($_REQUEST['type'] == 'journal') {
            $display .= shownavigation($mode,$cur_journal);
            $display .= editjournal($jrn_id);
        }
        break;
    case 'read':
        $jrn_id = DB_getItem ($_TABLES['journal_entry'], 'je_jrn_id',
                              "je_id = '$je_id'");
        $display .= shownavigation($mode,$jrn_id);
        $display .= printjournalentry($je_id, true);
        break;
    case 'changejournal':
        changejournal($jrn_id);
        break;
    case 'newjournal':
        $display .= shownavigation('user');
        $display .= journaleditor(0);
        break;
    case 'newentry':
        $display .= shownavigation('user',$cur_journal);
        $display .= journalentryeditor($cur_journal,0);
        break;
    case 'export':
        $display .= shownavigation('usr', $cur_journal);
        $display .= journal_export_interface( $cur_journal );
        break;
    case 'doexport':
        header("Content-Type: text/xml");
        $display .= journal_export( $cur_journal, $_REQUEST['private'], $_REQUEST['startDate'], $_REQUEST['endDate'] );
        break;
    case $LANG_JOURNAL['delete']:
        if ($type == 'journal') {
            if ($_REQUEST['verified'] == 0) {
                $display .= COM_startBlock($LANG_JOURNAL['deletejournalqmark']);
                $display .= $LANG_JOURNAL['deletejournalwarning'];
                $display .= COM_endBlock();
                // the 1 lets us know the user was warned
                $display .= editjournal($jrn_id, 1);
            } else {
                deletejournal($jrn_id);
            }
        } else if ($type == 'entry') {
            if ($_REQUEST['verified'] == 0) {
                $display .= COM_startBlock($LANG_JOURNAL['deleteentryqmark']);
                $display .= $LANG_JOURNAL['deleteentrywarning'];
                $display .= COM_endBlock();
                $display .= editjournalentry($je_id, 1);
            } else {
                deletejournalentry($je_id);
            }
        }
        break;
    case $LANG_JOURNAL['save']:
        if ($_REQUEST['type'] == 'journal') {
            // $display .= shownavigation('user');
            $display .= savejournal ($jrn_id, $_REQUEST['jrn_uid'],
                 $_REQUEST['jrn_name'], $_REQUEST['jrn_jt_id'],
                $_REQUEST['jrn_public'], $_REQUEST['jrn_hits'],
                $_REQUEST['unixdate'], $_REQUEST['jrn_iscurrent'],
                $_REQUEST['jrn_feed'], $_REQUEST['jrn_ping']);
        } else if ($_REQUEST['type'] == 'entry') {
            // $display .= shownavigation('user');
            savejournalentry($je_id, $_REQUEST['je_jrn_id'],
                            $_REQUEST['je_summary'], $_REQUEST['je_text'],
                            $_REQUEST['je_public'], $_REQUEST['unixdate'],
                            $_REQUEST['je_hits'], $_REQUEST['je_mood'],
                            $_REQUEST['postmode']);
            journal_update_feed ($_REQUEST['je_jrn_id']);
        }
        break;
    default:
        if (!empty ($je_id)) {
            $jrn_id = DB_getItem ($_TABLES['journal_entry'], 'je_jrn_id',
                                  "je_id = '$je_id'");
            $display .= shownavigation($mode,$jrn_id);
            $display .= printjournalentry($je_id, true);
        } else {
            $display .= shownavigation($mode,$cur_journal);
            $display .= listjournals($uid);
        }
        break;
}
if (($mode <> 'changejournal') AND ($_REQUEST['verified'] <> 1) AND ($mode <> 'save') AND ($mode <> 'doexport')) {
    $display .= COM_siteFooter();
}

echo $display;
?>

 

Do you think I have a problem here anywhere?

edit: I have the forked version of journal 0.2 . How do I send it to someone who wants it? should I submit it to geeklog.net? if so how to go about it?
thanks
 Quote

All times are EST. The time is now 01:22 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content