if (!empty($_POST)) {
    if (!empty($_POST['uid'])) {
        $msg = NULL;
        if (empty($_POST['comment'])) {
            $msg = __('Comment can not be empty');
        }
        if (empty($msg)) {
            $obj = new ChannelComment();
            $obj->user_id = $_POST['uid'];
            $obj->comment = $_POST['comment'];
            $obj->slug = $_POST['slug'];
            $obj->channel_id = $_POST['c_id'];
            $obj->is_active = 1;
            $obj->save();
            //if the comment is posted then need to print the new set of comments.
            $channel_id = ChannelComment::convert_slug_to_channel_id($_POST['slug']);
            $new_comments = ChannelComment::get_channel_comments($channel_id, NULL, FALSE, 5, 1);
            $cnt = count($new_comments);
            $result = NULL;
            if ($cnt > 0) {
                $i = 1;
                $result .= '<div class="mheader_t"><span class="mh1 blue">' . $cnt . '</span></div><br><br><ul>';
                foreach ($new_comments as $comment) {
                    $img = uihelper_resize_mk_user_img($comment['author_details']->picture, 35, 35);
                    $login = User::get_login_name_from_id($comment['author_details']->user_id);
                    $result .= '<li><div class="asc_i"><a href="' . PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $login . '" target="_blank">' . $img . '</a></div><div><div class="asc_t"><span class="mh3b"><a href="' . PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $login . '" target="_blank">' . $login . '</a></span><br><span class="nh_body2">' . $comment["comment"] . '</span></div><div class="clear"></div></li>';
                    $i++;
                }
                $result .= '</ul>';
            }
            print $result;
* @license http://bit.ly/aVWqRV PayAsYouGo License
* @copyright Copyright (c) 2010 Broadband Mechanics
* @package PeopleAggregator
*/
error_reporting(E_ALL);
include_once dirname(__FILE__) . "/../../../config.inc";
include_once "web/Widgets/Comment/ChannelComment.php";
require_once "web/includes/classes/Pagination.php";
global $paging;
//spliting the path_info to get the id and the channel id.
$param = preg_split("|/|", $path_info);
for ($i = 2; $i < count($param); $i++) {
    list($k, $v) = explode('=', $param[$i]);
    $url_param[$k] = $v;
}
$channel_id = ChannelComment::convert_slug_to_channel_id($url_param['slug']);
$paging_new['count'] = ChannelComment::get_channel_comments($channel_id, NULL, TRUE);
$paging_new['show'] = 5;
$paging_new['page'] = $paging['page'];
$comments = ChannelComment::get_channel_comments($channel_id, NULL, FALSE, $paging_new['show'], $paging_new['page']);
$paging_new['extra'] = "onclick='javascript:ajax_pagination(this,{$channel_id});return false;'";
//setting pagination
$Pagination = new Pagination();
$Pagination->setPaging($paging_new);
$page_links = $Pagination->getPageLinks();
$template_file = 'web/Widgets/' . $widget_name . '/widget.tpl';
$template = new Template($template_file);
$template->set('url_param', $url_param);
$template->set('login_uid', PA::$login_uid);
$template->set('comments', $comments);
$template->set('channel_id', $channel_id);