changed git call from https to git readonly
[atutor.git] / mods / certificate / certificate_delete.php
1 <?php\r
2 /****************************************************************************/\r
3 /* ATutor                                                                                                                                       */\r
4 /****************************************************************************/\r
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton        */\r
6 /* Adaptive Technology Resource Centre / University of Toronto                          */\r
7 /* http://atutor.ca                                                                                                                     */\r
8 /*                                                                                                                                                      */\r
9 /* This program is free software. You can redistribute it and/or                        */\r
10 /* modify it under the terms of the GNU General Public License                          */\r
11 /* as published by the Free Software Foundation.                                                        */\r
12 /****************************************************************************/\r
13 // $Id: certificate_delete.php 7208 2008-02-20 16:07:24Z cindy $\r
14 \r
15 define('AT_INCLUDE_PATH', '../../include/');\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
17 authenticate(AT_PRIV_CERTIFICATE);\r
18 \r
19 if (isset($_POST['submit_no'])) {\r
20         $msg->addFeedback('CANCELLED');\r
21         header('Location: index_instructor.php');\r
22         exit;\r
23 } else if (isset($_POST['submit_yes'])) {\r
24         /* delete has been confirmed, delete this category */\r
25         $certificate_id = intval($_POST['certificate_id']);\r
26 \r
27         $sql = "DELETE FROM ".TABLE_PREFIX."certificate WHERE certificate_id=$certificate_id";\r
28         $result = mysql_query($sql, $db) or die(mysql_error());\r
29 \r
30         write_to_log(AT_ADMIN_LOG_DELETE, 'certificate', mysql_affected_rows($db), $sql);\r
31 \r
32         $sql = "DELETE FROM ".TABLE_PREFIX."certificate_text WHERE certificate_id=$certificate_id";\r
33         $result = mysql_query($sql, $db) or die(mysql_error());\r
34 \r
35         write_to_log(AT_ADMIN_LOG_DELETE, 'certificate_text', mysql_affected_rows($db), $sql);\r
36 \r
37         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
38         header('Location: index_instructor.php');\r
39         exit;\r
40 }\r
41 \r
42 //require('../../include/header.inc.php');\r
43 require(AT_INCLUDE_PATH.'header.inc.php');\r
44 \r
45 $_GET['certificate_id'] = intval($_GET['certificate_id']); \r
46 \r
47 $sql = "SELECT certificate_id, title FROM ".TABLE_PREFIX."certificate c, ".TABLE_PREFIX."tests t WHERE c.certificate_id=$_GET[certificate_id] and c.test_id=t.test_id";\r
48 $result = mysql_query($sql,$db) or die(mysql_error());\r
49 \r
50 if (mysql_num_rows($result) == 0) {\r
51         $msg->printErrors('ITEM_NOT_FOUND');\r
52 } else {\r
53         $row = mysql_fetch_assoc($result);\r
54         \r
55         $hidden_vars['title']= $row['title'];\r
56         $hidden_vars['certificate_id']  = $row['certificate_id'];\r
57 \r
58         $confirm = array('DELETE_CERTIFICATE', $row['title']);\r
59         $msg->addConfirm($confirm, $hidden_vars);\r
60         \r
61         $msg->printConfirm();\r
62 }\r
63 \r
64 require(AT_INCLUDE_PATH.'footer.inc.php');\r
65 \r
66 ?>