예제 #1
0
 public function action_delete()
 {
     $this->auto_render = false;
     $send_email = $_POST['sendEmail'];
     $photo_id = $_POST['photoID'];
     $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find();
     $user = ORM::factory('user')->where('id', '=', $photo->user_id)->find();
     if (Helper_Account::is_admin()) {
         $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find();
     } else {
         $photo = ORM::factory('photo')->where('id', '=', $photo_id)->where('user_id', '=', $this->user->id)->find();
     }
     if ($photo->loaded()) {
         if (Helper_Account::is_admin()) {
             if ($send_email != 'undefined' && $send_email == 'true') {
                 $reason = $_POST['emailComment'];
                 $additional_text = $_POST['otherText'];
                 if ($reason == 'other') {
                     $additional_text = $_POST['otherText'];
                 } else {
                     $additional_text = $reason;
                 }
                 $email_text = Helper_SendEmail::generate_email($photo->user_id, 'photo', $additional_text);
                 //creative variable naming ftw!
                 $post_office = Library_Notification::factory();
                 $letter_body = $email_text;
                 $letter = Library_Notification::new_message()->setSubject('NG Kids My Shot - Photo removed!')->setFrom(Kohana::config('email.from'))->setTo(array($user->email => 'Guardian of ' . $user->display_name))->setBody($letter_body, 'text/html');
                 $post_office->add_message($letter);
                 $post_office->send_messages();
             }
         } else {
             $email_text = View::factory("email/userremoved")->set("user", $user)->set("photo", $photo);
             $post_office = Library_Notification::factory();
             $letter_body = $email_text->render();
             $letter = Library_Notification::new_message()->setSubject('NG Kids My Shot - Photo removed by user')->setFrom(Kohana::config('email.from'))->setTo(Kohana::config('email.ng_staff'))->setBody($letter_body, 'text/html');
             $post_office->add_message($letter);
             $post_office->send_messages();
         }
         $photo_owner_id = $photo->user_id;
         //remove photo approval action here
         //-------------------
         $gameUser = Helper_Game::getUser($photo->user_id);
         $gameUser->removeItem($photo->id);
         $photo->delete();
         echo $photo_owner_id;
     }
 }
예제 #2
0
 private function send_approval_email($user)
 {
     //creative variable naming ftw!
     $post_office = Library_Notification::factory();
     $letter_body = View::factory('admin/avatars/emails/approved');
     $letter_body->user = $user;
     $letter = Library_Notification::new_message()->setSubject('Kids My Shot - Avatar approved!')->setFrom(Kohana::config('email.from'))->setTo(array($user->email => 'Guardian of ' . $user->display_name))->setBody($letter_body->render(), 'text/html');
     $post_office->add_message($letter);
     return $post_office->send_messages();
 }
예제 #3
0
 /**
  * Sends reset email to guardian address.
  *
  * @return boolean
  * @author Merrick Christensen
  * @param ORM $user, ORM $approval
  */
 private function send_reset_email($user, $reset)
 {
     //creative variable naming ftw!
     $post_office = Library_Notification::factory();
     $letter_body = View::factory('account/emails/reset');
     $letter_body->key = $reset->key;
     $letter_body->user = $user;
     $letter = Library_Notification::new_message()->setSubject('Reset Child Password for NG Kids My Shot')->setFrom(Kohana::config('email.from'))->setTo(array($user->email => 'Guardian of ' . $user->display_name))->setBody($letter_body->render(), 'text/html');
     $post_office->add_message($letter);
     return $post_office->send_messages();
 }
예제 #4
0
 private function send_approval_email($photo, $user)
 {
     if (empty($user->sendmessages)) {
         return;
     }
     $key = ORM::factory("key")->where("user_id", "=", $user->id)->where("type", "=", "settings")->find();
     if (!$key->loaded()) {
         $key = ORM::factory('key');
         // Generates a unique key.
         $key->key = Key_URL::factory()->key;
         $key->user_id = $user->id;
         $key->type = 'settings';
         $key->save();
     }
     //creative variable naming ftw!
     $post_office = Library_Notification::factory();
     $letter_body = View::factory('admin/photos/emails/approved');
     $letter_body->user = $user;
     $letter_body->photo = $photo;
     $letter_body->key = $key->key;
     $letter = Library_Notification::new_message()->setSubject('NG Kids My Shot - Photo approved!')->setFrom(Kohana::config('email.from'))->setTo(array($user->email => 'Guardian of ' . $user->display_name))->setBody($letter_body->render(), 'text/html');
     $post_office->add_message($letter);
     return $post_office->send_messages();
 }