public function action_reject() { $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 ($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 rejected!')->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(); $photo->delete(); Message::set(Message::SUCCESS, 'Email successfully sent and photo rejected.'); } else { $photo->delete(); Message::set(Message::SUCCESS, 'Photo successfully rejected.'); } //stop loading the template and just return die; }
public function action_reject() { $this->auto_render = false; $send_email = $_POST['sendEmail']; $comment_id = $_POST['commentID']; $comment = ORM::factory('comment')->where('id', '=', $comment_id)->find(); 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($comment->user_id, 'comment', $additional_text); $user = ORM::factory('user')->where('id', '=', $comment->user_id)->find(); //creative variable naming ftw! $post_office = Library_Notification::factory(); $letter_body = $email_text; $letter = Library_Notification::new_message()->setSubject('NG Kids My Shot - Comment rejected!')->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(); $comment->delete(); //Message::set(Message::SUCCESS, 'Email successfully sent and comment rejected.'); } else { $comment->delete(); //Message::set(Message::SUCCESS, 'Comment successfully rejected'); } echo "rejected"; }
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; } }