Skip to content

Commit f0d76d6

Browse files
authored
fix 0009390: Keyword features not available for the admin (#400)
Use the method testlinkInitPage like in others features (Project, Platform, ...).
1 parent 1866003 commit f0d76d6

File tree

4 files changed

+24
-50
lines changed

4 files changed

+24
-50
lines changed

lib/keywords/keywordsEdit.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
require_once("keywordsEnv.php");
2020

2121

22-
testlinkInitPage($db);
22+
testlinkInitPage($db, false, false, "checkRights");
2323
$tplCfg = templateConfiguration();
2424

2525
$tplEngine = new TLSmarty();
@@ -119,18 +119,7 @@ function initEnv(&$dbHandler) {
119119
throw new Exception("Error Invalid Test Project ID", 1);
120120
}
121121

122-
// Check rights before doing anything else
123-
// Abort if rights are not enough
124122
$args->user = $_SESSION['currentUser'];
125-
$env['tproject_id'] = $args->tproject_id;
126-
$env['tplan_id'] = 0;
127-
128-
$check = new stdClass();
129-
$check->items = array('mgt_modify_key','mgt_view_key');
130-
$check->mode = 'and';
131-
checkAccess($dbHandler,$args->user,$env,$check);
132-
133-
// OK Go ahead
134123
$args->canManage = true;
135124
$args->mgt_view_events = $args->user->hasRight($dbHandler,"mgt_view_events",$args->tproject_id);
136125

@@ -346,3 +335,8 @@ function initializeGui(&$dbH,&$args) {
346335

347336
return $gui;
348337
}
338+
339+
function checkRights(&$db,&$user) {
340+
return ($user->hasRightOnProj($db,'mgt_view_key')
341+
|| $user->hasRightOnProj($db,'mgt_modify_key'));
342+
}

lib/keywords/keywordsExport.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
require_once("xml.inc.php");
1616
require_once("keywordsEnv.php");
1717

18-
testlinkInitPage($db);
18+
testlinkInitPage($db, false, false, "checkRights");
1919
$templateCfg = templateConfiguration();
2020
$args = init_args($db);
2121
$gui = initializeGui($args);
@@ -46,17 +46,7 @@ function init_args(&$dbHandler) {
4646
throw new Exception("Error Invalid Test Project ID", 1);
4747
}
4848

49-
// Check rights before doing anything else
50-
// Abort if rights are not enough
5149
$args->user = $_SESSION['currentUser'];
52-
$env['tproject_id'] = $args->tproject_id;
53-
$env['tplan_id'] = 0;
54-
55-
$check = new stdClass();
56-
$check->items = array('mgt_view_key');
57-
$check->mode = 'and';
58-
checkAccess($dbHandler,$args->user,$env,$check);
59-
6050
$tproj_mgr = new testproject($dbHandler);
6151
$dm = $tproj_mgr->get_by_id($args->tproject_id,array('output' => 'name'));
6252
$args->tproject_name = $dm['name'];
@@ -131,4 +121,8 @@ function exportKeywordsToCSV($kwSet) {
131121
$keys = array( "keyword","notes","tcv_qty" );
132122
$csv = exportDataToCSV($kwSet,$keys,$keys,array('addHeader' => 1));
133123
return $csv;
134-
}
124+
}
125+
126+
function checkRights(&$db,&$user) {
127+
return ($user->hasRightOnProj($db,'mgt_view_key'));
128+
}

lib/keywords/keywordsImport.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
require_once('csv.inc.php');
1717
require_once('xml.inc.php');
1818

19-
testlinkInitPage($db);
19+
testlinkInitPage($db, false, false, "checkRights");
2020
$templateCfg = templateConfiguration();
2121

2222
$args = init_args($db);
@@ -77,17 +77,6 @@ function init_args(&$dbHandler)
7777
throw new Exception(" Error Invalid Test Project ID", 1);
7878
}
7979

80-
// Check rights before doing anything else
81-
// Abort if rights are not enough
82-
$user = $_SESSION['currentUser'];
83-
$env['tproject_id'] = $args->tproject_id;
84-
$env['tplan_id'] = 0;
85-
86-
$check = new stdClass();
87-
$check->items = array('mgt_modify_key');
88-
$check->mode = 'and';
89-
checkAccess($dbHandler,$user,$env,$check);
90-
9180
$tproj_mgr = new testproject($dbHandler);
9281
$dm = $tproj_mgr->get_by_id($args->tproject_id,
9382
array('output' => 'name'));
@@ -145,4 +134,8 @@ function initializeGui(&$argsObj)
145134

146135

147136
return $gui;
148-
}
137+
}
138+
139+
function checkRights(&$db,&$user) {
140+
return ($user->hasRightOnProj($db,'mgt_modify_key'));
141+
}

lib/keywords/keywordsView.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
require_once("common.php");
1212
require_once("keywordsEnv.php");
1313

14-
testlinkInitPage($db);
14+
testlinkInitPage($db, false, false, "checkRights");
1515
$templateCfg = templateConfiguration();
1616
$gui = $args = init_args($db);
1717

@@ -31,18 +31,7 @@ function init_args(&$dbHandler) {
3131
throw new Exception("Error Invalid Test Project ID", 1);
3232
}
3333

34-
// Check rights before doing anything else
35-
// Abort if rights are not enough
3634
$user = $_SESSION['currentUser'];
37-
$env['tproject_id'] = $tproject_id;
38-
$env['tplan_id'] = 0;
39-
40-
$check = new stdClass();
41-
$check->items = array('mgt_view_key');
42-
$check->mode = 'and';
43-
checkAccess($dbHandler,$user,$env,$check);
44-
45-
// OK, go ahead
4635
$args = getKeywordsEnv($dbHandler,$user,$tproject_id);
4736
$args->tproject_id = $tproject_id;
4837

@@ -62,4 +51,8 @@ function init_args(&$dbHandler) {
6251
}
6352

6453
return $args;
65-
}
54+
}
55+
56+
function checkRights(&$db,&$user) {
57+
return ($user->hasRightOnProj($db,'mgt_view_key'));
58+
}

0 commit comments

Comments
 (0)