public function process() { if (!$this->addLock()) { return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username')))); } if ($this->isSiteStart()) { return $this->failure($this->modx->lexicon('resource_err_unpublish_sitestart')); } $this->resource->set('published', false); $this->resource->set('pub_date', false); $this->resource->set('unpub_date', false); $this->resource->set('editedby', $this->modx->user->get('id')); $this->resource->set('editedon', time(), 'integer'); $this->resource->set('publishedby', false); $this->resource->set('publishedon', false); if ($this->resource->save() == false) { $this->resource->removeLock(); return $this->failure($this->modx->lexicon('resource_err_unpublish')); } $this->fireAfterUnPublishEvent(); $this->logManagerAction(); $skipClearCache = $this->getProperty('skipClearCache', false); if ($skipClearCache == false) { $this->clearCache(); } return $this->success('', $this->resource->get(array('id'))); }
public function process() { if (!$this->addLock()) { return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username')))); } $duplicateAlias = $this->checkForDuplicateAlias(); if ($duplicateAlias !== false) { return $this->failure($duplicateAlias); } /* publish resource */ $this->resource->set('published', true); $this->resource->set('pub_date', false); $this->resource->set('unpub_date', false); $this->resource->set('editedby', $this->modx->user->get('id')); $this->resource->set('editedon', time(), 'integer'); $this->resource->set('publishedby', $this->modx->user->get('id')); $this->resource->set('publishedon', time()); $saved = $this->resource->save(); $this->resource->removeLock(); if (!$saved) { return $this->failure($this->modx->lexicon('resource_err_publish')); } $this->fireAfterPublish(); $this->logManagerAction(); $this->clearCache(); return $this->success('', $this->resource->get(array('id', 'pub_date', 'unpub_date', 'editedby', 'editedon', 'publishedby', 'publishedon'))); }
/** * Cleanup the processor and return the resulting object * * @return array */ public function cleanup() { $this->object->removeLock(); $this->clearCache(); $returnArray = $this->object->get(array_diff(array_keys($this->object->_fields), array('content', 'ta', 'introtext', 'description', 'link_attributes', 'pagetitle', 'longtitle', 'menutitle', 'properties'))); foreach ($returnArray as $k => $v) { if (strpos($k, 'tv') === 0) { unset($returnArray[$k]); } } $returnArray['class_key'] = $this->object->get('class_key'); $this->workingContext->prepare(true); $returnArray['preview_url'] = $this->modx->makeUrl($this->object->get('id'), $this->object->get('context_key'), '', 'full'); return $this->success('', $returnArray); }
/** * Delete all children of this resource * @return array */ public function deleteChildren() { if (count($this->children) > 0) { /** @var modResource $child */ foreach ($this->children as $child) { $locked = $child->addLock(); if ($locked !== true) { /** @var modUser $user */ $user = $this->modx->getObject('modUser', $locked); if ($user) { $this->modx->log(modX::LOG_LEVEL_ERROR, $this->modx->lexicon('resource_locked_by', array('id' => $child->get('id'), 'user' => $user->get('username')))); } } $child->set('deleted', true); $child->set('deletedby', $this->modx->user->get('id')); $child->set('deletedon', $this->deletedTime); if ($child->save() == false) { $child->removeLock(); $this->resource->removeLock(); } } } return $this->children; }
/** * {@inheritDoc} * @return mixed */ public function cleanup() { $this->object->removeLock(); $this->clearCache(); return $this->success('', array('id' => $this->object->get('id'))); }
/** * Remove the lock from the Resource * @return boolean */ public function removeLock() { return $this->resource->removeLock(); }