3 * FusionForge News Facility
5 * Copyright (C) 1999-2001 VA Linux Systems
6 * Copyright (C) 2002-2004 GForge Team
7 * Copyright (C) 2008-2010 Alcatel-Lucent
9 * http://fusionforge.org/
11 * This file is part of FusionForge.
13 * FusionForge 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 * FusionForge 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 FusionForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * Standard Alcatel-Lucent disclaimer for contributing to open source
31 * "The Submit News Form ("Contribution") has not been tested and/or
32 * validated for release as or in products, combinations with products or
33 * other commercial use. Any use of the Contribution is entirely made at
34 * the user's own responsibility and the user can not rely on any features,
35 * functionalities or performances Alcatel-Lucent has attributed to the
38 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
39 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
40 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
41 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
42 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
43 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
44 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
45 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
46 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
50 require_once('../env.inc.php');
51 require_once $gfcommon.'include/pre.php';
52 require_once $gfwww.'include/note.php';
53 require_once $gfwww.'news/news_utils.php';
54 require_once $gfcommon.'forum/Forum.class.php';
55 require_once $gfcommon.'include/TextSanitizer.class.php'; // to make the HTML input by the user safe to store
57 $group_id = getIntFromRequest('group_id');
59 if (session_loggedin()) {
61 if (!user_ismember($group_id,'A')) {
62 exit_permission_denied(_('You cannot submit news for a project unless you are an admin on that project'),'home');
65 $group_id = getIntFromRequest('group_id');
67 if ($group_id == forge_get_config('news_group')) {
68 exit_permission_denied(_('Submitting news from the news group is not allowed.'),'home');
71 if (getStringFromRequest('post_changes')) {
72 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
73 exit_form_double_submit('news');
75 $summary = getStringFromRequest('summary');
76 $details = getStringFromRequest('details');
78 //check to make sure both fields are there
79 if ($summary && $details) {
80 $sanitizer = new TextSanitizer();
81 $details = $sanitizer->purify($details);
84 Insert the row into the db if it's a generic message
85 OR this person is an admin for the group involved
89 create a new discussion forum without a default msg
90 if one isn't already there
94 $f=new Forum(group_get_object(forge_get_config('news_group')));
95 if (!$f->create(ereg_replace('[^_\.0-9a-z-]','-', strtolower($summary)),$details,1,'',0,0)) {
97 exit_error($f->getErrorMessage(),'news');
100 $sql='INSERT INTO news_bytes (group_id,submitted_by,is_approved,post_date,forum_id,summary,details)
101 VALUES ($1, $2, $3, $4, $5, $6, $7)';
102 $result=db_query_params($sql,
103 array($group_id, user_getid(), 0, time(), $new_id, htmlspecialchars($summary), $details));
106 form_release_key(getStringFromRequest('form_key'));
107 $error_msg = _('ERROR doing insert');
110 $feedback = _('News Added.');
113 form_release_key(getStringFromRequest('form_key'));
114 $error_msg = _('ERROR - both subject and body are required');
118 //news must now be submitted from a project page -
126 news_header(array('title'=>_('Submit News')));
127 echo '<h1>' . _('Submit News') . '</h1>';
129 $jsfunc = notepad_func();
130 $group = group_get_object($group_id);
133 '. 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.'), forge_get_config ('forge_name')) .'</p>' . $jsfunc .
135 <form id="newssubmitform" action="'.getStringFromServer('PHP_SELF').'" method="post">
136 <input type="hidden" name="group_id" value="'.$group_id.'" />
137 <input type="hidden" name="post_changes" value="y" />
138 <input type="hidden" name="form_key" value="'. form_generate_key() .'" />
139 <p><strong>'._('For project').' '.$group->getPublicName().'</strong></p>
141 <strong>'._('Subject').':</strong>'.utils_requiredField().'<br />
142 <input type="text" name="summary" value="" size="60" maxlength="60" /></p>
144 <strong>'._('Details').':</strong>'.notepad_button('document.forms.newssubmitform.details').utils_requiredField().'</p>';
146 $GLOBALS['editor_was_set_up']=false;
148 $params['name'] = 'details';
149 $params['width'] = "800";
150 $params['height'] = "500";
151 $params['body'] = "";
152 $params['group'] = $group_id;
153 plugin_hook("text_editor",$params);
154 if (!$GLOBALS['editor_was_set_up']) {
155 //if we don't have any plugin for text editor, display a simple textarea edit box
156 echo '<textarea name="details" rows="5" cols="50"></textarea><br />';
158 unset($GLOBALS['editor_was_set_up']);
159 echo '<div><input type="submit" name="submit" value="'._('Submit').'" />
162 news_footer(array());
166 exit_not_logged_in();
172 // c-file-style: "bsd"