zoneminder/web/ajax/modal.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2020-09-11 05:56:58 +08:00
<?php
// HOW TO IMPLEMENT A NEW MODAL
// 1) Create a function in skins/classic/includes/functions that returns the desired modal HTML
// 2) Add a new entry to the switch case below that calls the new HTML function
// 3) Create a $j.getJSON Ajax call in js with the right parameters to retrieve the modal
// 4) Open the modal with $j('#myModal').modal('show')
//
// Should only report json
error_reporting(0);
2020-09-11 05:56:58 +08:00
if ( empty($_REQUEST['modal']) ) ajaxError('Modal Name Not Provided');
2020-09-11 20:51:00 +08:00
global $OLANG;
2020-09-11 05:56:58 +08:00
$modal = validJsStr($_REQUEST['modal']);
$data = array();
switch ( $modal ) {
case 'optionhelp' :
if ( empty($_REQUEST['ohndx']) ) ajaxError('Option Help Index Not Provided');
2020-09-11 20:51:00 +08:00
$data['html'] = getOptionHelpHTML($_REQUEST['ohndx'], $OLANG);
2020-09-11 05:56:58 +08:00
break;
2020-09-12 21:36:19 +08:00
case 'enoperm' :
$data['html'] = getENoPermHTML();
break;
2020-09-13 23:39:51 +08:00
case 'delconfirm' :
$data['html'] = getDelConfirmHTML();
break;
2020-09-14 22:50:04 +08:00
case 'storage' :
if ( !isset($_REQUEST['id']) ) ajaxError('Storage Id Not Provided');
$data['html'] = getStorageModalHTML($_REQUEST['id']);
break;
2020-09-16 21:30:45 +08:00
case 'server' :
if ( !isset($_REQUEST['id']) ) ajaxError('Storage Id Not Provided');
$data['html'] = getServerModalHTML($_REQUEST['id']);
break;
2020-09-15 02:47:09 +08:00
case 'eventdetail' :
2020-09-15 02:51:24 +08:00
$eid = isset($_REQUEST['eid']) ? $_REQUEST['eid'] : '';
$eids = isset($_REQUEST['eids']) ? $_REQUEST['eids'] : '';
2020-09-15 02:47:09 +08:00
$data['html'] = getEventDetailHTML($eid, $eids);
break;
2020-09-11 05:56:58 +08:00
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
2020-09-11 05:56:58 +08:00
ajaxResponse($data);
return;
?>