-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #9 - Managing penalties via admin panel
- Loading branch information
Sebastian Schulz
committed
Dec 5, 2018
1 parent
1356fb5
commit ea8a2b0
Showing
6 changed files
with
300 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
$returnArray = array( | ||
'status' => FALSE, | ||
'message' => array() | ||
); | ||
|
||
try { | ||
|
||
$_language->readModule('cups', false, true); | ||
|
||
if (!$loggedin || !iscupadmin($userID)) { | ||
throw new \Exception($_language->module['access_denied']); | ||
} | ||
|
||
if (empty($getAction)) { | ||
throw new \Exception($_language->module['unknown_action']); | ||
} | ||
|
||
if ($getAction == 'getPenaltyDetails') { | ||
|
||
$penalty_id = (isset($_GET['penalty_id']) && validate_int($_GET['penalty_id'], true)) ? | ||
(int)$_GET['penalty_id'] : 0; | ||
|
||
if ($penalty_id < 1) { | ||
throw new \Exception('unknown_penalty_id'); | ||
} | ||
|
||
$selectQuery = mysqli_query( | ||
$_database, | ||
"SELECT | ||
cp.`adminID`, | ||
cp.`date`, | ||
cp.`duration_time`, | ||
cp.`teamID`, | ||
cp.`userID`, | ||
cp.`comment`, | ||
cp.`reasonID`, | ||
cpc.`name_de`, | ||
cpc.`name_uk`, | ||
cpc.`points`, | ||
cpc.`lifetime`, | ||
u.`nickname`, | ||
ct.`name` AS `team_name` | ||
FROM `" . PREFIX . "cups_penalty` cp | ||
JOIN `" . PREFIX . "cups_penalty_category` cpc ON cp.`reasonID` = cpc.`reasonID` | ||
LEFT JOIN `" . PREFIX . "user` u ON u.`userID` = cp.`userID` | ||
LEFT JOIN `" . PREFIX . "cups_teams` ct ON ct.`teamID` = cp.`teamID` | ||
WHERE `ppID` = " . $penalty_id | ||
); | ||
|
||
if (!$selectQuery) { | ||
$returnArray['message'][] = mysqli_error($_database); | ||
throw new \Exception($_language->module['query_select_failed']); | ||
} | ||
|
||
$get = mysqli_fetch_array($selectQuery); | ||
|
||
if ($get['userID'] > 0) { | ||
$receiver_url = $hp_url . '/index.php?site=profile&id=' . $get['userID']; | ||
$receiver_name = $get['nickname']; | ||
} else { | ||
$receiver_url = $hp_url . '/index.php?site=teams&action=details&id=' . $get['teamID']; | ||
$receiver_name = $get['team_name']; | ||
} | ||
|
||
$receiver = '<a href="' . $receiver_url . '" target="_blank" class="blue">' . $receiver_name . '</a>'; | ||
|
||
$returnArray['details'] = array( | ||
'receiver' => $receiver, | ||
'duration' => getformatdatetime($get['date']), | ||
'comment' => $get['comment'], | ||
'category' => array( | ||
'name_de' => $get['name_de'], | ||
'name_uk' => $get['name_uk'] | ||
) | ||
); | ||
|
||
} else { | ||
throw new \Exception($_language->module['unknown_action']); | ||
} | ||
|
||
$returnArray['status'] = TRUE; | ||
|
||
} catch (Exception $e) { | ||
$returnArray['message'][] = $e->getMessage(); | ||
} | ||
|
||
echo json_encode($returnArray); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
<tr> | ||
<td><a href="$profile" class="blue">$name</a></td> | ||
<td> | ||
<a href="$profile" class="blue">$name</a> | ||
</td> | ||
<td>$reason_name</td> | ||
<td><a href="$admin_profile" class="blue" target="_blank">$admin</a></td> | ||
<td> | ||
<a href="$admin_profile" class="blue" target="_blank"> | ||
$admin | ||
</a> | ||
</td> | ||
<td>$duration</td> | ||
<td> | ||
<button type="button" class="btn btn-info btn-xs white darkshadow"> | ||
<button type="button" name="showPenaltyDetails" | ||
id="btnPenaltyDetails_$penalty_id" | ||
class="btn-penalty-details btn btn-info btn-xs white darkshadow"> | ||
Details | ||
</button> | ||
</td> | ||
</tr> | ||
</tr> |
Oops, something went wrong.