-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of Matchgrid Settings (CO-1803)
- Loading branch information
Benn Oshrin
committed
Oct 29, 2019
1 parent
05569cf
commit 38c4048
Showing
13 changed files
with
516 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| <?php | ||
| /** | ||
| * COmanage Matchgrid Settings Controller | ||
| * | ||
| * Portions licensed to the University Corporation for Advanced Internet | ||
| * Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at: | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * @link http://www.internet2.edu/comanage COmanage Project | ||
| * @package match | ||
| * @since COmanage Match v1.0.0 | ||
| * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| */ | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| namespace App\Controller; | ||
|
|
||
| class MatchgridSettingsController extends StandardController { | ||
| public $paginate = [ | ||
| 'order' => [ | ||
| 'MatchgridSetting.matchgrid_id' => 'asc' | ||
| ] | ||
| ]; | ||
|
|
||
| /** | ||
| * Callback run prior to the view rendering. | ||
| * | ||
| * @since COmanage Match v1.0.0 | ||
| * @param Event $event Cake Event | ||
| */ | ||
|
|
||
| public function beforeRender(\Cake\Event\Event $event) { | ||
| parent::beforeRender($event); | ||
|
|
||
| // Override page title | ||
| if($this->request->getParam('action') == 'edit') { | ||
| $this->set('vv_title', __("match.op.edit.a", [__("match.ct.matchgrid_settings", 1)])); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Handle an index request by checking for an existing CO Setting, | ||
| * creating it if not present, and then redirecting to edit. | ||
| * | ||
| * @since COmanage Match v1.0.0 | ||
| */ | ||
|
|
||
| public function index() { | ||
| if(empty($this->cur_mg->id)) { | ||
| throw new RuntimeException(__("match.er.mgid")); | ||
| } | ||
|
|
||
| // Let any exception pass up the stack | ||
| $id = $this->MatchgridSettings->getIdForMatchgrid($this->cur_mg->id); | ||
|
|
||
| return $this->redirect(['action' => 'edit', $id]); | ||
| } | ||
|
|
||
| /** | ||
| * Authorization for this Controller, called by Auth component | ||
| * - postcondition: $vv_permissions set with calculated permissions for this Controller | ||
| * | ||
| * @since COmanage Match v1.0.0 | ||
| * @param Array $user Array of user data | ||
| * @return Boolean True if authorized for the current action, false otherwise | ||
| */ | ||
|
|
||
| public function isAuthorized(Array $user) { | ||
| $mgid = isset($this->cur_mg->id) ? $this->cur_mg->id : null; | ||
|
|
||
| $platformAdmin = $this->Authorization->isPlatformAdmin($user['username']); | ||
|
|
||
| $mgAdmin = $this->Authorization->isMatchAdmin($user['username'], $mgid); | ||
|
|
||
| $p = [ | ||
| // No add or delete here | ||
| 'add' => false, | ||
| 'delete' => false, | ||
| 'edit' => $platformAdmin || $mgAdmin, | ||
| 'index' => $platformAdmin || $mgAdmin, | ||
| 'view' => false | ||
| ]; | ||
|
|
||
| $this->set('vv_permissions', $p); | ||
| return $p[$this->request->getParam('action')]; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php | ||
| /** | ||
| * COmanage Match Matchgrid Setting Entity | ||
| * | ||
| * Portions licensed to the University Corporation for Advanced Internet | ||
| * Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * UCAID licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with the | ||
| * License. You may obtain a copy of the License at: | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * @link http://www.internet2.edu/comanage COmanage Project | ||
| * @package match | ||
| * @since COmanage Match v1.0.0 | ||
| * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
| */ | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| namespace App\Model\Entity; | ||
|
|
||
| use Cake\ORM\Entity; | ||
|
|
||
| class MatchgridSetting extends Entity { | ||
| protected $_accessible = [ | ||
| '*' => true, | ||
| 'id' => false, | ||
| 'slug' => false, | ||
| ]; | ||
| } |
Oops, something went wrong.