* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('collaboration');
$l = OC_L10N::get('collaboration');
if (isset($_POST['comment_id'])) {
    if (!OC_Collaboration_Comment::isCommentWrittenByMember($_POST['comment_id'], OC_User::getUser())) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to edit comment with ID ' . $_POST['comment_id'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    $time = OC_Collaboration_Comment::editComment($_POST['comment_id'], $_POST['content']);
    $updated_time = NULL;
    $success = false;
    if (!is_null($time)) {
        $success = true;
        $datetime = explode(' ', $time);
        $updated_time = $l->t('On %s at %s', array($l->l('date', $datetime[0]), $l->l('time', $datetime[1])));
    }
    OCP\JSON::success(array('edit_succeeded' => $success, 'updated_time' => $updated_time));
    exit;
}
OC_JSON::error();
exit;
*
* @authors Dr.J.Akilandeswari, R.Ramki, R.Sasidharan, P.Suresh
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('collaboration');
if (isset($_POST['comment_id'])) {
    if (!OC_Collaboration_Comment::isCommentWrittenByMember($_POST['comment_id'], OC_User::getUser())) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to delete comment with ID ' . $_POST['comment_id'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    OCP\JSON::success(array('delete_succeeded' => OC_Collaboration_Comment::deleteComment($_POST['comment_id'])));
    exit;
}
OC_JSON::error();
exit;
        exit;
    }
    $posts = OC_Collaboration_Post::readPosts($_POST['member'], $_POST['project'], $_POST['start'], $_POST['count']);
    $text = '';
    foreach ($posts as $each) {
        if (!isset($each['title']) || $each['title'] == '') {
            break;
        }
        $datetime = explode(' ', $each['time']);
        $text .= '<div class="unit">
		<div class="post_title">' . $each['title'] . '</div>
		
		<div class="contents">' . $each['content'] . '<br />
			<br />
			<div class="comment" >
				<button class="btn_comment" id="btn_comment_' . $each['post_id'] . '" >' . ($l->t('Comments') . ' (' . OC_Collaboration_Comment::getCommentCount($each['post_id']) . ')') . '</button>
			</div>
		</div>
		
		<div class="details">
			<div class="proj_title">' . (isset($each['proj_title']) && !is_null($each['proj_title']) ? $l->t('Project: %s', array($each['proj_title'])) : '') . '</div>
			
			<div class="creation_details">' . $l->t('On %s at %s by %s', array($l->l('date', $datetime[0]), $l->l('time', $datetime[1]), $each['creator'])) . '</div>
		</div>
		</div>';
    }
    OCP\JSON::success(array('posts' => $text));
    exit;
}
OC_JSON::error();
exit;
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
\OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('collaboration');
OCP\App::setActiveNavigationEntry('collaboration');
OCP\Util::addScript('collaboration', 'comment');
OCP\Util::addStyle('collaboration', 'tabs');
OCP\Util::addStyle('collaboration', 'content_header');
OCP\Util::addStyle('collaboration', 'comment');
$tpl = new OCP\Template("collaboration", "comment", "user");
if (isset($_GET['post'])) {
    $details = OC_Collaboration_Post::getPostDetails($_GET['post']);
    if (count($details) == 0 || !OC_Collaboration_Post::isPostAccessibleToMember($_GET['post'], OC_User::getUser())) {
        goToDashboard();
    } else {
        $tpl->assign('details', $details);
        $tpl->assign('comments', OC_Collaboration_Comment::readComments($_GET['post']));
    }
} else {
    goToDashboard();
}
function goToDashboard()
{
    header('Location: ' . \OCP\Util::linkToRoute('collaboration_route', 'dashboard'));
    exit;
}
$tpl->printPage();
						  </div>
				      <div class="contents">
					     <?php 
        p($each['content']);
        ?>
			  	    </div>
              <div class="cb-date">
	          <?php 
        $datetime = explode(' ', $each['time']);
        p($l->t('On %s at %s by %s', array($l->l('date', $datetime[0]), $l->l('time', $datetime[1]), $each['creator'])));
        ?>
            </div>
            <div class="comment" >
	            <button class="btn_comment" id="<?php 
        p('btn_comment_' . $each['post_id']);
        ?>
" >
		             <?php 
        p($l->t('Comments') . ' (' . OC_Collaboration_Comment::getCommentCount($each['post_id']) . ')');
        ?>
	            </button>
            </div>
				  </div>
			  </div></div>
	    <?php 
    }
}
?>
		</div>
</div>
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('collaboration');
$l = OC_L10N::get('collaboration');
if (isset($_POST['content']) && isset($_POST['post_id'])) {
    if (!OC_Collaboration_Post::isPostAccessibleToMember($_POST['post_id'], OC_User::getUser())) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to write comment on post with ID ' . $_POST['post_id'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    $comment_id = OC_Collaboration_Comment::createComment($_POST['content'], OC_User::getUser(), $_POST['post_id']);
    if ($comment_id == false) {
        OC_JSON::error();
        exit;
    }
    $comment = OC_Collaboration_Comment::readComment($comment_id);
    $datetime = explode(' ', $comment['time']);
    $text = '<div class="comment" id="comment_' . $comment['comment_id'] . '" >
			<span class="comment_creator" >' . $comment['creator'] . ': </span>
			<span id="comment_content_' . $comment['comment_id'] . '" >' . $comment['content'] . '</span>
			<hr />
			<div class="comment_details" >
			<span class="updated_time" >' . $l->t('On %s at %s', array($l->l('date', $datetime[0]), $l->l('time', $datetime[1]))) . '</span>
			<div class="edit_delete_comment" >
			<a class="edit" data-collaboration-type="comment" data-collaboration-id="' . $comment['comment_id'] . '" >' . $l->t('Edit') . '</a>
			 | 
			 <a class="delete" data-collaboration-type="comment" data-collaboration-id="' . $comment['comment_id'] . '">' . $l->t('Delete') . '</a>
			 </div>
			 </div>
			 </div>';
    OCP\JSON::success(array('creation_string' => $text));