Skip to content

Commit

Permalink
improvement: added intval() in some places and make the code shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
interduo committed Jun 5, 2023
1 parent 3085a83 commit 53d2aed
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions modules/eventedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
ConfigHelper::getConfig('phpui.allow_modify_closed_events_newer_than', 604800)
);

if (isset($_GET['id'])) {
$event = $LMS->GetEvent($_GET['id']);
$action = isset($_GET['action']) ? $_GET['action'] : null;
$id = !empty($_GET['id']) ? intval($_GET['id']) : null;
$ticketid = !empty($_GET['ticketid']) ? intval($_GET['ticketid']) : null;

if (!empty($id)) {
$event = $LMS->GetEvent($id);
if (empty($event)) {
$SESSION->redirect('?m=eventlist');
}
Expand All @@ -58,11 +62,10 @@
$backid = $SESSION->get('backid');
$backurl = '?' . $backto . (empty($backid) ? '' : '#' . $backid);

$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
case 'open':
if (empty($event['closeddate']) || ($event['closed'] == 1 && $aee && (time() - $event['closeddate'] < $aee)) || ConfigHelper::checkPrivilege('superuser')) {
$LMS->EventOpen($_GET['id']);
$LMS->EventOpen($id);
$SESSION->remove_history_entry();
$SESSION->redirect($backurl);
} else {
Expand All @@ -71,17 +74,16 @@
break;
case 'close':
$SESSION->remove_history_entry();
if (isset($_GET['ticketid'])) {
$params = array('ticketid' => $_GET['ticketid']);
if (isset($ticketid)) {
$LMS->EventClose(array('ticketid' => $ticketid));
} else {
$params = array('id' => $_GET['id']);
$LMS->EventClose(array('id' => $id));
}
$LMS->EventClose($params);
$SESSION->redirect($backurl);
break;
case 'assign':
if ($event['closed'] != 1 || ($event['closed'] == 1 && $aee && ((time() - $event['closeddate']) < $aee)) || ConfigHelper::checkPrivilege('superuser')) {
$LMS->AssignUserToEvent($_GET['id'], Auth::GetCurrentUser());
$LMS->AssignUserToEvent($id, Auth::GetCurrentUser());
$SESSION->remove_history_entry();
$SESSION->redirect($backurl);
} else {
Expand All @@ -90,7 +92,7 @@
break;
case 'unassign':
if ($event['closed'] != 1 || ($event['closed'] == 1 && $aee && ((time() - $event['closeddate']) < $aee)) || ConfigHelper::checkPrivilege('superuser')) {
$LMS->UnassignUserFromEvent($_GET['id'], Auth::GetCurrentUser());
$LMS->UnassignUserFromEvent($id, Auth::GetCurrentUser());
$SESSION->remove_history_entry();
$SESSION->redirect($backurl);
} else {
Expand Down

0 comments on commit 53d2aed

Please sign in to comment.