5 * Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge 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
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 require_once('../../env.inc.php');
27 require_once $gfwww.'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 = getStringFromRequest('details');
41 $id = getIntFromRequest('id');
45 if ($group_id && $group_id != $sys_news_group && user_ismember($group_id,'A')) {
46 $status = getIntFromRequest('status');
47 $summary = getStringFromRequest('summary');
48 $details = getStringFromRequest('details');
52 Per-project admin pages.
54 Shows their own news items so they can edit/update.
56 If their news is on the homepage, and they edit, it is removed from
63 Update the db so the item shows on the home page
65 if ($status != 0 && $status != 4) {
66 //may have tampered with HTML to get their item on the home page
70 //foundry stuff - remove this news from the foundry so it has to be re-approved by the admin
71 db_query_params ('DELETE FROM foundry_news WHERE news_id=$1',
81 $sanitizer = new TextSanitizer();
82 $details = $sanitizer->SanitizeHtml($details);
83 $result = db_query_params("UPDATE news_bytes SET is_approved=$1, summary=$2,
84 details=$3 WHERE id=$4 AND group_id=$5", array($status, htmlspecialchars($summary), $details, $id, $group_id));
86 if (!$result || db_affected_rows($result) < 1) {
87 $feedback .= _('Error On Update:');
89 $feedback .= _('NewsByte Updated.');
90 // No notification if news is deleted.
92 // send_news_notification_email($id);
102 news_header(array('title'=>_('News admin')));
109 $result=db_query_params("SELECT * FROM news_bytes WHERE id=$1 AND group_id=$2", array($id, $group_id));
110 if (db_numrows($result) < 1) {
111 exit_error(_('Error'), _('NewsByte not found'));
114 $group =& group_get_object($group_id);
118 <h1>'.sprintf(_('Approve a NewsByte For Project: %1$s'), $group->getPublicName()).'</h1>
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="30" maxlength="60" /><br />
137 <strong>'._('Details').'</strong>'.notepad_button('document.forms.newsadminform.details').'<br />';
139 $GLOBALS['editor_was_set_up']=false;
141 $params['name'] = 'details';
142 $params['width'] = "600";
143 $params['height'] = "300";
144 $params['group'] = $group_id;
145 $params['body'] = db_result($result,0,'details');
146 plugin_hook("text_editor",$params);
147 if (!$GLOBALS['editor_was_set_up']) {
148 //if we don't have any plugin for text editor, display a simple textarea edit box
149 echo '<textarea name="details" rows="5" cols="50">'.db_result($result,0,'details').'</textarea><br />';
151 unset($GLOBALS['editor_was_set_up']);
154 <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><br /></p>
155 <input type="submit" name="submit" value="'._('Submit').'" />
160 Show list of waiting news items
163 $result=db_query_params("SELECT * FROM news_bytes WHERE is_approved <> 4 AND group_id=$1", array($group_id));
164 $rows=db_numrows($result);
165 $group =& group_get_object($group_id);
167 echo '<h1>'._('List of News Submitted for Project').': '.$group->getPublicName().'</h1>';
170 <div class="warning_msg">'._('No Queued Items Found').'</div>';
174 for ($i=0; $i<$rows; $i++) {
176 <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>';
182 news_footer(array());
184 } else if (user_ismember($sys_news_group,'A')) {
187 News uber-user admin pages
189 Show all waiting news items except those already rejected.
191 Admin members of $sys_news_group (news project) can edit/change/approve news items
198 Update the db so the item shows on the home page
200 $sanitizer = new TextSanitizer();
201 $details = $sanitizer->SanitizeHtml($details);
202 $result=db_query_params("UPDATE news_bytes SET is_approved='1', post_date=$1,
203 summary=$2, details=$3 WHERE id=$4", array(time(), htmlspecialchars($summary), $details, $id));
204 if (!$result || db_affected_rows($result) < 1) {
205 $feedback .= _('Error On Update:');
207 $feedback .= _('NewsByte Updated.');
209 } else if ($status==2) {
211 Move msg to deleted status
213 $result=db_query_params("UPDATE news_bytes SET is_approved='2' WHERE id=$1", array($id));
214 if (!$result || db_affected_rows($result) < 1) {
215 $feedback .= _('Error On Update:');
216 $feedback .= db_error();
218 $feedback .= _('NewsByte Deleted.');
227 } else if (getStringFromRequest('mass_reject')) {
229 Move msg to rejected status
231 $news_id = getArrayFromRequest('news_id');
232 $result = db_query_params("UPDATE news_bytes
234 WHERE id = ANY($1)",array(db_int_array_to_any_clause($news_id)));
235 if (!$result || db_affected_rows($result) < 1) {
236 $feedback .= _('Error On Update:');
237 $feedback .= db_error();
239 $feedback .= _('NewsBytes Rejected.');
244 news_header(array('title'=>_('News admin')));
251 $result=db_query_params("SELECT groups.unix_group_name,groups.group_id,news_bytes.*
252 FROM news_bytes,groups WHERE id=$1
253 AND news_bytes.group_id=groups.group_id ", array($id));
254 if (db_numrows($result) < 1) {
255 exit_error(_('Error'), _('NewsByte not found'));
257 if (db_result($result,0,'is_approved') == 4) {
258 exit_error(_('Error'), _('NewsByte deleted'));
261 $group =& group_get_object(db_result($result,0,'group_id'));
262 $user =& user_get_object(db_result($result,0,'submitted_by'));
265 <h1>'.sprintf(_('Approve a NewsByte For Project: %1$s'), $group->getPublicName()).'</h1>
267 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
268 <input type="hidden" name="for_group" value="'.db_result($result,0,'group_id').'" />
269 <input type="hidden" name="id" value="'.db_result($result,0,'id').'" />
270 <strong>'._('Submitted for group').':</strong> '.
271 util_make_link_g (strtolower(db_result($result,0,'unix_group_name')),db_result($result,0,'group_id'),$group->getPublicName()).'<br />
272 <strong>'._('Submitted by').':</strong> '.$user->getRealName().'<br />
273 <input type="hidden" name="approve" value="y" />
274 <input type="hidden" name="post_changes" value="y" />
275 <input type="radio" name="status" value="1" /> '._('Approve For Front Page').'<br />
276 <input type="radio" name="status" value="0" /> '._('Do Nothing').'<br />
277 <input type="radio" name="status" value="2" checked="checked" /> '._('Reject').'<br />
278 <strong>'._('Subject').':</strong><br />
279 <input type="text" name="summary" value="'.db_result($result,0,'summary').'" size="30" maxlength="60" /><br />
280 <strong>'._('Details').':</strong><br />';
282 $GLOBALS['editor_was_set_up']=false;
284 $params['name'] = 'details';
285 $params['width'] = "600";
286 $params['height'] = "300";
287 $params['group'] = db_result($result,0,'group_id');
288 $params['body'] = db_result($result,0,'details');
289 plugin_hook("text_editor",$params);
290 if (!$GLOBALS['editor_was_set_up']) {
291 //if we don't have any plugin for text editor, display a simple textarea edit box
292 echo '<textarea name="details" rows="5" cols="50">'.db_result($result,0,'details').'</textarea><br />';
294 unset($GLOBALS['editor_was_set_up']);
298 <input type="submit" name="submit" value="'._('Submit').'" />
304 Show list of waiting news items
307 $old_date = time()-60*60*24*30;
308 $qpa_pending = db_construct_qpa (false, 'SELECT groups.group_id,id,post_date,summary,
309 group_name,unix_group_name
310 FROM news_bytes,groups
312 AND news_bytes.group_id=groups.group_id
314 AND groups.is_public=1
316 ORDER BY post_date', array ($old_date, 'A')) ;
318 $old_date = time()-(60*60*24*7);
319 $qpa_rejected = db_construct_qpa (false, 'SELECT groups.group_id,id,post_date,summary,
320 group_name,unix_group_name
321 FROM news_bytes,groups
323 AND news_bytes.group_id=groups.group_id
325 ORDER BY post_date', array ($old_date)) ;
327 $qpa_approved = db_construct_qpa (false, 'SELECT groups.group_id,id,post_date,summary,
328 group_name,unix_group_name
329 FROM news_bytes,groups
331 AND news_bytes.group_id=groups.group_id
333 ORDER BY post_date', array ($old_date)) ;
334 show_news_approve_form(
341 news_footer(array());
345 exit_error(_('Permission denied.'),sprintf(_('You have to be an admin on the project you are editing or a member of the %s News team.'), forge_get_config ('forge_name')));
351 // c-file-style: "bsd"