Skip to content

Commit

Permalink
change edit form to match RT style
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Root committed Aug 12, 2016
1 parent 510b743 commit a021003
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 174 deletions.
38 changes: 19 additions & 19 deletions wwwroot/inc/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -5984,28 +5984,28 @@ function releaseDBMutex ($name)
return $row === '1';
}

function getSNMPProfileList ()
function getSNMPProfile ($id = NULL)
{
$result = usePreparedSelectBlade
(
'SELECT id, name, version as ver, community, sec_name,
sec_level, auth_protocol, priv_protocol
FROM SNMPProfile'
);
return reindexById ($result->fetchAll (PDO::FETCH_ASSOC));
}

function getSNMPProfile ($id)
{
$result = usePreparedSelectBlade
(
'SELECT id, name, version as ver, community, sec_name,
$query = 'SELECT id, name, version as ver, community, sec_name,
sec_level, auth_protocol, auth_passphrase,
priv_protocol, priv_passphrase,
contextname, contextengineid
FROM SNMPProfile where id = ?', array ($id)
);
return $result->fetch (PDO::FETCH_ASSOC);
contextname, contextengineid,
(SELECT count(SNMPProfileMapping.profile_id) FROM SNMPProfileMapping WHERE SNMPProfileMapping.profile_id = SNMPProfile.id) as refs
FROM SNMPProfile';

$params = array();
if ($id !== NULL)
{
$query .= ' WHERE id = ?';
$params[] = $id;
}

$result = usePreparedSelectBlade ($query, $params);

if ($id !== NULL)
return $result->fetch (PDO::FETCH_ASSOC);
else
return reindexById ($result->fetchAll (PDO::FETCH_ASSOC));
}

function getObjectSNMPProfile ($object_id)
Expand Down
83 changes: 22 additions & 61 deletions wwwroot/inc/interface-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1165,17 +1165,17 @@ function renderSNMPProfiles ()
startPortlet ("SNMP Profiles");

$cols = array (
array ('row_key' => 'id', 'th_text' => 'Id'),
array ('row_key' => 'name', 'th_text' => 'Name'),
array ('row_key' => 'ver', 'th_text' => 'Version'),
array ('row_key' => 'community', 'th_text' => 'Community'),
array ('row_key' => 'sec_name', 'th_text' => 'Security Name'),
array ('row_key' => 'sec_level', 'th_text' => 'Security Level'),
array ('row_key' => 'auth_protocol', 'th_text' => 'Auth Protocol'),
array ('row_key' => 'priv_protocol', 'th_text' => 'Priv Protocol')
);

renderTableViewer ($cols, getSNMPProfileList ());
array ('row_key' => 'id', 'th_text' => 'Id'),
array ('row_key' => 'name', 'th_text' => 'Name'),
array ('row_key' => 'ver', 'th_text' => 'Version'),
array ('row_key' => 'community', 'th_text' => 'Community'),
array ('row_key' => 'sec_name', 'th_text' => 'Security Name'),
array ('row_key' => 'sec_level', 'th_text' => 'Security Level'),
array ('row_key' => 'auth_protocol', 'th_text' => 'Auth Protocol'),
array ('row_key' => 'priv_protocol', 'th_text' => 'Priv Protocol')
);

renderTableViewer ($cols, getSNMPProfile ());

finishPortlet ();
}
Expand All @@ -1184,70 +1184,31 @@ function renderSNMPProfilesEditor ()
{
startPortlet ("SNMP Profiles");

addSNMPProfileFormJS (TRUE);

echo '<table cellspacing=0 cellpadding=5 align=center class="widetable zebra">';
echo '<thead><tr>
<th></th>
<th>Id</th>
<th>Name</th>
<th>Version</th>
<th>Community</th>
<th>Security Name</th>
<th>Community/<br>Security Name</th>
<th>Security Level</th>
<th>Auth Protocol</th>
<th>Priv Protocol</th>
<th>Auth<br>Protocol</th>
<th>Auth<br>Passphrase</th>
<th>Priv<br>Protocol</th>
<th>Priv<br>Passphrase</th>
</tr></thead>';

echo '<tbody>';
foreach (getSNMPProfileList () as $profile)
printSNMPProfileFormFields (array ('id' => 'new'), FALSE, FALSE);
foreach (getSNMPProfile () as $profile)
{
$id = $profile['id'];
echo '<tr>';

echo "<td><a href=".makeHref (array ('page' => 'SNMPProfile', 'tab' => 'editprofile', 'id' => $id)).">$id</a></td>";
echo "<td>{$profile['name']}</td>";
echo "<td>{$profile['ver']}</td>";
echo "<td>{$profile['community']}</td>";
echo "<td>{$profile['sec_name']}</td>";
echo "<td>{$profile['sec_level']}</td>";
echo "<td>{$profile['auth_protocol']}</td>";
echo "<td>{$profile['priv_protocol']}</td>";
echo '<td>
<a href='.makeHrefProcess (array ('page' => 'SNMPProfile', 'tab' => 'editprofile', 'op' => 'delete', 'id' => $id)).'>'.
getImageHREF ('destroy', 'delete profile').
'</a></td>';

echo '</tr>';
printSNMPProfileFormFields ($profile, FALSE, FALSE);
}
echo '<tr>';

echo '<td>
<a href='.makeHref (array ('page' => 'SNMPProfile', 'tab' => 'editprofile', 'newprofile' => 1)).'>'.
getImageHREF ('create', 'add profile').
'</a></td>';
echo '<td colspan=8></td>';

echo '</tr>';
echo '</tbody></table>';

finishPortlet ();
}

function renderSNMPProfilesEditProfile ()
{
$newprofile = TRUE;
$profile = NULL;
if (! isset ($_GET['newprofile']))
{
$newprofile = FALSE;
$id = genericAssertion('id', 'uint');
$profile = getSNMPProfile($id);
startPortlet ("Edit profile '{$profile['name']}'");
}
else
startPortlet ('Edit new profile');

printSNMPProfileForm ($profile, $newprofile, TRUE);

finishPortlet ();
}

?>
Loading

0 comments on commit a021003

Please sign in to comment.