Instead of modifying the code, I think you need to give yourself permission to create and save resources in the other context.
Go to Security -> Access Controls -> User Groups tab
Right-click on the Administrator group and select "Update User Group"
Click on the "Context Access" tab.
Click on the "Add Context" button.
Context: Select the other context
Minimum Role: admin Super User
Policy: Administrator
Click on the save button.
Security -> Flush Permissions
Security -> Flush Sessions
Rights have been configured correctly (I configured them the same context, the Web)
After several hours of debugging using x-debug I found out the reason, but I do not know whether corrected.
if you look at x-debug $resource->context_key=="myCtx" and after $resource->save() (in the parent class modResource) $this->context_key=="web",
I’m not finding that in the code. Can you tell me what file it’s in?
1) Put a breakpoint on this line
(breackpoint there) if ($resource->save() == false) {
return $modx->error->failure($modx->lexicon(’resource_err_save’));
}
(\core\model\modx\processors\resource\create.php line 273)
2) watch $resource->context_key (I see "myCtx")
3) step into
4) throws us into a class modResource (\core\model\modx\modresource.class.php line 382)
public function save($cacheFlag= null) {
if ($this->_new) {
if (!$this->get(’createdon’)) $this->set(’createdon’, time());
if (!$this->get(’createdby’) && $this->xpdo instanceof modX) $this->set(’createdby’, $this->xpdo->getLoginUserID());
}
$rt= parent :: save($cacheFlag);
return $rt;
}
5) watch $this->context_key (and what I see?? I see "web")
-
MODX Staff
- 10,725 Posts
It is indeed a critical bug for multi-context usage and will be addressed ASAP.
I ran into this bug, too. Is there allready a bug report to be able to track this issue?
Add-On to easily manage your multilingual sites:
Babel