From 467e75a11c297c3bf3780172b7c205328480bdba Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 18 Sep 2020 11:03:20 -0500 Subject: [PATCH] convert eventdetail function to php file --- web/ajax/modal.php | 28 +++--- .../modals/{delconfig.php => delconfirm.php} | 0 web/ajax/modals/eventdetail.php | 89 +++++++++++++++++++ web/skins/classic/includes/functions.php | 84 ----------------- 4 files changed, 99 insertions(+), 102 deletions(-) rename web/ajax/modals/{delconfig.php => delconfirm.php} (100%) create mode 100644 web/ajax/modals/eventdetail.php diff --git a/web/ajax/modal.php b/web/ajax/modal.php index 9f29de932..bd96b137f 100644 --- a/web/ajax/modal.php +++ b/web/ajax/modal.php @@ -8,24 +8,16 @@ if ( empty($_REQUEST['modal']) ) { $modal = validJsStr($_REQUEST['modal']); $data = array(); -switch ( $modal ) { - case 'eventdetail' : - $eid = isset($_REQUEST['eid']) ? $_REQUEST['eid'] : ''; - $eids = isset($_REQUEST['eids']) ? $_REQUEST['eids'] : ''; - $data['html'] = getEventDetailHTML($eid, $eids); - break; - default : - ZM\Logger::Debug("Including modals/$modal.php"); - # Shouldn't be necessary but at the moment we have last .conf file contents - ob_start(); - @$result = include('modals/'.$modal.'.php'); - $data['html'] = ob_get_contents(); - ob_end_clean(); - if ( !$result ) { - ajaxError("Unknown modal '".$modal."'"); - return; - } -} # end switch $modal +ZM\Logger::Debug("Including modals/$modal.php"); +# Shouldn't be necessary but at the moment we have last .conf file contents +ob_start(); +@$result = include('modals/'.$modal.'.php'); +$data['html'] = ob_get_contents(); +ob_end_clean(); +if ( !$result ) { + ajaxError("Unknown modal '".$modal."'"); + return; +} ajaxResponse($data); return; diff --git a/web/ajax/modals/delconfig.php b/web/ajax/modals/delconfirm.php similarity index 100% rename from web/ajax/modals/delconfig.php rename to web/ajax/modals/delconfirm.php diff --git a/web/ajax/modals/eventdetail.php b/web/ajax/modals/eventdetail.php new file mode 100644 index 000000000..bb2f53ecc --- /dev/null +++ b/web/ajax/modals/eventdetail.php @@ -0,0 +1,89 @@ +'; + $newEvent = dbFetchOne('SELECT E.* FROM Events AS E WHERE E.Id = ?', NULL, array($eid)); + +} elseif ( $eids ) { // Multi Event Mode + + $title = translate('Events'); + $sql = 'SELECT E.* FROM Events AS E WHERE '; + $sqlWhere = array(); + $sqlValues = array(); + foreach ( $eids as $eid ) { + $eid = validInt($eid); + $inputs .= ''; + $sqlWhere[] = 'E.Id = ?'; + $sqlValues[] = $eid; + } + unset($eid); + $sql .= join(' OR ', $sqlWhere); + foreach( dbFetchAll( $sql, NULL, $sqlValues ) as $row ) { + if ( !isset($newEvent) ) { + $newEvent = $row; + } else { + if ( $newEvent['Cause'] && $newEvent['Cause'] != $row['Cause'] ) + $newEvent['Cause'] = ''; + if ( $newEvent['Notes'] && $newEvent['Notes'] != $row['Notes'] ) + $newEvent['Notes'] = ''; + } + } + +} else { // Event Mode not specified - should we really proceed if neither eid nor eids is set? + $title = translate('Events'); +} + +?> + + diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index f35cea751..d61c6aaee 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -815,90 +815,6 @@ function getStatsTableHTML($eid, $fid, $row='') { return $result; } -function getEventDetailHTML($eid='', $eids='') { - $result = ''; - $inputs = ''; - $disabled = 'disabled="disabled"'; - $null = ''; - - if ( !canEdit('Events') ) return; - - if ( $eid ){ // Single Event Mode - $eid = validInt($eid); - $title = translate('Event').' '.$eid.PHP_EOL; - $inputs .= ''.PHP_EOL; - $newEvent = dbFetchOne('SELECT E.* FROM Events AS E WHERE E.Id = ?', NULL, array($eid)); - - } elseif ( $eids ) { // Multi Event Mode - - $title = translate('Events'); - $sql = 'SELECT E.* FROM Events AS E WHERE '; - $sqlWhere = array(); - $sqlValues = array(); - foreach ( $eids as $eid ) { - $eid = validInt($eid); - $inputs .= ''.PHP_EOL; - $sqlWhere[] = 'E.Id = ?'; - $sqlValues[] = $eid; - } - unset($eid); - $sql .= join(' OR ', $sqlWhere); - foreach( dbFetchAll( $sql, NULL, $sqlValues ) as $row ) { - if ( !isset($newEvent) ) { - $newEvent = $row; - } else { - if ( $newEvent['Cause'] && $newEvent['Cause'] != $row['Cause'] ) - $newEvent['Cause'] = ''; - if ( $newEvent['Notes'] && $newEvent['Notes'] != $row['Notes'] ) - $newEvent['Notes'] = ''; - } - } - - } else { // Event Mode not specified - should we really proceed if neither eid nor eids is set? - $title = translate('Events'); - } - - $result .= ''.PHP_EOL; - - return $result; -} - // Use this function to manually insert the csrf key into the form when using a modal generated via ajax call function getCSRFinputHTML() { if ( isset($GLOBALS['csrf']['key']) ) {