cec7e4a0f32d1b099e1e45fc5dbd5df9fd11c28d
[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 //$path = $contentManager->getContentPath($cid);
39
40 require(AT_INCLUDE_PATH.'header.inc.php');
41
42 if ($_GET['cid'] == 0) {
43         $msg->printErrors('ID_ZERO');
44         require(AT_INCLUDE_PATH.'footer.inc.php');
45         exit;
46 }
47
48 $children = $contentManager->getContent($_GET['cid']);
49
50 $hidden_vars['cid'] = $_GET['cid'];
51
52 if (is_array($children) && (count($children)>0) ) {
53         $msg->addConfirm('SUB_CONTENT_DELETE', $hidden_vars);
54         $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
55 } else {
56         $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
57 }
58         
59 $sql = "SELECT * from ".TABLE_PREFIX."content WHERE content_id = '$hidden_vars[cid]'";
60 $result = mysql_query($sql, $db);
61 while ($row = mysql_fetch_assoc($result)){
62         $title = $row['title'];
63 }
64
65 $msg->addConfirm(array('DELETE', $title),  $hidden_vars);
66 $msg->printConfirm();
67         
68 require(AT_INCLUDE_PATH.'footer.inc.php');
69 ?>