[geeklog-cvs] journal functions.inc,1.5,1.6

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Thu Jul 31 13:58:42 EDT 2003


Update of /usr/cvs/geeklog/journal
In directory geeklog_prod:/tmp/cvs-serv6552

Modified Files:
	functions.inc 
Log Message:
This upgrade adds the ability to have RSS feeds for individual journals (plus various cleanups, moving text to the language file). Also includes and installs the Journal block now.


Index: functions.inc
===================================================================
RCS file: /usr/cvs/geeklog/journal/functions.inc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** functions.inc	30 Jul 2003 20:13:00 -0000	1.5
--- functions.inc	31 Jul 2003 17:58:40 -0000	1.6
***************
*** 88,107 ****
  }
  
! function plugin_dopluginsearch_journal($query, $datestart, $dateend, $topic, $type, $author) {
! 	global $_TABLES,$_CONF;
! 	
! 	
  	if (empty($type)) {
          $type = 'all';
      }
!     
! 	// Bail if we aren't supppose to do our search
      if ($type <> 'all' AND $type <> 'journal') {
          $plugin_results = new Plugin();
!         $plugin_results->plugin_name = 'Journal';
!         $plugin_results->searchlabel = 'Journal Search Results';
          return $plugin_results;
      }
! 	
  	$sql = "SELECT je_id,je_summary,je_text,UNIX_TIMESTAMP(je_date) as day,'journal' as type,jrn_name,jt_name,jrn_uid,je_hits FROM {$_TABLES['journal_entry']},{$_TABLES['journal_type']},{$_TABLES['journal']}"; 
  	$sql .= " WHERE ((jrn_id = je_jrn_id) AND (jt_id = jrn_jt_id) AND (je_public = 1) AND (jrn_public = 1)) AND ";
--- 88,107 ----
  }
  
! function plugin_dopluginsearch_journal($query, $datestart, $dateend, $topic, $type, $author)
! {
!     global $_TABLES, $_CONF, $LANG_JOURNAL;
! 
  	if (empty($type)) {
          $type = 'all';
      }
! 
!     // Bail if we aren't supppose to do our search
      if ($type <> 'all' AND $type <> 'journal') {
          $plugin_results = new Plugin();
!         $plugin_results->plugin_name = $LANG_JOURNAL['journal'];
!         $plugin_results->searchlabel = $LANG_JOURNAL['searchlabel'];
          return $plugin_results;
      }
! 
  	$sql = "SELECT je_id,je_summary,je_text,UNIX_TIMESTAMP(je_date) as day,'journal' as type,jrn_name,jt_name,jrn_uid,je_hits FROM {$_TABLES['journal_entry']},{$_TABLES['journal_type']},{$_TABLES['journal']}"; 
  	$sql .= " WHERE ((jrn_id = je_jrn_id) AND (jt_id = jrn_jt_id) AND (je_public = 1) AND (jrn_public = 1)) AND ";
***************
*** 159,163 ****
      global $_CONF, $LANG_JOURNAL;
  
!     return array ($LANG_JOURNAL['journal'],  
                    $_CONF['site_url'] . '/journal/index.php',
                    $_CONF['site_url'] . '/journal/images/journal.gif');
--- 159,163 ----
      global $_CONF, $LANG_JOURNAL;
  
!     return array ($LANG_JOURNAL['journal'],
                    $_CONF['site_url'] . '/journal/index.php',
                    $_CONF['site_url'] . '/journal/images/journal.gif');
***************
*** 166,170 ****
  function plugin_adminedit_journal() {
  	global $_CONF, $LANG_JOURNAL;
! 	
  	$retval = "<table border=0 cellspacing=0 cellpadding=2 width=\"100%\">";
      $retval .= "<tr><td rowspan=2><img src={$_CONF["site_url"]}/journal/images/journal.gif></td>";
--- 166,170 ----
  function plugin_adminedit_journal() {
  	global $_CONF, $LANG_JOURNAL;
! 
  	$retval = "<table border=0 cellspacing=0 cellpadding=2 width=\"100%\">";
      $retval .= "<tr><td rowspan=2><img src={$_CONF["site_url"]}/journal/images/journal.gif></td>";
***************
*** 211,215 ****
  	$nrows = DB_numRows($result);
  	if ($nrows == 0) {
! 		return "No journals found for you! Click 'New Journal' to create one";
  	}
  	$text = '<form action="' . $PHP_SELF . '" method="post">';
--- 211,215 ----
  	$nrows = DB_numRows($result);
  	if ($nrows == 0) {
! 		return $LANG_JOURNAL['none_found'];
  	}
  	$text = '<form action="' . $PHP_SELF . '" method="post">';
***************
*** 231,244 ****
  }
  
! function shownavigation($mode,$jrn_id="") {
! 	global $_CONF,$_USER,$LANG_JOURNAL;
  
! 	$uid = 0;
! 	if (empty($_USER["uid"])) {
! 		$uid = 1;	
! 		$retval = COM_startBlock($LANG_JOURNAL['anonymous'] . ' Journal Menu');
! 	} else {
! 		$retval = COM_startBlock($_USER['username'] . '\'s Journal Menu');
! 	}
  
  	$retval .= "<table border=0 cellspacing=0 cellpadding=2 width=\"100%\">";
--- 231,255 ----
  }
  
! function shownavigation ($mode, $jrn_id = '')
! {
!     global $_CONF, $_USER, $_TABLES, $LANG_JOURNAL;
  
!     if (empty ($jrn_id) && ($_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);
!             $jrn_id = $C['jrn_id'];
!         }
!     }
! 
!     $uid = 0;
!     if (empty ($_USER['uid'])) {
!         $uid = 1;	
!         $retval = COM_startBlock ($LANG_JOURNAL['anonymous']
!                                  . $LANG_JOURNAL['journal_menu']);
!     } else {
!         $retval = COM_startBlock ($_USER['username']
!                                  . $LANG_JOURNAL['s_journal_menu']);
!     }
  
  	$retval .= "<table border=0 cellspacing=0 cellpadding=2 width=\"100%\">";
***************
*** 252,256 ****
  		$retval .= "<td>[ ";
  		if ($mode <> "user") {
! 			$retval .= "<a href={$_CONF["site_url"]}/journal/index.php?mode=user>My Journals</a> | ";
  		}
  
--- 263,267 ----
  		$retval .= "<td>[ ";
  		if ($mode <> "user") {
! 			$retval .= "<a href={$_CONF['site_url']}/journal/index.php?mode=user>" . $LANG_JOURNAL['myjournals'] . '</a> | ';
  		}
  
***************
*** 260,264 ****
  		#$retval .= "<a href={$_CONF["site_url"]}/journal/index.php?mode=newjournal>New Journal</a> | <a href={$_CONF["site_url"]}/journal/index.php?mode=newentry&jrn_id=$jrn_id>New Entry</a> | <a href={$_CONF["site_url"]}/journal/prefs.php>{$LANG_JOURNAL["preferences"]}</a> ]</td></tr>";
  		$retval .= "<a href={$_CONF["site_url"]}/journal/index.php?mode=newjournal>{$LANG_JOURNAL['newjournal']}</a> | <a href={$_CONF["site_url"]}/journal/index.php?mode=newentry&jrn_id=$jrn_id>{$LANG_JOURNAL['newentry']}</a> | <a href={$_CONF["site_url"]}/journal/index.php>{$LANG_JOURNAL['publicjournals']}</a> ]</td></tr>";
! 		$retval .= "<tr><td colspan=2>";
  		$retval .= userjournaldropdown($_USER["uid"],$jrn_id,$LANG_JOURNAL['currentjournal'].": ");
  		$retval .= "</td></tr></table>";
--- 271,275 ----
  		#$retval .= "<a href={$_CONF["site_url"]}/journal/index.php?mode=newjournal>New Journal</a> | <a href={$_CONF["site_url"]}/journal/index.php?mode=newentry&jrn_id=$jrn_id>New Entry</a> | <a href={$_CONF["site_url"]}/journal/prefs.php>{$LANG_JOURNAL["preferences"]}</a> ]</td></tr>";
  		$retval .= "<a href={$_CONF["site_url"]}/journal/index.php?mode=newjournal>{$LANG_JOURNAL['newjournal']}</a> | <a href={$_CONF["site_url"]}/journal/index.php?mode=newentry&jrn_id=$jrn_id>{$LANG_JOURNAL['newentry']}</a> | <a href={$_CONF["site_url"]}/journal/index.php>{$LANG_JOURNAL['publicjournals']}</a> ]</td></tr>";
! 		$retval .= '<tr><td colspan="2">';
  		$retval .= userjournaldropdown($_USER["uid"],$jrn_id,$LANG_JOURNAL['currentjournal'].": ");
  		$retval .= "</td></tr></table>";
***************
*** 273,277 ****
  
  	if (empty($jrn_id)) {
! 		$error = "No journal was passed to function journalentryeditor";
  	} else {
  		$result = DB_query("SELECT * FROM {$_TABLES['journal']} WHERE jrn_id = $jrn_id");
--- 284,288 ----
  
  	if (empty($jrn_id)) {
! 		$error = $LANG_JOURNAL['error_no_journal'];
  	} else {
  		$result = DB_query("SELECT * FROM {$_TABLES['journal']} WHERE jrn_id = $jrn_id");
***************
*** 288,292 ****
  
      if ($error) {
!         $retval .= $error . "<BR><BR>";
      } else {
          $retval .= COM_startBlock($LANG_JOURNAL['journalentryeditor']);
--- 299,303 ----
  
      if ($error) {
!         $retval .= $error . "<br><br>";
      } else {
          $retval .= COM_startBlock($LANG_JOURNAL['journalentryeditor']);
***************
*** 320,341 ****
          $retval .= "\n<tr><td align=right><b>{$LANG_JOURNAL['summary']}</b>:</td><td><input type=text size=48 maxlength=255 name=je_summary value=\"" . stripslashes($A["je_summary"]) . "\"></td></tr>";
  		$retval .= "\n<tr><td align=right><b>{$LANG_JOURNAL['mood']}</b>:</td><td>";
! 		$retval .= '<img alt="confused" title="confused" src="' . $_CONF['site_url'] . '/journal/images/confused_phpbb.gif"> <input type="radio" name="je_mood" value="confused" ';
! 		if ($A['je_mood'] == 'confused') $retval .= 'checked="checked"';
! 		$retval .= '>    <img alt="embarassed" title="embarassed" src="' . $_CONF['site_url'] . '/journal/images/embarassed_phpbb.gif"> <input type="radio" name="je_mood" value="embarassed" ';
! 		if ($A['je_mood'] == 'embarassed') $retval .= 'checked="checked"';
! 		$retval .= '>    <img alt="happy" title="happy" src="' . $_CONF['site_url'] . '/journal/images/happy_phpbb.gif"> <input type="radio" name="je_mood" value="happy" ';
! 		if ($A['je_mood'] == 'happy') $retval .= 'checked="checked"';
! 		$retval .= '>    <img alt="mad" title="mad" src="' . $_CONF['site_url'] . '/journal/images/mad_phpbb.gif"> <input type="radio" name="je_mood" value="mad" ';
! 		if ($A['je_mood'] == 'mad') $retval .= 'checked="checked"';
! 		$retval .= '>    <img alt="sad" title="sad" src="' . $_CONF['site_url'] . '/journal/images/sad_phpbb.gif"> <input type="radio" name="je_mood" value="sad" ';
! 		if ($A['je_mood'] == 'sad') $retval .= 'checked="checked"';
! 		$retval .= '>    <img alt="surprised" title="surprised" src="' . $_CONF['site_url'] . '/journal/images/surprised_phpbb.gif"> <input type="radio" name="je_mood" value="surprised" ';
! 		if ($A['je_mood'] == 'surprised') $retval .= 'checked="checked"';
! 		$retval .= '></td><tr>';
  		$retval .= "\n<tr><td valign=top align=right><b>{$LANG_JOURNAL['text']}<b>:</td><td><textarea name=je_text cols=75 rows=20 wrap=virtual>" . stripslashes($A["je_text"]) . "</textarea></td></tr>";
  		if ($JOURNAL["jrn_public"] == 1) {
              $retval .= "\n<tr><td align=right><b>{$LANG_JOURNAL['public']}</b>:</td><td><input type=checkbox name=je_public ";                
  			if (($A["je_public"] == 1) || ($JOURNAL["jrn_public"] == 1)) {	
!                 $retval .= "checked";
              }
  			$retval .= ">  (If checked, others will be able to read this journal entry)</td></tr>";
--- 331,355 ----
          $retval .= "\n<tr><td align=right><b>{$LANG_JOURNAL['summary']}</b>:</td><td><input type=text size=48 maxlength=255 name=je_summary value=\"" . stripslashes($A["je_summary"]) . "\"></td></tr>";
  		$retval .= "\n<tr><td align=right><b>{$LANG_JOURNAL['mood']}</b>:</td><td>";
! 
!         $moods = array ('confused', 'embarassed', 'happy', 'mad', 'sad',
!                         'surprised');
!         foreach ($moods as $m) {
!             $retval .= '<img src="' . $_CONF['site_url'] . '/journal/images/'
!                     . $m . '_phpbb.gif" alt="' . $LANG_JOURNAL['mood_' . $m]
!                     . '" title="' . $LANG_JOURNAL['mood_' . $m]
!                     . '"> <input type="radio" name="je_mood" value="'
!                     . $m . '"';
!             if ($A['je_mood'] == $m) {
!                 $retval .= ' checked="checked"';
!             }
!             $retval .= '>    ';
!         }
! 
! 		$retval .= '</td><tr>';
  		$retval .= "\n<tr><td valign=top align=right><b>{$LANG_JOURNAL['text']}<b>:</td><td><textarea name=je_text cols=75 rows=20 wrap=virtual>" . stripslashes($A["je_text"]) . "</textarea></td></tr>";
  		if ($JOURNAL["jrn_public"] == 1) {
              $retval .= "\n<tr><td align=right><b>{$LANG_JOURNAL['public']}</b>:</td><td><input type=checkbox name=je_public ";                
  			if (($A["je_public"] == 1) || ($JOURNAL["jrn_public"] == 1)) {	
!                 $retval .= 'checked="checked"';
              }
  			$retval .= ">  (If checked, others will be able to read this journal entry)</td></tr>";
***************
*** 361,365 ****
  
      if ($error) {
!         $retval .= $error . "<BR><BR>";
      } else {
          $retval .= COM_startBlock($LANG_JOURNAL['journaleditor']);
--- 375,379 ----
  
      if ($error) {
!         $retval .= $error . "<br><br>";
      } else {
          $retval .= COM_startBlock($LANG_JOURNAL['journaleditor']);
***************
*** 367,371 ****
          $retval .= "\n<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">";
          $retval .= "\n<tr><td colspan=2>";
! 		$retval .= "<input type=hidden value=journal name=type>";
  		$retval .= "<input type=submit value={$LANG_JOURNAL['save']} name=mode>";
  		if (!empty($A["jrn_id"])) {
--- 381,385 ----
          $retval .= "\n<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">";
          $retval .= "\n<tr><td colspan=2>";
! 		$retval .= '<input type="hidden" value="journal" name="type">';
  		$retval .= "<input type=submit value={$LANG_JOURNAL['save']} name=mode>";
  		if (!empty($A["jrn_id"])) {
***************
*** 396,400 ****
              $retval .= "checked";
          }
! 		$retval .= ">  (If checked, others will be able to read this journal)</td></tr>";
  		#if the following is true false then we have a prexisting record and there is no need
  		# allow them to edit this because we must always have at least one current journal
--- 410,423 ----
              $retval .= "checked";
          }
! 		$retval .= '>  ' . $LANG_JOURNAL['public_explain'] . '</td></tr>';
! 
!         $retval .= '<tr><td align="right">' . $LANG_JOURNAL['rss_feed']
!                 . ':</td><td><input type="checkbox" name="jrn_feed"';
!         if ($A['jrn_feed'] == 1) {
!             $retval .= ' checked="checked"';
!         }
!         $retval .= '>  ' . $LANG_JOURNAL['enable_feed']
!                 . '</td></tr>' . LB;
! 
  		#if the following is true false then we have a prexisting record and there is no need
  		# allow them to edit this because we must always have at least one current journal
***************
*** 410,414 ****
                      $retval .= "checked";
                  }
! 				$retval .= ">  (If checked, this will be your default journal)</td></tr>";
  			}
  		}
--- 433,438 ----
                      $retval .= "checked";
                  }
! 				$retval .= '>  ' . $LANG_JOURNAL['explaincurrent']
!                         . '</td></tr>';
  			}
  		}
***************
*** 424,428 ****
              if ($nrows > 0) {
                  $retval .= "<select name=jrn_jt_id>\n";
! 				$retval .= "<option value=\"\">Select Journal Type</option>\n";
                  for ($i=0;$i<$nrows;$i++) {
                      $B = DB_fetchArray($result);
--- 448,452 ----
              if ($nrows > 0) {
                  $retval .= "<select name=jrn_jt_id>\n";
! 				$retval .= '<option value="">' . $LANG_JOURNAL['select_type'] . "</option>\n";
                  for ($i=0;$i<$nrows;$i++) {
                      $B = DB_fetchArray($result);
***************
*** 453,457 ****
          if (strlen($je_id) == 0) $je_id = COM_makesid();
          $je_date = date("Y-m-d H:i:s",$je_date);
!         if ($je_public == on) {
              $je_public = 1;
          } else {
--- 477,481 ----
          if (strlen($je_id) == 0) $je_id = COM_makesid();
          $je_date = date("Y-m-d H:i:s",$je_date);
!         if ($je_public == 'on') {
              $je_public = 1;
          } else {
***************
*** 477,481 ****
  }
  
! function savejournal($jrn_id, $jrn_uid, $jrn_name, $jrn_jt_id, $jrn_public, $jrn_hits, $jrn_date, $jrn_iscurrent) {
  	global $_CONF,$LANG12,$LANG50,$LANG01,$_TABLES;
  
--- 501,506 ----
  }
  
! function savejournal($jrn_id, $jrn_uid, $jrn_name, $jrn_jt_id, $jrn_public, $jrn_hits, $jrn_date, $jrn_iscurrent, $jrn_feed)
! {
  	global $_CONF,$LANG12,$LANG50,$LANG01,$_TABLES;
  
***************
*** 483,496 ****
  		$jrn_date = date("Y-m-d H:i:s",$jrn_date);
  
!         if ($jrn_public == on) {
              $jrn_public = 1;
          } else {
              $jrn_public = 0;
          }
!         if ($jrn_iscurrent == "on") {
              $jrn_iscurrent = 1;
          } else {
              $jrn_iscurrent = 0;
          }
  
  		if (empty($jrn_hits)) $jrn_hits = 0;
--- 508,526 ----
  		$jrn_date = date("Y-m-d H:i:s",$jrn_date);
  
!         if ($jrn_public == 'on') {
              $jrn_public = 1;
          } else {
              $jrn_public = 0;
          }
!         if ($jrn_iscurrent == 'on') {
              $jrn_iscurrent = 1;
          } else {
              $jrn_iscurrent = 0;
          }
+         if ($jrn_feed == 'on') {
+             $jrn_feed = 1;
+         } else {
+             $jrn_feed = 0;
+         }
  
  		if (empty($jrn_hits)) $jrn_hits = 0;
***************
*** 500,506 ****
  		if (strlen($jrn_id)==0) {
              if ($jrn_iscurrent == 1) DB_query("UPDATE {$_TABLES['journal']} SET jrn_iscurrent = 0 WHERE jrn_iscurrent = 1 AND jrn_uid = $jrn_uid");
! 			DB_save($_TABLES["journal"],"jrn_uid,jrn_name,jrn_jt_id,jrn_public,jrn_hits,jrn_date,jrn_iscurrent","$jrn_uid,'$jrn_name',$jrn_jt_id,$jrn_public,$jrn_hits,'$jrn_date',$jrn_iscurrent");
  		} else {
! 			DB_save($_TABLES["journal"],"jrn_id,jrn_uid,jrn_name,jrn_jt_id,jrn_public,jrn_hits,jrn_date,jrn_iscurrent","$jrn_id,$jrn_uid,'$jrn_name',$jrn_jt_id,$jrn_public,$jrn_hits,'$jrn_date',$jrn_iscurrent");
  		}
  
--- 530,536 ----
  		if (strlen($jrn_id)==0) {
              if ($jrn_iscurrent == 1) DB_query("UPDATE {$_TABLES['journal']} SET jrn_iscurrent = 0 WHERE jrn_iscurrent = 1 AND jrn_uid = $jrn_uid");
! 			DB_save($_TABLES["journal"],"jrn_uid,jrn_name,jrn_jt_id,jrn_public,jrn_hits,jrn_date,jrn_iscurrent,jrn_feed","$jrn_uid,'$jrn_name',$jrn_jt_id,$jrn_public,$jrn_hits,'$jrn_date',$jrn_iscurrent,$jrn_feed");
  		} else {
! 			DB_save($_TABLES["journal"],"jrn_id,jrn_uid,jrn_name,jrn_jt_id,jrn_public,jrn_hits,jrn_date,jrn_iscurrent,jrn_feed","$jrn_id,$jrn_uid,'$jrn_name',$jrn_jt_id,$jrn_public,$jrn_hits,'$jrn_date',$jrn_iscurrent,$jrn_feed");
  		}
  
***************
*** 586,589 ****
--- 616,620 ----
  	return journalentryeditor($A["je_jrn_id"],$userwaswarned,$A);	
  }
+ 
  function getjournalprefs() {
  	#hardcoded until I get time to implement user preferences
***************
*** 591,594 ****
--- 622,626 ----
  	return $PREFS;
  }
+ 
  function showjournalentries($jrn_id,$offset,$mode) {
  	global $_CONF,$_TABLES, $LANG_JOURNAL,$_USER,$JOURNAL_PREFS;
***************
*** 623,627 ****
          $offset = 0;
      }
! 	
  	# get the data
  	if ($isadmin) {
--- 655,659 ----
          $offset = 0;
      }
! 
  	# get the data
  	if ($isadmin) {
***************
*** 639,652 ****
  		$curtime = COM_getUserDateTimeFormat($A["je_date"]);
  		if (($i % 2) > 0) {
! 			$retval .= "<tr bgcolor=#DDDDDD>";
  		} else {
  			$retval .= "<tr>";
  		}
! 		if (empty($A["je_mood"])) {
! 			$image = $_CONF["site_url"]."/images/speck.gif width=15 height=15";
! 		} else {
! 			$image = $_CONF["site_url"]."/journal/images/".$A["je_mood"]."_phpbb.gif alt=".$A["je_mood"];
! 		}
! 		$retval .= "<td width=5% align=center><img src=$image></td><td width=30%><a href={$_CONF["site_url"]}/journal/index.php?mode=read&type=entry&je_id={$A["je_id"]}>".stripslashes($A["je_summary"])."</a>";
  		if ($isadmin) {
  			$retval .= "  [<a href={$_CONF["site_url"]}/journal/index.php?mode=edit&type=entry&je_id={$A["je_id"]}>{$LANG_JOURNAL['edit']}</a>]</td>";
--- 671,691 ----
  		$curtime = COM_getUserDateTimeFormat($A["je_date"]);
  		if (($i % 2) > 0) {
! 			$retval .= '<tr bgcolor="#DDDDDD">';
  		} else {
  			$retval .= "<tr>";
  		}
!         if (empty ($A['je_mood'])) {
!             $image = '"' . $_CONF['site_url']
!                    . '/images/speck.gif" width="15" height="15" alt=""';
!         } else {
!             $image = '"' . $_CONF['site_url'] . '/journal/images/'
!                    . $A['je_mood'] . '_phpbb.gif" alt="' . $LANG_JOURNAL['mood_'
!                    . $A['je_mood']] . '" title="' . $LANG_JOURNAL['mood_'
!                    . $A['je_mood']] . '"';
!         }
!         $retval .= '<td width="5%" align="center"><img src=' . $image
!                 . '></td><td width="30%"><a href="' . $_CONF['site_url']
!                 . '/journal/index.php?mode=read&type=entry&je_id='
!                 . $A['je_id'] . '">' . stripslashes ($A['je_summary']) . '</a>';
  		if ($isadmin) {
  			$retval .= "  [<a href={$_CONF["site_url"]}/journal/index.php?mode=edit&type=entry&je_id={$A["je_id"]}>{$LANG_JOURNAL['edit']}</a>]</td>";
***************
*** 706,716 ****
          $retval .= "{$LANG_JOURNAL['next']}<p>\n";
  	}
! 		
  	$retval .= "</td></tr></table>";
! 	
  	$retval .= COM_endBlock();
! 	
  	return $retval;
  }	
  function getprevnextentries($je_id,$jrn_id,$date) {
      global $_TABLES;
--- 745,756 ----
          $retval .= "{$LANG_JOURNAL['next']}<p>\n";
  	}
! 
  	$retval .= "</td></tr></table>";
! 
  	$retval .= COM_endBlock();
! 
  	return $retval;
  }	
+ 
  function getprevnextentries($je_id,$jrn_id,$date) {
      global $_TABLES;
***************
*** 770,783 ****
  
  	DB_change($_TABLES["journal_entry"],"je_hits",$A["je_hits"]+1,"je_id","$je_id");
! 	$A["je_hits"]++;
  	$entries = getprevnextentries($je_id, $A["je_jrn_id"], $A["je_date"]);
  	$A["prev"] = $entries[0];
  	$A["next"] = $entries[1];
  	$thedate = COM_getUserDateTimeFormat($A["je_date"]);
! 	if (!empty($A["je_mood"])) {
! 		$image = "<img src=" . $_CONF["site_url"] . "/journal/images/" . $A["je_mood"] . "_phpbb.gif alt=" . $A["je_mood"] . ">";
! 	} else {
! 		$image = "";
! 	}
      $retval .= '<table border="0" cellpadding="0" cellspacing="0" width="100%">'
              . LB;
--- 810,826 ----
  
  	DB_change($_TABLES["journal_entry"],"je_hits",$A["je_hits"]+1,"je_id","$je_id");
! 	$A['je_hits']++;
  	$entries = getprevnextentries($je_id, $A["je_jrn_id"], $A["je_date"]);
  	$A["prev"] = $entries[0];
  	$A["next"] = $entries[1];
  	$thedate = COM_getUserDateTimeFormat($A["je_date"]);
!     if (!empty ($A['je_mood'])) {
!         $image = '<img src="' . $_CONF['site_url'] . '/journal/images/'
!                . $A['je_mood'] . '_phpbb.gif" alt="' . $LANG_JOURNAL['mood_'
!                . $A['je_mood']] . '" title="' . $LANG_JOURNAL['mood_'
!                . $A['je_mood']] . '">';
!     } else {
!         $image = '';
!     }
      $retval .= '<table border="0" cellpadding="0" cellspacing="0" width="100%">'
              . LB;
***************
*** 798,802 ****
      if ($A['je_hits'] > 0) {
          $retval .= '<tr><td class="storybyline">';
!         $retval .= 'Hits: ' . $A['je_hits'] . '</td></tr>' . LB;
      } else {
          $retval .= '<br>';
--- 841,845 ----
      if ($A['je_hits'] > 0) {
          $retval .= '<tr><td class="storybyline">';
!         $retval .= $LANG_JOURNAL['hits'] . ': ' . $A['je_hits'] . '</td></tr>' . LB;
      } else {
          $retval .= '<br>';
***************
*** 965,968 ****
--- 1008,1024 ----
                    . '?mode=user&jrn_id=' . $A['jrn_id'] . '">'
                    . stripslashes ($A['jrn_name']) . '</a>';
+             if ($A['jrn_feed'] == 1) {
+                 $feedpath = $_CONF['rdf_file'];
+                 $pos = strrpos ($feedpath, '/');
+                 $feed = substr ($feedpath, 0, $pos + 1)
+                       . sprintf ('journal%d.rss', $A['jrn_id']);
+                 $feedurl = substr_replace ($feed, $_CONF['site_url'], 0,
+                                            strlen ($_CONF['path_html']) - 1);
+                 $link .= '  <a href="' . $feedurl . '" title="'
+                       . $LANG_JOURNAL['rss_feed_title'] . '"><img src="'
+                       . $_CONF['site_url'] . '/journal/images/rss.gif" '
+                       . 'border="0" alt="[' . $LANG_JOURNAL['rss_feed']
+                       . ']"></a>';
+             }
              if ($num > 1) {
                  $journals .= $i . '. ' . $link;
***************
*** 1067,1071 ****
      COM_errorLog('Attempting to remove the group id from the vars table',1);
      DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = 'jrn_group_id'");
!     COM_errorLog('success',1);
  
      // Unregister the plugin with Geeklog
--- 1123,1131 ----
      COM_errorLog('Attempting to remove the group id from the vars table',1);
      DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = 'jrn_group_id'");
!     COM_errorLog('....success',1);
! 
!     COM_errorLog ('Attempting to remove the Journal block', 1);
!     DB_query ("DELETE FROM {$_TABLES['blocks']} WHERE name = 'journal_block'");
!     COM_errorLog ('....success', 1);
  
      // Unregister the plugin with Geeklog
***************
*** 1075,1081 ****
      COM_errorLog('...success',1);
  
!     COM_errorLog('leaving plugin_uninstall_journal',1);
  
      return true;
  }
  
--- 1135,1337 ----
      COM_errorLog('...success',1);
  
!     COM_errorLog('Leaving plugin_uninstall_journal',1);
  
      return true;
+ }
+ 
+ 
+ /**
+ * Create an RSS feed.
+ *
+ * @param   $filename   string   file name (no path) of the RSS feed file
+ * @param   $link       string   full URL of the journal
+ * @param   $title      string   title of the journal
+ * @param   $desc       string   description of the journal
+ * @param   $content    array    entries for the feed (title, text, link)
+ *
+ */
+ function journal_write_rss ($filename, $link, $title, $desc, $content)
+ {
+     global $_CONF, $LANG01;
+ 
+     if ($_CONF['backend'] > 0) {
+         $feedpath = $_CONF['rdf_file'];
+         $pos = strrpos ($feedpath, '/');
+         $feed = substr ($feedpath, 0, $pos + 1) . $filename;
+ 
+         if (!empty ($_CONF['default_charset'])) {
+             $feedencoding = $_CONF['default_charset'];
+         } else {
+             $feedencoding = 'UTF-8';
+         }
+         if (!empty ($_CONF['rdf_language'])) {
+             $feedlang = $_CONF['rdf_language'];
+         } else {
+             $feedlang = $_CONF['locale'];
+         }
+ 
+         $feedtitle = htmlspecialchars ($title);
+         $feeddesc = htmlspecialchars ($desc);
+         $feedlink = htmlspecialchars ($link);
+ 
+         if ($fd = @fopen ($feed, 'w')) {
+             fputs ($fd, "<?xml version=\"1.0\" encoding=\"$feedencoding\"?>\n\n");
+             fputs ($fd, "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n");
+             fputs ($fd, "<rss version=\"0.91\">\n\n");      
+             fputs ($fd, "<channel>\n");
+             fputs ($fd, '<title>' . $feedtitle . "</title>\n");
+             fputs ($fd, '<link>' . $feedlink . "</link>\n");
+             fputs ($fd, '<description>' . $feeddesc . "</description>\n");
+             fputs ($fd, '<language>' . $feedlang . "</language>\n\n");
+ 
+             foreach ($content as $entry) {    
+                 $desc = '';
+                 if ($_CONF['rdf_storytext'] > 0) {
+                     $storytext = trim (strip_tags ($entry['text']));
+                     $storytext = preg_replace ("/(\015)/", "", $storytext);
+                     if ($_CONF['rdf_storytext'] > 1) {
+                         if (strlen ($storytext) > $_CONF['rdf_storytext']) {
+                             $storytext = substr ($storytext, 0,
+                                 $_CONF['rdf_storytext'] - 3) . '...';
+                         }
+                     }
+                     $desc = '<description>' . htmlspecialchars ($storytext)     
+                           . "</description>\n";
+                 }
+ 
+                 $title = '<title>' . htmlspecialchars ($entry['title'])
+                        . "</title>\n"; 
+                 $link = '<link>' . htmlspecialchars ($entry['link'])
+                       . "</link>\n";
+ 
+                 fputs ($fd, "<item>\n");
+                 fputs ($fd, $title);
+                 fputs ($fd, $link);           
+                 if (!empty ($desc)) {
+                     fputs ($fd, $desc);
+                 }
+                 fputs ($fd, "</item>\n\n");
+             }
+ 
+             fputs ($fd, "</channel>\n");
+             fputs ($fd, "</rss>\n");
+ 
+             fclose ($fd);
+         } else {
+             COM_errorLog ($LANG01[54] . ' ' . $feed, 1);
+         }
+     }
+ }
+ 
+ /**
+ * Update feed for a journal.
+ *
+ * @param   $jrn_id   int   id of the journal
+ *
+ */
+ function journal_update_feed ($jrn_id)
+ {
+     global $_TABLES, $_CONF;
+ 
+     $result = DB_query ("SELECT jrn_public,jrn_feed,jrn_name FROM {$_TABLES['journal']} WHERE jrn_id = $jrn_id");
+     $J = DB_fetchArray ($result);    
+     if (($J['jrn_feed'] == 1) && ($J['jrn_public'] == 1)) {
+         $journal = stripslashes ($J['jrn_name']);
+         $jlink = $_CONF['site_url'] . '/journal/index.php?mode=user&jrn_id='
+                . $jrn_id;
+ 
+         $where = '';
+         $limit = '';
+         if (!empty ($_CONF['rdf_limit'])) {
+             if (substr ($_CONF['rdf_limit'], -1 ) == 'h') { // last xx hours
+                 $hours = substr ($_CONF['rdf_limit'], 0, -1);
+                 $where = " AND (je_date >= DATE_SUB(NOW(),INTERVAL $hours HOUR))";
+             } else {
+                 $limit = ' LIMIT ' . $_CONF['rdf_limit'];
+             }
+         } else {
+             $limit = ' LIMIT 10';
+         }
+ 
+         $result = DB_query ("SELECT je_id,je_summary,je_text,je_public FROM {$_TABLES['journal_entry']} WHERE (je_jrn_id = $jrn_id) AND (je_public = 1)" . $where . " ORDER BY je_date DESC" . $limit);
+         $num = DB_numRows ($result);
+         $content = array ();
+         for ($i = 0; $i < $num; $i++) {
+             $A = DB_fetchArray ($result);
+             $title = stripslashes ($A['je_summary']);
+             $text = stripslashes ($A['je_text']);
+             $link = $_CONF['site_url']
+                   . '/journal/index.php?mode=read&type=entry&je_id='
+                   . $A['je_id'];
+             $content[] = array ('title' => $title,
+                                 'text' => $text,
+                                 'link' => $link);
+         }
+ 
+         $jfile = sprintf ('journal%d.rss', $jrn_id);
+         journal_write_rss ($jfile, $jlink, $journal, $journal, $content);
+     }
+ }
+ 
+ /**
+ * Block to List the latest public entry from each public journal.
+ *
+ * Note: The links point to the journals, not the actual last entry
+ *       - not sure if that is a good thing or not ...
+ *
+ */
+ function phpblock_journal ()
+ {
+     global $_CONF, $_TABLES, $LANG_JOURNAL;
+ 
+     $retval = '';
+ 
+     $sql = "SELECT jrn_id,jrn_uid,jrn_name FROM {$_TABLES['journal']} WHERE jrn_public = 1 ORDER BY jrn_name";
+     $result = DB_query ($sql);
+     $journals = DB_numRows ($result);
+     if ($journals > 0) {
+         $retval .= '<table border="0" width="100%">' . LB;
+         for ($j = 1; $j <= $journals; $j++) {
+             $J = DB_fetchArray ($result);
+             $username = DB_getItem ($_TABLES['users'], 'username', "uid = {$J['jrn_uid']}");
+             $sql = "SELECT je_summary,je_mood,UNIX_TIMESTAMP(je_date) AS date FROM {$_TABLES['journal_entry']} WHERE (je_jrn_id = {$J['jrn_id']}) AND (je_public = 1) ORDER BY je_date DESC LIMIT 1";
+             $eresult = DB_query ($sql);
+             $entries = DB_numRows ($eresult);
+             if ($entries == 0) {
+                 $retval .= '<tr><td> </td>';
+                 $retval .= '<td><a href="' . $_CONF['site_url']
+                         . '/journal/index.php?mode=user&jrn_id='
+                         . $J['jrn_id'] . '">' . stripslashes ($J['jrn_name'])
+                         . '</a> (' . $username . ')<br><em>'
+                         . $LANG_JOURNAL['block_no_entries'] . '</em></td></tr>'
+                         . LB;
+             } else {
+                 $A = DB_fetchArray ($eresult);
+                 $mood = $A['je_mood'];
+                 if (empty ($mood)) {
+                     $retval .= '<tr><td> </td>';
+                 } else {
+                     $retval .= '<tr><td valign="top"><img src="'
+                             . $_CONF['site_url'] . '/journal/images/' . $mood
+                             . '_phpbb.gif' . '" alt="[' . $LANG_JOURNAL['mood_'
+                             . $mood] . ']" title="' . $LANG_JOURNAL['mood_'
+                             . $mood] . '"></td>';
+                 }
+                 $retval .= '<td><a href="' . $_CONF['site_url']
+                         . '/journal/index.php?mode=user&jrn_id='
+                         . $J['jrn_id'] . '">' . stripslashes ($J['jrn_name'])
+                         . '</a> (' . $username . ')<br>'
+                         . '<strong>' . stripslashes ($A['je_summary'])
+                         . '</strong><br>'
+                         . '<em>' . strftime ($_CONF['shortdate'], $A['date'])
+                         . '</em></td></tr>' . LB;
+             }
+         }
+         $retval .= '</table>' . LB;
+     } else {
+         $retval .= '<em>' . $LANG_JOURNAL['block_no_journals'] . '</em>';
+     }
+ 
+     return $retval;
  }
  





More information about the geeklog-cvs mailing list