2 /****************************************************************************/
4 /****************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton */
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************************/
13 // $Id: certificate_delete.php 7208 2008-02-20 16:07:24Z cindy $
15 define('AT_INCLUDE_PATH', '../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_CERTIFICATE);
19 if (isset($_POST['submit_no'])) {
20 $msg->addFeedback('CANCELLED');
21 header('Location: index_instructor.php');
23 } else if (isset($_POST['submit_yes'])) {
24 /* delete has been confirmed, delete this category */
25 $certify_id = intval($_POST['certify_id']);
27 //$sql = 'DELETE members FROM '.TABLE_PREFIX.'certify AS certify INNER JOIN '.TABLE_PREFIX.'certify_members AS members WHERE certify.certify_id='.$_POST['certify_id'].' AND certify.certify_id=members.certify_id';
28 //mysql_query($sql, $db) or die('1:'.mysql_error());
29 $sql = 'DELETE tests FROM '.TABLE_PREFIX.'certify AS certify INNER JOIN '.TABLE_PREFIX.'certify_tests AS tests WHERE certify.certify_id='.$_POST['certify_id'].' AND certify.certify_id=tests.certify_id';
30 mysql_query($sql, $db) or die('2:'.mysql_error());
31 $sql = 'DELETE FROM '.TABLE_PREFIX.'certify WHERE '.TABLE_PREFIX.'certify.certify_id='.$_POST['certify_id'];
32 mysql_query($sql, $db) or die('3:'.mysql_error());
34 write_to_log(AT_ADMIN_LOG_DELETE, 'certify', mysql_affected_rows($db), $sql);
36 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
40 $sql = "DELETE FROM ".TABLE_PREFIX."certificate WHERE certify_id=$certify_id";
41 $result = mysql_query($sql, $db) or die(mysql_error());
43 write_to_log(AT_ADMIN_LOG_DELETE, 'certificate', mysql_affected_rows($db), $sql);
45 $sql = "DELETE FROM ".TABLE_PREFIX."certificate_text WHERE certify_id=$certify_id";
46 $result = mysql_query($sql, $db) or die(mysql_error());
48 write_to_log(AT_ADMIN_LOG_DELETE, 'certificate_text', mysql_affected_rows($db), $sql);
50 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
54 header('Location: index_instructor.php');
58 //require('../../include/header.inc.php');
59 require(AT_INCLUDE_PATH.'header.inc.php');
61 $_GET['certify_id'] = intval($_GET['certify_id']);
63 $sql = "SELECT certify_id, title FROM ".TABLE_PREFIX."certify c WHERE c.certify_id=$_GET[certify_id]";
64 $result = mysql_query($sql,$db) or die(mysql_error());
66 if (mysql_num_rows($result) == 0) {
67 $msg->printErrors('ITEM_NOT_FOUND');
69 $row = mysql_fetch_assoc($result);
71 $hidden_vars['title']= $row['title'];
72 $hidden_vars['certify_id'] = $row['certify_id'];
74 $confirm = array('DELETE_CERTIFICATE', $row['title']);
75 $msg->addConfirm($confirm, $hidden_vars);
80 require(AT_INCLUDE_PATH.'footer.inc.php');