remove old readme
[atutor.git] / mods / _standard / forums / edit_forum.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 authenticate(AT_PRIV_FORUMS);
19
20 require (AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
21
22 if (isset($_POST['cancel'])) {
23         $msg->addFeedback('CANCELLED');
24         header('Location: '.AT_BASE_HREF.'mods/_standard/forums/index.php');
25         exit;
26 } else if (isset($_POST['edit_forum'])) {
27         $_POST['fid'] = intval($_POST['fid']);
28
29         if ($_POST['title'] == '') {
30                 $msg->addError(array('EMPTY_FIELDS', _AT('title')));
31         } else {
32                 $_POST['title'] = validate_length($_POST['title'], 60);
33         }
34
35         if (!$msg->containsErrors()) {
36                 if (!is_shared_forum($_POST['fid'])) {
37                         edit_forum($_POST);
38                         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
39                 } else {
40                         $msg->addError('FORUM_NO_EDIT_SHARE');
41                 }
42                 
43                 header('Location: '.AT_BASE_HREF.'mods/_standard/forums/index.php');
44                 exit;
45         }
46 }
47
48 $onload = 'document.form.title.focus();';
49 require(AT_INCLUDE_PATH.'header.inc.php');
50
51 $fid = intval($_REQUEST['fid']);
52
53 if (!isset($_POST['submit'])) {
54         $row = get_forum($fid, $_SESSION['course_id']);
55         if (!is_array($row)) {
56                 $msg->addError('FORUM_NOT_FOUND');
57                 $msg->printALL();
58                 require(AT_INCLUDE_PATH.'footer.inc.php');
59                 exit;
60         }
61 } else {
62         $row['description'] = $_POST['body'];
63         $row['mins_to_edit'] = $_POST['edit'];
64 }
65
66 $msg->printErrors();
67 $savant->assign('row', $row);
68 $savant->assign('fid', $fid);
69 $savant->display('instructor/forums/edit_forum.tmpl.php');
70 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>