00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: submit.php 5386 2006-02-15 15:12:21Z yeupou $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Copyright 2000-2003 (c) Free Software Foundation
00009 # Mathieu Roy <yeupou--gnu.org>
00010 #
00011 # Copyright 2004-2006 (c) Mathieu Roy <yeupou--gnu.org>
00012 #
00013 # The Savane project is free software; you can redistribute it and/or
00014 # modify it under the terms of the GNU General Public License
00015 # as published by the Free Software Foundation; either version 2
00016 # of the License, or (at your option) any later version.
00017 #
00018 # The Savane project is distributed in the hope that it will be useful,
00019 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021 # GNU General Public License for more details.
00022 #
00023 # You should have received a copy of the GNU General Public License
00024 # along with the Savane project; if not, write to the Free Software
00025 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00026
00027 require "../include/pre.php";
00028
00029 # FIXME: this should use register_globals_off() instead
00030 if ($_POST['group_id'])
00031 { $group_id= $_POST['group_id']; }
00032 elseif ($_GET['group_id'])
00033 { $group_id = $_GET['group_id']; }
00034
00035 if ($_POST['post_changes'])
00036 { $post_changes = $_POST['post_changes']; }
00037 if ($_POST['summary'])
00038 { $summary = $_POST['summary']; }
00039 if ($_POST['details'])
00040 { $details = $_POST['details']; }
00041 if ($_POST['feedback'])
00042 { $feedback = $_POST['feedback']; }
00043 elseif ($_GET['feedback'])
00044 { $feedback = $_GET['feedback']; }
00045 if ($_POST['group'])
00046 { $group = $_POST['group']; }
00047 elseif ($_GET['group'])
00048 { $group = $_GET['group']; }
00049 if ($_POST['id'])
00050 { $id = $_POST['id']; }
00051 elseif ($_GET['id'])
00052 { $id = $_GET['id']; }
00053
00054 if (!group_restrictions_check($group_id, "news"))
00055 {
00056 exit_error(sprintf(_("Action Unavailable: %s"), group_getrestrictions_explained($group_id, ARTIFACT)));
00057 }
00058
00059
00060 if (!group_restrictions_check($group_id, "news"))
00061 {
00062 exit_error(sprintf(_("Action Unavailable: %s"), group_getrestrictions_explained($group_id, "news")));
00063 }
00064
00065
00066 if ($update)
00067 {
00068 $valid = form_check($form_id);
00069
00070 # Insert the new item, with 5 as status: project admin
00071 # must moderate it.
00072 # There must be a title.
00073
00074 if (!$summary)
00075 {
00076 fb(_("Title is missing"),1);
00077 $valid = 0;
00078 }
00079
00080 if ($valid)
00081 {
00082 $new_id=forum_create_forum($group_id,$summary,1,0);
00083 $sql="INSERT INTO news_bytes (group_id,submitted_by,is_approved,date,forum_id,summary,details) ".
00084 " VALUES ('$group_id','".user_getid()."','5','".time()."','$new_id','".htmlspecialchars($summary)."','".htmlspecialchars($details)."')";
00085 $result=db_query($sql);
00086 }
00087
00088 if (!$result)
00089 {
00090 fb(_("Error doing insert"),1);
00091 }
00092 else
00093 {
00094 #
00095
00096 # $details needs to be keept only if there was an error
00097 unset($details);
00098 $feedback = _("News Posted: it will need to be approved by a news manager of this project before it shows on the project front page.");
00099
00100 form_clean($form_id);
00101
00102 session_redirect($GLOBALS['sys_home'].'news/?group='.$group_name.'&feedback='.urlencode($feedback));
00103 }
00104 }
00105
00106 # News must be submitted from a project page
00107
00108
00109 if (!$group_id)
00110 {
00111 exit_no_group();
00112 }
00113
00114 # Show the submit form
00115 site_project_header(array('title'=>_("Submit News"),
00116 'group'=>$group_id,
00117 'context'=>'news'));
00118
00119
00120 if($feedback)
00121 {
00122 print '<h3 class="warn">'.$feedback.'</h3>';
00123 }
00124
00125 print '
00126 <p class="warn">'._("A news manager of this project will have to review and approve the news.")."</p>\n<p>"
00127 ._("You may include URLs, emails, that will be made clickable, but not HTML.").'
00128 </p>'.
00129 form_header($PHP_SELF, $form_id).
00130 form_input("hidden", "group_id", $group_id).'
00131 <span class="preinput">'._("Subject:").'</span><br/>
00132 <input type="text" name="summary" value="'.$summary.'" size="65" maxlenght="80" />
00133 <br />
00134 <span class="preinput">'._("Details:").'</span><br />
00135 <textarea name="details" rows="20" cols="65" wrap="soft">'.$details.'</textarea><br />'.
00136 form_footer();
00137
00138 site_project_footer(array());
00139
00140
00141 ?>