| <?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 |
| *******************************************************************************/ |
| |
| #***************************************************************************** |
| # |
| # edit_category.php |
| # |
| # Author: Wayne Beaton |
| # Date: November 14, 2006 |
| # |
| # Description: |
| # This file is used to edit categories. |
| #**************************************************************************** |
| |
| 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('category_id'); |
| $name = get_parameter('category_name'); |
| $broker->update_category($id, $name); |
| } else if (get_parameter('delete')) { |
| $id = get_parameter('category_id'); |
| $broker->delete_category($id); |
| } |
| display_messages($broker->messages); |
| |
| ?> |
| <script language="javascript" type="text/javascript"> |
| function confirm_delete() { |
| return confirm("Are you sure you want to delete this category?"); |
| } |
| </script> |
| <div class="section"> |
| <h3>Edit Categories</h3> |
| <table style="border-style:solid;border-width:1px"> |
| <tr><th>Name</th><th>#</th></tr> |
| <?php |
| $result = mysql_query('select category.id, category.name, count(resource_category.resource_id) from category left join resource_category on (category.id = resource_category.category_id) group by category.name order by category.name'); |
| |
| if ($error = mysql_error()) { |
| echo "Error querying authors: $error<br/>"; |
| break; |
| } |
| while ($row = mysql_fetch_array($result)) { |
| $id = $row[0]; |
| $name = $row[1]; |
| $count = $row[2]; |
| ?> |
| <form method="post" action="edit_category.php""> |
| <input type="hidden" name="category_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="category_name" value="<?= $name ?>"/></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"); |
| ?> |