本文整理汇总了PHP中Application_Model_User::isParentOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_User::isParentOf方法的具体用法?PHP Application_Model_User::isParentOf怎么用?PHP Application_Model_User::isParentOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application_Model_User
的用法示例。
在下文中一共展示了Application_Model_User::isParentOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userCan
/**
* Still playing around with how I want to handle permissions.
* This is a method that can be called before each action to
* see if the user can do what they are asking to.
*
* @access public
* @return void
*/
protected function userCan()
{
// User can edit themselves
if ($this->id == $this->user->getId()) {
return true;
}
// TODO: Need to expand upon this? Probably...
// we can add in what the user is trying to do, and check perms
// on top of just ownership. This will do for now.
if ($this->id) {
if ($this->user->isParentOf($this->id) || $this->user->isSuperAdmin()) {
return true;
}
} else {
// If there was no id already set, we are probably adding a folder.
// TODO: Need to handle perms somehow here.
return true;
}
// Set this entity to not valid so we do not give anything away
// TODO: Maybe make a default() method that we can reset a built entity to it's defaults.
// defaults could be set from the entity profile.
$this->valid = false;
$this->error = 'User does not have permission to execute the request.';
//$this->error = 'ID does not exist for this user.';
return false;
}
示例2: _isValid
/**
* Checks whether this keyword is a valid keyword or not... useful for
* saving edits
*
* REQUIRED ELEMENTS:
* - Keyword
* - Folder id that user is parent of
* - Reply body
*
* @access protected
* @return boolean
*/
protected function _isValid()
{
if ($this->folderid) {
if ($this->_user instanceof Application_Model_User && $this->_user->getId() && $this->_user->isParentOf($this->folderid)) {
if ($this->replybody) {
return true;
} else {
$this->setError('A keyword requires a auto response message');
}
} else {
$this->setError('Permission denied');
}
} else {
$this->setError('A keyword must be added to a folder');
}
return false;
}