diff --git a/app/Controller/Component/RoleComponent.php b/app/Controller/Component/RoleComponent.php index e52093001..69d1eeff8 100644 --- a/app/Controller/Component/RoleComponent.php +++ b/app/Controller/Component/RoleComponent.php @@ -501,9 +501,12 @@ public function calculateCMRoles() { $authCoId = $this->Session->read('Auth.User.co_id'); $privd = $this->Session->read('Auth.User.privileged'); - - if($authCoId == 1) { - // API users in CO 1 are given platform privileges + + $Co = ClassRegistry::init('Co'); + $comanageCoId = $Co->getCOmanageCOID(); + + if($comanageCoId && ((int)$authCoId === (int)$comanageCoId)) { + // API users in the COmanage CO are given platform privileges $ret['cmadmin'] = true; } elseif(($coId == $authCoId) && $privd) { // Privileged users in other COs are given CO privileges diff --git a/app/Controller/StandardController.php b/app/Controller/StandardController.php index 3339f6de6..4e6942cd8 100644 --- a/app/Controller/StandardController.php +++ b/app/Controller/StandardController.php @@ -319,8 +319,9 @@ function beforeFilter() { // Apply the rule only when the validateExtendedType function is used as a custom rule $model = $this->modelClass; if(!empty($this->$model->validate['type']['content']['rule']) - && array_search('validateExtendedType', $this->$model->validate['type']['content']['rule'], true) !== null - && !empty($this->cur_co['Co']['id'])) { + && in_array('validateExtendedType', $this->$model->validate['type']['content']['rule']) + && !empty($this->cur_co['Co']['id']) + ) { $vrule = $this->$model->validate['type']['content']['rule']; $vrule[1]['coid'] = $this->cur_co['Co']['id']; $this->$model->validator()->getField('type')->getRule('content')->rule = $vrule;