fix the bug that once the a content is deleted from the lesson via "delete content...
[acontent.git] / docs / home / editor / delete_content.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 define('TR_INCLUDE_PATH', '../../include/');
14 require(TR_INCLUDE_PATH.'vitals.inc.php');
15
16 global $_content_id, $_content_id, $contentManager;
17
18 Utility::authenticate(TR_PRIV_ISAUTHOR);
19
20 $cid = $_GET['cid'] = $_content_id;
21
22 if (isset($_POST['submit_yes'])) {
23
24         $cid = intval($_POST['_cid']);
25
26         $result = $contentManager->deleteContent($cid);
27
28         $msg->addFeedback('CONTENT_DELETED');
29         header('Location: '.TR_BASE_HREF.'home/course/index.php?_course_id='.$_course_id);
30         exit;
31 } else if (isset($_POST['submit_no'])) {
32         $msg->addFeedback('CANCELLED');
33         $cid = intval($_POST['_cid']);
34         $row = $contentManager->getContentPage($cid);
35         if ($row['content_type'] == CONTENT_TYPE_FOLDER) {
36                 header('Location: '.TR_BASE_HREF.'home/editor/edit_content_folder.php?_cid='.$cid);
37         } else {
38                 header('Location: '.TR_BASE_HREF.'home/course/content.php?_cid='.$cid);
39         }
40         exit;
41 }
42
43 $path   = $contentManager->getContentPath($cid);
44 require(TR_INCLUDE_PATH.'header.inc.php');
45
46 if ($_GET['cid'] == 0) {
47         $msg->printErrors('ID_ZERO');
48         require(TR_INCLUDE_PATH.'footer.inc.php');
49         exit;
50 }
51
52 $children = $contentManager->getContent($_GET['cid']);
53
54 $hidden_vars['_cid'] = $_GET['cid'];
55
56 if (is_array($children) && (count($children)>0) ) {
57         $msg->addConfirm('SUB_CONTENT_DELETE', $hidden_vars);
58 //      $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
59 //} else {
60 //      $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
61 }
62         
63 $row = $contentManager->getContentPage($_GET['cid']);
64 $title = $row['title'];
65
66 $msg->addConfirm(array('DELETE', $title),  $hidden_vars);
67 $msg->printConfirm();
68         
69 require(TR_INCLUDE_PATH.'footer.inc.php');
70 ?>