[geeklog-cvs] geeklog-1.3/public_html article.php,1.43,1.44 comment.php,1.62,1.63 lib-common.php,1.324,1.325

vinny at iowaoutdoors.org vinny at iowaoutdoors.org
Thu May 20 14:57:47 EDT 2004


Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv26948/public_html

Modified Files:
	article.php comment.php lib-common.php 
Log Message:
Added ability to link to a comment directly by cid


Index: comment.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/comment.php,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** comment.php	17 May 2004 11:34:22 -0000	1.62
--- comment.php	20 May 2004 18:57:45 -0000	1.63
***************
*** 677,680 ****
--- 677,718 ----
                                 COM_applyFilter ($sid), COM_applyFilter ($type));
      break;
+ case 'view':
+     $cid = COM_applyFilter ($HTTP_GET_VARS['cid'], true);
+     if (!empty($cid)) {
+         $sql = "SELECT sid, title, type FROM {$_TABLES['comments']} WHERE cid = $cid";
+         $A = DB_fetchArray( DB_query($sql) );
+         $sid = $A['sid'];
+         $title = $A['title'];
+         $type = $A['type'];
+         $allowed = 1;
+         if ($type == 'article') {
+             $result = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (sid = '$sid') AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL ('AND'));
+             $A = DB_fetchArray ($result);
+             $allowed = $A['count'];
+         } else if ($type == 'poll') {
+             $result = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['pollquestions']} WHERE (qid = '$sid')" . COM_getPermSQL ('AND'));
+             $A = DB_fetchArray ($result);
+             $allowed = $A['count'];
+         }
+         $display .= COM_siteHeader();
+         if ($allowed == 1) {
+             $format = COM_applyFilter ($HTTP_GET_VARS['format']);
+             if ( $format != 'threaded' && $format != 'nested' && $format != 'flat' ) {  //FIXME
+                 $format = 'threaded';
+             }
+             $display .= COM_userComments ($sid, $title, $type, 
+                             COM_applyFilter ($HTTP_GET_VARS['order']), $format, $cid,
+                             COM_applyFilter ($HTTP_GET_VARS['page']), true);
+         } else {
+             $display .= COM_startBlock ($LANG_ACCESS['accessdenied'], '',
+                                 COM_getBlockTemplate ('_msg_block', 'header'))
+                      . $LANG_ACCESS['storydenialmsg']
+                      . COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+         }
+         $display .= COM_siteFooter();
+     } else {
+         $display .= COM_refresh($_CONF['site_url'] . '/index.php');
+     }
+     break;
  case 'display':
      $sid = COM_applyFilter ($HTTP_GET_VARS['sid']);

Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.324
retrieving revision 1.325
diff -C2 -d -r1.324 -r1.325
*** lib-common.php	15 May 2004 18:41:32 -0000	1.324
--- lib-common.php	20 May 2004 18:57:45 -0000	1.325
***************
*** 1875,1879 ****
                      $Q['perm_anon'] ) == 3 ? true : false );
                  $retval .= COM_userComments( $qid, $Q['question'], 'poll',
!                                              $order, $mode, 0, 1, $delete_option ); 
              }
          }
--- 1875,1879 ----
                      $Q['perm_anon'] ) == 3 ? true : false );
                  $retval .= COM_userComments( $qid, $Q['question'], 'poll',
!                                              $order, $mode, 0, 1, false, $delete_option ); 
              }
          }
***************
*** 2929,2932 ****
--- 2929,2934 ----
  * @param        string      $mode      comment mode (nested, flat, etc.)
  * @param        int         $pid       id of parent comment
+ * @param        int         $page      page number of comments to display
+ * @param        boolean     $cid       true if $pid should be interpreted as a cid instead
  * @param        boolean     $delete_option   if current user can delete comments
  * @see function COM_commentBar
***************
*** 2935,2939 ****
  *
  */
! function COM_userComments( $sid, $title, $type='article', $order='', $mode='', $pid = 0, $page = 1, $delete_option = false )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01;
--- 2937,2941 ----
  *
  */
! function COM_userComments( $sid, $title, $type='article', $order='', $mode='', $pid = 0, $page = 1, $cid = false, $delete_option = false )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01;
***************
*** 2989,2999 ****
          {
              case 'flat':
!                 $count = DB_count($_TABLES['comments'], "sid", $sid);
              
!                 $q = "SELECT c.*, u.username, u.fullname, u.photo, " 
!                      . "unix_timestamp(c.date) AS nice_date "
!                    . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
!                    . "WHERE c.uid = u.uid AND c.sid = '$sid' "
!                    . "ORDER BY date $order LIMIT $start, $limit";
                  break;
  
--- 2991,3010 ----
          {
              case 'flat':
!                 if ( cid ) {
!                     $count = 1;
! 
!                     $q = "SELECT c.*, u.username, u.fullname, u.photo, " 
!                          . "unix_timestamp(c.date) AS nice_date "
!                        . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
!                        . "WHERE c.uid = u.uid AND c.cid = $pid";
!                 } else {
!                     $count = DB_count($_TABLES['comments'], "sid", $sid);
              
!                     $q = "SELECT c.*, u.username, u.fullname, u.photo, " 
!                          . "unix_timestamp(c.date) AS nice_date "
!                        . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
!                        . "WHERE c.uid = u.uid AND c.sid = '$sid' "
!                        . "ORDER BY date $order LIMIT $start, $limit";
!                 }
                  break;
  
***************
*** 3012,3044 ****
                  // We can simplify the query, and hence increase performance when pid=0
                  // (when fetching all the comments for a given sid)
!                 if ( $pid == 0 )
!                 {
!                     // count the total number of applicable comments
!                     $count = DB_count($_TABLES['comments'], "sid", $sid);
! 
!                     $q = "SELECT c.*, u.username, u.fullname, u.photo, 0 as pindent, " 
!                          . "unix_timestamp(c.date) AS nice_date "
!                        . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
!                        . "WHERE c.sid = '$sid' AND c.uid = u.uid "
!                        . "ORDER BY $cOrder LIMIT $start, $limit";
!                 }
!                 else
!                 {
                      // count the total number of applicable comments
                      $q2 = "SELECT COUNT(*) "
                          . "FROM {$_TABLES['comments']} as c, {$_TABLES['comments']} as c2 "
!                         . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
                          . "AND c2.cid = $pid";
                      $result = DB_query($q2);
                      list($count) = DB_fetchArray($result);
  
!                     $q = "SELECT c.*, u.username, u.fullname, u.photo, c2.indent + 1 as pindent, " 
                           . "unix_timestamp(c.date) AS nice_date "
                         . "FROM {$_TABLES['comments']} as c, {$_TABLES['comments']} as c2, "
                           . "{$_TABLES['users']} as u "
!                        . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
                           . "AND c2.cid = $pid AND c.uid = u.uid "
                         . "ORDER BY $cOrder LIMIT $start, $limit";
  
                  }
                  break;
--- 3023,3069 ----
                  // We can simplify the query, and hence increase performance when pid=0
                  // (when fetching all the comments for a given sid)
!                 if ( $cid ) {
                      // count the total number of applicable comments
                      $q2 = "SELECT COUNT(*) "
                          . "FROM {$_TABLES['comments']} as c, {$_TABLES['comments']} as c2 "
!                         . "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
                          . "AND c2.cid = $pid";
                      $result = DB_query($q2);
                      list($count) = DB_fetchArray($result);
  
!                     $q = "SELECT c.*, u.username, u.fullname, u.photo, c2.indent as pindent, " 
                           . "unix_timestamp(c.date) AS nice_date "
                         . "FROM {$_TABLES['comments']} as c, {$_TABLES['comments']} as c2, "
                           . "{$_TABLES['users']} as u "
!                        . "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
                           . "AND c2.cid = $pid AND c.uid = u.uid "
                         . "ORDER BY $cOrder LIMIT $start, $limit";
+                 } else {
+                     if ( $pid == 0 ) {
+                         // count the total number of applicable comments
+                         $count = DB_count($_TABLES['comments'], "sid", $sid);
+ 
+                         $q = "SELECT c.*, u.username, u.fullname, u.photo, 0 as pindent, " 
+                              . "unix_timestamp(c.date) AS nice_date "
+                            . "FROM {$_TABLES['comments']} as c, {$_TABLES['users']} as u "
+                            . "WHERE c.sid = '$sid' AND c.uid = u.uid "
+                            . "ORDER BY $cOrder LIMIT $start, $limit";
+                     } else {
+                         // count the total number of applicable comments
+                         $q2 = "SELECT COUNT(*) "
+                             . "FROM {$_TABLES['comments']} as c, {$_TABLES['comments']} as c2 "
+                             . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
+                             . "AND c2.cid = $pid";
+                         $result = DB_query($q2);
+                         list($count) = DB_fetchArray($result);
  
+                         $q = "SELECT c.*, u.username, u.fullname, u.photo, c2.indent + 1 as pindent, " 
+                              . "unix_timestamp(c.date) AS nice_date "
+                            . "FROM {$_TABLES['comments']} as c, {$_TABLES['comments']} as c2, "
+                              . "{$_TABLES['users']} as u "
+                            . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
+                              . "AND c2.cid = $pid AND c.uid = u.uid "
+                            . "ORDER BY $cOrder LIMIT $start, $limit";
+                     }
                  }
                  break;

Index: article.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/article.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** article.php	1 May 2004 17:57:04 -0000	1.43
--- article.php	20 May 2004 18:57:45 -0000	1.44
***************
*** 207,211 ****
                  $story_template->set_var ('commentbar',
                          COM_userComments ($story, $A['title'], 'article',
!                                           $order, $mode, 0, $page, $delete_option));
              }
              $display .= $story_template->finish ($story_template->parse ('output', 'article'));
--- 207,211 ----
                  $story_template->set_var ('commentbar',
                          COM_userComments ($story, $A['title'], 'article',
!                                           $order, $mode, 0, $page, false, $delete_option));
              }
              $display .= $story_template->finish ($story_template->parse ('output', 'article'));




More information about the geeklog-cvs mailing list