* 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['post_id']) && isset($_POST['title']) && isset($_POST['content'])) {
    if (!OC_Collaboration_Post::isPostAccessibleToMember($_POST['post_id'], OC_User::getUser())) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to edit post with ID ' . $_POST['post_id'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    if (!OC_Collaboration_Post::isPostEditable($_POST['post_id'])) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to edit read only post with ID ' . $_POST['post_id'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    OCP\JSON::success(array('edit_succeeded' => OC_Collaboration_Post::editPost($_POST['post_id'], $_POST['title'], $_POST['content'])));
    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();