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. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * Standard Alcatel-Lucent disclaimer for contributing to open source
30 * "The Submit News Form ("Contribution") has not been tested and/or
31 * validated for release as or in products, combinations with products or
32 * other commercial use. Any use of the Contribution is entirely made at
33 * the user's own responsibility and the user can not rely on any features,
34 * functionalities or performances Alcatel-Lucent has attributed to the
37 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
38 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
39 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
40 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
41 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
42 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
43 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
45 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
49 require_once('../env.inc.php');
50 require_once $gfcommon.'include/pre.php';
51 require_once $gfwww.'include/note.php';
52 require_once $gfwww.'news/news_utils.php';
53 require_once $gfcommon.'forum/Forum.class.php';
54 require_once $gfcommon.'include/TextSanitizer.class.php'; // to make the HTML input by the user safe to store
56 $group_id = getIntFromRequest('group_id');
60 $group=group_get_object($group_id);
61 if (!$group || !is_object($group)) {
63 } elseif ($group->isError()) {
64 exit_error($group->getErrorMessage(),'news');
67 $summary = getStringFromRequest('summary');
68 $details = getHtmlTextFromRequest('details');
71 if (session_loggedin()) {
73 if (!forge_check_perm('project_admin', $group_id)) {
74 exit_permission_denied(_('You cannot submit news for a project unless you are an admin on that project'),'home');
77 if ($group_id == forge_get_config('news_group')) {
78 exit_permission_denied(_('Submitting news from the news group is not allowed.'),'home');
81 if (getStringFromRequest('post_changes')) {
82 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
83 exit_form_double_submit('news');
86 //check to make sure both fields are there
87 if ($summary && $details) {
89 create a new discussion forum without a default msg
90 if one isn't already there
94 $f = new Forum($group);
95 if (!$f->create(preg_replace('/[^_\.0-9a-z-]/','-', strtolower($summary)),$details,1,'',0,0)) {
97 exit_error($f->getErrorMessage(),'news');
99 $group->normalizeAllRoles();
101 $sql='INSERT INTO news_bytes (group_id,submitted_by,is_approved,post_date,forum_id,summary,details)
102 VALUES ($1, $2, $3, $4, $5, $6, $7)';
103 $result=db_query_params($sql,
104 array($group_id, user_getid(), 0, time(), $new_id, htmlspecialchars($summary), $details));
107 form_release_key(getStringFromRequest('form_key'));
108 $error_msg = _('ERROR doing insert');
111 $feedback = _('News Added.');
114 form_release_key(getStringFromRequest('form_key'));
115 $error_msg = _('ERROR - both subject and body are required');
119 //news must now be submitted from a project page -
130 $group = group_get_object($group_id);
131 news_header(array('title'=>_('Submit News for Project: ').' '.$group->getPublicName()));
133 $jsfunc = notepad_func();
137 '. 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 .
139 <form id="newssubmitform" action="'.getStringFromServer('PHP_SELF').'" method="post">
140 <input type="hidden" name="group_id" value="'.$group_id.'" />
141 <input type="hidden" name="post_changes" value="y" />
142 <input type="hidden" name="form_key" value="'. form_generate_key() .'" />
143 <p><strong>'._('For project').' '.$group->getPublicName().'</strong></p>
145 <strong>'._('Subject').':</strong>'.utils_requiredField().'<br />
146 <input required="required" type="text" name="summary" value="'.$summary.'" size="60" maxlength="60" /></p>
148 <strong>'._('Details').':</strong>'.notepad_button('document.forms.newssubmitform.details').utils_requiredField().'</p>';
151 $params['name'] = 'details';
152 $params['width'] = "800";
153 $params['height'] = "500";
154 $params['body'] = $details;
155 $params['group'] = $group_id;
156 $params['content'] = '<textarea name="details" rows="5" cols="50">'.$details.'</textarea>';
157 plugin_hook_by_reference("text_editor",$params);
159 echo $params['content'].'<br />';
160 echo '<div><input type="submit" name="submit" value="'._('Submit').'" />
163 news_footer(array());
167 exit_not_logged_in();
173 // c-file-style: "bsd"