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/admin/news_admin_utils.php';
32 require_once $gfwww.'news/news_utils.php';
33 //common forum tools which are used during the creation/editing of news items
34 require_once $gfcommon.'forum/Forum.class.php';
35 require_once $gfcommon.'include/TextSanitizer.class.php'; // to make the HTML input by the user safe to store
37 $group_id = getIntFromRequest('group_id');
38 $post_changes = getStringFromRequest('post_changes');
39 $approve = getStringFromRequest('approve');
40 $status = getIntFromRequest('status');
41 $summary = getStringFromRequest('summary');
42 $details = getStringFromRequest('details');
43 $id = getIntFromRequest('id');
47 if ($group_id && $group_id != $sys_news_group && user_ismember($group_id,'A')) {
48 $status = getIntFromRequest('status');
49 $summary = getStringFromRequest('summary');
50 $details = getStringFromRequest('details');
54 Per-project admin pages.
56 Shows their own news items so they can edit/update.
58 If their news is on the homepage, and they edit, it is removed from
65 Update the db so the item shows on the home page
67 if ($status != 0 && $status != 4) {
68 //may have tampered with HTML to get their item on the home page
72 //foundry stuff - remove this news from the foundry so it has to be re-approved by the admin
73 db_query("DELETE FROM foundry_news WHERE news_id='$id'");
82 $sanitizer = new TextSanitizer();
83 $details = $sanitizer->SanitizeHtml($details);
84 $sql="UPDATE news_bytes SET is_approved='$status', summary='".htmlspecialchars($summary)."', ".
85 "details='".$details."' WHERE id='$id' AND group_id='$group_id'";
86 $result=db_query($sql);
88 if (!$result || db_affected_rows($result) < 1) {
89 $feedback .= _('Error On Update:');
91 $feedback .= _('NewsByte Updated.');
101 news_header(array('title'=>_('News admin')));
108 $sql="SELECT * FROM news_bytes WHERE id='$id' AND group_id='$group_id'";
109 $result=db_query($sql);
110 if (db_numrows($result) < 1) {
111 exit_error(_('Error'), _('NewsByte not found'));
114 $group =& group_get_object($group_id);
118 <h3>'.sprintf(_('Approve a NewsByte For Project: %1$s'), $group->getPublicName()).'</h3>
120 <form 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[1].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 plugin_hook("text_editor",$params);
146 if (!isset($GLOBALS['editor_was_set_up'])) {
147 //if we don't have any plugin for text editor, display a simple textarea edit box
148 echo '<textarea name="details" rows="5" cols="50" wrap="soft">'.db_result($result,0,'details').'</textarea><br />';
150 unset($GLOBALS['editor_was_set_up']);
153 <strong>'.sprintf(_('If this item is on the %1$s home page and you edit it, it will be removed from the home page.'), $GLOBALS['sys_name']).'</strong><br /></p>
154 <input type="submit" name="submit" value="'._('Submit').'" />
159 Show list of waiting news items
162 $sql="SELECT * FROM news_bytes WHERE is_approved <> 4 AND group_id='$group_id'";
163 $result=db_query($sql);
164 $rows=db_numrows($result);
165 $group =& group_get_object($group_id);
169 <h4>'._('No Queued Items Found').': '.$group->getPublicName().'</h4>';
172 <h4>'._('List of News Submitted for Project').': '.$group->getPublicName().'</h4>
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 $sql="UPDATE news_bytes SET is_approved='1', post_date='".time()."', ".
203 "summary='".htmlspecialchars($summary)."', details='".$details."' WHERE id='$id'";
204 $result=db_query($sql);
205 if (!$result || db_affected_rows($result) < 1) {
206 $feedback .= _('Error On Update:');
208 $feedback .= _('NewsByte Updated.');
210 } else if ($status==2) {
212 Move msg to deleted status
214 $sql="UPDATE news_bytes SET is_approved='2' WHERE id='$id'";
215 $result=db_query($sql);
216 if (!$result || db_affected_rows($result) < 1) {
217 $feedback .= _('Error On Update:');
218 $feedback .= db_error();
220 $feedback .= _('NewsByte Deleted.');
229 } else if (getStringFromRequest('mass_reject')) {
231 Move msg to rejected status
233 $news_id = getArrayFromRequest('news_id');
234 $sql="UPDATE news_bytes "
235 ."SET is_approved='2' "
236 ."WHERE id IN ('".implode("','",$news_id)."')";
237 $result=db_query($sql);
238 if (!$result || db_affected_rows($result) < 1) {
239 $feedback .= _('Error On Update:');
240 $feedback .= db_error();
242 $feedback .= _('NewsBytes Rejected.');
247 news_header(array('title'=>_('News admin')));
254 $sql="SELECT groups.unix_group_name,groups.group_id,news_bytes.* ".
255 "FROM news_bytes,groups WHERE id='$id' ".
256 "AND news_bytes.group_id=groups.group_id ";
257 $result=db_query($sql);
258 if (db_numrows($result) < 1) {
259 exit_error(_('Error'), _('NewsByte not found'));
262 $group =& group_get_object(db_result($result,0,'group_id'));
263 $user =& user_get_object(db_result($result,0,'submitted_by'));
266 <h3>'.sprintf(_('Approve a NewsByte For Project: %1$s'), $group->getPublicName()).'</h3>
268 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
269 <input type="hidden" name="for_group" value="'.db_result($result,0,'group_id').'" />
270 <input type="hidden" name="id" value="'.db_result($result,0,'id').'" />
271 <strong>'._('Submitted for group').':</strong> '.
272 util_make_link_g (strtolower(db_result($result,0,'unix_group_name')),db_result($result,0,'group_id'),$group->getPublicName()).'<br />
273 <strong>'._('Submitted by').':</strong> '.$user->getRealName().'<br />
274 <input type="hidden" name="approve" value="y" />
275 <input type="hidden" name="post_changes" value="y" />
276 <input type="radio" name="status" value="1" /> '._('Approve For Front Page').'<br />
277 <input type="radio" name="status" value="0" /> '._('Do Nothing').'<br />
278 <input type="radio" name="status" value="2" checked="checked" /> '._('Reject').'<br />
279 <strong>'._('Subject').':</strong><br />
280 <input type="text" name="summary" value="'.db_result($result,0,'summary').'" size="30" maxlength="60" /><br />
281 <strong>'._('Details').':</strong><br />';
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" wrap="soft">'.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;
309 SELECT groups.group_id,id,post_date,summary,
310 group_name,unix_group_name
311 FROM news_bytes,groups
313 AND news_bytes.group_id=groups.group_id
314 AND post_date > '$old_date'
315 AND groups.is_public=1
316 AND groups.status='A'
320 $old_date = time()-(60*60*24*7);
322 SELECT groups.group_id,id,post_date,summary,
323 group_name,unix_group_name
324 FROM news_bytes,groups
326 AND news_bytes.group_id=groups.group_id
327 AND post_date > '$old_date'
332 SELECT groups.group_id,id,post_date,summary,
333 group_name,unix_group_name
334 FROM news_bytes,groups
336 AND news_bytes.group_id=groups.group_id
337 AND post_date > '$old_date'
340 show_news_approve_form(
347 news_footer(array());
351 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.'), $GLOBALS['sys_name']));
357 // c-file-style: "bsd"