public function process() { /* @var modResourceGroupResource $resourceGroupResource */ $resourceGroupResource = $this->modx->getObject('modResourceGroupResource', array('document_group' => $this->resourceGroup->get('id'), 'document' => $this->resource->get('id'))); if (empty($resourceGroupResource)) { return $this->failure($this->modx->lexicon('resource_group_resource_err_nf')); } if ($resourceGroupResource->remove() == false) { return $this->failure($this->modx->lexicon('resource_group_resource_err_remove')); } else { $this->fireAfterRemove(); } return $this->success('', $resourceGroupResource); }
/** * Prepare object for iteration * * @param modResourceGroup $resourceGroup * @return array */ public function prepareRow(modResourceGroup $resourceGroup) { if ($this->getProperty('tv')) { $rgtv = $this->modx->getObject('modTemplateVarResourceGroup', array('tmplvarid' => $this->getProperty('tv'), 'documentgroup' => $resourceGroup->get('id'))); } else { $rgtv = null; } $resourceGroupArray = $resourceGroup->toArray(); $resourceGroupArray['access'] = $rgtv ? true : false; $resourceGroupArray['menu'] = array(); return $resourceGroupArray; }
public function beforeSave() { /* format data */ $resourceId = substr(strrchr($this->getProperty('resource', ''), '_'), 1); $resourceGroupId = substr(strrchr($this->getProperty('resourceGroup', ''), '_'), 1); if (empty($resourceId) || empty($resourceGroupId)) { return $this->modx->lexicon('invalid_data'); } $this->resource = $this->modx->getObject('modResource', $resourceId); if (!$this->resource) { return $this->modx->lexicon('resource_err_nfs', array('id' => $resourceId)); } $this->resourceGroup = $this->modx->getObject('modResourceGroup', $resourceGroupId); if (!$this->resourceGroup) { return $this->modx->lexicon('resource_group_err_nf'); } if ($this->doesAlreadyExist(array('document' => $this->resource->get('id'), 'document_group' => $this->resourceGroup->get('id')))) { return $this->modx->lexicon($this->objectType . '_err_ae'); } $this->object->set('document', $this->resource->get('id')); $this->object->set('document_group', $this->resourceGroup->get('id')); return parent::beforeSave(); }
/** * Log the manager action * * @return void */ public function logManagerAction() { $this->modx->logManagerAction('update_resource_group', 'modResourceGroup', $this->resourceGroup->get('id')); }