public function testConstructor() { $factory = new \Jackalope\Factory(); $repository = $this->getMock('Jackalope\\Repository', array(), array($factory), '', false); $workspaceName = 'asdfads'; $userID = 'abcd'; $cred = new \PHPCR\SimpleCredentials($userID, 'xxxx'); $cred->setAttribute('test', 'toast'); $cred->setAttribute('other', 'value'); $transport = new Transport\Davex\Client($factory, 'http://example.com'); $s = new Session($factory, $repository, $workspaceName, $cred, $transport); $this->assertSame($repository, $s->getRepository()); $this->assertSame($userID, $s->getUserID()); $this->assertSame(array('test', 'other'), $s->getAttributeNames()); $this->assertSame('toast', $s->getAttribute('test')); $this->assertSame('value', $s->getAttribute('other')); }
public static function getProjectsByUserID($userID = null, $limit = null) { if ($userID === null) { return null; } $loggedInUserID = Session::getUserID(); $query = " SELECT pu.project_id AS id FROM " . self::DB_TABLE . " pu"; $query .= " INNER JOIN " . Project::DB_TABLE . " p ON"; $query .= " pu.project_id = p.id"; $query .= " WHERE pu.user_id = " . $userID; $query .= " AND pu.relationship != " . self::BANNED; // only show private projects if logged-in user is also a member if (!empty($loggedInUserID)) { $query .= " AND (p.private = 0"; $query .= " OR pu.project_id IN ("; $query .= " SELECT project_id FROM " . self::DB_TABLE; $query .= " WHERE user_id = " . $loggedInUserID; $query .= " AND relationship != " . self::BANNED; $query .= " ))"; } else { $query .= " AND p.private = 0"; } $query .= " ORDER BY p.title ASC"; if (!empty($limit)) { $query .= " LIMIT " . $limit; } $db = Db::instance(); $result = $db->lookup($query); if (!mysql_num_rows($result)) { return array(); } $projects = array(); while ($row = mysql_fetch_assoc($result)) { $projects[$row['id']] = Project::load($row['id']); } return $projects; }
/** * Handles the session * @return User/null if null, then no user is logged in */ function handleSessions() { if (isset($_SESSION['orongo-id']) && isset($_SESSION['orongo-session-id'])) { $externID = Security::escapeSQL($_SESSION['orongo-id']); $externSession = Security::escapeSQL($_SESSION['orongo-session-id']); if (Session::isGoodSessionID($externSession)) { $sessionUserID = Session::getUserID($externSession); if ($sessionUserID == $externID) { try { $user = new User($externID); return $user; } catch (Exception $e) { if ($e->getCode() == USER_NOT_EXIST) { header("Location: orongo-logout.php"); exit; } else { header('HTTP/1.1 500 Internal Server Error'); exit; } } } else { Session::delete($externSession); session_destroy(); header("Location: orongo-logout.php"); exit; } } else { Session::delete($externSession); session_destroy(); header("Location: orongo-logout.php"); exit; } } else { return null; } }
include_once TEMPLATE_PATH . '/site/helper/format.php'; $project = $SOUP->get('project'); $task = $SOUP->get('task'); $joined = $SOUP->get('accepted'); $id = $SOUP->get('id', 'contributors'); $hasJoinedTask = $SOUP->get('hasJoinedTask', false); // can user join or leave task? $hasLeavePermission = false; $hasJoinPermission = false; if ($task->getStatus()) { $openTask = true; } else { $openTask = false; } if (Session::isLoggedIn() && !$project->isBanned(Session::getUserID())) { if ($hasJoinedTask) { $hasLeavePermission = true; } else { $hasJoinPermission = true; } } // num joined $numJoined = $task->getNumAccepted(); // num needed $numNeeded = $task->getNumNeeded(); if (empty($numNeeded)) { $numNeeded = '∞ people'; } else { $numNeeded = $numNeeded - $numJoined; if ($numNeeded < 0) {
<?php require_once "../../global.php"; $soup = new Soup(); if (Session::isLoggedIn()) { $projects = Project::getPublicProjects(Session::getUserID()); } else { $projects = Project::getPublicProjects(); } $soup->set('projects', $projects); $soup->render('site/page/find');
<?php include_once TEMPLATE_PATH . '/site/helper/format.php'; $project = $SOUP->get('project'); $accepted = $SOUP->get('accepted'); $update = $SOUP->get('update'); $updates = $SOUP->get('updates'); $uploads = $SOUP->get('uploads'); $task = $SOUP->get('task', null); $comments = $SOUP->get('comments'); // only update creator may edit or create $hasPermission = Session::isAdmin() || $update->getCreatorID() == Session::getUserID(); $fork = $SOUP->fork(); $fork->set('title', 'Contribution'); $fork->set('id', 'update'); $fork->set('editable', $hasPermission); $fork->set('editLabel', 'Edit'); $fork->startBlockSet('body'); ?> <?php if ($hasPermission) { ?> <script type="text/javascript"> $(document).ready(function(){ $('#selStatus').val('<?php echo $accepted->getStatus(); ?> ');
if ($creator->getNotifyDiscussionStarted()) { // compose email $body = "<p>" . formatUserLink(Session::getUserID()) . ' replied to your discussion <a href="' . Url::discussion($discussionID) . '">' . $discussion->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>'; $body .= "<blockquote>" . formatDiscussionReply($message) . "</blockquote>"; $email = array('to' => $creator->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New reply to your discussion in ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } } // others who replied to discussion $repliers = $discussion->getDistinctRepliers(); foreach ($repliers as $r) { if ($r->getID() != Session::getUserID()) { // don't email yourself if ($r->getNotifyDiscussionReply()) { // compose email $body = "<p>" . formatUserLink(Session::getUserID()) . ' replied to the discussion <a href="' . Url::discussion($discussionID) . '">' . $discussion->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>'; $body .= "<blockquote>" . formatDiscussionReply($message) . "</blockquote>"; $email = array('to' => $r->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New reply to a discussion in ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } } } $json = array('success' => '1'); Session::setMessage("You replied to the discussion."); echo json_encode($json); } else { $json = array('error' => 'Invalid action.'); exit(json_encode($json)); }
public static function saveToDatabase($originalName = null, $storedName = null, $itemType = null, $itemID = null, $projectID = null) { // all but projectID required if ($originalName == null || $storedName == null || $itemType == null || $itemID == null) { return null; } // get extension $ext = pathinfo($originalName, PATHINFO_EXTENSION); $storedName .= '.' . $ext; // temp variable for absolute path $absPath = UPLOAD_PATH . '/' . $storedName; // get file size $size = filesize($absPath); // get mime type $mime = getMimeType($absPath); // get height and width (if image) $imgSize = getimagesize($absPath); if ($imgSize) { $height = $imgSize[1]; $width = $imgSize[0]; } else { $height = null; $width = null; } // store in db $upload = new Upload(array('creator_id' => Session::getUserID(), 'original_name' => $originalName, 'stored_name' => $storedName, 'mime' => $mime, 'size' => $size, 'height' => $height, 'width' => $width, 'item_type' => $itemType, 'item_id' => $itemID, 'project_id' => $projectID)); $upload->save(); return $upload->getID(); }
<?php require_once "../../global.php"; $user = User::load(Session::getUserID()); $action = Filter::text($_POST['action']); if ($action == 'theme') { // get the new theme $themeID = Filter::numeric($_POST['themeID']); $theme = Theme::load($themeID); // validate the theme if (empty($theme)) { $json = array('error' => 'That theme does not exist.'); exit(json_encode($json)); } // save the new theme $user->setThemeID($theme->getID()); $user->save(); // send us back Session::setMessage("Theme changed."); $json = array('success' => '1'); echo json_encode($json); } elseif ($action == 'notification') { $notificationType = Filter::alphanum($_POST['notificationType']); $notificationValue = Filter::alphanum($_POST['notificationValue']); // convert checkbox value to database-friendly 1 or 0 $value = $notificationValue == 'notify' ? 1 : 0; // figure out which User setter to use based on notification type switch ($notificationType) { case 'chkCommentTaskLeading': $user->setNotifyCommentTaskLeading($value); break;
$hasJoinedTask = $SOUP->get('hasJoinedTask', false); $updates = $task->getUpdates(); //$uploads = $SOUP->get('uploads'); $fork = $SOUP->fork(); $fork->set('project', $project); $fork->set('pageTitle', $project->getTitle()); $fork->set('headingURL', Url::project($project->getID())); $fork->set('selected', "tasks"); $fork->set('breadcrumbs', Breadcrumbs::task($task->getID())); $fork->startBlockSet('body'); ?> <td class="left"> <?php $SOUP->render('project/partial/task', array()); ?> </td> <td class="right"> <?php if ($hasJoinedTask && !$project->isBanned(Session::getUserID())) { $SOUP->render('project/partial/contribs', array('updates' => $updates)); $SOUP->render('project/partial/taskContributors', array()); } else { $SOUP->render('project/partial/taskContributors', array()); $SOUP->render('project/partial/contribs', array('updates' => $updates)); } ?> <?php $SOUP->render('site/partial/activity', array('title' => "Recent Activity", 'size' => 'small', 'events' => $events, 'olderURL' => Url::activityTasks($project->getID()), 'class' => 'subtle'));
<?php include_once TEMPLATE_PATH . '/site/helper/format.php'; $project = $SOUP->get('project'); // admin, trusted, creator may edit $hasPermission = Session::isAdmin() || $project->isTrusted(Session::getUserID()) || $project->isCreator(Session::getUserID()); $formattedRules = formatRules($project->getRules()); $fork = $SOUP->fork(); $fork->set('title', "Rules"); $fork->set('id', "rules"); $fork->set('editable', $hasPermission); //$fork->set('editLabel', 'Edit Rules'); $fork->startBlockSet('body'); ?> <?php if ($hasPermission) { ?> <script type="text/javascript"> $(document).ready(function(){ $("#btnSaveRules").mousedown(function(){ buildPost({ 'processPage':'<?php echo Url::detailsProcess($project->getID()); ?> ', 'info': { 'action':'rules', 'rules':$("#txtRules").val()
?> function initializeUploader() { var uploadButtonID = 'btnUploadPicture'; // // clear file list // $('#filelist').html(''); var uploader = new plupload.Uploader({ runtimes : 'flash,html5,gears,silverlight,browserplus', browse_button : uploadButtonID, max_file_size : '500kb', chunk_size : '100kb', url : '<?php echo Url::userPictureProcess(Session::getUserID()); ?> ', unique_names : true, //resize : {width : 320, height : 240, quality : 90}, flash_swf_url : '<?php echo Url::base(); ?> /lib/plupload/js/plupload.flash.swf', silverlight_xap_url : '<?php echo Url::base(); ?> /lib/plupload/js/plupload.silverlight.xap', filters : [ {title : "Allowed files", extensions : "jpg,jpeg,gif,png"} ]
public function markAllRead() { $dateRead = date("Y-m-d H:i:s"); // get it once for consistency // mark replies as read $replies = $this->getReplies(); if (!empty($replies)) { foreach ($replies as $reply) { if ($reply->getDateRead() == null && $reply->getRecipientID() == Session::getUserID()) { $reply->setDateRead($dateRead); $reply->save(); } } } }
function chatHeartbeat($slug, $pageId) { //Add check for open chat boxes in order to keep track of multiple windows if (empty($_SESSION['openChatBoxes']["{$pageId}"])) { $_SESSION['openChatBoxes']["{$pageId}"] = 0; $lastRecord = 0; } else { $lastRecord = $_SESSION['openChatBoxes']["{$pageId}"]; } //**JAG check that SLUG is not null $project = Project::getProjectFromSlug($slug); $projectName = $project->getTitle(); //This line is used to track whether we are switching between projects and need to close down chat rooms $_SESSION['lastProjectID'] = $project->getID(); //signed in user $userId = Session::getUserID(); $chatBoxes = array(); $chats = Chat::getChats($slug, $lastRecord); $numRows = count($chats); $rowIndex = 0; $items = ''; if (is_array($chats)) { foreach ($chats as $row => $chat) { $rowIndex++; if (!isset($_SESSION['openChatBoxes'][$chat['recipient']]) && isset($_SESSION['chatHistory'][$chat['recipient']])) { $items = $_SESSION['chatHistory'][$chat['recipient']]; } //Grab username if available (should always be available) $chatFrom = User::load($chat['sender'])->getUsername(); $chat['message'] = sanitize($chat['message']); $message = str_replace('"', '\\"', formatParagraphs($chat['message'], true)); //Since chatHeartbeat always returns records greater than the stored last id, the only time that // the returned id of a search will match the stored last id will be on the first post in an empty // chat room if ($chat['id'] !== $lastRecord) { $items .= <<<EOD \t\t\t\t\t { \t\t\t"s": "0", \t\t\t"f": "{$chatFrom}", \t\t\t"m": "{$message}", "r": "{$chat['id']}", "t": "{$projectName}" \t }, EOD; } if (!isset($_SESSION['chatHistory'][$chat['recipient']])) { $_SESSION['chatHistory'][$chat['recipient']] = ''; } $_SESSION['chatHistory'][$chat['recipient']] .= <<<EOD \t\t\t\t\t\t { \t\t\t"s": "0", \t\t\t"f": "{$chatFrom}", \t\t\t"m": "{$message}", "r": "{$chat['id']}", "t": "{$projectName}" \t }, EOD; $_SESSION['openChatBoxes'][$chat['recipient']] = $chat['sent']; unset($_SESSION['tsChatBoxes'][$chat['recipient']]); if ($numRows == $rowIndex && $numRows > 0) { $_SESSION['openChatBoxes']["{$pageId}"] = $chat['id']; } } } //Update user record with heart beat (used to tell logged in members) Chat::updateUserLocation($userId, $project->getID()); if ($items != '') { $items = substr($items, 0, -1); } header('Content-type: application/json'); ?> { "items": [ <?php echo $items; ?> ] } <?php exit(0); }
<?php require_once "../../global.php"; $soup = new Soup(); if (Session::isLoggedIn()) { // dashboard $yourProjects = ProjectUser::getProjectsByUserID(Session::getUserID()); $publicProjects = Project::getPublicProjects(Session::getUserID(), 10); // projects to join //$user = User::load(Session::getUserID()); $events = Event::getDashboardEvents(Session::getUserID(), 10); // $updates = Update::getByUserID($user->getID()); // $discussions = Discussion::getByUserID($user->getID()); $invitations = Invitation::getByUserID(Session::getUserID()); $unrespondedInvites = Invitation::getByUserID(Session::getUserID(), null, false); $yourTasks = Task::getYourTasks(Session::getUserID()); $soup->set('yourProjects', $yourProjects); $soup->set('publicProjects', $publicProjects); //$soup->set('user', $user); $soup->set('events', $events); // $soup->set('updates', $updates); // $soup->set('discussions', $discussions); $soup->set('invitations', $invitations); $soup->set('unrespondedInvites', $unrespondedInvites); $soup->set('tasks', $yourTasks); $soup->render('site/page/dashboard'); } else { // home page $events = Event::getHomeEvents(10); $soup->set('events', $events); $soup->render('site/page/home');
public static function getUserEvents($userID = null, $limit = null) { if ($userID == null) { return null; } $loggedInUserID = Session::getUserID(); $query = "SELECT e.id AS id FROM " . self::DB_TABLE . " e"; $query .= " INNER JOIN " . EventType::DB_TABLE . " et ON "; $query .= " e.event_type_id = et.id"; $query .= " LEFT OUTER JOIN " . Project::DB_TABLE . " p ON "; $query .= " e.project_id = p.id"; $query .= " WHERE e.user_1_id = " . $userID; if (empty($loggedInUserID)) { $query .= " AND et.hidden = 0"; // ignore hidden events $query .= " AND ( (p.private = 0) OR"; $query .= " (e.project_id IS NULL) )"; } elseif (!Session::isAdmin()) { // let fellow members see private project events $query .= " AND et.hidden = 0"; // ignore hidden events $query .= " AND (p.private = 0"; $query .= " OR p.id IN ("; $query .= " SELECT project_id FROM " . ProjectUser::DB_TABLE; $query .= " WHERE user_id = " . $loggedInUserID; $query .= " AND relationship != " . ProjectUser::BANNED; $query .= " ) OR (e.project_id IS NULL) )"; } $query .= " ORDER BY e.date_created DESC"; if ($limit != null) { $query .= " LIMIT " . $limit; } //echo $query; $db = Db::instance(); $result = $db->lookup($query); if (!mysql_num_rows($result)) { return array(); } $events = array(); while ($row = mysql_fetch_assoc($result)) { $events[$row['id']] = self::load($row['id']); } return $events; }
<?php require_once "../../global.php"; $slug = Filter::text($_GET['slug']); $project = Project::getProjectFromSlug($slug); // kick us out if slug invalid or not organizer/creator if ($project == null) { header('Location: ' . Url::error()); exit; } elseif (!Session::isAdmin() && !$project->isTrusted(Session::getUserID()) && !$project->isCreator(Session::getUserID())) { header('Location: ' . Url::error()); exit; } //do not allow banned members to access project $isBanned = ProjectUser::isBanned(Session::getUserID(), $project->getID()); if ($isBanned) { header('Location: ' . Url::error()); exit; } $yourTasks = Task::getYourTasks(Session::getUserID(), $project->getID()); $soup = new Soup(); $soup->set('project', $project); $soup->set('yourTasks', $yourTasks); $soup->render('project/page/taskNew');
public static function profile() { $userID = Session::getUserID(); return self::user($userID); }
<?php require_once "../../global.php"; $slug = Filter::text($_GET['slug']); $filter = Filter::text($_GET['filter']); $project = Project::getProjectFromSlug($slug); // kick us out if slug invalid if ($project == null) { header('Location: ' . Url::error()); exit; } // if private project, limit access to invited users, members, and admins // and exclude banned members if ($project->getPrivate()) { if (!Session::isAdmin() && !$project->isCreator(Session::getUserID())) { if (!$project->isInvited(Session::getUserID()) && !$project->isMember(Session::getUserID()) && !$project->isTrusted(Session::getUserID()) || ProjectUser::isBanned(Session::getUserID(), $project->getID())) { header('Location: ' . Url::error()); exit; } } } $projectID = $project->getID(); // page number, if any if (empty($_GET['page'])) { $page = 1; } else { $page = Filter::numeric($_GET['page']); } define('EVENTS_PER_PAGE', 10); // how many events per page switch ($filter) {
if (!Session::isAdmin() && !$project->isCreator(Session::getUserID())) { if (!$project->isInvited(Session::getUserID()) && !$project->isMember(Session::getUserID()) && !$project->isTrusted(Session::getUserID()) || ProjectUser::isBanned(Session::getUserID(), $project->getID())) { header('Location: ' . Url::error()); exit; } } } // // validate username // $username = Filter::text($_GET['u']); // $user = User::loadByUsername($username); // // check if user has accepted task //$accepted = Accepted::getByUserID(Session::getUserID(), $taskID); // if($accepted == null) { // header('Location: '.Url::error()); // exit(); // } //$updates = Update::getByAcceptedID($accepted->getID()); // get existing updates $accepted = Accepted::getByUserID(Session::getUserID(), $taskID); if ($accepted == null) { header('Location: ' . Url::error()); exit; } $updates = Update::getByAcceptedID($accepted->getID()); $soup = new Soup(); $soup->set('project', $project); $soup->set('task', $task); $soup->set('updates', $updates); //$soup->set('user', $user); //$soup->set('accepted', $accepted); $soup->render('project/page/updateNew');
<?php // never empty because there is always a creator foreach ($allMembers as $m) { echo '<li>'; if ($project->isTrusted($m->getID())) { // trusted member if ($hasEditPermission && $m->getID() != Session::getUserID()) { echo '<input id="ban-' . $m->getID() . '" type="button" class="ban" value="Ban" /> <input id="untrust-' . $m->getID() . '" type="button" class="untrust" value="Untrust" />'; } echo formatUserPicture($m->getID(), 'small'); echo '<h6 class="primary">' . formatUserLink($m->getID(), $project->getID()) . '</h6>'; echo '<p class="secondary">trusted member</p>'; } else { // member if ($hasEditPermission && $m->getID() != Session::getUserID()) { echo '<input id="ban-' . $m->getID() . '" type="button" class="ban" value="Ban" /> <input id="trust-' . $m->getID() . '" type="button" class="trust" value="Trust" />'; } echo formatUserPicture($m->getID(), 'small'); echo '<h6 class="primary">' . formatUserLink($m->getID(), $project->getID()) . '</h6>'; echo '<p class="secondary">member</p>'; } echo '</li>'; } // member invites if ($hasInvitePermission && !empty($memberInvites)) { foreach ($memberInvites as $mi) { // don't list accepted invites if ($mi->getResponse() == Invitation::ACCEPTED) { continue; }
$email = array('to' => $u->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] Invitation to join the project ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } } foreach ($emails as $e) { // generate code // $code = sha1(microtime(true).mt_rand(10000,90000)); // send invitation $invite = new Invitation(array('inviter_id' => Session::getUserID(), 'invitee_email' => $e, 'project_id' => $project->getID(), 'trusted' => $trusted, 'invitation_message' => $message)); $invite->save(); // log event $logEvent = new Event(array('event_type_id' => 'invite_member_email', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $invite->getID(), 'data_1' => $e, 'data_2' => $message, 'data_3' => $trusted)); $logEvent->save(); // compose email $body = "<p>" . formatUserLink(Session::getUserID()) . ' invited you to join the project ' . formatProjectLink($project->getID()) . '.</p>'; if (!empty($message)) { $body .= '<blockquote>' . formatInvitationMessage($message) . '</blockquote>'; } if ($trusted) { $body .= '<p>If you accept this invitation, you will become a <a href="' . Url::help() . '">trusted member</a> of this project.</p>'; } $body .= '<p>To respond to this invitation, <a href="' . Url::consent($e) . '">register</a> a free account on ' . PIPELINE_NAME . ' using this email address (' . $e . ').</p>'; $email = array('to' => $e, 'subject' => '[' . PIPELINE_NAME . '] Invitation to join the project ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } // send us back $numInvitations = count($users) + count($emails); Session::setMessage(formatCount($numInvitations, 'invitation', 'invitations') . ' sent.'); $json = array('success' => '1');
<?php require_once './../../global.php'; $relationship = Filter::text($_GET['relationship']); $term = Filter::text($_GET['term']); if ($relationship == 'not-me') { $usernames = User::getAllUsernames($term, Session::getUserID()); } echo json_encode($usernames);
//Format Leader, if empty or an invalid name is given, don't enter in anyone if (!empty($line[4])) { $leaderId = User::loadByUsername(Filter::alphanum($line[4])); //***need to change with Chloe's updated user filter*** if (empty($leaderId)) { $leaderId = Session::getUserID(); } } else { //$leaderId = NULL; $leaderId = Session::getUserID(); } } //Create Task Record $title = Filter::text($line[0]); $description = Filter::text(iconv(mb_detect_encoding($line[1], mb_detect_order(), true), "UTF-8", $line[1])); $task = new Task(array('creator_id' => Session::getUserID(), 'leader_id' => $leaderId, 'project_id' => $projectId, 'title' => $title, 'description' => $description, 'status' => 1, 'deadline' => $deadline, 'num_needed' => $numberOfPeople)); array_push($taskArray, $task); //Increment row in file $row++; } fclose($handle); } //Save each task to the database if no errors are found if ($errorFound == 1) { $errorString = "<strong><span class='bad'>Your CSV file was not uploaded.</span></strong><br/>" . $errorString; $json = array("error" => $errorString); exit(json_encode($json)); } else { foreach ($taskArray as $task) { $task->save(); }
<?php include_once TEMPLATE_PATH . '/site/helper/format.php'; $project = $SOUP->get('project'); $comments = $SOUP->get('comments', array()); $processURL = $SOUP->get('processURL'); $parentID = $SOUP->get('parentID'); $task = $SOUP->get('task'); if ($task->getStatus()) { $openTask = true; } else { $openTask = false; } // any logged-in user may comment $hasPermission = Session::isLoggedIn() && !$project->isBanned(Session::getUserID()); //$fork = $SOUP->fork(); //$fork->set('title', 'Comments'); //$fork->startBlockSet('body'); ?> <?php if ($hasPermission) { ?> <script type="text/javascript"> $(document).ready(function(){ <?php if ($openTask) { ?> //$('#txtComment').focus(); $('#btnComment').click(function(){
$body .= "<blockquote>" . formatComment($message) . "</blockquote>"; $email = array('to' => $leader->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New comment reply on a task you are leading in ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } } // to task crew $crew = Accepted::getByTaskID($taskID); if ($crew != null) { foreach ($crew as $c) { $user = User::load($c->getCreatorID()); if ($user->getID() != Session::getUserID()) { // don't email yourself if ($user->getNotifyCommentTaskAccepted()) { // compose email $body = "<p>" . formatUserLink(Session::getUserID()) . ' replied to a comment on the task <a href="' . Url::task($taskID) . '">' . $task->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>'; $body .= "<blockquote>" . formatComment($message) . "</blockquote>"; $email = array('to' => $user->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New comment reply on a task you joined in ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } } } } // send us back Session::setMessage('You replied to a comment on this task.'); $json = array('success' => '1'); echo json_encode($json); } } else { $json = array('error' => 'Invalid action.');
$json = array('error' => 'Your reply cannot be empty.'); exit(json_encode($json)); } else { // post the comment $reply = new Comment(array('creator_id' => Session::getUserID(), 'project_id' => $project->getID(), 'update_id' => $updateID, 'parent_id' => $commentID, 'message' => $message)); $reply->save(); // log it $logEvent = new Event(array('event_type_id' => 'create_update_comment_reply', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $commentID, 'item_2_id' => $reply->getID(), 'item_3_id' => $updateID, 'data_1' => $message)); $logEvent->save(); // send email notification, if desired $creator = User::load($update->getCreatorID()); if ($creator->getID() != Session::getUserID()) { // don't email yourself if ($creator->getNotifyCommentTaskUpdate()) { // compose email $msg = "<p>" . formatUserLink(Session::getUserID()) . ' replied to a comment on your task update <a href="' . Url::update($updateID) . '">' . $update->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>'; $msg .= "<blockquote>" . formatUpdate($message) . "</blockquote>"; $email = array('to' => $creator->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New comment reply on your task update in ' . $project->getTitle(), 'message' => $msg); // send email Email::send($email); } } // send us back Session::setMessage('You replied to a comment on this update.'); $json = array('success' => '1'); echo json_encode($json); } } else { $json = array('error' => 'Action not recognized.'); exit(json_encode($json)); }
// must be valid deadline or empty $formattedDeadline = strtotime($deadline); if ($formattedDeadline === false && $deadline != '') { $json = array('error' => 'Deadline must be a valid date or empty.'); exit(json_encode($json)); } // format deadline for MYSQL $formattedDeadline = $formattedDeadline != '' ? date("Y-m-d H:i:s", $formattedDeadline) : null; // format private $private = empty($private) ? 0 : 1; // create the project $project = new Project(array('creator_id' => Session::getUserID(), 'title' => $title, 'slug' => '', 'pitch' => $pitch, 'specs' => $specs, 'rules' => $rules, 'status' => Project::STATUS_PRE_PRODUCTION, 'deadline' => $formattedDeadline, 'private' => $private)); $project->save(); // generate slug from project title/ID $slug = toAscii($title); $slug = $project->getID() . '-' . $slug; // save new slug $project->setSlug($slug); $project->save(); // add creator as ProjectUser $pu = new ProjectUser(array('project_id' => $project->getID(), 'user_id' => Session::getUserID(), 'relationship' => ProjectUser::CREATOR)); $pu->save(); // log it $logEvent = new Event(array('event_type_id' => 'create_project', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID())); $logEvent->save(); // send us back //$successURL = Url::project($project->getID()); $successURL = Url::peopleInvite($project->getID()); Session::setMessage('Project created! Now you need some members.'); $json = array('success' => '1', 'successUrl' => $successURL); echo json_encode($json);
<?php require_once "../../global.php"; if (!Session::isLoggedIn()) { header('Location: ' . Url::error()); exit; } $messages = Message::getReceivedMessagesByUserID(Session::getUserID()); $soup = new Soup(); $soup->set('messages', $messages); $soup->render('site/page/inbox');
$updates = $SOUP->get('updates', array()); $update = $SOUP->get('update', null); $title = $SOUP->get('title', 'Updates'); //$creatable = $SOUP->get('creatable', true); $id = $SOUP->get('id', 'updates'); $accepted = $SOUP->get('accepted'); //print_r( $accepted ); $size = $SOUP->get('size', 'large'); $task = $SOUP->get('task'); //$taskUpdates = $SOUP->get('taskUpdates', false); //$updateID = ($update != null) ? $update->getID() : null; $hasPermission = $SOUP->get('hasPermission', null); // allow value to be passed in if ($hasPermission === null) { $hasPermission = false; if ($accepted->getCreatorID() == Session::getUserID()) { // only works if we're looking at this user's updates $hasPermission = true; } } $fork = $SOUP->fork(); $fork->set('title', $title); $fork->set('creatable', $hasPermission); $fork->set('createLabel', 'Contribute'); // if($size == 'small') { // $fork->set('createLabel', 'New'); // } else { // $fork->set('createLabel', 'New Update'); // } $fork->startBlockSet('body'); ?>