本文整理汇总了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;
}