示例#1
0
 public function action_view()
 {
     $id = $this->request->param('id');
     if (!$id) {
         $this->request->redirect('/community');
     } else {
         $view = View::factory('community_view');
         $community = DB::select()->from('communities')->where('communities_id', '=', $id)->execute()->current();
         $view->admin = name_from_id($community['admin']);
         $mods = explode(',', $community['mods']);
         for ($i = 0; $i < count($mods); $i++) {
             $mods[$i] = name_from_id($mods[$i]);
         }
         $mods = implode(', ', $mods);
         $view->mods = $mods;
         $view->name = $community['name'];
         $view->description = $community['description'];
         $view->members = DB::select('user')->from('membership')->where('community', '=', $id)->execute()->as_array('user', 'user');
         $view->join = '';
         // If the logged in user is not already in the community, add a join link
         if (!DB::select()->from('membership')->where('community', '=', $id)->where('user', '=', $this->user)->execute()->current()) {
             $view->join = '<a href="/community/join/' . $id[0] . '">Join this community!</a>';
         }
         $this->template->content = $view;
     }
 }
示例#2
0
 public function action_edit()
 {
     $id = $this->request->param('id');
     if ($id != $this->user) {
         $this->request->redirect(URL::base());
     }
     $view = View::factory('player_edit');
     $view->realname = @real_name_from_id($id);
     if ($_POST) {
         $realname = @$_POST['realname'];
         $current_password = @$_POST['current_password'];
         $new_password = @$_POST['new_password'];
         $confirm_password = @$_POST['confirm_password'];
         if ($new_password) {
             if (!Auth::check_password($current_password)) {
                 array_push($this->template->errors, "Password did not match password on file.");
             }
             if ($new_password != $confirm_password) {
                 array_push($this->template->errors, "New passwords did not match.");
             }
             if (empty($this->template->errors)) {
                 password(name_from_id($id));
             }
         }
         if ($realname) {
             DB::update('users')->set(array('realname' => $realname))->where('id', '=', $id)->execute();
         }
         $this->request->redirect('/player/view/2');
     }
     $this->template->content = $view;
 }
示例#3
0
 public function action_view()
 {
     $id = $this->request->param('id');
     if (!$id) {
         $this->request->redirect(URL::base() . 'tournament');
     }
     $view = View::factory('tournament_view');
     $tournament = DB::select()->from('tournies')->where('tournies_id', '=', $id)->execute()->current();
     $view->name = $tournament['name'];
     $view->community = $tournament['community'];
     $view->admin = name_from_id($tournament['admin']);
     $view->refs = explode(",", $tournament['refs']);
     $view->players = DB::select('player')->from('tournies_players')->where('tournies_id', '=', $id)->execute()->as_array('player', 'player');
     $view->maps = DB::select('map')->from('tournies_maps')->where('tournies_id', '=', $id)->execute()->as_array('map');
     $view->description = $tournament['description'];
     $view->exclusive = $tournament['exclusive'];
     $this->template->content = $view;
 }
<?
	$i = 0;
	foreach($refs as $ref)
	{
		echo name_from_id($ref);
		if($i+1 != count($refs)) {
			echo ", ";
		}
		$i++;
	}
?>
</h4>
<h4>Players</h4>
<ul>
	<? foreach($players as $player) {
		echo "<li>" . name_from_id($player) . "</li>";
	}
	?>
</ul>
<h4>Maps</h4>
<ul>
<? 
foreach($maps as $map) 
{
	echo "<li>" . map_name($map) . "</li>";
}
?>
</ul>
<h4>Description</h4>
<p><?php 
echo $description;
示例#5
0
function name_link_from_id($id) {
	return '<a href="' . URL::base() . 'player/view/' . $id . '">' . name_from_id($id) . '</a>';
}
<h2><?php 
echo $community;
?>
 Leaderboard</h2>
<table>
	<tr>
		<th>Rank</th>
		<th>Player</th>
		<th>Score</th>
	</tr>
	<?
		$i = 1;
		foreach($scores as $score) {
			echo "<tr>\n";
			echo "\t<td>" . $i . ". </td>";
			echo "\t" . '<td><a href="' . URL::base() . 'player/view/' . $score['user'] . '">' . name_from_id($score['user']) . "</a></td>\n";
			echo "\t<td>" . $score['score'] . "</td>\n";
			echo "</tr>\n";
			$i++;
		}
	?>
</table>
示例#7
0
<h2><?php 
echo name_from_id($id);
?>
 - <?php 
echo race_from_id($id);
?>
</h2>
<?
if(!empty($communities)) 
{
	foreach($communities as $community)
	{
		echo "<h4>" . $community['name'] . "</h4>";
		echo "<p>" . $community['description'] . "</p>";
	}
} else {
	echo "<p>No commmunities!</p>";
}
?>
<?php 
echo $edit;