blob: fbf34ce153379ca0ef4345cabf0d239cb9f21b02 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2006 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wayne Beaton (Eclipse Foundation)- initial API and implementation
*******************************************************************************/
#*****************************************************************************
#
# add_resource.php
#
# Author: Wayne Beaton
# Date: February 16, 2006
#
# Description:
# This file is used to create a new resource.
#****************************************************************************
include("scripts/common.php");
include("scripts/sql.php");
include("scripts/header.php");
function get_selected($parameter, $value) {
return get_parameter($parameter) == $value ? 'selected' : '';
}
$broker = new ResourceBroker();
if (get_parameter('update')) {
$id = get_parameter('author_id');
$name = get_parameter('author_name');
$email = get_parameter('author_email');
$company = get_parameter('author_company');
$url = get_parameter('author_url');
$broker->update_author($id, $name, $email, $company, $url);
} else if (get_parameter('delete')) {
$id = get_parameter('author_id');
$broker->delete_author($id);
}
display_messages($broker->messages);
?>
<script language="javascript" type="text/javascript">
function confirm_delete() {
return confirm("Are you sure you want to delete this author?");
}
</script>
<div class="section">
<h3>Add Resource</h3>
<table border="1">
<tr><th>Name</th><th>email</th><th>Company</th><th>URL</th><th>#</th></tr>
<?php
$result = mysql_query('select author.id, author.name, author.email, author.company, author.link, count(link_author.author_id) from author left join link_author on (author.id = link_author.author_id) group by author.name order by author.name');
if ($error = mysql_error()) {
echo "Error querying authors: $error<br/>";
break;
}
while ($row = mysql_fetch_array($result)) {
$id = $row[0];
$name = $row[1];
$email = $row[2];
$company = $row[3];
$url = $row[4];
$count = $row[5];
?>
<form method="post" action="edit_author.php">
<input type="hidden" name="author_id" value="<?= $id ?>"/>
<tr <?= $count == 0 ? 'style="background:red;color:white;font-weight:bold"' : ''?>>
<td><input type="text" style="border-style:none;width: 150px;" name="author_name" value="<?= $name ?>"/></td>
<td><input type="text" style="border-style:none;width: 100px;" name="author_email" value="<?= $email ?>"/></td>
<td><input type="text" style="border-style:none;width: 100px;" name="author_company" value="<?= $company ?>"/></td>
<td><input type="text" style="border-style:none;width: 100px;" name="author_url" value="<?= $url ?>"/></td>
<td><?= $count ?></td>
<td>
<input type="submit" name="update" value="Update"/>
<input type="submit" name="delete" value="Delete" onclick="return confirm_delete();"/>
</td>
</tr>
</form>
<?php
}
?>
</table>
</div>
<?php
include("scripts/footer.php");
?>