/**
  * status changing methods
  */
 public function accept()
 {
     $this->accept_date = new DateTime();
     // create new project membership
     //
     $invitee = User::getByEmail($this->email);
     $projectMembership = new ProjectMembership(array('membership_uid' => GUID::create(), 'project_uid' => $this->project_uid, 'user_uid' => $invitee->user_uid, 'admin_flag' => false));
     $projectMembership->save();
 }
 public function postCreate()
 {
     $user = User::getByUsername(Input::get('username'));
     $user = $user ? $user : User::getByEmail(Input::get('email'));
     if (!$user) {
         return Response::json(array('success' => true));
     }
     $passwordResetNonce = $nonce = GUID::create();
     $passwordReset = new PasswordReset(array('password_reset_key' => Hash::make($passwordResetNonce), 'user_uid' => $user->user_uid));
     $passwordReset->save();
     $passwordReset->send($nonce);
     return Response::json(array('success' => true));
 }
 public function sendEmail()
 {
     if (!Input::has('subject')) {
         return Response::make('Missing subject field.', 500);
     } elseif (!Input::has('body')) {
         return Response::make('Missing body field.', 500);
     } elseif (!Input::has('recipients')) {
         return Response::make('Missing recipients field.', 500);
     }
     $this->subject = Input::get('subject');
     $body = Input::get('body');
     if ($this->subject == '' || $body == '') {
         return Response::make('The email subject and body fields must not be empty.', 500);
     }
     $recipients = Input::get('recipients');
     if (sizeof($recipients) < 1) {
         return Response::make('The email must have at least one recipient.', 500);
     }
     $failures = new Collection();
     foreach ($recipients as $email) {
         $user = User::getByEmail($email);
         if (!$user) {
             return Response::make("Could not load user: {$email}", 500);
         }
         $data = array('user' => $user, 'body' => $body);
         $this->secure = false;
         if (strpos($body, 'END PGP SIGNATURE') != FALSE || strpos($body, 'END GPG SIGNATURE') != FALSE) {
             $this->secure = true;
         }
         if ($user && filter_var($user->email, FILTER_VALIDATE_EMAIL) && trim($user->email) != '' && trim($user->getFullName()) != '') {
             Mail::send(array('text' => 'emails.admin'), $data, function ($message) use($user) {
                 $message->to($user->email, $user->getFullName());
                 $message->subject($this->subject);
                 if ($this->secure) {
                     $message->from('*****@*****.**');
                 }
             });
         } else {
             $failures->push(array('user' => $user->toArray(), 'email' => $email));
         }
     }
     return $failures;
 }
 public function requestUsername()
 {
     // get parameters
     //
     $email = Input::get('email');
     // query database
     //
     $this->user = User::getByEmail($email);
     // send email notification
     //
     if ($this->user != null) {
         Mail::send('emails.request-username', array('user' => $this->user), function ($message) {
             $message->to($this->user->email, $this->user->getFullName());
             $message->subject('SWAMP Username Request');
         });
     }
     // return response
     //
     return Response::json(array('success' => true));
 }
 public function getInvitee($invitationKey)
 {
     $projectInvitation = ProjectInvitation::where('invitation_key', '=', $invitationKey)->get()->first();
     $invitee = User::getByEmail($projectInvitation->email);
     return $invitee;
 }