[pLog-svn] r6449 - in plog/trunk: . class/action class/action/admin class/dao class/gallery/resizers templates/LifeType/en_UK templates/admin

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Fri May 9 10:10:24 EDT 2008


Author: jondaley
Date: 2008-05-09 10:10:24 -0400 (Fri, 09 May 2008)
New Revision: 6449

Modified:
   plog/trunk/class/action/addcommentaction.class.php
   plog/trunk/class/action/addtrackbackaction.class.php
   plog/trunk/class/action/admin/adminaddbloguseraction.class.php
   plog/trunk/class/dao/articlecomments.class.php
   plog/trunk/class/dao/commentscommon.class.php
   plog/trunk/class/dao/model.class.php
   plog/trunk/class/dao/trackbacks.class.php
   plog/trunk/class/gallery/resizers/gallerygdresizer.class.php
   plog/trunk/templates/LifeType/en_UK/strings.txt
   plog/trunk/templates/admin/addbloguser_form.template
   plog/trunk/version.php
Log:
merged 6437 through 6448 from 1.2 branch

Modified: plog/trunk/class/action/addcommentaction.class.php
===================================================================
--- plog/trunk/class/action/addcommentaction.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/action/addcommentaction.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -210,17 +210,27 @@
 				$comment->setUserId( 0 );
 			}
 
-			// fire an event
-			$this->notifyEvent( EVENT_PRE_COMMENT_ADD, Array( "comment" => &$comment ));
-											 
-			if( !$comments->addComment( $comment )) {
-               	// show an error message if problems
+                // check if there is already a comment with the same text, topic and made from the same
+                // IP already in the database because if so, then we will not add the comment that
+                // the user is trying to add (a reload or submit button mistake, perhaps?)
+            if( $comments->getIdentical( $comment )){
                 $this->_view = new ErrorView( $this->_blogInfo );
                 $this->_view->setValue( "message", "error_adding_comment" );
                 $this->setCommonData();
                 return false;
             }
-			
+
+                // fire an event
+            $this->notifyEvent( EVENT_PRE_COMMENT_ADD, Array( "comment" => &$comment ));
+            
+            if( !$comments->addComment( $comment )) {
+                    // show an error message if problems
+                $this->_view = new ErrorView( $this->_blogInfo );
+                $this->_view->setValue( "message", "error_adding_comment" );
+                $this->setCommonData();
+                return false;
+            }
+            
             // finally, check if there was any user who wanted to be notified of new comments
             // to this post...
             $notifier = new ArticleNotifications();

Modified: plog/trunk/class/action/addtrackbackaction.class.php
===================================================================
--- plog/trunk/class/action/addtrackbackaction.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/action/addtrackbackaction.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -128,7 +128,7 @@
             // as spam. The first one would be created by the spam filter and the second one would be created
             // by us here, so we need to know if the trackback is already there and if not, don't add it.
             // This also works as an additional protection feature agains repeating trackback spammers.
-            if( !$trackbacks->getIdenticalTrackback( $trackback )) {
+            if( !$trackbacks->getIdentical( $trackback )) {
                 // throw the event in case somebody is listening to it!
                 $pm->notifyEvent( EVENT_PRE_TRACKBACK_ADD, Array( "trackback" => &$trackback ));
                 $result = $trackbacks->addTrackBack( $trackback );

Modified: plog/trunk/class/action/admin/adminaddbloguseraction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddbloguseraction.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/action/admin/adminaddbloguseraction.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -17,7 +17,7 @@
         	$this->AdminAction( $actionInfo, $request );
 
 			// data validation
-			$this->registerFieldValidator( "userName", new StringValidator(), false, $this->_locale->tr("error_invalid_user"));
+			$this->registerFieldValidator( "userName", new UserNameValidator(), false, $this->_locale->tr("error_invalid_user"));
 			$this->_sendNotification = ($this->_request->getValue( "sendNotification" ) != "" );
 			$this->registerField( "sendNotification" );
 			$this->registerField( "perm" );
@@ -126,4 +126,4 @@
             return true;			
 		}
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/articlecomments.class.php
===================================================================
--- plog/trunk/class/dao/articlecomments.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/dao/articlecomments.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -46,21 +46,6 @@
         }
 
         /**
-         * Returns true if there already is a comment in the database with the same
-         * article_id field, topic, text, replying to the same comment, username and so on
-         * Useful in case we want to check if the user sent the same comment by mistake
-         * by pressing the 'reload' button twice or something...
-         *
-         * @return Returns true if there already is such comment or false otherwise.
-         */
-        function getIdenticalComment( $topic, $text, $articleId, $parentId = 0, $userName = "", $userEmail = "", $userUrl = "", $clientIp = "0.0.0.0" )
-        {
-			return( CommentsCommon::getIdenticalComment( $topic, $text, $articleId,
-			                                             $parentId, $userName, $userEmail,
-														 $userUrl, $clientIp, CommentsCommon::COMMENT_TYPE_COMMENT ));
-        }
-
-        /**
          * removes all comments marked as spam from the database
          */
         // TODO: CommentsCommon::purgeSpamComments doesn't exist,

Modified: plog/trunk/class/dao/commentscommon.class.php
===================================================================
--- plog/trunk/class/dao/commentscommon.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/dao/commentscommon.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -524,7 +524,7 @@
 		/**
 		 * Delete all the article comments
 		 *
-		 * @param blogId
+		 * @param articleId
 		 */
 		function deleteArticleComments( $articleId )
 		{
@@ -554,6 +554,39 @@
 			}
 			
 			return( $res );
-		}		
+		}
+
+		/**
+		 * Search for an identical comment (or trackback) already saved to the database
+		 *
+		 * @param comment
+		 */
+        function getIdentical( $comment )
+        {
+            $query = "SELECT COUNT(id) AS total FROM ".$this->getPrefix()."articles_comments ".
+                "WHERE topic = '".Db::qstr($comment->getTopic())."' AND ".
+                "text = '".Db::qstr($comment->getText())."' AND ".
+                "article_id = '".Db::qstr($comment->getArticleId())."' AND ".
+                "parent_id = '".Db::qstr($comment->getParentId())."' AND ".
+                "client_ip = '".Db::qstr($comment->getClientIp())."' AND ".
+                "user_name = '".Db::qstr($comment->getUserName())."' AND ".
+                "user_email = '".Db::qstr($comment->getUserEmail())."' AND ".
+                "user_url = '".Db::qstr($comment->getUserUrl())."'";
+            if( $comment->type != CommentsCommon::COMMENT_TYPE_ANY )
+                $query .= " AND type = '".Db::qstr($comment->getType())."'";
+
+            $result = $this->Execute( $query );
+
+            if( !$result )
+                return false;
+
+            $row = $result->FetchRow();
+            $result->Close();
+            
+            if( $row["total"] >= 1 )
+                return true;
+            else
+                return false;
+        }
 	}
 ?>
\ No newline at end of file

Modified: plog/trunk/class/dao/model.class.php
===================================================================
--- plog/trunk/class/dao/model.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/dao/model.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -137,9 +137,9 @@
                 $log =& LoggerManager::getLogger( "sqlerr" );
                 $error = $this->DbError();
                 $log->error( "The following query = \n" .
-                              $query .
+                             "\"$query\"" .
                              "\ngenerated the following error message = \n" .
-                              $error );
+                             "\"$error\"" );
             }
 
 			if( true ) {

Modified: plog/trunk/class/dao/trackbacks.class.php
===================================================================
--- plog/trunk/class/dao/trackbacks.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/dao/trackbacks.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -158,25 +158,5 @@
 		{
 			return( CommentsCommon::deleteComment( $trackbackId, CommentsCommon::COMMENT_TYPE_TRACKBACK ));
 		}
-		
-		/**
-		 * @private
-		 * @return Returns true if this trackback already exists in the db
-		 */
-        function getIdenticalTrackback( $trackback )
-        {
-			// :TODO:
-			//
-			// implement this
-			/*return( CommentsCommon::getIdenticalComment( $trackback->getTopic(), 
-														 $trackback->getText(), 
-														 $trackback->getArticleId(),
-			                                             $trackback->getParentId(),
-														 $trackback->getUserName(), 
-														 $trackback->getUserEmail(),
-														 $trackback->getUserUrl(), 
-														 $trackback->getClientIp(), 
-														 CommentsCommon::COMMENT_TYPE_TRACKBACK ));*/
-        }
     }
 ?>
\ No newline at end of file

Modified: plog/trunk/class/gallery/resizers/gallerygdresizer.class.php
===================================================================
--- plog/trunk/class/gallery/resizers/gallerygdresizer.class.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/class/gallery/resizers/gallerygdresizer.class.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -89,9 +89,7 @@
 
             }
             else {
-            	// not a recognized format
-                throw( new Exception( "Trying to generate a thumbnail of an unsupported format!"));
-                //die();
+                return false;
             }
 
             // check for errors

Modified: plog/trunk/templates/LifeType/en_UK/strings.txt
===================================================================
--- plog/trunk/templates/LifeType/en_UK/strings.txt	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/templates/LifeType/en_UK/strings.txt	2008-05-09 14:10:24 UTC (rev 6449)
@@ -1,8 +1,8 @@
 ltTagline = """LifeType is an open-source blogging platform with support for multiple blogs and users
 in a single installation."""
 
-frontPageLeft = """The latest stable version of LifeType is <b>1.2.7</b>. Click the link below to download.<br/>
-Take a look at the <a href="/post/2008/03/30/lifetype-1.2.7">Release Page</a>."""
+frontPageLeft = """The latest stable version of LifeType is <strong>1.2.8</strong>. Click the link below to download.<br/>
+Take a look at the <a href="/post/2008/05/04/lifetype-1.2.8-released">Release Page</a>."""
 
 frontPageRight = """LifeType supports multiple blogs and users, media management,
 generation of standard content, clean URLs and support for subdomains.

Modified: plog/trunk/templates/admin/addbloguser_form.template
===================================================================
--- plog/trunk/templates/admin/addbloguser_form.template	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/templates/admin/addbloguser_form.template	2008-05-09 14:10:24 UTC (rev 6449)
@@ -6,7 +6,7 @@
       <label for="userName">{$locale->tr("username")}</label>
       <span class="required">*</span>
       <div class="formHelp">{$locale->tr("new_blog_username_help")}</div>
-      <input type="text" id="userName" name="userName" value="{$newBlogUserName}" style="width:50%" />
+      <input type="text" id="userName" name="userName" value="{$newBlogUserName|escape:"html"}" style="width:50%" />
       <input type="hidden" id="userId" name="userId" />
 	  {check_perms adminperm=view_users}
 	   <a href="#" onclick="window.open('?op=siteUsersChooser','UserChooser','scrollbars=yes,resizable=yes,toolbar=no,height=450,width=600');">
@@ -56,4 +56,4 @@
     <input type="submit" name="Add this user" value="{$locale->tr("add")}"/>
     <input type="hidden" name="op" value="addBlogUser"/>
   </div> 
- </form>
\ No newline at end of file
+ </form>

Modified: plog/trunk/version.php
===================================================================
--- plog/trunk/version.php	2008-05-09 13:53:48 UTC (rev 6448)
+++ plog/trunk/version.php	2008-05-09 14:10:24 UTC (rev 6449)
@@ -1,3 +1,3 @@
 <?php
-$version = 'lifetype-1.2.8-dev';
+$version = 'lifetype-2.0-dev';
 ?>



More information about the pLog-svn mailing list