Skip to content

Commit b9e0ef4

Browse files
committed
[spalenque] - #13200 * add a security group to access survey free text tagging
1 parent fd174c1 commit b9e0ef4

5 files changed

Lines changed: 74 additions & 5 deletions

File tree

migrations/migrations.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ migrations:
8383
- AddUniqueIndexMemberScheduleFavorites
8484
- AddONDELETECascadeFKOnInheritanceMappingMigration
8585
- SurveyDoubleEntryTableQuestionTemplateDataFixMigration
86+
- CreateFreeTextTaggingGroupMigration

sangria/code/SangriaPage.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,17 @@ final class SangriaPage_Controller extends AdminController implements Permission
3939

4040
function init()
4141
{
42-
if (!Permission::check("SANGRIA_ACCESS")) {
43-
Security::permissionFailure();
42+
43+
if ($this->request->param('Action') == 'ViewSurveyFreeAnswersList') {
44+
if (!Permission::check("FREE_TEXT_TAGGING_ACCESS")) {
45+
return Security::permissionFailure();
46+
}
47+
} else {
48+
if (!Permission::check("SANGRIA_ACCESS")) {
49+
Security::permissionFailure();
50+
}
4451
}
52+
4553
parent::init();
4654

4755
Requirements::css('fonts.googleapis.com/css?family=PT+Sans&subset=latin');
@@ -77,6 +85,12 @@ function providePermissions()
7785
'help' => '',
7886
'sort' => 0
7987
),
88+
'FREE_TEXT_TAGGING_ACCESS' => array(
89+
'name' => 'Access the free text tagging page',
90+
'category' => 'Sangria',
91+
'help' => '',
92+
'sort' => 1
93+
),
8094
);
8195
}
8296

sangria/code/interfaces/restfull_api/SangriaApi.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ class SangriaApi extends AbstractRestfulJsonApi
2222
protected function authorize()
2323
{
2424
//check permissions
25-
if(!Permission::check("SANGRIA_ACCESS"))
26-
return false;
25+
if ($this->request->param('SUBROUTE') == SangriaSurveyBuilderRouterApiExtension::SubRouteSurveyTemplates) {
26+
if(!Permission::check("FREE_TEXT_TAGGING_ACCESS"))
27+
return false;
28+
} else {
29+
if(!Permission::check("SANGRIA_ACCESS"))
30+
return false;
31+
}
32+
2733
return true;
2834
}
2935

survey_builder/code/interfaces/restfull_api/SangriaSurveyTemplateApi.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ public function __construct(ISurveyFreeTextAnswerManager $manager, ISurveyTempl
7171
protected function authorize()
7272
{
7373
//check permissions
74-
if(!Permission::check("SANGRIA_ACCESS"))
74+
if(!Permission::check("FREE_TEXT_TAGGING_ACCESS")) {
7575
return false;
76+
}
77+
7678
return true;
7779
}
7880

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2017 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
final class CreateFreeTextTaggingGroupMigration extends AbstractDBMigrationTask
16+
{
17+
protected $title = "Create Survey Free Text Tagging Group";
18+
19+
protected $description = "creates group survey-free-text-tagging.";
20+
21+
function doUp()
22+
{
23+
global $database;
24+
//$members = array(93000); // members to add
25+
26+
$group = new Group();
27+
$group->setTitle('Free Text Tagging');
28+
$group->setDescription('Allows access to sangria survey free text tagging page.');
29+
$group->setSlug('survey-free-text-tagging');
30+
$group->write();
31+
32+
//$group->Members()->setByIDList($members);
33+
34+
Permission::grant($group->getIdentifier(), 'FREE_TEXT_TAGGING_ACCESS');
35+
36+
// update sangria group
37+
$sangria_group = Group::get()->filter('Code','sangria')->first();
38+
Permission::grant($sangria_group->getIdentifier(), 'FREE_TEXT_TAGGING_ACCESS');
39+
40+
}
41+
42+
function doDown()
43+
{
44+
45+
}
46+
}

0 commit comments

Comments
 (0)