[geeklog-cvs] geeklog: Merged changes from Jared's 2008 GSoC project - all cre...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Apr 10 13:02:39 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/d1d8a0120489
changeset: 6899:d1d8a0120489
user:      Dirk Haun <dirk at haun-online.de>
date:      Fri Apr 10 11:53:06 2009 +0200
description:
Merged changes from Jared's 2008 GSoC project - all credits to Jared Wenerd and Michael Jervis

diffstat:

17 files changed, 975 insertions(+), 121 deletions(-)
public_html/admin/moderation.php                                       |   59 
public_html/admin/story.php                                            |   47 
public_html/article.php                                                |    9 
public_html/comment.php                                                |   97 +
public_html/layout/professional/admin/story/storyeditor.thtml          |   49 
public_html/layout/professional/admin/story/storyeditor_advanced.thtml |   37 
public_html/layout/professional/comment/commentbar.thtml               |   24 
public_html/layout/professional/comment/commentform.thtml              |    6 
public_html/layout/professional/comment/commentform_advanced.thtml     |    6 
public_html/layout/professional/featuredstorytext.thtml                |    2 
public_html/layout/professional/storytext.thtml                        |    2 
public_html/layout/professional/style.css                              |    3 
sql/mysql_tableanddata.php                                             |   41 
system/classes/story.class.php                                         |  106 +
system/lib-comment.php                                                 |  602 ++++++++--
system/lib-database.php                                                |    3 
system/lib-story.php                                                   |    3 

diffs (truncated from 1720 to 300 lines):

diff -r 9ffd281952bd -r d1d8a0120489 public_html/admin/moderation.php
--- a/public_html/admin/moderation.php	Thu Apr 09 07:52:18 2009 +0200
+++ b/public_html/admin/moderation.php	Fri Apr 10 11:53:06 2009 +0200
@@ -36,6 +36,7 @@
 require_once 'auth.inc.php';
 require_once $_CONF['path_system'] . 'lib-user.php';
 require_once $_CONF['path_system'] . 'lib-story.php';
+require_once $_CONF['path_system'] . 'lib-comment.php';
 
 // Uncomment the line below if you need to debug the HTTP variables being passed
 // to the script.  This will sometimes cause errors but it will allow you to see
@@ -219,6 +220,11 @@
             $retval .= draftlist ($token);
         }
     }
+    
+    if (SEC_hasRights('comment.moderate')) {
+        $retval .= itemlist('comment', $token);
+    }
+
     if ($_CONF['usersubmission'] == 1) {
         if (SEC_hasRights ('user.edit') && SEC_hasRights ('user.delete')) {
             $retval .= userlist ($token);
@@ -249,7 +255,7 @@
     $retval = '';
     $isplugin = false;
 
-    if ((strlen ($type) > 0) && ($type <> 'story')) {
+    if ((strlen ($type) > 0) && ($type <> 'story') && ($type <> 'comment')) {
         $function = 'plugin_itemlist_' . $type;
         if (function_exists ($function)) {
             // Great, we found the plugin, now call its itemlist method
@@ -264,11 +270,18 @@
                 $isplugin = true;
             }
         }
-    } else { // story submission
+    } elseif ( $type == 'story') { // story submission
         $sql = "SELECT sid AS id,title,date,tid FROM {$_TABLES['storysubmission']}" . COM_getTopicSQL ('WHERE') . " ORDER BY date ASC";
         $H =  array($LANG29[10],$LANG29[14],$LANG29[15]);
         $section_title = $LANG29[35];
         $section_help = 'ccstorysubmission.html';
+    } elseif ($type == 'comment') {
+        $sql = "SELECT cid AS id,title,comment,date,uid "
+              . "FROM {$_TABLES['commentsubmissions']} "
+              . "ORDER BY cid ASC";
+        $H = array($LANG29[10],$LANG29[36], $LANG29[37]);
+        $section_title = $LANG29[41];
+        $section_help = 'i do not know';
     }
 
     // run SQL but this time ignore any errors
@@ -289,6 +302,10 @@
         if ($isplugin)  {
             $A['edit'] = $_CONF['site_admin_url'] . '/plugins/' . $type
                      . '/index.php?mode=editsubmission&id=' . $A[0];
+        } elseif ($type == 'comment') {
+            $A['edit'] = $_CONF['site_url'] . '/comment.php'
+                    . '?mode=editsubmission&cid=' . $A[0] .
+                    '&' . CSRF_TOKEN . '=' . $token;
         } else {
             $A['edit'] = $_CONF['site_admin_url'] . '/' .  $type
                      . '.php?mode=editsubmission&id=' . $A[0];
@@ -298,6 +315,7 @@
         $data_arr[$i] = $A;
     }
 
+
     $header_arr = array(      // display 'text' and use table field 'field'
         array('text' => $LANG_ADMIN['edit'], 'field' => 0),
         array('text' => $H[0], 'field' => 1),
@@ -305,6 +323,13 @@
         array('text' => $H[2], 'field' => 3),
         array('text' => $LANG29[2], 'field' => 'delete'),
         array('text' => $LANG29[1], 'field' => 'approve'));
+    if ($type == 'comment') {
+        //data for comment submission headers
+        $header_arr[6]['text'] = $LANG29[42];
+        $header_arr[6]['field'] = 'uid';
+        $header_arr[7]['text'] = $LANG29[43];
+        $header_arr[7]['field'] = 'publishfuture';
+    }
 
     $text_arr = array('has_menu'    => false,
                       'title'       => $section_title,
@@ -485,6 +510,11 @@
         $submissiontable = $_TABLES['storysubmission'];
         $fields = 'sid,uid,tid,title,introtext,date,postmode';
         break;
+    case 'comment':
+        $id = 'cid';
+        $submissiontable = $_TABLES['commentsubmissions'];
+        $sidArray[] = '';
+        break;
     default:
         if (strlen($type) <= 0) {
             // something is terribly wrong, bail
@@ -552,6 +582,11 @@
 
                 COM_rdfUpToDateCheck ();
                 COM_olderStuff ();
+            } else if ($type == 'comment') {
+                $sid = CMT_approveModeration($mid[$i]);
+                if ( !in_array($sid, $sidArray) ) {
+                    $sidArray[$i] = $sid; 
+                }
             } else {
                 // This is called in case this is a plugin. There may be some
                 // plugin specific processing that needs to happen.
@@ -559,6 +594,26 @@
                 $retval .= PLG_approveSubmission($type,$mid[$i]);
             }
             break;
+        }
+    }
+    
+    // after loop update comment tree and count for each story
+    if (isset($sidArray)) {
+        foreach($sidArray as $sid) {
+            CMT_rebuildTree($sid);
+            //update comment count of stories;
+            $comments = DB_count ($_TABLES['comments'], 'sid', $sid);
+            DB_change ($_TABLES['stories'], 'comments', $comments, 'sid', $sid);
+        }
+    }
+    
+    //Add new comment users to group comment.submit group
+    if (isset($_POST['publishfuture']) ) {
+        for ($i = 0; $i < count($_POST['publishfuture']); $i++ ) {
+            $uid =  COM_applyFilter($_POST['publishfuture'][$i], true);
+            if ($uid > 1 && !SEC_inGroup('Comment Submitters', $uid) ) {
+                SEC_addUserToGroup($uid, 'Comment Submitters');
+            }
         }
     }
 
diff -r 9ffd281952bd -r d1d8a0120489 public_html/admin/story.php
--- a/public_html/admin/story.php	Thu Apr 09 07:52:18 2009 +0200
+++ b/public_html/admin/story.php	Fri Apr 10 11:53:06 2009 +0200
@@ -572,7 +572,54 @@
     $story_templates->set_var ('trackback_options',
             COM_optionList ($_TABLES['trackbackcodes'], 'code,name',
                             $story->EditElements('trackbackcode')));
+    // comment expire 
+    $story_templates->set_var ('lang_cmt_disable', $LANG24[63]);
+    if ($story->EditElements('cmt_close') ) {
+        $story_templates->set_var('is_checked5', 'checked="checked"'); //check box if enabled
+        $story_templates->set_var('showcmtclosedisabled', 'false');
+    } else {
+        $story_templates->set_var('showcmtclosedisabled', 'true');
+    }
 
+    $month_options = COM_getMonthFormOptions($story->EditElements('cmt_close_month'));
+    $story_templates->set_var('cmt_close_month_options', $month_options);
+    
+    $day_options = COM_getDayFormOptions($story->EditElements('cmt_close_day'));
+    $story_templates->set_var('cmt_close_day_options', $day_options);
+    
+    $year_options = COM_getYearFormOptions($story->EditElements('cmt_close_year'));
+    $story_templates->set_var('cmt_close_year_options', $year_options);
+    
+    $cmt_close_ampm = '';
+    $cmt_close_hour = $story->EditElements('cmt_close_hour');
+    //correct hour
+    if ($cmt_close_hour >= 12) {
+        if ($cmt_close_hour > 12) {
+            $cmt_close_hour = $cmt_close_hour - 12;
+        }
+        $ampm = 'pm';
+    } else {
+        $ampm = 'am';
+    }
+    $ampm_select = COM_getAmPmFormSelection ('cmt_close_ampm', $ampm);
+    if (empty ($ampm_select)) {
+        // have a hidden field to 24 hour mode to prevent JavaScript errors
+        $ampm_select = '<input type="hidden" name="cmt_close_ampm" value=""' . XHTML . '>';
+    }
+    $story_templates->set_var ('cmt_close_ampm_selection', $ampm_select);
+    
+    if ($_CONF['hour_mode'] == 24) {
+        $hour_options = COM_getHourFormOptions ($story->EditElements('cmt_close_hour'), 24);
+    } else {
+        $hour_options = COM_getHourFormOptions ($cmt_close_hour);
+    }
+    $story_templates->set_var('cmt_close_hour_options', $hour_options);
+    
+    $minute_options = COM_getMinuteFormOptions($story->EditElements('cmt_close_minute'));
+    $story_templates->set_var('cmt_close_minute_options', $minute_options);
+    
+    $story_templates->set_var('cmt_close_second', $story->EditElements('cmt_close_second'));
+    
     if (($_CONF['onlyrootfeatures'] == 1 && SEC_inGroup('Root'))
         or ($_CONF['onlyrootfeatures'] !== 1)) {
         $featured_options = "<select name=\"featured\">" . LB
diff -r 9ffd281952bd -r d1d8a0120489 public_html/article.php
--- a/public_html/article.php	Thu Apr 09 07:52:18 2009 +0200
+++ b/public_html/article.php	Fri Apr 10 11:53:06 2009 +0200
@@ -46,6 +46,7 @@
 */
 require_once 'lib-common.php';
 require_once $_CONF['path_system'] . 'lib-story.php';
+require_once $_CONF['path_system'] . 'lib-comment.php';
 if ($_CONF['trackback_enabled']) {
     require_once $_CONF['path_system'] . 'lib-trackback.php';
 }
@@ -57,6 +58,7 @@
 // echo COM_debug($_POST);
 
 // MAIN
+CMT_updateCommentcodes();
 $display = '';
 
 $order = '';
@@ -311,6 +313,13 @@
                  . '/trackback.php?mode=sendall&id=' . $story->getSid();
             $story_options[] = COM_createLink($LANG_TRB['send_trackback'], $url);
         }
+		
+        if (true) { // can subscribe
+            $commentSubscribeURL = '';
+            $story_options[] = COM_createLink('Nubbies', $commentSubscribeURL, array('rel' => 'nofollow'));
+            $story_template->set_var ('comment_subscribe_url', $commentSubscribeURL);
+            $story_template->set_var ('lang_comment_subscribe', 'Nubbies');
+        }
         $related = STORY_whatsRelated($story->displayElements('related'),
                                       $story->displayElements('uid'),
                                       $story->displayElements('tid'));
diff -r 9ffd281952bd -r d1d8a0120489 public_html/comment.php
--- a/public_html/comment.php	Thu Apr 09 07:52:18 2009 +0200
+++ b/public_html/comment.php	Fri Apr 10 11:53:06 2009 +0200
@@ -15,6 +15,7 @@
 // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
 // |          Dirk Haun         - dirk AT haun-online DOT de                   |
 // |          Vincent Furia     - vinny01 AT users DOT sourceforge DOT net     |
+// |          Jared Wenerd      - wenerd87 AT gmail DOT com                    |
 // +---------------------------------------------------------------------------+
 // |                                                                           |
 // | This program is free software; you can redistribute it and/or             |
@@ -40,6 +41,7 @@
 * @author   Jason Whittenburg
 * @author   Tony Bibbs, tonyAT tonybibbs DOT com
 * @author   Vincent Furia, vinny01 AT users DOT sourceforge DOT net
+* @author   Jared Wenerd, wenerd87 AT gmail DOT com
 *
 */
 
@@ -87,7 +89,10 @@
                 $_POST['comment'], $sid, COM_applyFilter ($_POST['pid'], true), 
                 'article', COM_applyFilter ($_POST['postmode']));
 
-            if ( $ret > 0 ) { // failure //FIXME: some failures should not return to comment form
+            if ($ret == -1) {
+                $display = COM_refresh (COM_buildUrl ($_CONF['site_url']
+                    . "/article.php?story=$sid&msg=15"));    
+            } elseif ( $ret > 0 ) { // failure //FIXME: some failures should not return to comment form
                 $display .= COM_siteHeader ('menu', $LANG03[1])
                          . CMT_commentForm ($_POST['title'], $_POST['comment'],
                            $sid, COM_applyFilter($_POST['pid']), $type,
@@ -114,7 +119,7 @@
 }
 
 /**
- * Handles a comment submission
+ * Handles a comment delete
  *
  * @copyright Vincent Furia 2005
  * @author Vincent Furia, vinny01 AT users DOT sourceforge DOT net
@@ -251,7 +256,67 @@
     return COM_siteHeader('menu', $title) . $display . COM_siteFooter();
 }
 
+/**
+ * Handles a comment edit submission
+ *
+ * @copyright Jared Wenerd 2008
+ * @author Jared Wenerd <wenerd87 AT gmail DOT com>
+ * @return string HTML (possibly a refresh)
+ */
+function handleEdit($mode) {
+    global $_TABLES; $LANG03;
+    
+    //get needed data
+    $cid = COM_applyFilter ($_REQUEST['cid']);
+    if ($mode == 'editsubmission') {
+        $table = $_TABLES['commentsubmissions'];
+        $result = DB_query("SELECT type, sid FROM {$_TABLES['commentsubmissions']} WHERE cid = $cid");
+        list($type, $sid) = DB_fetchArray($result);
+    } else {
+        $sid = COM_applyFilter ($_REQUEST['sid']);
+        $type = COM_applyFilter ($_REQUEST['type']);
+        $table = $_TABLES['comments'];
+    }
+    
+    //check for bad data 
+    if (!is_numeric ($cid) || ($cid < 0) || empty ($sid) || empty ($type)) {
+        COM_errorLog("handleEdit(): {$_USER['uid']} from {$_SERVER['REMOTE_ADDR']} tried "
+               . 'to edit a comment with one or more missing/bad values.');
+        return COM_refresh($_CONF['site_url'] . '/index.php');
+    }
+        



More information about the geeklog-cvs mailing list