本文整理匯總了PHP中modResource::addLock方法的典型用法代碼示例。如果您正苦於以下問題:PHP modResource::addLock方法的具體用法?PHP modResource::addLock怎麽用?PHP modResource::addLock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類modResource
的用法示例。
在下文中一共展示了modResource::addLock方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addLock
/**
* Add a lock to the Resource while unpublishing it
* @return boolean
*/
public function addLock()
{
$locked = $this->resource->addLock();
if ($locked !== true) {
$user = $this->modx->getObject('modUser', $locked);
if ($user) {
$locked = false;
}
}
return $locked;
}
示例2: addLock
/**
* Add a lock to the resource we are saving
* @return boolean
*/
public function addLock()
{
$locked = $this->object->addLock();
if ($locked !== true) {
$stealLock = $this->getProperty('steal_lock', false);
if (!empty($stealLock)) {
if (!$this->modx->hasPermission('steal_locks') || !$this->object->checkPolicy('steal_lock')) {
return false;
}
if ($locked > 0 && $locked != $this->modx->user->get('id')) {
$this->object->removeLock($locked);
$locked = $this->object->addLock($this->modx->user->get('id'));
}
}
if ($locked !== true) {
$lockedBy = intval($locked);
$this->lockedUser = $this->modx->getObject('modUser', $lockedBy);
if ($this->lockedUser) {
$locked = false;
} else {
$this->object->removeLock($lockedBy);
$locked = true;
}
}
}
return $locked;
}
示例3: afterSave
/**
* {@inheritDoc}
* @return mixed
*/
public function afterSave()
{
$this->object->addLock();
$this->setParentToContainer();
$this->saveResourceGroups();
$this->checkIfSiteStart();
return parent::afterSave();
}
示例4: checkForLocks
/**
* Check for locks on the Resource
*
* @return bool
*/
public function checkForLocks()
{
$lockedBy = $this->resource->addLock($this->modx->user->get('id'));
$this->canSave = $this->modx->hasPermission('save_document') ? 1 : 0;
$this->locked = false;
$this->lockedText = '';
if (!empty($lockedBy) && $lockedBy !== true) {
$this->canSave = false;
$this->locked = true;
$locker = $this->modx->getObject('modUser', $lockedBy);
if ($locker) {
$lockedBy = $locker->get('username');
}
$this->lockedText = $this->modx->lexicon('resource_locked_by', array('user' => $lockedBy, 'id' => $this->resource->get('id')));
}
return $this->locked;
}