+++ to secure your transactions use the Bitcoin Mixer Service +++

 

summaryrefslogtreecommitdiff
path: root/frontend/php/bugs/admin/other_settings.php
blob: a3112f65dd24b7ae4cc700251e1d0ec32b1a1289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
# Edit miscellaneous tracker settings (preambles).
#
# Copyright (C) 1999, 2000 The SourceForge Crew
# Copyright (C) 2001, 2002 Laurent Julliard, CodeX Team, Xerox
# Copyright (C) 2000-2006 Mathieu Roy <yeupou--gnu.org>
# Copyright (C) 2014, 2016, 2017 Assaf Gordon
# Copyright (C) 2001-2011, 2013, 2017 Sylvain Beucler
# Copyright (C) 2013, 2014, 2017-2024 Ineiev
#
# This file is part of Savane.
#
# Code written before 2008-03-30 (commit 8b757b2565ff) is distributed
# under the terms of the GNU General Public license version 3 or (at your
# option) any later version; further contributions are covered by
# the GNU Affero General Public license version 3 or (at your option)
# any later version.  The license notices for the AGPL and the GPL follow.
#
# Savane is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Savane is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Savane is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Savane is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require_once ('../../include/init.php');
require_once ('../../include/trackers/general.php');
$artifact = ARTIFACT;
$pref_preamble_titles = [
  'comment' => [
     _("Comment Post Form Preamble"),
     _("Introductory message for comments"),
  ],
  'file' => [
    _("File Post Form Preamble"),
    _("Introductory message for files"),
  ],
];

function pref_name ($name, $artifact)
{
  return "{$artifact}_{$name}_preamble";
}
function form_pref_name ($x)
{
  return "form_$x";
}
$pref_preambles = [];
foreach ($pref_preamble_titles as $pre => $t)
  {
    $name = pref_name ($pre, $artifact);
    $pref_preambles[] = $name;
    $form_pref_preambles[] = form_pref_name ($name);
  }

$form_preambles = $form_pref_preambles;
$form_preambles[] = 'form_preamble';

extract (sane_import ('post',
  ['true' => 'update', 'specialchars' => $form_preambles]
));
form_check ('update');
require_directory ("project");

$is_admin_page = 'y';

if (!$group_id)
  exit_no_group();

if (
  # Must be at least Bug Admin or Project Admin.
  !member_check (0, $group_id, member_create_tracker_flag (ARTIFACT) . '2')
  && !user_ismember ($group_id, 'A')
)
  exit_permission_denied ();

function fetch_preamble ($group_id, $artifact)
{
  global $current_preamble;
  $res_grp = db_execute ("SELECT * FROM groups WHERE group_id = ?", [$group_id]);
  if (db_numrows ($res_grp) < 1)
    exit_no_group ();
  $row_grp = db_fetch_array ($res_grp);
  return $row_grp["{$artifact}_preamble"];
}

$current_preamble = fetch_preamble ($group_id, $artifact);

$new_pref_keys = [];
$new_pref_vals = [];
function fetch_pref_preambles ($group_id)
{
  global $cur_pref_preambles, $pref_preambles, $new_pref_keys, $new_pref_vals;
  $cur_pref_preambles = group_get_preference ($group_id, $pref_preambles);
  foreach ($pref_preambles as $pre)
    {
      $new_val = $GLOBALS["form_$pre"];
      if ($cur_pref_preambles[$pre] === $new_val)
        continue;
      $new_pref_keys[] = $pre;
      $new_pref_vals[] = $new_val;
    }
}

fetch_pref_preambles ($group_id);

$changed = $form_preamble != $current_preamble;
$pref_changed = !empty ($new_pref_keys);

if ($update && ($changed || $pref_changed))
  {
    group_add_history ('Changed Tracking System Settings', '', $group_id);
    $update_failed = false;
    if ($changed)
      {
        $result = db_execute (
          "UPDATE groups SET {$artifact}_preamble = ?  WHERE group_id = ?",
          [$form_preamble, $group_id]
        );
        if ($result)
          $current_preamble = fetch_preamble ($group_id, $artifact);
        else
          $update_failed = true;
     }
    if ($pref_changed)
      {
        if (group_set_preference ($group_id, $new_pref_keys, $new_pref_vals))
          fetch_pref_preambles ($group_id);
        else
          $update_failed = true;
      }
    if ($update_failed)
      fb (_("Update failed"), 1);
    else
      fb (_("Updated successfully"));
  }

trackers_header_admin (['title' => _("Other Settings")]);

print html_h (2, _("Item Post Form Preamble"));
print form_tag () . form_hidden (['group_id' => $group_id]);
print '<span class="preinput">'
 . html_label ("form_preamble",
    _("Introductory message showing at the top of the item submission form")
   );
print markup_info ("rich") . "</span>\n<br />\n"
  . form_textarea ('form_preamble', $current_preamble,
      "cols='70' rows='8' wrap='virtual'"
    )
  . "\n";

function pref_preamble_input ($form_name, $title, $current)
{
  $heading = $title[0]; $info = $title[1];

  print html_h (2, $heading);
  print "<span class='preinput'>" . html_label ($form_name, $info);
  print markup_info ("rich") . "</span>\n<br />\n"
    . form_textarea ($form_name, $current, "cols='70' rows='8' wrap='virtual'")
    . "\n";
}

foreach ($pref_preamble_titles as $pre => $title)
  {
    $name = pref_name ($pre, $artifact);
    $form_name = form_pref_name ($name);
    pref_preamble_input ($form_name, $title, $cur_pref_preambles[$name]);
  }

print form_footer ();
trackers_footer ();
?>