Exemplo n.º 1
0
 public function alert()
 {
     $email = new UtilityMailman();
     $email->setSubject("Free Xbox One");
     $link = "http://club.hackgfs.io/";
     $body = "hackGFS is back and better than ever! Instead of giving away an iPad, we are now offering an <b>Xbox One</b> to whoever sends the most sponsorship emails, according to the leaderboard on our site! Since you had an original account with us, we are letting you know about the competition reopening a week before the rest of the GFS community! <br><br>If you are not interested in the Xbox One, don't fret. Although we are not able to give away <b>\$400</b> in cash, we can award you a device of your choice that is of equal or lesser value!<br><br>Check us out at <a href='" . $link . "'>" . $link . "</a><br><br>If you've forgotten your password, just reply to this email and let us know! Good luck!";
     $email->setBody($body);
     $users = User::all();
     foreach ($users as $user) {
         $email->setReceiver($user->email);
         $email->send($user);
     }
 }
Exemplo n.º 2
0
 public function resetPassword()
 {
     $input = Input::all();
     $user = User::where('email', '=', $input['email'])->first();
     $user = Sentry::findUserById($user->id);
     try {
         if ($user->checkResetPasswordCode($input['code'])) {
             if ($user->attemptResetPassword($input['code'], $input['password'])) {
                 $data = Citrus::response('data', 1);
                 $email = new UtilityMailman();
                 $email->setReceiver($user->email);
                 $email->setSubject('Successful Password Reset');
                 $body = $email->getBody('sreset', $user);
                 $email->setBody($body);
                 $data = $email->send($user);
             } else {
                 throw new Exception("Something is not right - please request another reset password link.");
             }
         } else {
             throw new Exception("Your reset code has expired. Please request another one.");
         }
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
Exemplo n.º 3
0
 public function activate($code)
 {
     $user = User::where('activation_code', '=', $code)->first();
     try {
         if (is_null($user)) {
             throw new Exception("There is no user with that activation code");
         }
         $user = Sentry::findUserById($user->id);
         $data = Authenticator::activate($user);
         if ($user->activated) {
             $email = new UtilityMailman();
             $email->setReceiver($user->email);
             $email->setSubject('You are now Activated!');
             $body = $email->getBody('activated');
             $email->setBody($body);
             $data = $email->send($user);
         }
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
Exemplo n.º 4
0
 public function custom()
 {
     $user = Sentry::getUser();
     $input = Input::all();
     try {
         if ($user->id != 1) {
             throw new Exception("You do not have valid permissions to perform this action");
         }
         $teachers = Email::where('mass', '=', false)->take(25)->get();
         $email = new UtilityMailman();
         $email->setSubject($input['subject']);
         $email->setBody(nl2br($input['body']));
         //Decide if the response data should be parsed by Citrus
         $email->setReportStatus(0);
         // Where the attempted emails are stored
         $array = array();
         // Number of emails attempted
         $counter = 0;
         foreach ($teachers as $teacher) {
             $email->setReceiver($teacher->to);
             if (!is_null($teacher->name)) {
                 $email->name = $teacher->name;
             } else {
                 $email->name = $teacher->company;
             }
             $array[] = array('to' => $teacher->to, 'school' => $teacher->company, 'status' => $email->send(null, $teacher), 'name' => $teacher->name);
             if ($array[0]['status'] == 1) {
                 $teacher->mass = 1;
                 $teacher->save();
             }
             $counter = $counter + 1;
         }
         $data = Citrus::combine('total', $counter . ' messages were attempted', 'report', $array);
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }