5 * Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('pre.php');
29 require_once('note.php');
30 require_once('www/news/news_utils.php');
31 require_once('common/forum/Forum.class');
33 $group_id = getIntFromRequest('group_id');
35 if (session_loggedin()) {
37 if (!user_ismember($group_id,'A')) {
38 exit_permission_denied($Language->getText('news_submit','cannot'));
41 $group_id = getIntFromRequest('group_id');
43 if ($group_id == $sys_news_group) {
44 exit_permission_denied($Language->getText('news_submit','cannotadmin'));
47 if (getStringFromRequest('post_changes')) {
48 $summary = getStringFromRequest('summary');
49 $details = getStringFromRequest('details');
51 //check to make sure both fields are there
52 if ($summary && $details) {
54 Insert the row into the db if it's a generic message
55 OR this person is an admin for the group involved
59 create a new discussion forum without a default msg
60 if one isn't already there
64 $f=new Forum(group_get_object($sys_news_group));
65 if (!$f->create(ereg_replace('[^_\.0-9a-z-]','-', strtolower($summary)),$details,1,'',0,0)) {
67 exit_error('Error',$f->getErrorMessage());
70 $sql="INSERT INTO news_bytes (group_id,submitted_by,is_approved,post_date,forum_id,summary,details) ".
71 " VALUES ('$group_id','".user_getid()."','0','".time()."','$new_id','".htmlspecialchars($summary)."','".htmlspecialchars($details)."')";
72 $result=db_query($sql);
75 $feedback .= ' '.$Language->getText('news_submit', 'errorinsert').' ';
78 $feedback .= ' '.$Language->getText('news_submit', 'newsadded').' ';
81 $feedback .= ' '.$Language->getText('news_submit', 'errorboth').' ';
85 //news must now be submitted from a project page -
93 news_header(array('title'=>$Language->getText('news', 'title'),'pagename'=>'news_submit','titlevals'=>array(group_getname($group_id))));
95 $jsfunc = notepad_func();
96 $group = group_get_object($group_id);
99 '. $Language->getText('news_submit', 'post_blurb', $GLOBALS['sys_name']) .'</p>' . $jsfunc .
101 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
102 <input type="hidden" name="group_id" value="'.$group_id.'" />
103 <strong>'.$Language->getText('news_submit', 'forproject').': '.$group->getPublicName().'</strong>
104 <input type="hidden" name="post_changes" value="y" /></p>
106 <strong>'.$Language->getText('news_submit', 'subject').':</strong>'.utils_requiredField().'<br />
107 <input type="text" name="summary" value="" size="30" maxlength="60" /></p>
109 <strong>'.$Language->getText('news_submit', 'details').':</strong>'.notepad_button('document.forms[1].details').utils_requiredField().'<br />
110 <textarea name="details" rows="5" cols="50" wrap="soft"></textarea><br />
111 <input type="submit" name="submit" value="'.$Language->getText('general', 'submit').'" />
114 news_footer(array());
118 exit_not_logged_in();