00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: editgroupfeatures.php 5444 2006-02-19 15:28:12Z yeupou $
00006 #
00007 # Copyright 2003-2004 (c) Mathieu Roy <yeupou--at--gnu.org>
00008 #
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00022
00023
00024 require "../../include/pre.php";
00025
00026 session_require(array('group'=>$group_id,'admin_flags'=>'A'));
00027
00028
00029 # If this was a submission, make updates
00030
00031 if ($update)
00032 {
00033
00034 #FIXME: feeds the database with default values... instead of checkbox,
00035 # it should be select boxes "default/activated/deactivated"
00036
00037 group_add_history('Changed Activated Features','',$group_id);
00038
00039 # in the database, these all default to '1',
00040 # so we have to explicity set 0
00041 # (this is ugly)
00042 if (!$use_bugs)
00043 { $use_bugs=0; }
00044 if (!$use_mail)
00045 { $use_mail=0; }
00046 if (!$use_homepage)
00047 { $use_homepage=0; }
00048 if (!$use_download)
00049 { $use_download=0; }
00050 if (!$use_patch)
00051 { $use_patch=0; }
00052 if (!$use_forum)
00053 { $use_forum=0; }
00054 if (!$use_task)
00055 { $use_task=0; }
00056 if (!$use_cvs)
00057 { $use_cvs=0; }
00058 if (!$use_arch)
00059 { $use_arch=0; }
00060 if (!$use_svn)
00061 { $use_svn=0; }
00062 if (!$use_news)
00063 { $use_news=0; }
00064 if (!$use_news)
00065 { $use_news=0; }
00066 if (!$use_support)
00067 { $use_support=0; }
00068 if (!$use_extralink_documentation)
00069 { $use_extralink_documentation=0; }
00070
00071 $cases = array("use_homepage",
00072 "use_bugs",
00073 "use_mail",
00074 "use_patch",
00075 "use_forum",
00076 "use_task",
00077 "use_cvs",
00078 "use_arch",
00079 "use_svn",
00080 "use_news",
00081 "use_support",
00082 "use_download",
00083 "use_extralink_documentation",
00084 "url_homepage",
00085 "url_bugs",
00086 "url_mail",
00087 "url_patch",
00088 "url_forum",
00089 "url_task",
00090 "url_download",
00091 "url_cvs",
00092 "url_cvs_viewcvs",
00093 "url_cvs_viewcvs_homepage",
00094 "url_arch",
00095 "url_arch_viewcvs",
00096 "url_svn",
00097 "url_svn_viewcvs",
00098 "url_support",
00099 "dir_download",
00100 "url_extralink_documentation");
00101
00102 unset($upd_list);
00103 while (list(,$field) = each($cases))
00104 {
00105 $field_name = substr($field, 4, strlen($field));
00106 $type = substr($field, 0, 3);
00107
00108 if ($field_name == "bugs")
00109 { $field_name = "bug"; }
00110 if ($field_name == "mail")
00111 { $field_name = "mailing_list"; }
00112
00113 if ($project->CanUse($field_name) ||
00114 ($field_name == "extralink_documentation") ||
00115 ($field == "url_cvs_viewcvs_homepage" && $project->CanUse("homepage")) ||
00116 ($field == "url_cvs_viewcvs" && $project->CanUse("cvs")))
00117 {
00118 if ($type == "use" ||
00119 ($type == "use" && $field_name == "extralink_documentation" && $project->CanModifyUrl("extralink_documentation")))
00120 {
00121 $upd_list .= $field."='".$$field."', ";
00122 }
00123 elseif ($type == "url")
00124 {
00125 if ($field_name == "bug")
00126 { $field_name = "bugs"; }
00127 if ($field_name == "mail")
00128 { $field_name = "mailing_list"; }
00129
00130 if ($project->CanModifyUrl($field_name))
00131 {
00132 $upd_list .= $field."='".$$field."', ";
00133 }
00134 }
00135 elseif ($type == "dir" && $field == "dir_download" && $project->CanUse("download") && $project->CanModifyDir("download_dir"))
00136 {
00137 $upd_list .= $field."='".$$field."', ";
00138 }
00139 }
00140 }
00141
00142 if ($upd_list)
00143 {
00144 $upd_list = rtrim($upd_list, ", ");
00145
00146 $sql = "UPDATE groups SET "
00147 .$upd_list
00148 ." WHERE group_id=$group_id";
00149
00150 $result = db_numrows(db_query($sql));
00151
00152 if ($result > 0)
00153 { fb(_("Update failed."), 1); }
00154 else
00155 { fb(_("Update successful.")); }
00156
00157 }
00158 else
00159 { fb(_("Nothing to update.")); }
00160 }
00161
00162 $project =& new Project($group_id); # do not mess with previous values
00163
00164 site_project_header(array('title'=>_("Editing Active Features"),'group'=>$group_id,'context'=>'ahome'));
00165
00166
00167
00168 function specific_line ($artifact, $explanation, $use, $increment=1)
00169 {
00170
00171 # just a little fonction to clean that part of the code, no
00172 # interest to generalize it
00173 global $i, $project;
00174 if ($increment)
00175 { $i++; }
00176 print '<tr>';
00177 print ' <td class="'.utils_get_alt_row_color($i).'">'.$explanation.'</td>';
00178 print ' <td class="'.utils_get_alt_row_color($i).'">';
00179 # print the checkbox to de/activate it
00180 # (viewcvs cannot be activated or deactivated, they are not in the menu)
00181 if (!preg_match("/viewcvs/", $artifact))
00182 { html_build_checkbox("use_".$artifact, $use); }
00183 else
00184 { print "---"; }
00185 print '</td>';
00186 # print the default setting
00187 # (extralink_* does not have any default)
00188 print ' <td class="'.utils_get_alt_row_color($i).'">';
00189 if (!preg_match("/extralink/", $artifact))
00190 {
00191 print '<a href="'.group_get_artifact_url($artifact).'">'.group_get_artifact_url($artifact).'</a>';
00192 }
00193 print '</td>';
00194 # if allowed from the group type, add a text field to put a non-standard
00195 # url.
00196 # (news cannot be activated and using a non-standard url, it would
00197 # broke the news system)
00198 print ' <td class="'.utils_get_alt_row_color($i).'">';
00199 if ($project->CanModifyUrl($artifact))
00200 {
00201 if ($artifact == "homepage" ||
00202 $artifact == "download" ||
00203 $artifact == "cvs_viewcvs" ||
00204 $artifact == "arch_viewcvs" ||
00205 $artifact == "svn_viewcvs" ||
00206 preg_match("/viewcvs/", $artifact) ||
00207 preg_match("/extralink/", $artifact))
00208 {
00209 $url = $project->getUrl($artifact);
00210 }
00211 else
00212 {
00213 $url = $project->getArtifactUrl($artifact);
00214 }
00215
00216 print '<input type="text" name="url_'.$artifact.'" value="'.$url.'" size="20" />';
00217 }
00218 else
00219 { print "---"; }
00220 print '</td>';
00221 print '</tr>';
00222 }
00223
00224 print _("You can activate or deactivate feature/artifact for your project. In some case, depending on the system administrator's choices, you can even use change the URL for a feature/artifact. If the field 'alternative address' is empty, the standard is used.");
00225 print '<p></p>';
00226
00227 print '
00228 <form action="'.$PHP_SELF.'" method="post">
00229 <input type="hidden" name="group_id" value="'.$group_id.'" />';
00230
00231
00232 $title_arr=array();
00233 $title_arr[]=_("Feature, Artifact");
00234 $title_arr[]=_("Activated?");
00235 $title_arr[]=_("Standard Address");
00236 $title_arr[]=_("Alternative Address");
00237
00238 print html_build_list_table_top ($title_arr);
00239
00240 if ($project->CanUse("homepage"))
00241 {
00242 specific_line("homepage", _("Homepage"), $project->Uses("homepage"));
00243 specific_line("cvs_viewcvs_homepage", _("Homepage Source Code Web Browsing"), 0, 0);
00244 }
00245
00246 if ($project->CanModifyUrl("extralink_documentation"))
00247 { specific_line("extralink_documentation", _("Documentation"), $project->Uses("extralink_documentation")); }
00248
00249 if ($project->CanUse("download"))
00250 { specific_line("download", _("Download Area"), $project->Uses("download")); }
00251
00252 if ($project->CanUse("download") && $project->CanModifyDir("download_dir"))
00253 {
00254 $i++; print '<tr>';
00255 print ' <td class="'.utils_get_alt_row_color($i).'">'._("Download Area Directory").'</td>';
00256 print ' <td class="'.utils_get_alt_row_color($i).'">';
00257 print "---";
00258 print '</td>';
00259 print ' <td class="'.utils_get_alt_row_color($i).'">';
00260 print $project->getTypeDir("download");
00261 print ' </td>';
00262
00263 print ' <td class="'.utils_get_alt_row_color($i).'">';
00264
00265 print ' <input type="text" name="dir_download" value="'.$project->getDir("download").'" size="20">';
00266
00267 print ' </td>';
00268 print '</tr>';
00269 }
00270
00271 if ($project->CanUse("support"))
00272 { specific_line("support", _("Support Tracker"), $project->Uses("support")); }
00273
00274 if ($project->CanUse("forum"))
00275 { specific_line("forum", _("Forum"), $project->Uses("forum")); }
00276
00277 if ($project->CanUse("mailing_list"))
00278 { specific_line("mail", _("Mailing-List"), $project->usesMail()); }
00279
00280 if ($project->CanUse("cvs") || $project->CanUse("homepage"))
00281 {
00282 specific_line("cvs", _("CVS"), $project->Uses("cvs"));
00283 specific_line("cvs_viewcvs", _("CVS Web Browsing"), 0, 0);
00284 }
00285 if ($project->CanUse("arch"))
00286 {
00287 specific_line("arch", _("GNU Arch"), $project->Uses("arch"));
00288 specific_line("arch_viewcvs", _("Arch Web Browsing"), 0, 0);
00289 }
00290
00291 if ($project->CanUse("svn"))
00292 {
00293 specific_line("svn", _("Subversion"), $project->Uses("svn"));
00294 specific_line("svn_viewcvs", _("Subversion Web Browsing"), 0, 0);
00295 }
00296
00297
00298 if ($project->CanUse("bug"))
00299 { specific_line("bugs", _("Bugs Tracker"), $project->Uses("bugs")); }
00300
00301 if ($project->CanUse("task"))
00302 { specific_line("task", _("Task Tracker"), $project->Uses("task")); }
00303
00304 if ($project->CanUse("patch"))
00305 { specific_line("patch", _("Patch Tracker"), $project->Uses("patch")); }
00306
00307 if ($project->CanUse("news"))
00308 { specific_line("news", _("News"), $project->Uses("news")); }
00309
00310 $HTML->box1_bottom();
00311
00312 print '<p align="center"><input type="submit" name="update" value="'._("Update").'" /></form><p>';
00313
00314 site_project_footer(array());
00315
00316 ?>