/usr/share/gforge/plugins/blocks/www/index.php is in fusionforge-plugin-blocks 5.3.2+20141104-3+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | <?php
/*
* Copyright (C) 2006 Alain Peyrat, Alcatel-Lucent
* Copyright (C) 2010 Alain Peyrat <aljeux@free.fr>
* Copyright (C) 2012-2014 Alain Peyrat - Alcatel-Lucent
*
* This file is part of FusionForge.
*
* FusionForge 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 2 of the License,
* or (at your option) any later version.
*
* FusionForge 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Standard Alcatel-Lucent disclaimer for contributing to open source
*
* "The provided file ("Contribution") has not been tested and/or
* validated for release as or in products, combinations with products or
* other commercial use. Any use of the Contribution is entirely made at
* the user's own responsibility and the user can not rely on any features,
* functionalities or performances Alcatel-Lucent has attributed to the
* Contribution.
*
* THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
* OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
* NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
* CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
* TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
* ALONE BASIS."
*/
require_once dirname(__FILE__)."/../../env.inc.php";
require_once $gfcommon.'include/pre.php';
require_once $gfcommon.'forum/ForumFactory.class.php';
require_once $gfcommon.'tracker/ArtifactFactory.class.php';
require_once $gfcommon.'mail/MailingListFactory.class.php';
require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
require_once $gfcommon.'survey/SurveyFactory.class.php';
function getAvailableBlocks($group) {
$blocks = array(
'summary_description' =>
_("Block to replace the default project description with an enhanced one."),
'request_join' =>
_("Block to list informations requested to ask to join a project"),
);
if ($group->usesForum()) {
// Get the blocks in the forums.
$blocks['forum index'] = _("Display block at the top of the listing");
$ff = new ForumFactory($group);
foreach ( $ff->getForums() as $f) {
$blocks['forum_'.$f->getName()] = _("Display block at the top");
}
}
if ($group->usesTracker()) {
// Get the blocks in the trackers.
$blocks['tracker index'] = _("Display block at the top of the listing");
$ff = new ArtifactTypeFactory($group);
foreach ( $ff->getArtifactTypes() as $f) {
$blocks['tracker_'.$f->getName()] = _("Display block at the top");
}
}
if ($group->usesMail()) {
// Get the blocks in the mailing lists.
$blocks['mail index'] = _("Display block at the top of the listing");
$ff = new MailingListFactory($group);
foreach ( $ff->getMailingLists() as $f) {
$blocks['mail_'.$f->getName()] = _("Display block at the top");
}
}
if ($group->usesPM()) {
// Get the blocks in the tasks.
$blocks['tasks index'] = _("Display block at the top of the listing");
$ff = new ProjectGroupFactory($group);
foreach ( $ff->getProjectGroups() as $f) {
$blocks['tasks_'.$f->getName()] = _("Display block at the top");
}
}
if ($group->usesDocman()) {
// Get the blocks in the doc.
$blocks['doc index'] = _("Display block at the top of the listing");
$blocks['doc help'] = _("Display block at the top of the main page");
}
if ($group->usesSurvey()) {
// Get the blocks in the survey.
$blocks['survey index'] = _("Display block at the top of the listing");
$ff = new SurveyFactory($group);
foreach ( $ff->getSurveys() as $f) {
$blocks['survey_'.$f->getTitle()] = _("Display block at the top");
}
}
if ($group->usesNews()) {
// Get the blocks in the news.
$blocks['news index'] = _("Display block at the top of the listing");
}
if ($group->usesSCM()) {
// Get the blocks in the scm.
$blocks['scm index'] = _("Display block at the top of the listing");
}
if ($group->usesFRS()) {
// Get the blocks in the files.
$blocks['files index'] = _("Display block at the top of the listing");
}
return $blocks;
}
// the header that displays for the user portion of the plugin
function blocks_Project_Header($params) {
global $id;
$params['toptab']='blocks';
$params['group']=$id;
/*
Show horizontal links
*/
site_project_header($params);
}
$type = getStringFromRequest('type');
$id = getStringFromRequest('id');
$pluginname = getStringFromRequest('pluginname');
$name = getStringFromRequest('name');
$body = getHtmlTextFromRequest('body');
$activate = getArrayFromRequest('activate');
$blocks_text = array(
'forum' => _('Forums'),
'tracker' => _('Trackers'),
'mail' => _('Lists'),
'tasks' => _('Tasks'),
'doc' => _('Docs'),
'survey' => _('Surveys'),
'news' => _('News'),
'scm' => _('SCM'),
'files' => _('Files')
);
if (!$type) {
exit_error(_('Cannot Process your request: No TYPE specified'),'home'); // you can create items in Base.tab and customize this messages
} elseif (!$id) {
exit_error(_('Cannot Process your request: No ID specified'),'home');
}
$group = group_get_object($id);
if ( !$group) {
exit_no_group();
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the blocks plugin active
exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'),$pluginname),'home');
}
session_require_perm ('project_admin', $id) ;
if ($type == 'admin') {
blocks_Project_Header(array('title'=>'Blocks Administration','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
$res = db_query_params('SELECT name, status FROM plugin_blocks WHERE group_id=$1',
array($id));
while ($row = db_fetch_array($res)) {
$status[ $row['name'] ] = $row['status'];
}
print _("Blocks are customizable HTML boxes in the left or right side of the pages the web site. They are created manually.");
print "<form action=\"/plugins/blocks/\" method=\"post\">";
print "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
print "<input type=\"hidden\" name=\"pluginname\" value=\"$pluginname\" />\n";
print "<input type=\"hidden\" name=\"type\" value=\"admin_post\" />\n";
print "<table class=\"centered listing\">";
print "<thead><tr><th>".
_("Name").
"</th>" .
"<th>".
_("Active").
"</th>" .
"<th>" .
_("Description").
"</th>" .
"<th>" .
_("Operation") .
"</th>" .
"</tr></thead>";
$blocks = getAvailableBlocks($group);
$class = 'even';
foreach ($blocks as $b => $help) {
$class = ($class == 'even') ? "odd" : "even";
$match = '';
if (preg_match('/(.*) index$/', $b, $match)) {
print '<tr><td colspan="4"><b>'.$blocks_text[$match[1]].'</b></td></tr>';
}
$checked = (isset($status[$b]) && $status[$b] == 1) ? ' checked="checked"' : '';
print "<tr class=\"$class\"><td>$b</td>\n" .
"<td class=\"align-center\">" .
"<input type=\"checkbox\" name=\"activate[$b]\" value=\"1\"$checked /></td>\n" .
"<td>$help</td>\n" .
"<td><a href=\"/plugins/blocks/index.php?id=$id&type=configure&pluginname=blocks&name=".urlencode($b)."\">"._('Configure')."</a></td>\n</tr>\n";
}
print "</table>\n";
print '<p class="align-center"><input type="submit" value="' .
_("Save Blocks") .
'" /></p>';
print "</form>\n";
} elseif ($type == 'admin_post') {
$res = db_query_params('SELECT name, status FROM plugin_blocks WHERE group_id=$1',
array($id));
while ($row = db_fetch_array($res)) {
$present[ $row['name'] ] = true;
$status[ $row['name'] ] = $row['status'];
}
$blocks = getAvailableBlocks($group);
// Workaround when a block has a name with a & inside.
// It seems sadly converted by the form (or php?).
foreach ($activate as $k => $v) {
$nk = str_replace("&","&", $k);
if ($nk !== $k) {
$activate[$nk] = $v;
unset($activate[$k]);
}
}
foreach ($blocks as $b => $help) {
if (!$activate[$b])
$activate[$b] = 0;
if ((!isset($status[$b]) && $activate[$b]) ||
(isset($status[$b]) && $activate[$b] !== $status[$b]))
// Must be updated.
if (!isset($present[$b])) {
db_query_params('INSERT INTO plugin_blocks (group_id, name, status)
VALUES ($1, $2, $3)',
array($id, $b, $activate[$b]));
} else {
db_query_params('UPDATE plugin_blocks SET status=$1
WHERE group_id=$2 AND name=$3',
array($activate[$b], $id, $b));
}
}
$msg = _('Block Saved');
session_redirect('/plugins/blocks/index.php?id='.$id.'&type=admin&pluginname=blocks&feedback='.urlencode($msg));
} elseif ($type == 'configure') {
blocks_Project_Header(array('title'=>'Edit Block','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
$blocks = getAvailableBlocks($group);
$res = db_query_params('SELECT content FROM plugin_blocks WHERE group_id=$1 AND name=$2',
array($id, $name));
$body = db_result($res,0,"content");
print _("Edit the block as you want. If you activate the HTML editor, you will be able to use WYSIWYG formatting (bold, colors...)");
print '<div class="align-center">';
print "<p><b>$blocks[$name]</b> ($name)</p>";
print "<form action=\"/plugins/blocks/\" method=\"post\">";
print "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
print "<input type=\"hidden\" name=\"pluginname\" value=\"$pluginname\" />\n";
print "<input type=\"hidden\" name=\"type\" value=\"configure_post\" />\n";
print "<input type=\"hidden\" name=\"name\" value=\"$name\" />\n";
// Get default body from the templates defined in the config file.
if (!$body) {
$body = forge_get_config($name, 'blocks');
if (!$body) {
$body = forge_get_config('default', 'blocks');
if (!$body) {
$body = '{boxHeader}'._('Enter your text here').'{boxFooter}';
}
}
}
$params['body'] = $body;
$params['width'] = "800";
$params['height'] = "500";
$params['group'] = $id;
$params['content'] = '<textarea name="body" rows="20" cols="80">'.$body.'</textarea>';
if (util_is_html($body)) {
// If user is editing HTML, keep HTML format by saying it's html
$params['content'] = '<input type="hidden" name="_body_content_type" value="html" />'."\n".$params['content'];
}
plugin_hook_by_reference("text_editor", $params);
echo $params['content'];
print "<br /><input type=\"submit\" value=\"" .
_("Save") .
"\" />";
print "</form>";
print "</div>";
print "<fieldset><legend>".
_("Tips").
"</legend>" .
"<p>" .
_("You can create boxes like the ones on the right site of summary page, by inserting the following sentences in the content:").
"</p><ul><li>".
"{boxTop Hello}".
_(": will create the top part of the box using Hello as title.").
"</li><li>".
"{boxMiddle Here}".
_(": will create a middle part of a box using Here as title (optional).").
"</li><li>".
"{boxBottom}".
_(": will create the end part of a box.").
"</li></ul><ul><li>".
"{boxHeader}".
_(": will create a header before a text.").
"</li><li>{boxFooter}".
_(": will create a footer after a text.").
"</li></ul><p>".
_("You can create as many boxes as you want, but a boxTop has to be closed by a boxBottom and a boxHeader has to be closed by a boxFooter.").
"</p>".
"</fieldset>";
} elseif ($type == 'configure_post') {
$res = db_query_params('SELECT id FROM plugin_blocks WHERE group_id=$1 AND name=$2',
array($id, htmlspecialchars($name)));
if (db_numrows($res)== 0) {
db_query_params('INSERT INTO plugin_blocks (group_id, name, content)
VALUES ($1, $2, $3)',
array($id, htmlspecialchars($name), $body));
} else {
db_query_params('UPDATE plugin_blocks SET content=$1
WHERE group_id=$2 AND name=$3',
array($body, $id, htmlspecialchars($name)));
}
$msg = $name .' : '. _('Block configuration saved');
session_redirect('/plugins/blocks/index.php?id='.$id.'&type=admin&pluginname=blocks&feedback='.urlencode($msg));
}
site_project_footer(array());
|