/**
  * create a forum
  * @param	string	title
  * @param	string  text/description
  * @return	added forum's id
  */
 function createForum($title, $text)
 {
     //create POST array
     $temp['title'] = $title;
     $temp['body'] = $text;
     $temp['edit'] = 0;
     //default 0 minutes
     add_forum($temp);
     //check forums.inc.php
     $sql = 'SELECT MAX(forum_id) as m FROM ' . TABLE_PREFIX . 'forums';
     $row = queryDB($sql, array(TABLE_PREFIX), TRUE);
     return $row['m'];
 }
 /**
  * create a forum
  * @param	string	title
  * @param	string  text/description
  * @return	added forum's id
  */
 function createForum($title, $text)
 {
     global $db;
     //create POST array
     $temp['title'] = $title;
     $temp['body'] = $text;
     $temp['edit'] = 0;
     //default 0 minutes
     add_forum($temp);
     //check forums.inc.php
     $sql = 'SELECT MAX(forum_id) FROM ' . TABLE_PREFIX . 'forums';
     $result = mysql_query($sql, $db);
     $row = mysql_fetch_row($result);
     return $row[0];
 }
Ejemplo n.º 3
0
/* This program is free software. You can redistribute it and/or			*/
/* modify it under the terms of the GNU General Public License				*/
/* as published by the Free Software Foundation.							*/
/****************************************************************************/
// $Id$
define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
authenticate(AT_PRIV_FORUMS);
if ($_POST['cancel']) {
    $msg->addFeedback('CANCELLED');
    header('Location: ' . AT_BASE_HREF . 'mods/_standard/forums/index.php');
    exit;
}
if ($_POST['add_forum'] && authenticate(AT_PRIV_FORUMS, AT_PRIV_RETURN)) {
    if ($_POST['title'] == '') {
        $msg->addError(array('EMPTY_FIELDS', _AT('title')));
    } else {
        $_POST['title'] = validate_length($_POST['title'], 60);
    }
    if (!$msg->containsErrors()) {
        require AT_INCLUDE_PATH . '../mods/_standard/forums/lib/forums.inc.php';
        add_forum($_POST);
        $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
        header('Location: ' . AT_BASE_HREF . 'mods/_standard/forums/index.php');
        exit;
    }
}
$onload = 'document.form.title.focus();';
require AT_INCLUDE_PATH . 'header.inc.php';
$savant->display('instructor/forums/add_forum.tmpl.php');
require AT_INCLUDE_PATH . 'footer.inc.php';
Ejemplo n.º 4
0
<?php 
            }
        }
        break;
    case 'add':
        print "Add a new forum:";
        print " (<a href='index.php?m=admin&act=forums&do=list'>Return to editing forums</a>)";
        $getcategories = dbquery("SELECT * FROM categories");
        $categories = array('0' => 'Uncategorised');
        while ($row = dbrow($getcategories)) {
            $categories[$row[id]] = $row[name];
        }
        // if it returns a non-blank string, it's an error
        // if it returns true (check with ===) the forum has been created successfully
        // if it returns nothing, just show the form
        $result = add_forum();
        if ($result === true) {
            header("Location: index.php?m=admin&act=forums&do=list");
        } else {
            if ($result != '') {
                print '<b>The following errors occurred while creating the forum:<br>' . $result . '</b><br>The data has been saved.<hr>';
            }
            ?>
<div class='bigspacing'></div>
<form action='index.php?m=admin&act=forums&do=add&id=<?php 
            echo $id;
            ?>
' method='post'>
<table style='margin: 0 auto; width: 100%'>
  <tr>
    <td align='left' style='width: 30%'><b>Forum Name:</b></td>