Skip to content

Commit 3c54422

Browse files
committed
Merge branch 'pu/ps/appRight' into 'main'
fix(Tinebase/Controller/Abstract): use correct $rightsApp See merge request tine20/tine20!7169
2 parents e3a54cf + dcccf5f commit 3c54422

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

tine20/Tinebase/Controller/Abstract.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,24 @@ public function getRequestContext()
114114
*/
115115
public function checkRight($_right, $_throwException = TRUE, $_includeTinebaseAdmin = TRUE)
116116
{
117-
if (empty($this->_applicationName)) {
118-
throw new Tinebase_Exception_UnexpectedValue('No application name defined!');
119-
}
120117
if (! is_object(Tinebase_Core::getUser())) {
121118
throw new Tinebase_Exception('No user found for right check!');
122119
}
123120

124121
$right = strtoupper($_right);
125-
122+
$applicationRightsClass = $this->_getApplicationRightsClass();
123+
$rightsApp = substr($applicationRightsClass, 0, strpos($applicationRightsClass, '_'));
124+
if (empty($rightsApp)) {
125+
throw new Tinebase_Exception_UnexpectedValue('No application name defined!');
126+
}
127+
126128
$cache = Tinebase_Core::getCache();
127129
$cacheId = Tinebase_Helper::convertCacheId(
128-
'checkRight' . Tinebase_Core::getUser()->getId() . $right . $this->_applicationName
130+
'checkRight' . Tinebase_Core::getUser()->getId() . $right . $rightsApp
129131
);
130132
$result = $cache->load($cacheId);
131-
133+
132134
if (!$result) {
133-
$applicationRightsClass = $this->_getApplicationRightsClass();
134-
135135
// array with the rights that should be checked, ADMIN is in it per default
136136
$rightsToCheck = ($_includeTinebaseAdmin) ? array(Tinebase_Acl_Rights::ADMIN) : array();
137137

@@ -142,15 +142,15 @@ public function checkRight($_right, $_throwException = TRUE, $_includeTinebaseAd
142142

143143
$rightsToCheck[] = constant($applicationRightsClass. '::' . $right);
144144

145-
$result = FALSE;
145+
$result = false;
146146

147147
foreach ($rightsToCheck as $rightToCheck) {
148148
if (Tinebase_Acl_Roles::getInstance()->hasRight(
149-
$this->_applicationName,
149+
$rightsApp,
150150
Tinebase_Core::getUser()->getId(),
151151
$rightToCheck
152152
)) {
153-
$result = TRUE;
153+
$result = true;
154154
break;
155155
}
156156
}
@@ -159,7 +159,9 @@ public function checkRight($_right, $_throwException = TRUE, $_includeTinebaseAd
159159
}
160160

161161
if (!$result && $_throwException) {
162-
throw new Tinebase_Exception_AccessDenied("You are not allowed to $right in application $this->_applicationName !");
162+
throw new Tinebase_Exception_AccessDenied(
163+
"You are not allowed to $right in application $rightsApp !"
164+
);
163165
}
164166

165167
return $result;
@@ -343,8 +345,10 @@ public function getModels($MCV2only = false)
343345

344346
if ($MCV2only) {
345347
if (! Setup_Core::isDoctrineAvailable()) {
346-
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__
347-
. ' Doctrine not available, could not get modelconfig v2 models for application (php version id: ' . PHP_VERSION_ID . ')');
348+
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
349+
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__
350+
. ' Doctrine not available, could not get modelconfig v2 models for application (php version id: ' . PHP_VERSION_ID . ')');
351+
}
348352
return array();
349353
}
350354

0 commit comments

Comments
 (0)