fbeb89994639bdb40ca1809946076427f1646631
[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         unset($_SESSION['s_cid']);
29         unset($_SESSION['from_cid']);
30                 
31         $msg->addFeedback('CONTENT_DELETED');
32         header('Location: '.TR_BASE_HREF.'home/course/index.php?_course_id='.$_course_id);
33         exit;
34 } else if (isset($_POST['submit_no'])) {
35         $msg->addFeedback('CANCELLED');
36         $cid = intval($_POST['_cid']);
37         $row = $contentManager->getContentPage($cid);
38         if ($row['content_type'] == CONTENT_TYPE_FOLDER) {
39                 header('Location: '.TR_BASE_HREF.'home/editor/edit_content_folder.php?_cid='.$cid);
40         } else {
41                 header('Location: '.TR_BASE_HREF.'home/course/content.php?_cid='.$cid);
42         }
43         exit;
44 }
45
46 $path   = $contentManager->getContentPath($cid);
47 require(TR_INCLUDE_PATH.'header.inc.php');
48
49 if ($_GET['cid'] == 0) {
50         $msg->printErrors('ID_ZERO');
51         require(TR_INCLUDE_PATH.'footer.inc.php');
52         exit;
53 }
54
55 $children = $contentManager->getContent($_GET['cid']);
56
57 $hidden_vars['_cid'] = $_GET['cid'];
58
59 if (is_array($children) && (count($children)>0) ) {
60         $msg->addConfirm('SUB_CONTENT_DELETE', $hidden_vars);
61 //      $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
62 //} else {
63 //      $msg->addConfirm('GLOSSARY_REMAINS', $hidden_vars);
64 }
65         
66 $row = $contentManager->getContentPage($_GET['cid']);
67 $title = $row['title'];
68
69 $msg->addConfirm(array('DELETE', $title),  $hidden_vars);
70 $msg->printConfirm();
71         
72 require(TR_INCLUDE_PATH.'footer.inc.php');
73 ?>