/**
  * Notify member about file/folder sharing
  */
 public static function notifyFileShare($args)
 {
     try {
         if (strcasecmp($args['itemType'], 'file') == 0 || strcasecmp($args['itemType'], 'folder') == 0) {
             $content = 'A ' . $args['itemType'] . ' has been shared with you at location /Shared' . $args['fileTarget'];
             OC_Collaboration_Post::createPost('File Shared', $content, $args['uidOwner'], NULL, 'File Share', array($args['shareWith']));
             OC_Log::write('collaboration', 'File share notification posted.', OCP\Util::INFO);
         }
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
 /**
  * @brief Delete a member from a role of a project
  * @param Project ID from which the role has to be removed
  * @param Member whose role has to be removed
  * @param Role to be removed
  * @param Member who removed the other member from his/her role
  * @param Whether the calling method has already initiated the (database) transaction
  * @return int|boolean (ID of the post intimating the role removal|false)
  */
 public static function deleteMemberRole($pid, $member, $role, $user, $inTransaction = false)
 {
     try {
         if (!$inTransaction) {
             \OCP\DB::beginTransaction();
         }
         // Remove from all roles
         if (is_null($pid) && is_null($role)) {
             $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*collaboration_works_on` WHERE `member`=?');
             $result = $query->execute(array($member));
         } else {
             $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*collaboration_works_on` WHERE `pid`=? AND `member`=? AND `role`=?');
             $result = $query->execute(array($pid, $member, $role));
         }
         // Member removed from owncloud
         if (is_null($pid)) {
             OC_Collaboration_Task::removeMembersTasks($member, $user, true);
         } else {
             if (!self::isMemberWorkingOnProject($member, $pid)) {
                 OC_Collaboration_Task::unassignMembersTasks($member, $pid, $user, true);
             }
         }
         $post_id = OC_Collaboration_Post::createPost('Removed from role', 'You are removed from \'' . $role . '\' role from project \'' . self::getProjectTitle($pid) . '\'.', $user, $pid, 'Role Deletion', array($member), true);
         if (!$inTransaction) {
             \OCP\DB::commit();
         }
         return $post_id;
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
* 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;
* 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'])) {
    if (!OC_Collaboration_Post::isPostAccessibleToMember($_POST['post_id'], OC_User::getUser())) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to delete 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 delete read only post with ID ' . $_POST['post_id'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    OCP\JSON::success(array('delete_succeeded' => OC_Collaboration_Post::deletePost($_POST['post_id'])));
    exit;
}
OC_JSON::error();
exit;
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('collaboration');
$l = OC_L10N::get('collaboration');
if (isset($_POST['member']) && isset($_POST['start']) && isset($_POST['count']) && isset($_POST['project'])) {
    if (strcasecmp($_POST['member'], OC_User::getUser()) != 0) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to access posts of ' . $_POST['member'], \OCP\Util::WARN);
        OC_JSON::error();
        exit;
    }
    if ($_POST['project'] != '' && !OC_Collaboration_Project::isMemberWorkingOnProjectByTitle(OC_User::getUser(), $_POST['project'])) {
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to access project ' . $_POST['project'], \OCP\Util::WARN);
        OC_JSON::error();
        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>
 * 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();
 *
 * 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', 'dashboard');
OCP\Util::addStyle('collaboration', 'tabs');
OCP\Util::addStyle('collaboration', 'content_header');
OCP\Util::addStyle('collaboration', 'dashboard');
$tpl = new OCP\Template("collaboration", "dashboard", "user");
if (isset($_GET['project']) && $_GET['project'] != 'ALL') {
    if (!OC_Collaboration_Project::isMemberWorkingOnProjectByTitle(OC_User::getUser(), $_GET['project'])) {
        header('Location: ' . \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'dashboard')));
        \OCP\Util::writeLog('collaboration', OC_User::getUser() . ' is trying to access project ' . $_GET['project'], \OCP\Util::WARN);
        exit;
    } else {
        $tpl->assign('project', $_GET['project']);
        $tpl->assign('posts', OC_Collaboration_Post::readPosts(OC_User::getUser(), $_GET['project']));
        $task_params["assigned_by"] = OC_User::getUser();
        $task_params["project"] = $_GET['project'];
        $tpl->assign('tasks', OC_Collaboration_Task::readTasks($task_params));
    }
} else {
    $tpl->assign('posts', OC_Collaboration_Post::readPosts(OC_User::getUser()));
    $task_params["assigned_to"] = OC_User::getUser();
    $tpl->assign('tasks', OC_Collaboration_Task::readTasks($task_params));
}
$tpl->printPage();
 /**
  * @brief Changes the status of the task
  * @param Title ID
  * @param Title of the task
  * @param Task modified status
  * @param Member who created the task
  * @param Member who modified the task status
  * @param Reason for status change
  * @param Whether the calling method has already initiated the (database) transaction
  * @return boolean (true|false)
  */
 public static function changeStatus($tid, $title, $status, $creator, $member = NULL, $reason = NULL, $inTransaction = false)
 {
     try {
         if (!$inTransaction) {
             \OCP\DB::beginTransaction();
         }
         if (strcmp($status, 'Unassigned') == 0) {
             $member = NULL;
         } else {
             $member = self::getWorkingMember($tid);
         }
         $query = OCP\DB::prepare('INSERT INTO `*PREFIX*collaboration_task_status`(`tid`, `status`, `member`, `reason`, `last_updated_time`) VALUES(?, ?, ?, ?, CURRENT_TIMESTAMP)');
         $result = $query->execute(array($tid, $status, $member, $reason));
         $post_to = array();
         if (is_null($member)) {
             $post_to = array(self::getTaskCreator($tid));
         } else {
             $post_to = array(self::getTaskCreator($tid), $member);
         }
         OC_Collaboration_Post::createPost('Task Status Changed', 'The status of the task \'' . $title . '\' has been changed. Current status: ' . self::getStatusInFormat($status, $member, self::getTaskCreator($tid)) . '.', $creator, self::getProjectId($tid), 'Task Status Updation', $post_to, true, $tid);
         if (!$inTransaction) {
             \OCP\DB::commit();
         }
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
     return true;
 }
 * 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 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', 'display_message');
OCP\Util::addStyle('collaboration', 'tabs');
OCP\Util::addStyle('collaboration', 'content_header');
OCP\Util::addStyle('collaboration', 'display_message');
$l = OC_L10N::get('collaboration');
$tpl = new OCP\Template('collaboration', 'display_message', 'user');
$tpl->assign('title', $l->t('Loading...'));
$tpl->assign('msg', $l->t('Creating notification \'%s\'. Please be patient.', array($_POST['title'])));
$tpl->printPage();
if (!isset($_POST['post_to_all'])) {
    $members = is_array($_POST['notify_to']) ? $_POST['notify_to'] : array($_POST['notify_to']);
    $status = OC_Collaboration_Post::createPost($_POST['title'], $_POST['content'], OC_User::getUser(), $_POST['pid'], 'Custom Post', $members);
} else {
    $status = OC_Collaboration_Post::createPost($_POST['title'], $_POST['content'], OC_User::getUser(), $_POST['pid'], 'Custom Post');
}
print_unescaped('<META HTTP-EQUIV="Refresh" Content="0; URL=' . \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'submit_new_notification')) . '?title=' . $_POST['title'] . '">');
* 
* 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');
$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 />