diff --git a/upload/ajax.php b/upload/ajax.php
index eadd3a73..19a72135 100644
--- a/upload/ajax.php
+++ b/upload/ajax.php
@@ -672,24 +672,6 @@ if(!empty($mode))
}
break;
- /**
- * Getting reply box for comment
- */
- case 'get_reply_box';
- {
- $id = mysql_clean($_POST['cid']);
- $new_com = $myquery->get_comment($id);
-
- assign('id',$new_com['type_id']);
- assign('type',$new_com['type']);
- assign('comment_id',$id);
- assign('mode','reply_box');
-
- //getting parent id if it is a reply comment
- echo json_encode(array("form"=>Fetch('blocks/comments/comment.html')));
-
- }
- break;
case 'count_comments';
echo '5';
@@ -1563,7 +1545,7 @@ if(!empty($mode))
{
$params = array();
- $limit = config('comments_per_page');
+ $limit = config('comment_per_page') ? config('comment_per_page') : 10;
$page = $_POST['page'];
$params['type'] = mysql_clean($_POST['type']);
$params['type_id'] = mysql_clean($_POST['type_id']);
@@ -1583,7 +1565,7 @@ if(!empty($mode))
assign('object_type',mysql_clean($_POST['object_type']));
//Pagination
$pages->paginate($total_pages,$page,NULL,NULL,'
#page#');
@@ -1598,18 +1580,13 @@ if(!empty($mode))
assign('comments_voting',$_POST['comments_voting']);
assign('commentPagination','yes');
- if($_POST['admin']=='yes' && has_access('admin_access',true))
- Template(BASEDIR.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/cbv2/layout/blocks/comments.html',false);
- else
+
Template('blocks/comments/comments.html');
assign('commentPagination','yes');
- if(SMARTY_VERSION > 2 )
- Template('blocks/pagination.html');
- // Template('blocks/common/pagination.html');
- else
- Template('blocks/pagination.html');
+
+ Template('blocks/pagination.html');
}
break;
diff --git a/upload/includes/classes/collections.class.php b/upload/includes/classes/collections.class.php
index 6588750f..37fb8990 100644
--- a/upload/includes/classes/collections.class.php
+++ b/upload/includes/classes/collections.class.php
@@ -1578,6 +1578,8 @@ class Collections extends CBCategory
);
insert_log('collection_comment',$log_array);
+ //Updating Number of comments of collection if comment is not a reply
+ if ($reply_to < 1)
$this->update_total_comments($obj_id);
}
return $comment;
@@ -1590,7 +1592,7 @@ class Collections extends CBCategory
function update_total_comments($cid)
{
global $db;
- $count = $db->count(tbl("comments"),"comment_id"," type = 'cl' AND type_id = '$cid'");
+ $count = $db->count(tbl("comments"),"comment_id"," type = 'cl' AND type_id = '$cid' AND parent_id='0'");
$db->update(tbl($this->section_tbl),array("total_comments","last_commented"),array($count,now())," collection_id = '$cid'");
}
diff --git a/upload/includes/classes/groups.class.php b/upload/includes/classes/groups.class.php
index a2a1e240..2aee6229 100644
--- a/upload/includes/classes/groups.class.php
+++ b/upload/includes/classes/groups.class.php
@@ -1609,7 +1609,8 @@ class CBGroups extends CBCategory
);
insert_log('topic_comment',$log_array);
- //Updating Number of comments of topics
+ //Updating Number of comments of group if comment is not a reply
+ if ($reply_to < 1)
$this->update_comments_count($obj_id);
}
return $add_comment;
@@ -1671,7 +1672,7 @@ class CBGroups extends CBCategory
function count_topic_comments($id)
{
global $db;
- $total_comments = $db->count(tbl('comments'),"comment_id","type='t' AND type_id='$id'");
+ $total_comments = $db->count(tbl('comments'),"comment_id","type='t' AND type_id='$id' AND parent_id='0'");
return $total_comments;
}
diff --git a/upload/includes/classes/my_queries.class.php b/upload/includes/classes/my_queries.class.php
index 17543c5d..b232f605 100644
--- a/upload/includes/classes/my_queries.class.php
+++ b/upload/includes/classes/my_queries.class.php
@@ -736,6 +736,8 @@ class myquery {
if($type_id!='*')
$typeid_query = "AND type_id='$type_id' ";
+
+
if(!$count_only)
{
@@ -768,60 +770,33 @@ class myquery {
if(!$results)
return false;
- $parent_cond = '';
- $parents_array = array();
+
+ //getting relies of comments
if($results)
- foreach($results as $result)
{
- if($result['parent_id'] && !in_array($result['parent_id'],$parents_array))
- {
- if($parent_cond)
- $parent_cond .= " OR ";
- $parent_cond .= " comment_id='".$result['parent_id']."' " ;
+ $parents_array = array();
+ foreach($results as $result)
+ {
+ $query = "SELECT * FROM ".tbl('comments');
+ $query .= " WHERE type='$type' $typeid_query AND parent_id='".$result['comment_id']."' ";
+ $replies = db_select($query);
+ if ($replies )
+ {
+ $replies = array("comments"=>$replies);
+ $result['children'] = $replies;
+ }
+ else
+ {
+ $result['children'] = '';
+ }
- $parents_array[] = $result['parent_id'];
- }
- }
-
- // //Getting Parents
- // $parents = $db->select(tbl("comments"),'*'
- // ," type='$type' AND ($parent_cond) ",NULL,$order);
-
- // if($parents)
- // foreach($parents as $parent)
- // $new_parents[$parent['comment_id']] = $parent;
-
-
- //Inserting user data
- $new_results = array();
-
- //pr($results,true);
- if($results)
- foreach($results as $com)
- {
- $userid = $com['userid'];
-
- $uservar = 'user_'.$userid;
-
- if($userid && !$$uservar)
- $$uservar = $userquery->get_user_details($userid);
- if($$uservar)
- $com = array_merge($com,$$uservar);
-
-
-
- $params['parent_id'] = $com['comment_id'];
- $params['get_reply_only'] = $com['comment_id'];
- $children = $this->getComments($params);
- $com['children'] = $children;
-
- $new_results[] = $com;
+ $parents_array[] = $result;
+ }
}
-
- $comment['comments'] = $new_results;
- //$comment['parents'] = $new_parents;
+
+ $comment['comments'] = $parents_array;
//Deleting any other previuos comment file
diff --git a/upload/includes/classes/photos.class.php b/upload/includes/classes/photos.class.php
index 53048ef8..d5ada9a3 100644
--- a/upload/includes/classes/photos.class.php
+++ b/upload/includes/classes/photos.class.php
@@ -2473,6 +2473,8 @@ class CBPhotos
$comment = $myquery->add_comment($comment,$obj_id,$reply_to,'p',$ownerID,$photoLink,$force_name_email);
if($comment)
{
+ //Updating Number of comments of photo if comment is not a reply
+ if ($reply_to < 1)
$this->update_total_comments($obj_id);
}
return $comment;
@@ -2485,7 +2487,7 @@ class CBPhotos
function update_total_comments($pid)
{
global $db;
- $count = $db->count(tbl("comments"),"comment_id"," type = 'p' AND type_id = '$pid'");
+ $count = $db->count(tbl("comments"),"comment_id"," type = 'p' AND type_id = '$pid' AND parent_id='0'");
$db->update(tbl('photos'),array("total_comments","last_commented"),array($count,now())," photo_id = '$pid'");
}
diff --git a/upload/includes/classes/user.class.php b/upload/includes/classes/user.class.php
index 1539397a..1eb21864 100644
--- a/upload/includes/classes/user.class.php
+++ b/upload/includes/classes/user.class.php
@@ -2035,7 +2035,7 @@ class userquery extends CBCategory{
function count_profile_comments($id)
{
global $db;
- $total_comments = $db->count(tbl('comments'),"comment_id","type='c' AND type_id='$id'");
+ $total_comments = $db->count(tbl('comments'),"comment_id","type='c' AND type_id='$id' AND parent_id='0'");
return $total_comments;
}
function count_channel_comments($id){ return $this->count_profile_comments($id); }
@@ -2094,7 +2094,8 @@ class userquery extends CBCategory{
);
insert_log('profile_comment',$log_array);
- //Updating Number of comments of video
+ //Updating Number of comments of user if comment is not a reply
+ if ($reply_to < 1)
$this->update_comments_count($obj_id);
}
return $add_comment;
diff --git a/upload/includes/classes/video.class.php b/upload/includes/classes/video.class.php
index c21b98ee..4a128400 100644
--- a/upload/includes/classes/video.class.php
+++ b/upload/includes/classes/video.class.php
@@ -1175,7 +1175,7 @@ class CBvideo extends CBCategory
function count_video_comments($id)
{
global $db;
- $total_comments = $db->count(tbl('comments'),"comment_id","type='v' AND type_id='$id'");
+ $total_comments = $db->count(tbl('comments'),"comment_id","type='v' AND type_id='$id' AND parent_id='0'");
return $total_comments;
}
@@ -1218,8 +1218,11 @@ class CBvideo extends CBCategory
);
insert_log('video_comment',$log_array);
- //Updating Number of comments of video
- $this->update_comments_count($obj_id);
+ //Updating Number of comments of video if comment is not a reply
+ if ($reply_to < 1)
+ $this->update_comments_count($obj_id);
+
+
}
return $add_comment;
}
diff --git a/upload/js/functions.js b/upload/js/functions.js
index d016fa33..01e20057 100644
--- a/upload/js/functions.js
+++ b/upload/js/functions.js
@@ -647,10 +647,11 @@ var loading_img_2 = "
';
+ html += '';
+ html += '';
+ html += '';
+ html += '';
+ html += '';
+ html += '';
+ $('.reply-box-' + cid).html(html).slideDown("slow");
+ $('#reply_box_' + cid).focus();
}
diff --git a/upload/styles/cb_27/layout/blocks/comments/add_comment.html b/upload/styles/cb_27/layout/blocks/comments/add_comment.html
index 9dd7b110..654ca29d 100644
--- a/upload/styles/cb_27/layout/blocks/comments/add_comment.html
+++ b/upload/styles/cb_27/layout/blocks/comments/add_comment.html
@@ -2,7 +2,8 @@
{if $userquery->login_check('',true) || $Cbucket->configs.anonym_comments == 'yes' }