5 * Copyright 2005, Raphaƫl Hertzog
6 * Copyright 2006-2009, Roland Mas
7 * Copyright 2009, Alain Peyrat
10 require_once ('../../../www/env.inc.php');
11 require_once $gfwww.'include/pre.php';
12 require_once $gfwww.'project/admin/project_admin_utils.php';
14 $group_id = getIntFromRequest ('group_id') ;
15 $index = getIntFromRequest ('index') ;
17 session_require(array('group'=>$group_id,'admin_flags'=>'A'));
19 // get current information
20 $group =& group_get_object($group_id);
21 if (!$group || !is_object($group)) {
22 exit_error('Error','Could Not Get Group');
23 } elseif ($group->isError()) {
24 exit_error('Error',$group->getErrorMessage());
29 // Calculate new index field
30 $res = db_query_params ('SELECT COUNT(*) as c FROM plugin_extratabs_main WHERE group_id = $1',
32 $row = db_fetch_array($res);
33 $newid = $row['c'] + 1;
35 $selected = 0; // No item selected by default
37 // Do work before displaying so that the result is immediately visible
38 if (getStringFromRequest ('addtab') != '') {
39 $tab_name = htmlspecialchars(trim(getStringFromRequest ('tab_name')));
40 $tab_url = htmlspecialchars(trim(getStringFromRequest ('tab_url')));
41 $res = db_query_params ('INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url) VALUES ($1,$2,$3,$4)',
46 if (!$res || db_affected_rows($res) < 1) {
47 $feedback = sprintf (_('Cannot insert new tab entry: %s'),
50 $feedback = _('Tab added');
52 } elseif (getStringFromRequest ('delete') != '') {
53 $res = db_query_params ('DELETE FROM plugin_extratabs_main WHERE group_id=$1 AND index=$2',
56 if (!$res || db_affected_rows($res) < 1) {
57 $feedback = sprintf (_('Cannot delete tab entry: %s'),
60 $res = db_query_params ('UPDATE plugin_extratabs_main SET index=index-1 WHERE group_id=$1 AND index > $2',
64 } elseif (getStringFromRequest ('up') != '') {
66 $previous = $index - 1;
67 $res = db_query_params('UPDATE plugin_extratabs_main SET index=0 WHERE group_id=$1 AND index=$2',
70 $res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=$3',
74 $res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=0',
77 $selected = $previous;
81 } elseif (getStringFromRequest ('down') != '') {
82 if ($index < $newid - 1) {
84 $res = db_query_params('UPDATE plugin_extratabs_main SET index=0 WHERE group_id=$1 AND index=$2',
87 $res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=$3',
91 $res = db_query_params('UPDATE plugin_extratabs_main SET index=$1 WHERE group_id=$2 AND index=0',
105 $adminheadertitle=sprintf(_('Project Admin: %1$s'), $group->getPublicName() );
106 project_admin_header(array('title'=>$adminheadertitle, 'group'=>$group->getID()));
112 <h3><?php echo _('Add new tabs'); ?></h3>
113 <p><?php echo _('You can add your own tabs in the menu bar with the form below.') ?></p>
116 <form name="new_tab" action="<?php echo util_make_url ('/plugins/extratabs/'); ?>" method="post">
117 <input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
118 <input type="hidden" name="addtab" value="1" />
119 <strong><?php echo _('Name of the tab:') ?></strong>
120 <?php echo utils_requiredField(); ?><br/>
121 <input type="text" size="15" maxlength="255" name="tab_name" /><br/>
122 <strong><?php echo _('URL of the tab:') ?></strong>
123 <?php echo utils_requiredField(); ?><br/>
124 <input type="text" size="15" name="tab_url" value="http://" /><br/>
125 <input type="submit" value="<?php echo _('Add tab') ?>" />
130 $res = db_query_params ('SELECT * FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index ASC', array ($group_id)) ;
131 $nbtabs = db_numrows($res) ;
137 <h3><?php echo _('Manage extra tabs') ;?></h3>
139 <?php echo _('You can move and delete the tabs that you already added. Please note that those extra tabs can only appear on the right of the standard tabs. And you can only move them inside the set of extra tabs.') ;
143 <form name="change_tab" action="<?php echo util_make_url ('/plugins/extratabs/'); ?>" method="post">
144 <input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
146 echo _('Tab to modify:')
148 <select name="index">
150 while ($row = db_fetch_array($res)) {
151 if ($row['index'] == $selected) {
152 echo "<option selected value='" . $row['index'] . "'>" . $row['tab_name'] . "</option>";
154 echo "<option value='" . $row['index'] . "'>" . $row['tab_name'] . "</option>";
158 <?php if ($nbtabs > 1) { ?>
159 <input type="submit" name="up" value="<?php echo _('Move tab left') ?>" /><br/>
160 <input type="submit" name="down" value="<?php echo _('Move tab right') ?>" /><br/>
162 <input type="submit" name="delete" value="<?php echo _('Delete tab') ?>" />
168 project_admin_footer(array());
172 // c-file-style: "bsd"