Пример #1
0
 public function __construct()
 {
     parent::__construct();
     $user = Helper_Widget::getBestUser();
     $loggedInUser = Auth::instance()->get_user();
     if ($user->loaded()) {
         $gameUser = Helper_Game::getUser($user->id);
         $this->template->following = $gameUser->following;
         if ($user->id === $loggedInUser->id) {
             $this->template->matchingUsers = true;
             $this->template->loggedInUser = new stdClass();
             $this->template->loggedInUser->id = $loggedInUser->id;
         }
     }
 }
Пример #2
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;
     }
 }
Пример #3
0
    ?>
    </div>
  <div class="footer"></div>
</div>
<div id="add_award_overlay" class="overlay_popup">
<div class="header">
    <h2>Award(s)</h2>
  </div>
  <div class="content">
    <p class="intro-copy"></p>
    <?php 
    echo form::open(Helper_Photos::get_photo_url($photo), array('method' => 'post', 'enctype' => 'multipart/form-data'));
    foreach ($allAwards as $award) {
        if ($award->winnable) {
            $attributes = array("id" => "award_" . $award->id, 'class' => 'award-checks', 'type' => 'checkbox');
            if (Helper_Game::getUser($photo->user->id)->getItem($photo->id)->hasAward($award)) {
                $attributes['checked'] = 'checked';
            }
            echo "<div class=\"award\"><label for=\"" . "award_" . $award->id . "\">" . html::image($award->images['x75']) . "<p class=\"award-title\">" . $award->title . "</p></label>" . form::input("awards[]", $award->id, $attributes) . "</div>";
        }
    }
    echo form::submit("submit_awards", "Add Awards", array('class' => 'submit'));
    echo form::close();
    ?>
    </div>
  <div class="footer"></div>
</div>
<div id="potd_overlay" class="overlay_popup">
	<div class="header">
		<h2>Photo of the Day</h2>
	</div>
Пример #4
0
 public function action_awardBadges($start = 0)
 {
     if ($this->active) {
         $users = ORM::factory("user")->find_all();
         $this->template->content = "";
         $completed = 0;
         $numUsers = $users->count();
         for ($i = $start; $i < $numUsers; ++$i) {
             $user = $users[$i];
             $gmUser = Helper_Game::getUser($user->id);
             $gmUser->awardBadges();
             $completed++;
             $this->template->content .= "<p>{$completed} complete. Started at {$start}</p>";
         }
     } else {
         $this->template->content = 'Initialized.';
         //$this->template->content =  View::factory('profiler/stats');
     }
 }
Пример #5
0
 public function action_removefan($id = null)
 {
     if ($id != null && $this->user->id != null) {
         $gameUser = Helper_Game::getUser($this->user->id);
         $toFollow = Helper_Game::getUser($id);
         $gameUser->stopFollowing($toFollow);
         $gotoUser = ORM::factory("user", $id);
         Message::set(Message::NOTICE, 'You are no longer following ' . $gotoUser->display_name);
         $myEvents = ORM::factory("game_EventLog")->where("site_user_id", '=', $gameUser->id)->find_all();
         foreach ($myEvents as $log) {
             if ($log->event->name == Helper_Game::FOLLOW_YOU && $log->data->fanned == $id) {
                 $log->delete();
                 //break;
             }
         }
         $yourEvents = ORM::factory("game_EventLog")->where("site_user_id", '=', $toFollow->id)->find_all();
         foreach ($yourEvents as $log) {
             if ($log->event->name == Helper_Game::FOLLOW_ME && $log->data->fanned_by == $this->user->id) {
                 $log->delete();
                 //break;
             }
         }
         if ($gotoUser->vanity_url) {
             Request::instance()->redirect('/profile/' . $gotoUser->vanity_url);
         } else {
             Request::instance()->redirect('/profile/' . $gotoUser->id);
         }
     } else {
         Request::instance()->redirect('/profile/');
     }
 }
Пример #6
0
 public function action_orderfollowing()
 {
     $loggedInUser = Auth::instance()->get_user();
     $givenUser = $_POST["userId"];
     if ($loggedInUser->id !== $givenUser) {
         exit;
     }
     $gameUser = Helper_Game::getUser($loggedInUser->id);
     $following = ORM::factory("Game_Following")->where("site_user_id", "=", $gameUser->id)->find_all();
     foreach ($following as $f) {
         foreach ($_POST["favorites"] as $fav) {
             $fav = (object) $fav;
             if ($fav->gameId == $f->following_id) {
                 $f->ordering = $fav->ordering;
                 $f->save();
             }
         }
     }
     exit;
 }