#include <infodrom.style>
#include "lt.style"
#include "functions.inc"
#include "edit.style"

<postgresconnect>

<ltpage title="Project Management -- URLs">

<?
  $error = false;

  if (!is_admin()) {
    echo  ("<p><b>You are not allowed to use this page.</b></p>");
    $error = true;
  } else {
    if (isset ($oid)) {
      $query = sprintf("SELECT url,description,visible,project FROM urls WHERE oid = %d", $oid);

      $sth = pg_exec($dbh, $query) or die ("Sorry, cannot execute query");

      if (pg_NumRows($sth) > 0) {
        $row = pg_fetch_array($sth, 0);

	if ($row['project'] != $LINUXTAG_AUTH['project']) {
  	  echo  ("<p><b>You are not allowed to edit this URL.</b></p>");
	  $error = true;
	}
      } else {
        echo  ("<p><b>Cannot fetch data.</b></p>");
        $error = true;
      }
    }
  }

  if (!$error) {
    if ($oid) {
      echo ("<p><b>Edit URL</b></p>");
    } else {
      echo ("<p><b>Add a new URL</b></p>");
    }
?>

<form method=post action=update.php3>
<input type=hidden name=type value=url>
<input type=hidden name=oid value="<? echo $oid; ?>">

<center><table cellpadding=0 cellspacing=1>

<row_input	name=url
		size=65
		title="<b>URL</b>"
		value="<? echo $row['url']; ?>"
		>
<row_input	name=description
		size=65
		title="<b>Description</b>"
		value="<? echo $row['description']; ?>"
		>
<row_checkbox	name=visible
		title="<b>Visible</b>"
		descr="Publically visible"
		checked="<? if ($row['visible'] == 1) { echo 'checked'; } ?>"
		>

<? if ($oid > 0) { ?>
<row_radiobox	name=delete
		title="<b>Delete</b>"
		checked_0="checked"
		checked_1=""
		>
<? } ?>

<row_submit>
</table></center>
</form>

<? } ?>
</ltpage>

# Local variables:
# mode: indented-text
# mode: auto-fill
# end:
