Update to use object instead of db row

This commit is contained in:
Isaac Connor 2018-11-28 09:55:34 -05:00
parent cd13dda294
commit a89dd83565
1 changed files with 19 additions and 30 deletions

View File

@ -23,34 +23,23 @@ if ( !canEdit('System') ) {
return;
}
if ( $_REQUEST['id'] ) {
if ( !($newServer = dbFetchOne('SELECT * FROM Servers WHERE Id = ?', NULL, ARRAY($_REQUEST['id'])) ) ) {
$view = 'error';
return;
}
} else {
$newServer = array();
$newServer['Name'] = translate('NewServer');
$newServer['Protocol'] = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
$newServer['Hostname'] = '';
$newServer['PathToIndex'] = '/zm/index.php';
$newServer['PathToZMS'] = ZM_PATH_ZMS;
$newServer['zmstats'] = '';
$newServer['zmaudit'] = '';
$newServer['zmtrigger'] = '';
$Server = new Server($_REQUEST['id']);
if ( $_REQUEST['id'] and ! $Server->Id() ) {
$view = 'error';
return;
}
$focusWindow = true;
xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name());
?>
<body>
<div id="page">
<div id="header">
<h2><?php echo translate('Server').' - '.$newServer['Name'] ?></h2>
<h2><?php echo translate('Server').' - '.$Server->Name() ?></h2>
</div>
<div id="content">
<form name="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm(this, <?php echo empty($newServer['Name'])?'true':'false' ?>)">
<form name="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm(this, <?php echo empty($Server->Name())?'true':'false' ?>)">
<input type="hidden" name="view" value="<?php echo $view ?>"/>
<input type="hidden" name="object" value="server"/>
<input type="hidden" name="id" value="<?php echo validHtmlStr($_REQUEST['id']) ?>"/>
@ -58,47 +47,47 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
<tbody>
<tr>
<th scope="row"><?php echo translate('Name') ?></th>
<td><input type="text" name="newServer[Name]" value="<?php echo $newServer['Name'] ?>"/></td>
<td><input type="text" name="newServer[Name]" value="<?php echo $Server->Name() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Protocol') ?></th>
<td><input type="text" name="newServer[Protocol]" value="<?php echo $newServer['Protocol'] ?>"/></td>
<td><input type="text" name="newServer[Protocol]" value="<?php echo $Server->Protocol() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Hostname') ?></th>
<td><input type="text" name="newServer[Hostname]" value="<?php echo $newServer['Hostname'] ?>"/></td>
<td><input type="text" name="newServer[Hostname]" value="<?php echo $Server->Hostname() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Port') ?></th>
<td><input type="number" name="newServer[Port]" value="<?php echo $newServer['Port'] ?>"/></td>
<td><input type="number" name="newServer[Port]" value="<?php echo $Server->Port() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('PathToIndex') ?></th>
<td><input type="text" name="newServer[PathToIndex]" value="<?php echo $newServer['PathToIndex'] ?>"/></td>
<td><input type="text" name="newServer[PathToIndex]" value="<?php echo $Server->PathToIndex() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('PathToZMS') ?></th>
<td><input type="text" name="newServer[PathToZMS]" value="<?php echo $newServer['PathToZMS'] ?>"/></td>
<td><input type="text" name="newServer[PathToZMS]" value="<?php echo $Server->PathToZMS() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('RunStats') ?></th>
<td>
<input type="radio" name="newServer[zmstats]" value="1"<?php echo $newServer['zmstats'] ? ' checked="checked"' : '' ?>/> Yes
<input type="radio" name="newServer[zmstats]" value="0"<?php echo $newServer['zmstats'] ? '' : ' checked="checked"' ?>/> No
<input type="radio" name="newServer[zmstats]" value="1"<?php echo $Server->zmstats() ? ' checked="checked"' : '' ?>/> Yes
<input type="radio" name="newServer[zmstats]" value="0"<?php echo $Server->zmstats() ? '' : ' checked="checked"' ?>/> No
</td>
</tr>
<tr>
<th scope="row"><?php echo translate('RunAudit') ?></th>
<td>
<input type="radio" name="newServer[zmaudit]" value="1"<?php echo $newServer['zmaudit'] ? ' checked="checked"' : '' ?>/> Yes
<input type="radio" name="newServer[zmaudit]" value="0"<?php echo $newServer['zmaudit'] ? '' : ' checked="checked"' ?>/> No
<input type="radio" name="newServer[zmaudit]" value="1"<?php echo $Server->zmaudit() ? ' checked="checked"' : '' ?>/> Yes
<input type="radio" name="newServer[zmaudit]" value="0"<?php echo $Server->zmaudit() ? '' : ' checked="checked"' ?>/> No
</td>
</tr>
<tr>
<th scope="row"><?php echo translate('RunTrigger') ?></th>
<td>
<input type="radio" name="newServer[zmtrigger]" value="1"<?php echo $newServer['zmtrigger'] ? ' checked="checked"' : '' ?>/> Yes
<input type="radio" name="newServer[zmtrigger]" value="0"<?php echo $newServer['zmtrigger'] ? '' : ' checked="checked"' ?>/> No
<input type="radio" name="newServer[zmtrigger]" value="1"<?php echo $Server->zmtrigger() ? ' checked="checked"' : '' ?>/> Yes
<input type="radio" name="newServer[zmtrigger]" value="0"<?php echo $Server->zmtrigger() ? '' : ' checked="checked"' ?>/> No
</td>
</tr>
</tbody>