5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'include/note.php';
29 require_once $gfwww.'news/admin/news_admin_utils.php';
30 require_once $gfwww.'news/news_utils.php';
31 //common forum tools which are used during the creation/editing of news items
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');
36 $post_changes = getStringFromRequest('post_changes');
37 $approve = getStringFromRequest('approve');
38 $status = getIntFromRequest('status');
39 $summary = getStringFromRequest('summary');
40 $details = getHtmlTextFromRequest('details');
41 $id = getIntFromRequest('id');
42 $for_group = getIntFromRequest('for_group');
44 if ($group_id && $group_id != forge_get_config('news_group')) {
45 session_require_perm ('project_admin', $group_id) ;
47 $status = getIntFromRequest('status');
48 $summary = getStringFromRequest('summary');
49 $details = getStringFromRequest('details');
53 Per-project admin pages.
55 Shows their own news items so they can edit/update.
57 If their news is on the homepage, and they edit, it is removed from
62 $result = db_query_params("SELECT forum_id FROM news_bytes WHERE id=$1 AND group_id=$2", array($id, $group_id));
63 if (db_numrows($result) < 1) {
64 exit_error(_('Newsbyte not found'),'news');
67 $forum_id = db_result($result,0,'forum_id');
68 $old_group_id = db_result($result,0,'group_id');
72 Update the db so the item shows on the home page
74 if ($status != 0 && $status != 4) {
75 //may have tampered with HTML to get their item on the home page
86 $result = db_query_params("UPDATE news_bytes SET is_approved=$1, summary=$2,
87 details=$3 WHERE id=$4 AND group_id=$5", array($status, htmlspecialchars($summary), $details, $id, $group_id));
89 if (!$result || db_affected_rows($result) < 1) {
90 $error_msg .= _('Error On Update:');
91 $error_msg .= db_error();
93 $feedback .= _('Newsbyte Updated.');
103 news_header(array('title'=>_('News admin')));
110 $result=db_query_params("SELECT * FROM news_bytes WHERE id=$1 AND group_id=$2", array($id, $group_id));
111 if (db_numrows($result) < 1) {
112 exit_error(_('Newsbyte not found'),'news');
115 $group = group_get_object($group_id);
120 <form id="newsadminform" action="'.getStringFromServer('PHP_SELF').'" method="post">
121 <input type="hidden" name="group_id" value="'.db_result($result,0,'group_id').'" />
122 <input type="hidden" name="id" value="'.db_result($result,0,'id').'" />';
124 $user =& user_get_object(db_result($result,0,'submitted_by'));
127 <strong>'._('Submitted by').':</strong> '.$user->getRealName().'<br />
128 <input type="hidden" name="approve" value="y" />
129 <input type="hidden" name="post_changes" value="y" />
131 <strong>'._('Status').'</strong><br />
132 <input type="radio" name="status" value="0" checked="checked" /> '._('Displayed').'<br />
133 <input type="radio" name="status" value="4" /> '._('Delete').'<br />
135 <strong>'._('Subject').'</strong><br />
136 <input type="text" name="summary" value="'.db_result($result,0,'summary').'" size="60" maxlength="60" /><br />
137 <strong>'._('Details').'</strong>'.notepad_button('document.forms.newsadminform.details').'<br />';
140 $params['name'] = 'details';
141 $params['width'] = "600";
142 $params['height'] = "300";
143 $params['group'] = $group_id;
144 $params['body'] = db_result($result,0,'details');
145 $params['content'] = '<textarea name="details" rows="5" cols="50">'.$params['body'].'</textarea>';
146 plugin_hook_by_reference("text_editor",$params);
148 echo $params['content'].'<br/>';
150 <strong>'.sprintf(_('If this item is on the %1$s home page and you edit it, it will be removed from the home page.'), forge_get_config ('forge_name')).'</strong></p>
151 <input type="submit" name="submit" value="'._('Submit').'" />
156 Show list of waiting news items
159 $result=db_query_params("SELECT * FROM news_bytes WHERE is_approved <> 4 AND group_id=$1", array($group_id));
160 $rows=db_numrows($result);
161 $group = group_get_object($group_id);
165 <p class="warning_msg">'._('No Queued Items Found').'</p>';
169 for ($i=0; $i<$rows; $i++) {
171 <li>'.util_make_link ('/news/admin/?approve=1&id='.db_result($result,$i,'id').'&group_id='.db_result($result,$i,'group_id'),db_result($result,$i,'summary')).'</li>';
177 news_footer(array());
179 } else { // No group, or newsadmin group
180 session_redirect('/admin/pending-news.php');
185 // c-file-style: "bsd"