fa80d2067be5810bc66e919ed3dc7207aba81d25
[atutor.git] / docs / mods / _core / editor / delete_content.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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$
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17
18 if (isset($_POST['submit_yes'])) {
19
20         $_POST['cid'] = intval($_POST['cid']);
21
22         $result = $contentManager->deleteContent($_POST['cid']);
23
24         unset($_SESSION['s_cid']);
25         unset($_SESSION['from_cid']);
26                 
27         $msg->addFeedback('CONTENT_DELETED');
28         header('Location: '.AT_BASE_HREF.'mods/_core/content/index.php');
29         exit;
30 } else if (isset($_POST['submit_no'])) {
31         $msg->addFeedback('CANCELLED');
32         header('Location: '.AT_BASE_HREF.'mods/_core/content/index.php');
33         exit;
34 }
35
36 $_GET['cid'] = intval($_REQUEST['cid']);
37
38
39 require(AT_INCLUDE_PATH.'header.inc.php');
40
41 if ($_GET['cid'] == 0) {
42         $msg->printErrors('ID_ZERO');
43         require(AT_INCLUDE_PATH.'footer.inc.php');
44         exit;
45 }
46
47 $children = $contentManager->getContent($_GET['cid']);
48
49 $hidden_vars['cid'] = $_GET['cid'];
50
51 if (is_array($children) && (count($children)>0) ) {
52         $msg->addConfirm('SUB_CONTENT_DELETE', $hidden_vars);
53         $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
54 } else {
55         $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
56 }
57         
58 $sql = "SELECT * from ".TABLE_PREFIX."content WHERE content_id = '$hidden_vars[cid]'";
59 $result = mysql_query($sql, $db);
60 while ($row = mysql_fetch_assoc($result)){
61         $title = $row['title'];
62 }
63
64 $msg->addConfirm(array('DELETE', $title),  $hidden_vars);
65 $msg->printConfirm();
66         
67 require(AT_INCLUDE_PATH.'footer.inc.php');
68 ?>