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('../env.inc.php');
29 require_once $gfwww.'include/pre.php';
30 require_once $gfwww.'include/note.php';
31 require_once $gfwww.'news/news_utils.php';
32 require_once $gfcommon.'forum/Forum.class.php';
33 require_once $gfcommon.'include/TextSanitizer.class.php'; // to make the HTML input by the user safe to store
35 $group_id = getIntFromRequest('group_id');
37 if (session_loggedin()) {
39 if (!user_ismember($group_id,'A')) {
40 exit_permission_denied(_('You cannot submit news for a project unless you are an admin on that project'));
43 $group_id = getIntFromRequest('group_id');
45 if ($group_id == $sys_news_group) {
46 exit_permission_denied(_('Submitting news from the news group is not allowed.'));
49 if (getStringFromRequest('post_changes')) {
50 $summary = getStringFromRequest('summary');
51 $details = getStringFromRequest('details');
53 //check to make sure both fields are there
54 if ($summary && $details) {
56 Insert the row into the db if it's a generic message
57 OR this person is an admin for the group involved
61 create a new discussion forum without a default msg
62 if one isn't already there
66 $f=new Forum(group_get_object($sys_news_group));
67 if (!$f->create(ereg_replace('[^_\.0-9a-z-]','-', strtolower($summary)),$details,1,'',0,0)) {
69 exit_error('Error',$f->getErrorMessage());
72 $sanitizer = new TextSanitizer();
73 $details = $sanitizer->SanitizeHtml($details);
74 $sql="INSERT INTO news_bytes (group_id,submitted_by,is_approved,post_date,forum_id,summary,details) ".
75 " VALUES ('$group_id','".user_getid()."','0','".time()."','$new_id','".htmlspecialchars($summary)."','".$details."')";
76 $result=db_query($sql);
79 $feedback = ' '._('ERROR doing insert').' ';
82 $feedback = ' '._('News Added.').' ';
85 $feedback = ' '._('ERROR - both subject and body are required').' ';
89 //news must now be submitted from a project page -
97 news_header(array('title'=>_('News')));
99 $jsfunc = notepad_func();
100 $group = group_get_object($group_id);
103 '. sprintf(_('You can post news about your project if you are an admin on your project. You may also post "help wanted" notes if your project needs help.</p><p>All posts <b>for your project</b> will appear instantly on your project summary page. Posts that are of special interest to the community will have to be approved by a member of the %1$s news team before they will appear on the %1$s home page.</p><p>You may include URLs, but not HTML in your submissions.</p><p>URLs that start with http:// are made clickable.'), $GLOBALS['sys_name']) .'</p>' . $jsfunc .
105 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
106 <input type="hidden" name="group_id" value="'.$group_id.'" />
107 <strong>'._('For project').' '.$group->getPublicName().'</strong>
108 <input type="hidden" name="post_changes" value="y" /></p>
110 <strong>'._('Subject').':</strong>'.utils_requiredField().'<br />
111 <input type="text" name="summary" value="" size="30" maxlength="60" /></p>
113 <strong>'._('Details').':</strong>'.notepad_button('document.forms[1].details').utils_requiredField().'<br />';
116 $params['name'] = 'details';
117 $params['width'] = "600";
118 $params['height'] = "300";
119 $params['body'] = "";
120 $params['group'] = $group_id;
121 plugin_hook("text_editor",$params);
122 if (!isset($GLOBALS['editor_was_set_up'])) {
123 //if we don't have any plugin for text editor, display a simple textarea edit box
124 echo '<textarea name="details" rows="5" cols="50" wrap="soft"></textarea><br />';
126 unset($GLOBALS['editor_was_set_up']);
127 echo '<input type="submit" name="submit" value="'._('Submit').'" />
130 news_footer(array());
134 exit_not_logged_in();
140 // c-file-style: "bsd"