edit.php
changeset 1 58094faf794d
child 2 9a485c41cfcf
equal deleted inserted replaced
0:2cd8c1649ba9 1:58094faf794d
       
     1 <?php
       
     2 
       
     3 // +--------------------------------------------------------------------+
       
     4 // | PowerAdmin								|
       
     5 // +--------------------------------------------------------------------+
       
     6 // | Copyright (c) 1997-2002 The PowerAdmin Team			|
       
     7 // +--------------------------------------------------------------------+
       
     8 // | This source file is subject to the license carried by the overal	|
       
     9 // | program PowerAdmin as found on http://poweradmin.sf.net		|
       
    10 // | The PowerAdmin program falls under the QPL License:		|
       
    11 // | http://www.trolltech.com/developer/licensing/qpl.html		|
       
    12 // +--------------------------------------------------------------------+
       
    13 // | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
       
    14 // |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
       
    15 // +--------------------------------------------------------------------+
       
    16 
       
    17 //
       
    18 // $Id: edit.php,v 1.12 2003/05/10 20:10:47 azurazu Exp $
       
    19 //
       
    20 
       
    21 require_once("inc/toolkit.inc.php");
       
    22 
       
    23 // Assigning records to user: Check for records owned by user
       
    24 
       
    25 if (isset($_POST["action"]) && $_POST["action"]=="record-user") {
       
    26    foreach ($_POST["rowid"] as $x_user => $x_value){
       
    27       $x_userid = $db->getOne("SELECT id FROM record_owners WHERE user_id = '".$_POST["userid"]."' AND record_id='".$x_value."'");
       
    28       if (empty($x_userid)) {
       
    29          $db->query("INSERT INTO record_owners SET user_id = '".$_POST["userid"]."',record_id='".$x_value."'");
       
    30       }
       
    31    }
       
    32 }
       
    33 
       
    34 $server_types = array("MASTER", "SLAVE", "NATIVE");
       
    35 
       
    36 if(isset($_POST['type_change']) && in_array($_POST['newtype'], $server_types))
       
    37 {
       
    38     change_domain_type($_POST['newtype'], $_GET['id']);
       
    39 }
       
    40 if(isset($_POST["newowner"]) && is_numeric($_POST["domain"]) && is_numeric($_POST["newowner"]))
       
    41 {
       
    42 	add_owner($_POST["domain"], $_POST["newowner"]);
       
    43 }
       
    44 
       
    45 if(isset($_POST["del_user"]) && is_numeric($_POST["del_user"]) && level(5))
       
    46 {
       
    47 	delete_owner($_GET["id"], $_POST["del_user"]);
       
    48 }
       
    49 
       
    50 include_once("inc/header.inc.php");
       
    51 ?>
       
    52 <H2>Edit domain "<?= get_domain_name_from_id($_GET["id"]) ?>"</H2>
       
    53 <?
       
    54 $info = get_domain_info_from_id($_GET["id"]);
       
    55 if(!isset($info["ownerid"]))
       
    56 {
       
    57 	?>
       
    58 	<P CLASS="warning">This domain isnt owned by anyone yet, please assign someone</P>
       
    59 	<?
       
    60 }
       
    61 ?>
       
    62 
       
    63 <TABLE class="text" cellspacing="0" style="width: 280px">
       
    64 <? if (level(5)) 
       
    65 { ?>	
       
    66 	<TR>
       
    67 		<FORM METHOD="post" ACTION="edit.php?id=<?=$_GET['id']?>">
       
    68 		<TD CLASS="none" VALIGN="middle" style="width: 250px;">
       
    69 			<B>Add an owner:</B>
       
    70 			<INPUT TYPE="hidden" NAME="domain" VALUE="<?= $_GET["id"] ?>">
       
    71 			<SELECT NAME="newowner">
       
    72 			<?
       
    73 			$users = show_users();
       
    74 			foreach ($users as $u)
       
    75 			{
       
    76 				unset($add);
       
    77 				if ($u["id"] == $info["ownerid"])
       
    78 				{
       
    79 					$add = " SELECTED";
       
    80 				}
       
    81 				?>
       
    82 				<OPTION<?= $add ?> VALUE="<?= $u["id"] ?>"><?= $u["fullname"] ?></OPTION><?
       
    83 			}
       
    84 			?>
       
    85 			</SELECT>
       
    86 		</TD>
       
    87 		<TD CLASS="none" VALIGN="middle"  align="right">
       
    88 			<INPUT TYPE="submit" CLASS="sbutton" NAME="co" VALUE="add">
       
    89 		</TD>
       
    90 		</FORM>
       
    91 	</TR>
       
    92 	<TR>
       
    93 		<TD CLASS="text">&nbsp;</TD>
       
    94 	</TR>
       
    95 <? 
       
    96 
       
    97 if(isset($info["ownerid"]))
       
    98 {?>
       
    99 	<TR>
       
   100 		<TD CLASS="text" ALIGN="left" COLSPAN="2" style="width:150px;">
       
   101 			<B>Current listed owners:</B>
       
   102 		</TD>
       
   103 	</TR>
       
   104 	<?
       
   105 	$userRes = get_users_from_domain_id($_GET["id"]);
       
   106 	foreach($userRes as $user)
       
   107 	{ ?>
       
   108 		<TR>
       
   109 			<FORM METHOD="post" ACTION="edit.php?id=<?=$_GET['id']?>">
       
   110 			<TD CLASS="text" ALIGN="left" style="width:150px;">
       
   111 				<?=$user["fullname"]?>
       
   112 			</TD>
       
   113 			<TD CLASS="text" align="right">
       
   114 				<INPUT TYPE="hidden" NAME="del_user" VALUE="<?=$user["id"]?>">
       
   115 				<INPUT TYPE="submit" CLASS="sbutton" NAME="co" VALUE="delete">
       
   116 			</TD>
       
   117 			</FORM>
       
   118 		</TR>
       
   119 	<? }
       
   120 }} ?>
       
   121 
       
   122 
       
   123 <? if(level(5) && $MASTER_SLAVE_FUNCTIONS)
       
   124 {
       
   125     $domain_type=get_domain_type($_GET['id']);
       
   126     // Let the user change the domain type.
       
   127 ?>
       
   128         <TR>
       
   129             <TD CLASS="text">&nbsp;</TD>
       
   130         </TR>
       
   131 		<TR>
       
   132 			<TD CLASS="text" COLSPAN="2"><B>Type of this domain: </B><?=$domain_type?></TD>
       
   133 		</TR>
       
   134 		<FORM ACTION="<?=$_SERVER['PHP_SELF']?>?&amp;id=<?=$_GET['id']?>" METHOD="post">
       
   135 		<TR>
       
   136             <TD CLASS="text"><B>Change type: </B>
       
   137                 <SELECT NAME="newtype">
       
   138                 <?
       
   139                 foreach($server_types as $s)
       
   140                 {
       
   141                     unset($add);
       
   142 				    if ($s == $domain_type)
       
   143 				    {
       
   144 					   $add = " SELECTED";
       
   145 				    }
       
   146                     ?><OPTION<?=$add ?> VALUE="<?=$s?>"><?=$s?></OPTION><?
       
   147                 }
       
   148                 ?>
       
   149                 </SELECT>
       
   150             </TD>
       
   151             <TD CLASS="text">
       
   152                 <INPUT TYPE="submit" CLASS="sbutton" NAME="type_change" VALUE="change">
       
   153             </TD>
       
   154         </TR>
       
   155         </FORM>
       
   156 <? } ?>
       
   157 </TABLE>
       
   158 <br />
       
   159 <FONT CLASS="nav">
       
   160 <A HREF="index.php">DNS Admin</A> &gt;&gt; <?= get_domain_name_from_id($_GET["id"]) ?>
       
   161 </FONT>
       
   162 <br /><br /><small><b>Number of records:</b> <?= $info["numrec"] ?>
       
   163 
       
   164 <?
       
   165 show_pages($info["numrec"],ROWAMOUNT,$_GET["id"]);
       
   166 ?>
       
   167 
       
   168 <br /><br />
       
   169 
       
   170 <form action="<?=$_SERVER["PHP_SELF"]?>?id=<?=$_GET["id"]?>" method="post">
       
   171 <input type="hidden" name="action" value="record-user" />
       
   172 
       
   173 <TABLE BORDER="0" CELLSPACING="4">
       
   174 <?
       
   175 
       
   176 $countinput=0;
       
   177 
       
   178 $rec_result = get_records_from_domain_id($_GET["id"],ROWSTART,ROWAMOUNT);
       
   179 
       
   180 if($rec_result != -1)
       
   181 {
       
   182 	?>
       
   183 	<TR STYLE="font-weight: Bold;">
       
   184 	<TD CLASS="tdbg">&nbsp;</TD>
       
   185 	<? if (level(10)) { echo "<TD CLASS=\"tdbg\">Sub-Owners</TD>"; } ?>
       
   186 	<TD CLASS="tdbg">Name</TD>
       
   187 	<TD CLASS="tdbg">Type</TD>
       
   188 	<TD CLASS="tdbg">Content</TD>
       
   189 	<TD CLASS="tdbg">Priority</TD>
       
   190 	<TD CLASS="tdbg">TTL</TD>
       
   191 	</TR>
       
   192 	<?
       
   193 	$recs = sort_zone($rec_result);
       
   194 	foreach($recs as $r)
       
   195 	{
       
   196 	        ?><TR><TD CLASS="tdbg"><?
       
   197 
       
   198 	        if(level(5) || (!($r["type"] == "SOA" && !$GLOBALS["ALLOW_SOA_EDIT"]) && !($r["type"] == "NS" && !$GLOBALS["ALLOW_NS_EDIT"])))
       
   199 	        {
       
   200                 // get_name_from_record_id($r["id"]) != get_domain_name_from_id(recid_to_domid($r["id"])) <-- hmm..
       
   201                 ?>
       
   202 	            <A HREF="edit_record.php?id=<?= $r['id'] ?>&amp;domain=<?= $_GET["id"] ?>"><IMG SRC="images/edit.gif" ALT="[ edit record ]" BORDER="0"></A>
       
   203 	            <A HREF="delete_record.php?id=<?= $r['id'] ?>&amp;domain=<?= $_GET["id"] ?>"><IMG SRC="images/delete.gif" ALT="[ delete record ]" BORDER="0"></A>
       
   204 	            <?
       
   205 	        }
       
   206 
       
   207 if(level(10)) { ?>
       
   208 
       
   209 <input type="checkbox" name="rowid[<?=$countinput++?>]" value="<?=$r['id']?>" />
       
   210 
       
   211 <? }
       
   212 		
       
   213 	        ?></TD>
       
   214 		
       
   215 <? if (level(10)) { ?>
       
   216 		<TD STYLE="border: 1px solid #000;width:120px">
       
   217 <?
       
   218 $x_result = $db->query("SELECT r.user_id,u.username FROM record_owners as r, users as u WHERE r.record_id='".$r['id']."' AND u.id=r.user_id");
       
   219 echo "<select style=\"width:120px;font-size:9px\">";
       
   220 while ($x_r = $x_result->fetchRow()) {
       
   221    echo "<option>".$x_r["username"]."</option>";
       
   222 }
       
   223 echo "</select>";
       
   224 ?>
       
   225 		</TD>
       
   226 <? } ?>
       
   227 		<TD STYLE="border: 1px solid #000000;"><?= $r['name'] ?></TD><TD STYLE="border: 1px solid #000000;"><?= $r['type'] ?></TD><TD STYLE="border: 1px solid #000000;"><?= $r['content'] ?></TD><?
       
   228 	        if ($r['prio'] != 0) {
       
   229 	                ?><TD STYLE="border: 1px solid #000000;"><?= $r['prio']; ?></TD><?
       
   230 	        } else {
       
   231 	                ?><TD CLASS="tdbg"></TD><?
       
   232 	        }
       
   233 	        ?><TD STYLE="border: 1px solid #000000;"><?= $r['ttl'] ?></TD></TR>
       
   234 	        <?
       
   235 	}
       
   236 }
       
   237 else
       
   238 {
       
   239 	?>
       
   240 	<TR>
       
   241 	<TD CLASS="tdbg"><DIV CLASS="warning">No records for this domain</DIV></TD>
       
   242 	</TR>
       
   243 	<?
       
   244 }
       
   245 ?>
       
   246 
       
   247 </TABLE>
       
   248 
       
   249 <? if (level(10)) { ?>
       
   250 <br>
       
   251 
       
   252 <img src="images/arrow.png" alt="arrow" style="margin-left:47px"/>
       
   253 <select name="userid">
       
   254 <?
       
   255 $users = show_users();
       
   256 foreach ($users as $user) {
       
   257 	echo "<option value=\"".$user[id]."\">".$user[fullname]."</option>";
       
   258 }
       
   259 ?>
       
   260 </select>
       
   261 
       
   262 <input type="submit" class="button" value="Assign to user">
       
   263 </form>
       
   264 <? } ?>
       
   265 
       
   266 <BR><BR>
       
   267 
       
   268 <?
       
   269 if ($_SESSION[$_GET["id"]."_ispartial"] != 1)  {
       
   270 ?>
       
   271 <INPUT TYPE="button" CLASS="button" OnClick="location.href='add_record.php?id=<?= $_GET["id"] ?>'" VALUE="Add record">
       
   272 <?
       
   273 }
       
   274 ?>
       
   275 
       
   276 <? if (level(5)) { ?>&nbsp;&nbsp;<INPUT TYPE="button" CLASS="button" OnClick="location.href='delete_domain.php?id=<?= $_GET["id"] ?>'" VALUE="Delete zone"><?
       
   277 }
       
   278 include_once("inc/footer.inc.php");
       
   279 ?>