b6f24386c84c72b6630dbf9a240cdbc6a5638851
[atutor.git] / docs / mods / _standard / forums / add_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 define('AT_INCLUDE_PATH', '../../../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
16
17 authenticate(AT_PRIV_FORUMS);
18
19 if ($_POST['cancel']) {
20         $msg->addFeedback('CANCELLED');
21         header('Location: '.AT_BASE_HREF.'mods/_standard/forums/index.php');
22         exit;
23 }
24
25 if ($_POST['add_forum'] && (authenticate(AT_PRIV_FORUMS, AT_PRIV_RETURN))) {
26         if ($_POST['title'] == '') {
27                 $msg->addError(array('EMPTY_FIELDS', _AT('title')));
28         } else {
29                 $_POST['title'] = validate_length($_POST['title'], 60);
30         }
31
32         if (!$msg->containsErrors()) {
33                 require(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
34                 add_forum($_POST);
35                 
36                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
37                 header('Location: '.AT_BASE_HREF.'mods/_standard/forums/index.php');
38                 exit;
39         }
40 }
41
42 $onload = 'document.form.title.focus();';
43
44 require(AT_INCLUDE_PATH.'header.inc.php');
45
46 $savant->display('instructor/forums/add_forum.tmpl.php');
47 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>