Skip to content

Commit

Permalink
Merge pull request #453 from jmo1121109/master
Browse files Browse the repository at this point in the history
Add-Excused-Missed-Turns
  • Loading branch information
jmo1121109 committed May 5, 2019
2 parents 9ebcdb8 + ea61d05 commit 9d7276f
Show file tree
Hide file tree
Showing 34 changed files with 4,446 additions and 3,618 deletions.
95 changes: 92 additions & 3 deletions admin/adminActions.php
Expand Up @@ -80,6 +80,11 @@ class adminActions extends adminActionsForms
'description' => 'Stops a player from joining or creating new games for that many days. To remove a temp ban, enter 0 days',
'params' => array('userID'=>'User ID', 'ban'=>'Days')
),
'modExcuseDelay' => array(
'name' => 'Mod Excuse Missed Turn',
'description' => 'Enter the user to excuse and the ID of the missed turn to excuse (found on RR breakdown page)',
'params' => array('userID'=>'User ID', 'excuseID'=>'Excuse ID','reason'=>'Reason')
),
'banUser' => array(
'name' => 'Ban a user',
'description' => 'Bans a user, setting his games to civil disorder, and removing his points.',
Expand Down Expand Up @@ -198,6 +203,26 @@ class adminActions extends adminActionsForms
'description' => 'Sets the given user ID to be the director of the given game ID (set to 0 to remove someone as game director).
This will give them mod capabilities for this game.',
'params' => array('gameID'=>'Game ID','userID'=>'User ID'),
),
'excusedMissedTurnsIncreaseAll' => array(
'name' => 'Excused Missed Turns - Add for All',
'description' => 'Adds 1 excused missed turn to all members in the game.',
'params' => array('gameID'=>'Game ID'),
),
'excusedMissedTurnsDecreaseAll' => array(
'name' => 'Excused Missed Turns - Remove for All',
'description' => 'Removes 1 excused missed turn for all members in the game. If the user(s) do not have excused turns left nothing will happen.',
'params' => array('gameID'=>'Game ID'),
),
'excusedMissedTurnsIncrease' => array(
'name' => 'Excused Missed Turns - Add',
'description' => 'Adds 1 excused missed turn to a specific user in a game.',
'params' => array('gameID'=>'Game ID','userID'=>'User ID'),
),
'excusedMissedTurnsDecrease' => array(
'name' => 'Excused Missed Turns - Remove',
'description' => 'Removes 1 excused missed turn for a specific user in a game. If the user(s) do not have excused turns left nothing will happen.',
'params' => array('gameID'=>'Game ID','userID'=>'User ID'),
)
);

Expand Down Expand Up @@ -1097,11 +1122,27 @@ public function tempBan(array $params)

$userID = (int)$params['userID'];
$days = (int)$params['ban'];
$DB->sql_put("UPDATE wD_Users SET tempBan = ". ( time() + ($days * 86400) )." WHERE id=".$userID);
if ($days == 0)
User::tempBanUser($userID, $days);
if ($days == 0)
return 'This user is now unblocked and can join and create games again.';

return 'This user is now blocked from joining and creating games for <b>'.$days.'</b> days.';
return 'This user is now blocked from joining, rejoining, and creating games for <b>'.$days.'</b> days.';
}
public function modExcuseDelay(array $params)
{
global $DB;

$userID = (int)$params['userID'];
$excuseID = (int)$params['excuseID'];

if( !isset($params['reason']) || strlen($params['reason'])==0 )
return l_t('Couldn\'t ban user; no reason was given.');

$modReason = $DB->msg_escape($params['reason']);

$DB->sql_put("UPDATE wD_MissedTurns SET modExcused = 1, modExcusedReason = '".$modReason."' WHERE id=".$excuseID);

return 'This user\'s missed turn has been excused.';
}
public function givePoints(array $params)
{
Expand Down Expand Up @@ -1163,6 +1204,54 @@ public function setDirector(array $params)

return l_t("The specified user ID has been assigned as the director for this game.");
}

public function excusedMissedTurnsIncreaseAll(array $params)
{
global $DB;

$gameID = (int)$params['gameID'];

$DB->sql_put("UPDATE wD_Members SET excusedMissedTurns = excusedMissedTurns + 1 WHERE gameID = ".$gameID);
return l_t("All users in this game have been given an extra excused missed turn.");
}

public function excusedMissedTurnsDecreaseAll(array $params)
{
global $DB;

$gameID = (int)$params['gameID'];

$DB->sql_put("UPDATE wD_Members SET excusedMissedTurns = excusedMissedTurns - 1 WHERE gameID = ".$gameID." and excusedMissedTurns > 0");
return l_t("All users in this game have had an extra excused missed turn removed.");
}

public function excusedMissedTurnsIncrease(array $params)
{
global $DB;

$userIDtoUpdate = (int)$params['userID'];
$gameID = (int)$params['gameID'];

if ($userIDtoUpdate > 0)
{
$DB->sql_put("UPDATE wD_Members SET excusedMissedTurns = excusedMissedTurns + 1 WHERE gameID = ".$gameID." and userID = ".$userIDtoUpdate);
return l_t("UserID: ".$userIDtoUpdate." has been given an extra excused missed turn in this game.");
}
}

public function excusedMissedTurnsDecrease(array $params)
{
global $DB;

$userIDtoUpdate = (int)$params['userID'];
$gameID = (int)$params['gameID'];

if ($userIDtoUpdate > 0)
{
$DB->sql_put("UPDATE wD_Members SET excusedMissedTurns = excusedMissedTurns - 1 WHERE gameID = ".$gameID." and userID = ".$userIDtoUpdate." and excusedMissedTurns > 0");
return l_t("UserID: ".$userIDtoUpdate." has had an extra excused missed turn removed in this game.");
}
}
}

?>
48 changes: 29 additions & 19 deletions admin/adminActionsForms.php
Expand Up @@ -66,7 +66,7 @@ private static function form($actionName, array $params, $description="")
print '<input type="hidden" name="globalUserID" value="'.intval($_REQUEST['globalUserID']).'" />';
if ( isset($_REQUEST['globalPostID']) )
print '<input type="hidden" name="globalPostID" value="'.intval($_REQUEST['globalPostID']).'" />';

if ($description)
print '<li class="modToolsformlistdesc" style="margin-bottom:10px">'.l_t($description).'</li>';

Expand All @@ -84,10 +84,20 @@ private static function form($actionName, array $params, $description="")
else
$defaultValue = '';

print '<li class="modToolsformlistfield">
<label for="'.$paramCode.'">'.l_t($paramName).'</label>:
<input class = "modTools" type="text" name="'.$paramCode.'" value="'.$defaultValue.'" length="50" />
</li>';
if ($paramCode == 'message')
{
print '<li class="modToolsformlistfield">
<label for="'.$paramCode.'">'.l_t($paramName).'</label>:
<textarea rows = "5" cols = "50" class="modTools" name="'.$paramCode.'"></textarea>
</li>';
}
else
{
print '<li class="modToolsformlistfield">
<label for="'.$paramCode.'">'.l_t($paramName).'</label>:
<input class = "modTools" type="text" name="'.$paramCode.'" value="'.$defaultValue.'"/>
</li>';
}
}

print '<li class="modToolsformlistfield">
Expand Down Expand Up @@ -127,19 +137,19 @@ private static function save($name, array $paramValues, $details)
$DB->sql_put("INSERT INTO wD_AdminLog ( name, userID, time, details, params )
VALUES ( '".$name."', ".$User->id.", ".time().", '".$details."', '".$paramValues."' )");
}

/**
* Defines the PHP script which the forms will target; will either be board.php or admincp.php
* @var string
*/
public static $target;

/**
* A reference to the static array of actions
* @var array
*/
public $actionsList;

/**
* For the given task display the form, and run the task if data entered from the corresponding form
*
Expand Down Expand Up @@ -329,11 +339,11 @@ public static function printActionLinks( array $actionCodes )
if( defined("INBOARD") )
{
// We're running in Director mode from within board.php

$adminActions = new adminActionsTD();
adminActionsForms::$target = "board.php?gameID=".$Game->id;
$adminActions->actionsList = adminActionsTD::$actions;

print '<h3>'.l_t('Director action forms').'</h3>';
// For each task display the form, and run the task if data entered from the corresponding form
print '<ul class="formlist">';
Expand All @@ -347,39 +357,39 @@ public static function printActionLinks( array $actionCodes )
{
print '<h2 class="modToolsHeadings">'.l_t('Emergency Actions').'</h2>';
adminActionsLayout::printActionShortcuts();

if ( $User->type['Admin'] )
$adminActions = new adminActionsRestricted();
elseif ( $User->type['ForumModerator'] )
$adminActions = new adminActionsForum();
else
$adminActions = new adminActions();

adminActionsForms::$target = "admincp.php";
$adminActions->actionsList = adminActions::$actions;

// Create a bullet-point set of anchor shortcuts to each task

$actionCodesByType = adminActionsLayout::actionCodesByType();

print '<h2 class="modToolsHeadings">'.l_t('Menu').'</h2>';
foreach($actionCodesByType as $type=>$actionCodes)
{
print '<a name="'.strtolower($type).'Actions"></a><h3 class = "modToolsHeadings">'.l_t($type.' actions').'</h3>';
adminActionsLayout::printActionLinks($actionCodes);
}

print '<div class="hr"></div>';

print '<h2 class="modToolsHeadings">'.l_t('All Actions').'</h2>';
// For each task display the form, and run the task if data entered from the corresponding form
print '<ul class="formlist">';
foreach($actionCodesByType as $type=>$actionCodes)
{
print '<h3 class="modToolsHeadings">'.l_t($type.' actions').'</h3>';

foreach($actionCodes as $actionCode)
$adminActions->process($actionCode);
}
print '</ul>';
}
}

0 comments on commit 9d7276f

Please sign in to comment.