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.]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
     1
<?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
if (isset($_GET["delid"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
   $db->query("DELETE FROM record_owners WHERE id='".$_GET["delid"]."'");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
$xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['recordid'];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
if(!xs(recid_to_domid($xsid)))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
    error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
if ($_POST["commit"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
        edit_record($_POST["recordid"], $_POST["domainid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
        clean_page("edit.php?id=".$_POST["domainid"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
} elseif($_SESSION["partial_".get_domain_name_from_id($_GET["domain"])] == 1)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
{
37
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    22
    $checkPartial = $db->queryOne("SELECT id FROM record_owners WHERE record_id='".$_GET["id"]."' AND user_id='".$_SESSION["userid"]."' LIMIT 1");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
    if (empty($checkPartial)) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
        error(ERR_RECORD_ACCESS_DENIED);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    27
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    28
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    29
    <h2><? echo _('Edit record in zone'); ?> "<? echo  get_domain_name_from_id($_GET["domain"]) ?>"</h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    30
<?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    32
$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");
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    33
if (level(10) && ($x_result->numRows() > 0)) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    34
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    35
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    36
    <div id="meta">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    37
     <div id="meta-left">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    38
      <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    39
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    40
        <th><? echo _('Sub-owners'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    41
        <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    42
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    43
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    44
	while ($x_r = $x_result->fetchRow()) 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    45
	{
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    47
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    48
	 <td class="tdbg"><? echo $x_r["fullname"]; ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    49
	 <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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    50
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    51
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    52
	}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    53
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    54
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    55
      </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    56
     </div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    57
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    58
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    59
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    60
    <form method="post" action="edit_record.php">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    61
     <input type="hidden" name="recordid" value="<? echo  $_GET["id"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    62
     <input type="hidden" name="domainid" value="<? echo  $_GET["domain"] ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    63
     <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    64
      <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    65
       <th><? echo _('Name'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    66
       <th>&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    67
       <th><? echo _('Type'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    68
       <th><? echo _('Priority'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    69
       <th><? echo _('Content'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    70
       <th><? echo _('TTL'); ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    71
      </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
	$rec = get_record_from_id($_GET["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    75
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    76
        <td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    77
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    78
if ($_SESSION[$_GET["domain"]."_ispartial"] == 1)  
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    79
{
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    80
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    81
         <input type="hidden" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.')?>" class="input">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    83
<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    84
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    85
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    86
else 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    87
{ 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    88
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    89
         <input type="text" name="name" value="<? echo  trim(str_replace(get_domain_name_from_id($_GET["domain"]), '', $rec["name"]), '.') ?>" class="input">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    90
<? 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    91
} 
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    92
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    93
.<? echo  get_domain_name_from_id($_GET["domain"]) ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    94
        </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    95
	<td class="n">IN</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    96
	<td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
    97
	 <select name="type">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
foreach (get_record_types() as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	if ($c == $rec["type"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
		$add = " SELECTED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
		$add = "";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   110
	<option<? echo  $add ?> value="<? echo  $c ?>"><? echo  $c ?></option><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   114
         </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   115
	</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   116
	<td><input type="text" name="prio" value="<? echo  $rec["prio"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   117
	<td><input type="text" name="content" value="<? echo  $rec["content"] ?>" class="input"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   118
	<td><input type="text" name="ttl" value="<? echo  $rec["ttl"] ?>" class="sinput"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   119
       </tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   120
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   121
      <p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   122
       <input type="submit" name="commit" value="<? echo _('Commit changes'); ?>" class="button">&nbsp;&nbsp;
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   123
       <input type="reset" name="reset" value="<? echo _('Reset changes'); ?>" class="button">
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   124
      </p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   125
     </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
<?
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 3
diff changeset
   127
include_once("inc/footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
?>