Exemplo n.º 1
0
 public function action_favorites($user = null)
 {
     if ($user === NULL) {
         Message::set(Message::NOTICE, 'User does not exist!');
         Request::instance()->redirect('/');
     } else {
         if (is_numeric($user)) {
             $account = ORM::factory('user')->where('id', '=', $user)->find();
         } else {
             $account = ORM::factory('user')->where('vanity_url', '=', $user)->find();
         }
         if ($account->loaded()) {
             if (!Helper_Account::is_approved($account)) {
                 Message::set(Message::NOTICE, 'User has not been approved!');
                 Request::instance()->redirect('/');
             }
         } else {
             Message::set(Message::NOTICE, 'User does not exist!');
             Request::instance()->redirect('/');
         }
     }
     if (!isset($account)) {
         Message::set(Message::NOTICE, 'User does not exist!');
         Request::instance()->redirect('/');
     }
     $this->template->content = View::factory("profile/favorites");
     $this->template->content->user = $account;
     $this->template->content->reel = Reel::factory($account->favorite_photos);
     $this->template->top = View::factory('profile/topper');
     $this->template->top->user = $account;
     $this->template->top->owner = $this->user;
     $this->template->top->photos = $account->viewablePhotos()->order_by(DB::expr('RAND()'))->limit(30)->find_all();
 }
Exemplo n.º 2
0
 public function action_save()
 {
     if (!$this->user->loaded()) {
         Message::set(Message::ERROR, "You must be logged in to create a slideshow.");
         $this->request->redirect("/");
         return;
     }
     if (!Helper_Account::is_approved()) {
         Message::set(Message::ERROR, "You must be approved to create a slideshow.");
         $this->request->redirect("/");
         return;
     }
     $slideshow = Model_Slideshow::getLastIncomplete($this->user);
     if ($slideshow->photos->find_all()->count() < 3) {
         Message::set(Message::ERROR, "You must have at least three images in your slideshow.");
         $this->request->redirect("slideshow/builder");
         return;
     }
     if ($slideshow->music_id == null || $slideshow->music_id == 0) {
         Message::set(Message::ERROR, "You must select music for your slideshow.");
         $this->request->redirect("slideshow/builder");
         return;
     }
     $slideshow->complete = 1;
     $slideshow->created = date("Y-m-d H:i:s");
     $slideshow->save();
     $this->request->redirect($slideshow->getLink());
 }
Exemplo n.º 3
0
 private function determine_status()
 {
     if ($user = Auth::instance()->get_user()) {
         if (Helper_Account::is_approved()) {
             return 'accountstatus/registered';
         } elseif ($user->loaded()) {
             return 'accountstatus/pending';
         } else {
             return 'accountstatus/login';
         }
     } else {
         return 'accountstatus/login';
     }
 }
Exemplo n.º 4
0
 /**
  * Add caption on photo.
  *
  * @param string $photo_id 
  * @return void
  * @author Vladimir Kokovic
  */
 public function action_on($photo_id)
 {
     if (Helper_Account::is_approved()) {
         $caption = ORM::factory('caption');
         $caption->user_id = $this->user->id;
         $caption->caption = Arr::get($_POST, 'caption');
         $caption->photo_id = $photo_id;
         if ($caption->check()) {
             $caption->save();
             Message::set(Message::SUCCESS, 'You have successfully captioned this photo! It is currently waiting approval.');
             //Helper_Game::logEvent(Helper_Game::CAPTION, $this->user->id, $photo_id, array("caption" => $caption->caption));
             Request::instance()->redirect('photos/caption/' . $photo_id);
         } else {
             Message::set(Message::ERROR, $caption->validate()->errors('caption'));
         }
     }
 }
Exemplo n.º 5
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'));
         }
     }
 }
Exemplo n.º 6
0
 public function action_keys()
 {
     $total_other = 0;
     $total_user = 0;
     $keys = ORM::factory('key')->where("type", "=", "approve")->where("type", "=", "remove")->where("type", "=", "reset")->find_all();
     foreach ($keys as $key) {
         if (strtotime($key->created) < strtotime($this->interval)) {
             if (Helper_Account::is_approved($key->user)) {
                 // Just kill the key, it wasn't bound to approval.
                 $key->delete();
                 $total_other += 1;
             } else {
                 // Due to InnoDB the key will be deleted via cascade.
                 $key->user->delete();
                 $total_user += 1;
             }
         }
     }
     echo "Total reset and remove keys deleted: {$total_other}\n";
     echo "Total pending users deleted: {$total_user}\n";
     $total = $total_other + $total_user;
     echo "Total keys removed: {$total} \n";
 }
Exemplo n.º 7
0
    echo date('F d, Y', strtotime($awaiting_comment->created));
    ?>
</span></p>
				<p>
					<?php 
    echo $awaiting_comment->comment;
    ?>
				</p>
			</div>
		</div> <!-- END comment_container -->
		<?php 
}
?>
	</div> <!-- END comments -->
	<?php 
if (Helper_Account::is_approved()) {
    ?>
	<div class="add_a_comment">
		<?php 
    echo form::open('/photos/view/' . $photo->id);
    ?>
			<div class="title">
				<h2>Add a comment</h2>
				<div class="max_characters counter"></div>
			</div>
			<?php 
    echo form::textarea('comment', Arr::get($_POST, 'comment'), array('data-max' => '600', 'class' => 'word_count'));
    ?>
			<input type="submit" value="" class="submit" />
		<?php 
    echo form::close();
Exemplo n.º 8
0
<br /><br />
			
			<h3>Set User as Admin:</h3>
			<?php 
echo form::checkbox('admin_user', '1', Arr::get($_POST, 'admin_user', Helper_Account::is_admin($user)), array("id" => "confirm"));
?>
 Yes
            
            <h3>Set User as NG Staff:</h3>
      		<?php 
echo form::checkbox('ngstaff_user', '1', Arr::get($_POST, 'ngstaff_user', Helper_Account::is_ngstaff($user)), array("id" => "ngstaff_confirm"));
?>
 Yes

			<?php 
if (!Helper_Account::is_approved($user)) {
    echo new Element("div", HTML::anchor("admin/users/approve/" . $user->id, "Force Parent Approval"), array("style" => "margin-top:15px;"));
}
?>
		</div> <!-- END: title -->
		<div class="title_bottom"></div>
		<div class="submit_container">
			<ul class="buttons">
				<li><?php 
echo form::submit('submit', '', array('class' => 'save'));
?>
</li>
			</ul>
		</div>
	<?php 
echo form::close();
Exemplo n.º 9
0
    echo date('F d, Y', strtotime($awaiting_caption->created));
    ?>
</span></p>
				<p class="caption">
					<?php 
    echo $awaiting_caption->caption;
    ?>
				</p>
			</div>
		</div> <!-- END comment_container -->
		<?php 
}
?>
	</div> <!-- END comments -->
	<?php 
if (Helper_Account::is_approved() && $caption_this_photo->isActive) {
    ?>
	<div class="add_a_comment">
		<?php 
    echo form::open('/backtalk/submit/' . $photo->id);
    ?>
			<div class="title">
				<h2>Add a Back Talk</h2>
				<div class="max_characters counter"></div>
			</div>
			<?php 
    echo form::textarea('caption', Arr::get($_POST, 'caption'), array('data-max' => '40', 'class' => 'word_count'));
    ?>
			<input type="submit" value="" class="submit" />
		<?php 
    echo form::close();