Skip to content

Commit

Permalink
Coding style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gapple committed May 13, 2011
1 parent 6c641ac commit 63ca1b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
15 changes: 7 additions & 8 deletions boardgame.api.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// $Id$
/**
* @file
* API functions to handle manipulation of player and game data.
Expand Down Expand Up @@ -41,7 +40,7 @@ function boardgame_get_error() {
/**
* Get information on supported game types
*/
function boardgame_gametypes(){
function boardgame_gametypes() {
static $types = NULL;

if (!isset($types)) {
Expand Down Expand Up @@ -124,7 +123,7 @@ function boardgame_init_game($playerid, $game_info) {
}
}
// Load default layout if available
else if (isset($gametypes[$game_info->type]['initialize'])) {
elseif (isset($gametypes[$game_info->type]['initialize'])) {
$func = $gametypes[$game_info->type]['initialize'];
$board = $func();
}
Expand Down Expand Up @@ -231,7 +230,7 @@ function boardgame_get_open_games($type = NULL, $playerid = NULL) {
$query_where = array();
$query_param = array();

if(!empty($type)){
if (!empty($type)) {
$query_where[] = 'bgg.type = "%s"';
$query_param[] = $type;
}
Expand Down Expand Up @@ -269,7 +268,7 @@ function boardgame_get_active_games($type = NULL, $playerid = NULL) {
$query_where = array();
$query_param = array();

if(!empty($type)){
if (!empty($type)) {
$query_where[] = 'bgg.type = "%s"';
$query_param[] = $type;
}
Expand Down Expand Up @@ -303,7 +302,7 @@ function boardgame_get_games($type = NULL, $playerid = NULL) {
$query_where = array();
$query_param = array();

if(!empty($type)){
if (!empty($type)) {
$query_where[] = 'bgg.type = "%s"';
$query_param[] = $type;
}
Expand Down Expand Up @@ -627,7 +626,7 @@ function boardgame_player_update($info) {
* @return
* The user id of the owner, or false if the playerid is invalid.
*/
function boardgame_player_get_user($playerid){
function boardgame_player_get_user($playerid) {
$uid = db_result(db_query('SELECT uid FROM {boardgame_player} WHERE playerid = %d', array($playerid)));

if (!$uid) {
Expand All @@ -645,7 +644,7 @@ function boardgame_player_get_user($playerid){
* @return
* An array of playerids.
*/
function boardgame_user_get_players($uid){
function boardgame_user_get_players($uid) {
$players = array();

$result = db_query('SELECT playerid FROM {boardgame_player} WHERE uid = %d', array($uid));
Expand Down
1 change: 0 additions & 1 deletion boardgame.install
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// $Id$
/**
* @file
* Install, update and uninstall functions for the boardgame module.
Expand Down
3 changes: 1 addition & 2 deletions boardgame.module
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// $Id$
/**
* Implementation of hook_perm().
*/
Expand Down Expand Up @@ -291,7 +290,7 @@ function boardgame_form_player_edit_submit($form, &$form_state) {
}

/**
* Implementation of hook_services_resources()
* Implementation of hook_services_resources().
*/
function boardgame_services_resources() {
$resource = array();
Expand Down
22 changes: 11 additions & 11 deletions services/game_resource.inc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
// $Id$
/**
* @file Integration functions for Services.module
* @file
* Integration functions for Services.module
*/

function _boardgame_game_resource_definition(){
function _boardgame_game_resource_definition() {

$resource['game']['create'] = array(
'help' => 'Create a new game.',
Expand Down Expand Up @@ -83,18 +83,18 @@ function _boardgame_game_resource_definition(){
/**
*
*/
function _boardgame_game_resource_access($op){
$access = false;
function _boardgame_game_resource_access($op) {
$access = FALSE;

$args = func_get_args();
array_shift($args); // remove $op

switch ($op){
switch ($op) {
case 'create':
// check that user is authorized to act for player
$playerid = array_shift($args);
module_load_include('inc', 'boardgame', 'boardgame.api');
if(boardgame_player_get_user($playerid) == $user->uid){
if (boardgame_player_get_user($playerid) == $user->uid) {
$access = TRUE;
}
break;
Expand All @@ -114,16 +114,16 @@ function _boardgame_game_resource_create($playerid, $gamedata) {
module_load_include('inc', 'boardgame', 'boardgame.api');

global $user;
if (boardgame_player_get_user($playerid) !== $user->uid){
if (boardgame_player_get_user($playerid) !== $user->uid) {
return services_error(t('Not authorized to act for player @playerid', array('@playerid', $playerid)));
}

$gameid = boardgame_init_game($playerid, $gamedata);
if(!$gameid){
if (!$gameid) {
return services_error(boardgame_get_error());
}

return (object)array(
return (object) array(
'gameid' => $gameid,
'uri' => services_resource_uri(array('game', $gameid)),
);
Expand All @@ -135,7 +135,7 @@ function _boardgame_game_resource_index($parameters) {
$playerid = (!empty($parameters['player']) && is_numeric($parameters['player']))? intval($parameters['player']) : NULL;
$type = !empty($parameters['type'])? $parameters['type'] : NULL;

switch($parameters['status']){
switch ($parameters['status']) {
default:
case 'all':
$result = boardgame_get_games($type, $playerid);
Expand Down

0 comments on commit 63ca1b1

Please sign in to comment.