Index: inc/core/class.dc.blog.php
===================================================================
--- inc/core/class.dc.blog.php	(revision 1429)
+++ inc/core/class.dc.blog.php	(revision 1491)
@@ -4,5 +4,5 @@
 # This file is part of Dotclear 2.
 #
-# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
+# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear
 # Licensed under the GPL version 2.0 license.
 # See LICENSE file or
@@ -91,13 +91,13 @@
 			$this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT);
 			
-			$this->post_status['-2'] = __('pending');
-			$this->post_status['-1'] = __('scheduled');
-			$this->post_status['0'] = __('unpublished');
-			$this->post_status['1'] = __('published');
-			
-			$this->comment_status['-2'] = __('junk');
-			$this->comment_status['-1'] = __('pending');
-			$this->comment_status['0'] = __('unpublished');
-			$this->comment_status['1'] = __('published');
+			$this->post_status['-2'] = __('Pending');
+			$this->post_status['-1'] = __('Scheduled');
+			$this->post_status['0'] = __('Unpublished');
+			$this->post_status['1'] = __('Published');
+			
+			$this->comment_status['-2'] = __('Junk');
+			$this->comment_status['-1'] = __('Pending');
+			$this->comment_status['0'] = __('Unpublished');
+			$this->comment_status['1'] = __('Published');
 			
 			# --BEHAVIOR-- coreBlogConstruct
@@ -203,26 +203,22 @@
 	@param	ids		<b>mixed</b>		Comment(s) ID(s)
 	@param	del		<b>boolean</b>		If comment is delete, set this to true
-	@param	affected_posts		<b>mixed</b>		Posts(s) ID(s)
-	*/
-	public function triggerComments($ids, $del=false, $affected_posts=null)
+	*/
+	public function triggerComments($ids,$del=false)
 	{
 		$co_ids = dcUtils::cleanIds($ids);
-		$a_ids = dcUtils::cleanIds($affected_posts);
-		$a_tbs = array();
 		
 		# a) Retrieve posts affected by comments edition
-		if (empty($a_ids)) {
-			$strReq = 
-				'SELECT post_id, comment_trackback '.
-				'FROM '.$this->prefix.'comment '.
-				'WHERE comment_id'.$this->con->in($co_ids).
-				'GROUP BY post_id,comment_trackback';
-			
-			$rs = $this->con->select($strReq);
-			
-			while ($rs->fetch()) {
-				$a_ids[] = (integer) $rs->post_id;
-				$a_tbs[] = (integer) $rs->comment_trackback;
-			}
+		$strReq = 
+			'SELECT post_id, comment_trackback '.
+			'FROM '.$this->prefix.'comment '.
+			'WHERE comment_id'.$this->con->in($co_ids).
+			'GROUP BY post_id,comment_trackback';
+		
+		$rs = $this->con->select($strReq);
+		
+		$a_ids = $a_tbs = array();
+		while ($rs->fetch()) {
+			$a_ids[] = (integer) $rs->post_id;
+			$a_tbs[] = (integer) $rs->comment_trackback;
 		}
 		
@@ -259,5 +255,4 @@
 		{
 			$nb_comment = $nb_trackback = 0;
-			//$cur->nb_comment = $nb_comment;
 			foreach($b_ids as $b_key => $b_id)
 			{
@@ -510,11 +505,5 @@
 		$this->core->callBehavior('coreBeforeCategoryCreate',$this,$cur);
 		
-		$id = $this->categories()->addNode($cur,$parent);
-		# Update category's cursor
-		$rs = $this->getCategory($id);
-		if (!$rs->isEmpty()) {
-			$cur->cat_lft = $rs->cat_lft;
-			$cur->cat_rgt = $rs->cat_rgt;
-		}
+		$this->categories()->addNode($cur,$parent);
 		
 		# --BEHAVIOR-- coreAfterCategoryCreate
@@ -645,55 +634,18 @@
 	private function checkCategory($title,$url,$id=null)
 	{
-		# Let's check if URL is taken...
-		$strReq = 
-			'SELECT cat_url FROM '.$this->prefix.'category '.
-			"WHERE cat_url = '".$this->con->escape($url)."' ".
-			($id ? 'AND cat_id <> '.(integer) $id. ' ' : '').
-			"AND blog_id = '".$this->con->escape($this->id)."' ".
-			'ORDER BY cat_url DESC';
+		$strReq = 'SELECT cat_id '.
+				'FROM '.$this->prefix.'category '.
+				"WHERE cat_url = '".$this->con->escape($url)."' ".
+				"AND blog_id = '".$this->con->escape($this->id)."' ";
+		
+		if ($id !== null) {
+			$strReq .= 'AND cat_id <> '.(integer) $id.' ';
+		}
 		
 		$rs = $this->con->select($strReq);
 		
-		if (!$rs->isEmpty())
-		{
-			if ($this->con->driver() == 'mysql') {
-				$clause = "REGEXP '^".$this->con->escape($url)."[0-9]+$'";
-			} elseif ($this->con->driver() == 'pgsql') {
-				$clause = "~ '^".$this->con->escape($url)."[0-9]+$'";
-			} else {
-				$clause = "LIKE '".$this->con->escape($url)."%'";
-			}
-			$strReq = 
-				'SELECT cat_url FROM '.$this->prefix.'category '.
-				"WHERE cat_url ".$clause.' '.
-				($id ? 'AND cat_id <> '.(integer) $id. ' ' : '').
-				"AND blog_id = '".$this->con->escape($this->id)."' ".
-				'ORDER BY cat_url DESC ';
-			
-			$rs = $this->con->select($strReq);
-			$a = array();
-			while ($rs->fetch()) {
-				$a[] = $rs->cat_url;
-			}
-			
-			natsort($a);
-			$t_url = end($a);
-			
-			if (preg_match('/(.*?)([0-9]+)$/',$t_url,$m)) {
-				$i = (integer) $m[2];
-				$url = $m[1];
-			} else {
-				$i = 1;
-			}
-			
-			return $url.($i+1);
-		}
-		
-		# URL is empty?
-		if ($url == '') {
-			throw new Exception(__('Empty category URL'));
-		}
-		
-		return $url;
+		if (!$rs->isEmpty()) {
+			throw new Exception(__('Category URL must be unique.'));
+		}
 	}
 	
@@ -717,5 +669,5 @@
 		
 		# Check if title or url are unique
-		$cur->cat_url = $this->checkCategory($cur->cat_title,$cur->cat_url,$id);
+		$this->checkCategory($cur->cat_title,$cur->cat_url,$id);
 		
 		if ($cur->cat_desc !== null) {
@@ -853,5 +805,5 @@
 		
 		if (!empty($params['user_id'])) {
-			$strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' ";
+			$strReq .= "AND U.user_id ".$this->con->in($params['user_id'])." ";
 		}
 		
@@ -937,8 +889,7 @@
 				$strReq .= 'ORDER BY post_dt DESC ';
 			}
-		}
-		
-		if (!$count_only && !empty($params['limit'])) {
-			$strReq .= $this->con->limit($params['limit']);
+			if (!empty($params['limit'])) {
+				$strReq .= $this->con->limit($params['limit']);
+			}
 		}
 		
@@ -2229,19 +2180,6 @@
 		$co_ids = dcUtils::cleanIds($ids);
 		
-		if (empty($co_ids)) {
+		if (empty($ids)) {
 			throw new Exception(__('No such comment ID'));
-		}
-		
-		# Retrieve posts affected by comments edition
-		$affected_posts = array();
-		$strReq =
-			'SELECT distinct(post_id) '.
-			'FROM '.$this->prefix.'comment '.
-			'WHERE comment_id'.$this->con->in($co_ids);
-		
-		$rs = $this->con->select($strReq);
-		
-		while ($rs->fetch()) {
-			$affected_posts[] = (integer) $rs->post_id;
 		}
 		
@@ -2273,5 +2211,5 @@
 		
 		$this->con->execute($strReq);
-		$this->triggerComments($co_ids, true, $affected_posts);
+		$this->triggerComments($co_ids,true);
 		$this->triggerBlog();
 	}
@@ -2328,8 +2266,6 @@
 		
 		if ($cur->comment_site !== null && $cur->comment_site != '') {
-			if (!preg_match('|^http(s?)://|i',$cur->comment_site, $matches)) {
+			if (!preg_match('|^http(s?)://|',$cur->comment_site)) {
 				$cur->comment_site = 'http://'.$cur->comment_site;
-			}else{
-				$cur->comment_site = strtolower($matches[0]).substr($cur->comment_site, strlen($matches[0]));
 			}
 		}
