| 1 | <?php |
||||||
| 2 | |||||||
| 3 | // ------------------------------------------------------------------------- |
||||||
| 4 | // OVIDENTIA http://www.ovidentia.org |
||||||
| 5 | // Ovidentia is free software; you can redistribute it and/or modify |
||||||
| 6 | // it under the terms of the GNU General Public License as published by |
||||||
| 7 | // the Free Software Foundation; either version 2, or (at your option) |
||||||
| 8 | // any later version. |
||||||
| 9 | // |
||||||
| 10 | // This program is distributed in the hope that it will be useful, but |
||||||
| 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 13 | // See the GNU General Public License for more details. |
||||||
| 14 | // |
||||||
| 15 | // You should have received a copy of the GNU General Public License |
||||||
| 16 | // along with this program; if not, write to the Free Software |
||||||
| 17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
||||||
| 18 | // USA. |
||||||
| 19 | // ------------------------------------------------------------------------- |
||||||
| 20 | /** |
||||||
| 21 | * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
||||||
| 22 | * @copyright Copyright (c) 2022 by SI4YOU ({@link https://www.siforyou.com}) |
||||||
| 23 | */ |
||||||
| 24 | namespace Capwelton\LibApp; |
||||||
| 25 | |||||||
| 26 | use Capwelton\LibApp\Set\AppRecordSet; |
||||||
| 27 | use Capwelton\LibApp\Set\AppRecord; |
||||||
| 28 | use Capwelton\LibOrm\Criteria\ORMFalseCriterion; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 29 | |||||||
| 30 | /** |
||||||
| 31 | * The AppAccessManager class |
||||||
| 32 | * |
||||||
| 33 | * @method Func_App App() |
||||||
| 34 | */ |
||||||
| 35 | class AppAccessManager implements AppObjectInterface |
||||||
| 36 | { |
||||||
| 37 | |||||||
| 38 | /** |
||||||
| 39 | * @var Func_App |
||||||
| 40 | */ |
||||||
| 41 | private $app = null; |
||||||
| 42 | |||||||
| 43 | /** |
||||||
| 44 | * @param Func_App $app |
||||||
| 45 | */ |
||||||
| 46 | public function __construct(Func_App $app) |
||||||
| 47 | { |
||||||
| 48 | $this->setApp($app); |
||||||
| 49 | } |
||||||
| 50 | |||||||
| 51 | /** |
||||||
| 52 | * Forces the Func_App object to which this object is 'linked'. |
||||||
| 53 | * |
||||||
| 54 | * @param Func_App $app |
||||||
| 55 | * @return this |
||||||
| 56 | */ |
||||||
| 57 | public function setApp(Func_App $app) |
||||||
| 58 | { |
||||||
| 59 | $this->app = $app; |
||||||
| 60 | return $this; |
||||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | /** |
||||||
| 64 | * Get APP object to use with this SET |
||||||
| 65 | * |
||||||
| 66 | * @return Func_App |
||||||
| 67 | */ |
||||||
| 68 | public function App() |
||||||
| 69 | { |
||||||
| 70 | return $this->app; |
||||||
| 71 | } |
||||||
| 72 | |||||||
| 73 | /** |
||||||
| 74 | * @param AppRecordSet $recordSet |
||||||
| 75 | * @param string $accessType |
||||||
| 76 | * @param int $user |
||||||
| 77 | */ |
||||||
| 78 | public function getAccessCriterion(AppRecordSet $recordSet, $accessType, $user = null) |
||||||
|
0 ignored issues
–
show
The parameter
$user is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$accessType is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 79 | { |
||||||
| 80 | return $recordSet->none(); |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | /** |
||||||
| 84 | * Check if at least one access criterion is not a FalseCriterion. |
||||||
| 85 | * If all access criterion are FalseCritertion, return true, otherwise return false. |
||||||
| 86 | * |
||||||
| 87 | * @param AppRecordSet $recordSet |
||||||
| 88 | * @param string $accessType |
||||||
| 89 | * @param int|null $user |
||||||
| 90 | * |
||||||
| 91 | * @return boolean |
||||||
| 92 | */ |
||||||
| 93 | public function hasNoAccess(AppRecordSet $recordSet, $accessType, $user = null) |
||||||
| 94 | { |
||||||
| 95 | $criterion = $this->getAccessCriterion($recordSet, $accessType, $user); |
||||||
| 96 | if(! $criterion instanceof ORMFalseCriterion){ |
||||||
| 97 | return false; |
||||||
| 98 | } |
||||||
| 99 | return true; |
||||||
| 100 | } |
||||||
| 101 | |||||||
| 102 | /** |
||||||
| 103 | * @param AppRecord $record |
||||||
| 104 | * @param string $accessType |
||||||
| 105 | * @param int $user |
||||||
| 106 | */ |
||||||
| 107 | public function getAccess(AppRecord $record, $accessType, $user = null) |
||||||
| 108 | { |
||||||
| 109 | $recordSet = $record->getParentSet(); |
||||||
| 110 | $criterion = $this->getAccessCriterion($recordSet, $accessType, $user); |
||||||
| 111 | |||||||
| 112 | $matches = $recordSet->select($criterion->_AND_($recordSet->id->is($record->id))); |
||||||
| 113 | |||||||
| 114 | return ($matches->count() !== 0); |
||||||
| 115 | } |
||||||
| 116 | } |
||||||
| 117 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths