// send email Email::send($email); } } } } Session::setMessage('You edited this task.'); $json = array('success' => '1', 'successUrl' => Url::task($task->getID())); echo json_encode($json); } else { $json = array('error' => 'No changes were detected.'); exit(json_encode($json)); } } elseif ($action == 'accept') { // join user to project, if they're not already $pu = ProjectUser::find(Session::getUserID(), $project->getID()); if (empty($pu)) { // not a project member yet, so make them one $pu = new ProjectUser(array('project_id' => $project->getID(), 'user_id' => Session::getUserID(), 'relationship' => ProjectUser::MEMBER)); $pu->save(); // log it $logEvent = new Event(array('event_type_id' => 'join_project', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID())); $logEvent->save(); } elseif ($project->isFollower(Session::getUserID())) { // convert follower to member $pu->setRelationship(ProjectUser::MEMBER); $pu->save(); // log it $logEvent = new Event(array('event_type_id' => 'join_project', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID())); $logEvent->save(); }
$body = "<p>" . formatUserLink(Session::getUserID()) . ' trusted you in the project ' . formatProjectLink($project->getID()) . '.</p>'; $email = array('to' => $u->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] Trusted in the project ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } // send us back $user = User::load($userID); Session::setMessage($user->getUsername() . ' is now trusted.'); $json = array('success' => '1'); echo json_encode($json); // --- UNTRUST MEMBER --- // } elseif ($action == 'untrust') { // get user $userID = Filter::numeric($_POST['userID']); // get project user $pu = ProjectUser::find($userID, $project->getID()); // untrust the user $pu->setRelationship(ProjectUser::MEMBER); $pu->save(); // log it $logEvent = new Event(array('event_type_id' => 'untrust_member', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'user_2_id' => $userID)); $logEvent->save(); // send notification email, if enabled $u = User::load($userID); if ($u->getNotifyTrustProject()) { // compose email $body = "<p>" . formatUserLink(Session::getUserID()) . ' untrusted you in the project ' . formatProjectLink($project->getID()) . '.</p>'; $email = array('to' => $u->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] Untrusted in the project ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); }