2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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 /************************************************************************/
14 define('AT_INCLUDE_PATH', '../../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_FORUMS);
18 if (isset($_POST['cancel'])) {
19 $msg->addFeedback('CANCELLED');
20 header('Location: '.AT_BASE_HREF.'mods/_standard/forums/admin/forums.php');
22 } else if (isset($_POST['add_forum'])) {
23 $missing_fields = array();
25 if (empty($_POST['title'])) {
26 $missing_fields[] = _AT('title');
29 if (empty($_POST['courses'])) {
30 $missing_fields[] = _AT('courses');
33 if ($missing_fields) {
34 $missing_fields = implode(', ', $missing_fields);
35 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
38 $_POST['edit'] = intval($_POST['edit']);
40 if (!($msg->containsErrors())) {
42 $sql = "INSERT INTO ".TABLE_PREFIX."forums (title, description, mins_to_edit) VALUES ('" . $_POST['title'] . "','" . $_POST['description'] ."', $_POST[edit])";
43 $result = mysql_query($sql, $db);
44 $forum_id = mysql_insert_id($db);
45 write_to_log(AT_ADMIN_LOG_INSERT, 'forums', mysql_affected_rows($db), $sql);
47 //for each course, add an entry to the forums_courses table
48 foreach ($_POST['courses'] as $course) {
49 $sql = "INSERT INTO ".TABLE_PREFIX."forums_courses VALUES (" . $forum_id . "," . $course . ")";
50 $result = mysql_query($sql, $db);
51 write_to_log(AT_ADMIN_LOG_INSERT, 'forums_courses', mysql_affected_rows($db), $sql);
54 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
56 $msg->addFeedback('FORUM_POSTING');
58 header('Location: '.AT_BASE_HREF.'mods/_standard/forums/admin/forums.php');
63 $onload = 'document.form.title.focus();';
65 require(AT_INCLUDE_PATH.'header.inc.php');
68 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
69 <input type="hidden" name="add_forum" value="true">
71 <div class="input-form">
73 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="title"><?php echo _AT('title'); ?></label><br />
74 <input type="text" name="title" size="40" id="title" value="<?php echo $_POST['title']; ?>" />
78 <label for="body"><?php echo _AT('description'); ?></label><br />
79 <textarea name="description" cols="45" rows="2" id="body" wrap="wrap"><?php echo $_POST['description']; ?></textarea>
83 <label for="edit"><?php echo _AT('allow_editing'); ?></label><br />
84 <input type="text" name="edit" size="3" id="edit" value="<?php echo intval($row['mins_to_edit']); ?>" /> <?php echo _AT('in_minutes'); ?>
88 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="courses"><?php echo _AT('courses'); ?></label><br />
89 <?php if ($system_courses): ?>
90 <select name="courses[]" id="courses" multiple="multiple" size="5"><?php
92 $sql = "SELECT course_id, title FROM ".TABLE_PREFIX."courses ORDER BY title";
93 $result = mysql_query($sql, $db);
94 while ($row = mysql_fetch_assoc($result)) {
95 echo '<option value="'.$row['course_id'].'">'.$row['title'].'</option>';
100 <span id="courses"><?php echo _AT('no_courses_found'); ?></span>
104 <div class="row buttons">
105 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
106 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
111 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>