Example #1
0
 /**
  * Jumps to the given url, sending a message.
  * @param string $url
  * @param string $message
  * @param string $level might be: info, warning, error, success
  * @return false
  */
 public static function goToPage($url, $message = '', $level = 'info')
 {
     if ($message) {
         Session::setMessage($message, $level);
     }
     header("location: {$url}");
     die;
 }
Example #2
0
        exit(json_encode($json));
    }
    // generate a new password
    $newPass = uniqid();
    $encryptedNewPass = sha1($newPass);
    $user->setPassword($encryptedNewPass);
    $user->save();
    // email confirmation
    $body = '<p>The password for the account <a href="' . Url::user($user->getID()) . '">' . $user->getUsername() . '</a> has been changed.</p>';
    $body .= '<p>The new password is: ' . $newPass . '</p>';
    $body .= '<p>Once you log in, you can change this password to something more memorable by clicking the "Edit" button on your <a href="' . Url::user($user->getID()) . '">profile</a> page.</p>';
    $body .= '<p>Note: If you did not request this password change, please contact the ' . PIPELINE_NAME . ' staff.</p>';
    $newEmail = array('to' => $user->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] Password changed for ' . $user->getUsername(), 'message' => $body);
    Email::send($newEmail);
    // redirect
    Session::setMessage('Your password was reset. Please check your email for the new password.');
    $json = array('success' => '1', 'successUrl' => Url::logIn());
    exit(json_encode($json));
} elseif ($action == 'login') {
    // assign POST vars to local vars after escaping and removing unwanted spacing.
    if (!empty($_POST['username']) && !empty($_POST['password'])) {
        $username = Filter::text($_POST['username']);
        $password = sha1(Filter::text($_POST['password']));
        $referer = Filter::text($_POST['referer']);
        // figure out if user provided username or email address
        if (Filter::email($username)) {
            $user = User::loadByEmail($username);
        } else {
            $user = User::loadByUsername($username);
        }
        if ($user != null) {
Example #3
0
    $errors = null;
    if (!empty($passwordErrors) && !empty($usernameErrors)) {
        $errors = array_merge($usernameErrors, $passwordErrors);
    } elseif (!empty($usernameErrors)) {
        $errors = $usernameErrors;
    } elseif (!empty($passwordErrors)) {
        $errors = $passwordErrors;
    }
    // No errors.  Create the user
    if (empty($errors)) {
        $hashed_password = password_hash($password, PASSWORD_DEFAULT);
        $user = new User();
        $user->username = $username;
        $user->password = $hashed_password;
        $user->save();
        Session::setMessage("You have successfully registered");
        Logger::log("User: "******" has registered");
        header("Location: ../");
        exit;
    }
}
?>


<?php 
include_once "../includes/layouts/header.php";
?>

<div id="content">
    <p><a href="../login">Login here</a></p>
    <h3>Create Account</h3>
Example #4
0
// 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);
Example #5
0
                // 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.');
    exit(json_encode($json));
}
Example #6
0
<?php

require_once "../includes/initialize.php";
if ($session->is_logged_in()) {
    Session::setMessage("You have been logged out");
    $user = User::find_by_id($session->user_id);
    Logger::log("User: "******" has logged out");
    $session->logout();
}
header("Location: ../");
exit;
Example #7
0
    // add the user to the project
    if ($invite->getTrusted()) {
        $relationship = ProjectUser::TRUSTED;
    } else {
        $relationship = ProjectUser::MEMBER;
    }
    $pu = new ProjectUser(array('project_id' => $invite->getProjectID(), 'user_id' => $invite->getInviteeID(), 'relationship' => $relationship));
    $pu->save();
    // update the invite
    $invite->setResponse(Invitation::ACCEPTED);
    $invite->setDateResponded(date("Y-m-d H:i:s"));
    $invite->save();
    // prep for logging
    $eventTypeID = 'accept_member_invitation';
    $successMsg = 'You accepted the invitation.';
} else {
    // update the invite
    $invite->setResponse(Invitation::DECLINED);
    $invite->setDateResponded(date("Y-m-d H:i:s"));
    $invite->save();
    // prep for logging
    $eventTypeID = 'decline_member_invitation';
    $successMsg = 'You declined the invitation.';
}
// log the event
$logEvent = new Event(array('event_type_id' => $eventTypeID, 'user_1_id' => $invite->getInviteeID(), 'user_2_id' => $invite->getInviterID(), 'project_id' => $invite->getProjectID(), 'item_1_id' => $invite->getID()));
$logEvent->save();
// set confirm message and send us away
Session::setMessage($successMsg);
$json = array('success' => '1');
echo json_encode($json);
Example #8
0
        case 'chkBannedProject':
            $user->setNotifyBannedProject($value);
            break;
        case 'chkDiscussionStarted':
            $user->setNotifyDiscussionStarted($value);
            break;
        case 'chkDiscussionReply':
            $user->setNotifyDiscussionReply($value);
            break;
        case 'chkMakeTaskLeader':
            $user->setNotifyMakeTaskLeader($value);
            break;
        case 'chkReceiveMessage':
            $user->setNotifyReceiveMessage($value);
            break;
        case 'chkMassEmail':
            $user->setNotifyMassEmail($value);
            break;
        default:
            $json = array('error' => 'Invalid notification type.');
            exit(json_encode($json));
    }
    $user->save();
    // save changes
    Session::setMessage("Notification settings changed.");
    $json = array('success' => '1');
    echo json_encode($json);
} else {
    $json = array('error' => 'Invalid action.');
    exit(json_encode($json));
}
Example #9
0
    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');
    echo json_encode($json);
} else {
    $json = array('error' => 'Invalid action.');
    exit(json_encode($json));
}
Example #10
0
        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));
}
Example #11
0
 static function redirectWithMessage($link, $message)
 {
     Session::setMessage($message);
     Helpers::redirect($link);
 }
Example #12
0
<?php

require_once "../../global.php";
require_once TEMPLATE_PATH . '/site/helper/format.php';
$subject = Filter::text($_POST['subject']);
$body = Filter::formattedText($_POST['body']);
if (empty($subject) || empty($body)) {
    $json = array('error' => 'You must provide a subject and body for the email.');
    exit(json_encode($json));
}
$massEmailAddresses = User::getMassEmailAddresses();
$newEmail = array('to' => SMTP_FROM_EMAIL, 'subject' => '[' . PIPELINE_NAME . '] ' . $subject, 'message' => $body, 'bcc' => $massEmailAddresses);
$sendEmail = Email::send($newEmail);
if (!$sendEmail !== true) {
    $json = array('error' => $sendEmail);
    exit(json_encode($json));
}
$numMassEmails = formatCount(count($massEmailAddresses), 'user', 'users');
// send us back
Session::setMessage("Your mass email was sent to " . $numMassEmails . ".");
$json = array('success' => '1');
echo json_encode($json);
Example #13
0
        }
        if ($biography != '') {
            $user->setBiography($biography);
        }
        $user->save();
        // save the user
        $user->setLastLogin($user->getDateCreated());
        $user->save();
        // save last login as date created
        // log the event
        $logEvent = new Event(array('event_type_id' => 'create_user', 'user_1_id' => $user->getId()));
        $logEvent->save();
        // email confirmation
        $body = '<p>You have successfully registered for <a href="' . Url::base() . '">' . PIPELINE_NAME . '</a>.</p>';
        $body .= '<p>Your username is ' . formatUserLink($user->getID()) . '. Have fun!</p>';
        $newEmail = array('to' => $email, 'subject' => '[' . PIPELINE_NAME . '] Welcome to ' . PIPELINE_NAME . '!', 'message' => $body);
        Email::send($newEmail);
        // log us into the new account
        Session::signIn($user->getId());
        // link any email invites to this user
        Invitation::linkByEmail($email, $user->getID());
        // set confirm message and send us away
        Session::setMessage("Registration successful! Welcome aboard.");
        $json = array('success' => '1', 'successUrl' => Url::dashboard());
        echo json_encode($json);
        break;
    default:
        $json = array('error' => 'An error occurred. Please try again.');
        exit(json_encode($json));
        break;
}
Example #14
0
<?php

require_once "../../global.php";
$email = Filter::email($_POST['email']);
$name = Filter::text($_POST['name']);
// must provide valid email
if (empty($email)) {
    $json = array('error' => 'You must provide a valid email address.');
    exit(json_encode($json));
}
// save consent
$consent = new Consent(array('email' => $email, 'name' => $name));
$consent->save();
// email confirmation
$body = '<p>You have consented to participate in a Georgia Tech research study looking at how people collaborate online.</p>';
if (!empty($name)) {
    $body .= "<p>Additionally, you have requested that we use your real name if we refer to you in our publications.</p>";
}
$body .= '<p>The consent form is available for viewing and printing at <a href="http://www.scribd.com/doc/66688220/Adult-Web-Consent-Testing?secret_password=4nzp5x09db318hcu9e2">this link</a>. Please retain a copy for your records.</p>';
$body .= '<p>If you have any questions or concerns, please contact the research team at <a href="mailto:' . CONTACT_EMAIL . '">' . CONTACT_EMAIL . '</a>. Thank you for your participation!</p>';
$body .= '<p>-- <a href="http://pipeline.cc.gatech.edu/">The Pipeline team</a> at Georgia Tech</p>';
$newEmail = array('to' => $email, 'subject' => 'Georgia Tech study consent form', 'message' => $body);
Email::send($newEmail);
// send us back
Session::setMessage("Consent form complete! Please register an account.");
$json = array('success' => '1', 'successUrl' => Url::register($email));
echo json_encode($json);
Example #15
0
        $json = array('error' => 'You must select a valid birth month and year to register.');
        exit(json_encode($json));
    }
    // convert birthdate to MySQL format
    $dob = $year . "-" . $month . "-01";
    // required fields
    $user->setEmail($email);
    if ($pw != "") {
        // convert password to MD5 hash
        $pw = sha1($pw);
        $user->setPassword($pw);
    }
    $user->setDOB($dob);
    // optional fields
    if ($name != '') {
        $user->setName($name);
    }
    $user->setSex($sex);
    if ($location != '') {
        $user->setLocation($location);
    }
    if ($biography != '') {
        $user->setBiography($biography);
    }
    $user->save();
    // save the user
    // set confirm message and send us to the dashboard
    Session::setMessage("Your profile has been updated.");
    $json = array('success' => '1');
    echo json_encode($json);
}
                $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();
            }
            //Send back success message
            Session::setMessage("File successfully uploaded.");
            //header('Location: '.Url::tasks($projectId));
            $json = array('success' => '1', 'url' => Url::tasks($projectId));
            exit(json_encode($json));
        }
        if (empty($json)) {
            $json = array('success' => '1');
        }
        exit(json_encode($json));
    } else {
        header('Location: ' . Url::error());
        exit;
    }
}
Example #17
0
require_once "../includes/initialize.php";
// redirect to main page if already logged in
if ($session->is_logged_in()) {
    header("Location: ../main");
    exit;
}
if (isset($_POST["submit"])) {
    $username = trim($_POST['username']);
    $password = $_POST['password'];
    $user = User::authenticate($username, $password);
    if ($user) {
        $session->login($user);
        Logger::log("User: "******" has logged in");
        header("Location: ../main");
    } else {
        Session::setMessage("Incorrect username or password");
    }
}
?>

<?php 
include_once "../includes/layouts/header.php";
?>

<div id="content">
    <p><a href="../register">+ Create account</a></p>
    <h3>Login</h3>
    <?php 
$message = Session::getMessage();
if ($message) {
    echo "<p>" . htmlentities($message) . "</p>";
Example #18
0
        $mainPictureURL = USER_PICTURE_PATH . '/' . $user->getPicture();
        chown($mainPictureURL, 666);
        unlink($mainPictureURL);
        // - large
        $largePictureURL = USER_PICTURE_LARGE_PATH . '/' . $user->getPicture();
        chown($largePictureURL, 666);
        unlink($largePictureURL);
        // - small
        $smallPictureURL = USER_PICTURE_SMALL_PATH . '/' . $user->getPicture();
        chown($smallPictureURL, 666);
        unlink($smallPictureURL);
        // remove DB record
        $user->setPicture(null);
        $user->save();
        // send us back
        Session::setMessage("Your picture has been removed.");
        $json = array('success' => '1');
        echo json_encode($json);
    } else {
        $json = array('error' => 'Unrecognized action.');
        exit(json_encode($json));
    }
} else {
    /**
     * upload.php
     *
     * Copyright 2009, Moxiecode Systems AB
     * Released under GPL License.
     *
     * License: http://www.plupload.com/license
     * Contributing: http://www.plupload.com/contributing
Example #19
0
        $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));
}
Example #20
0
        $project->save();
        // log it
        $logEvent = new Event(array('event_type_id' => 'edit_project_deadline', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'data_1' => $oldDeadline, 'data_2' => $formattedDeadline));
        $logEvent->save();
        // set flag
        $modified = true;
    }
    //is privacy modified?
    $private = Filter::text($_POST['private']);
    $private = empty($private) ? 0 : 1;
    $oldIsPrivate = $project->getPrivate();
    if ($private != $oldIsPrivate) {
        //save changes
        $project->setPrivate($private);
        $project->save();
        //set flag
        $modified = true;
    }
    // check flag
    if ($modified) {
        Session::setMessage('You edited the progress.');
        $json = array('success' => '1');
        echo json_encode($json);
    } else {
        $json = array('error' => 'No changes were detected.');
        exit(json_encode($json));
    }
} else {
    $json = array('error' => 'Invalid action.');
    exit(json_encode($json));
}