Example #1
0
 public function action_approve($avatar_id)
 {
     $avatar = ORM::factory('avatar')->where('id', '=', $avatar_id)->find();
     // Approve it
     $avatar->moderation_status_id = 2;
     $avatar->save();
     // Upload to the CDN
     $this->upload_all($avatar);
     // Alert the user
     $this->send_approval_email($avatar->user);
     Helper_Game::logEvent(Helper_Game::AVATAR_APPROVED, $avatar->user->id, $avatar->id);
     // Display thank you
     Message::set(Message::SUCCESS, 'Avatar successfully approved.');
     Request::instance()->redirect('admin/avatars');
 }
Example #2
0
 /**
  * Add comment on photo.
  *
  * @param string $photo_id 
  * @return void
  * @author Merrick Christensen
  */
 public function action_on($photo_id)
 {
     if (Helper_Account::is_approved()) {
         $comment = ORM::factory('comment');
         $comment->user_id = $this->user->id;
         $comment->comment = Arr::get($_POST, 'comment');
         $comment->photo_id = $photo_id;
         $comment->created = Date('Y-m-d H:i:s');
         if ($comment->check()) {
             $comment->save();
             Message::set(Message::SUCCESS, 'You have successfully commented on this photo! It is currently waiting approval.');
             Helper_Game::logEvent(Helper_Game::COMMENT, $this->user->id, array("comment" => $comment->id, "photo" => $photo_id));
             Request::instance()->redirect('photos/view/' . $photo_id);
         } else {
             Message::set(Message::ERROR, $comment->validate()->errors('comment'));
         }
     }
 }
Example #3
0
 public function action_flipfavorite($photo_id)
 {
     $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find();
     if ($this->user->id && $photo->loaded()) {
         if ($this->user->isFavorite($photo_id)) {
             $this->user->removeFavorite($photo_id);
             Message::set(Message::SUCCESS, 'You removed "' . $photo->name . '" as a favorite!');
         } else {
             $this->user->addFavorite($photo_id);
             $favLogs = Helper_Game::getUser($this->user->id)->getLogsforEvent(Helper_Game::getSite()->getEvent(Helper_Game::FAVORITE));
             $addLog = true;
             foreach ($favLogs as $log) {
                 if ($log->data->photo_id == $photo_id) {
                     $addLog = false;
                     break;
                 }
             }
             $event = $addLog ? Helper_Game::logEvent(Helper_Game::FAVORITE, $this->user->id, array('photo_id' => $photo_id)) : false;
             $event2 = $addLog ? Helper_Game::logEvent(Helper_Game::FAVORITED, $photo->user->id, $photo->id, array('photo_id' => $photo_id, 'user_id' => $this->user->id)) : false;
             Message::set(Message::SUCCESS, 'You added "' . $photo->name . '" as a favorite!');
         }
         Request::instance()->redirect('/photos/view/' . $photo_id);
     } else {
         Request::instance()->redirect('/');
     }
 }
Example #4
0
 public function action_addfan($id = null)
 {
     if ($id != null && $this->user->id != null) {
         $gameUser = Helper_Game::getUser($this->user->id);
         $toFollow = Helper_Game::getUser($id);
         $gameUser->startFollowing($toFollow);
         Helper_Game::logEvent(Helper_Game::FOLLOW_YOU, $this->user->id, array('fanned' => $id));
         Helper_Game::logEvent(Helper_Game::FOLLOW_ME, $id, array('fanned_by' => $this->user->id));
         $gotoUser = ORM::factory("user", $id);
         Message::set(Message::SUCCESS, 'You are now following ' . $gotoUser->display_name);
         if ($gotoUser->vanity_url) {
             Request::instance()->redirect('/profile/' . $gotoUser->vanity_url);
         } else {
             Request::instance()->redirect('/profile/' . $gotoUser->id);
         }
     } else {
         Request::instance()->redirect('/profile/');
     }
 }
Example #5
0
 public function action_approve($photo_id)
 {
     $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find();
     // Approve it
     $photo->moderation_status_id = 2;
     $photo->set_order();
     $photo->save();
     // Upload to the CDN
     $this->upload_all($photo);
     // Alert the user
     $this->send_approval_email($photo, $photo->user);
     $tagstr = "";
     foreach ($photo->tags->find_all() as $tag) {
         $tagstr .= $tag->name . ",";
     }
     //Log event
     Helper_Game::logEvent(Helper_Game::IMG_APPROVED, $photo->user->id, $photo->id, array('photo' => $photo->id, 'tags' => $tagstr, 'category' => $photo->category->name));
     // Display thank you
     Message::set(Message::SUCCESS, 'Photo successfully approved.');
     Request::instance()->redirect('admin');
 }
Example #6
0
 public function action_approve($uid)
 {
     $approved_role = new Model_Role(array('name' => 'approved'));
     $user = ORM::factory("user", $uid);
     if ($user->loaded()) {
         try {
             if ($user->add('roles', $approved_role)) {
                 $this->send_confirmation_email($user);
                 Message::set(Message::SUCCESS, 'Account was successfully approved!');
                 Helper_Game::logEvent(Helper_Game::REGISTER, $user->id);
                 Request::instance()->redirect('/admin/users/edit/' . $user->id);
                 return;
             }
         } catch (Exception $e) {
             Message::set(Message::ERROR, 'Account approval failed.');
             Request::instance()->redirect('/admin/users/edit/' . $uid);
         }
     }
     Message::set(Message::ERROR, 'Account approval failed.');
     Request::instance()->redirect('/admin/users/edit/' . $uid);
 }
Example #7
0
 public function action_approveall()
 {
     $comments = ORM::factory('comment')->where('moderation_status_id', '=', 1)->find_all();
     foreach ($comments as $comment) {
         $comment->moderation_status_id = 2;
         Helper_Game::logEvent(Helper_Game::COMMENT_APPROVED, $comment->user_id, $comment->photo_id, array("comment" => $comment->comment));
         Helper_Game::logEvent(Helper_Game::COMMENT_RECEIVED, $comment->photo->user->id, $comment->photo_id, array("comment" => $comment->id, "photo" => $comment->photo_id));
         $comment->save();
     }
     // Display thank you
     Message::set(Message::SUCCESS, 'Comments successfully approved.');
     Request::instance()->redirect('admin/comments');
 }