edit_record.php
author rejo
Tue, 10 Jul 2007 21:24:06 +0000
changeset 37 b785e54690ce
parent 13 2ff220cfde13
child 47 ae140472d97c
permissions -rw-r--r--
[feladat @ 84] Bugfix. The function zone_count() now also counts zones an owner has only partial access to, not just those zones the owner has full access to. This fixes just the count, the zones a user has partial access to are not (yet!) shown in the "list zones" page. Bugfix. In the zone listing the "edit" button is now show for users with access level 1. Untill now they were presented an overview of the zones they could change, but there was no link for them to actually edit the zone. Bugfix. Some of the buttons in the "edit zone" interface that are of no use to a user with access level 1 have been hidden. Bugfix. Make sure a user with access level 1 with only partial access to a zone cannot add new records to that zone. Only the zone owner should be able to add new record. Bugfix. If a user with access level 1 edits a record in a zone he has only partial access to, an error was shown because of call to a non- existing function in the PEAR:MDB2. This bug was most likely introduced while migrating from PEAR:DB to PEAR:MDB2. Bugfix. A user with access level 1 was able to delete all records of a zone he has only partial access to. Some additional checks have been added. Bugfix. If a user with accees level 1 has partial access to one or more zones starting with a certain character, but did not own at least one entire zone starting with the same character, the character wasn't clickable in the "list zone" page. Interface. If no record or zone id is given for delete_record.php or delete_domain.php, don't just die but echo a nice message. The i18n files have not yet been updated to reflect this change. Interface. If no master IP is given in delete_supermaster.php, don't just die but echo a nice message. The i18n files have not yet been updated to reflect this change. [All fixes by Peter Beernink.]

<?

require_once("inc/toolkit.inc.php");

if (isset($_GET["delid"])) {
   $db->query("DELETE FROM record_owners WHERE id='".$_GET["delid"]."'");
}

$xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['recordid'];

if(!xs(recid_to_domid($xsid)))
{
    error(ERR_RECORD_ACCESS_DENIED);
}

if ($_POST["commit"])
{
        edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
        clean_page("edit.php?id=".$_POST["domainid"]);
} elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
{
    $checkPartial = $db->queryOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
    if (empty($checkPartial)) {
        error(ERR_RECORD_ACCESS_DENIED);
    }
}
include_once("inc/header.inc.php");
?>
    <h2><? echo _('Edit record in zone'); ?> "<? echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
<?

$x_result = $db->query("SELECT r.id,u.fullname FROM record_owners as r, users as u WHERE r.record_id='".$_GET['id']."' AND u.id=r.user_id");
if (level(10) && ($x_result->numRows() > 0)) 
{
?>
    <div id="meta">
     <div id="meta-left">
      <table>
       <tr>
        <th><? echo _('Sub-owners'); ?></td>
        <th>&nbsp;</td>
       </tr>
<?
	while ($x_r = $x_result->fetchRow()) 
	{
?>
        <tr>
	 <td class="tdbg"><? echo $x_r["fullname"]; ?></td>
	 <td class="tdbg"><a href="<? echo $_SERVER["PHP_SELF"]; ?>?id=<? echo $_GET["id"]; ?>&amp;domain=<? echo $_GET["domain"]; ?>&amp;delid=<? echo $x_r["id"]; ?>"><img src="images/delete.gif" alt="trash"></a></td>
	</tr>
<?
	}
?>
       </table>
      </div>
     </div>
<? 
}
?>
    <form method="post" action="edit_record.php">
     <input type="hidden" name="recordid" value="<? echo  $_GET["id"] ?>">
     <input type="hidden" name="domainid" value="<? echo  $_GET["domain"] ?>">
     <table>
      <tr>
       <th><? echo _('Name'); ?></td>
       <th>&nbsp;</td>
       <th><? echo _('Type'); ?></td>
       <th><? echo _('Priority'); ?></td>
       <th><? echo _('Content'); ?></td>
       <th><? echo _('TTL'); ?></td>
      </tr>
<?
	$rec = get_record_from_id($_GET["id"]);
?>
       <tr>
        <td>
<? 
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
{
?>
         <input type="hidden" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" class="input">

<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
<? 
} 
else 
{ 
?>
         <input type="text" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" class="input">
<? 
} 
?>
.<? echo  get_domain_name_from_id($_GET["domain"]) ?>
        </td>
	<td class="n">IN</td>
	<td>
	 <select name="type">
<?
foreach (get_record_types() as $c)
{
	if ($c == $rec["type"])
	{
		$add = " SELECTED";
	}
	else
	{
		$add = "";
	}
	?>
	<option<? echo  $add ?> value="<? echo  $c ?>"><? echo  $c ?></option><?
}

?>
         </select>
	</td>
	<td><input type="text" name="prio" value="<? echo  $rec["prio"] ?>" class="sinput"></td>
	<td><input type="text" name="content" value="<? echo  $rec["content"] ?>" class="input"></td>
	<td><input type="text" name="ttl" value="<? echo  $rec["ttl"] ?>" class="sinput"></td>
       </tr>
      </table>
      <p>
       <input type="submit" name="commit" value="<? echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
       <input type="reset" name="reset" value="<? echo _('Reset changes'); ?>" class="button">
      </p>
     </form>
<?
include_once("inc/footer.inc.php");
?>