mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-28 20:45:00 +03:00
Пренос проверки прав в ACL
This commit is contained in:
parent
c78ac4b2d5
commit
098d5bcf79
|
@ -264,14 +264,13 @@ class ActionBlog extends Action {
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('not_access'),$this->Lang_Get('error'));
|
||||
return Router::Action('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Явлется ли авторизованный пользователь хозяином блога, либо его администратором
|
||||
*/
|
||||
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(),$this->oUserCurrent->getId());
|
||||
$bIsAdministratorBlog=$oBlogUser ? $oBlogUser->getIsAdministrator() : false;
|
||||
if ($oBlog->getOwnerId()!=$this->oUserCurrent->getId() and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog) {
|
||||
* Проверка на право редактировать блог
|
||||
*/
|
||||
if (!$this->ACL_IsAllowEditBlog($oBlog, $this->oUserCurrent)) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
$this->Viewer_AddHtmlTitle($oBlog->getTitle());
|
||||
$this->Viewer_AddHtmlTitle($this->Lang_Get('blog_edit'));
|
||||
|
@ -375,14 +374,14 @@ class ActionBlog extends Action {
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('not_access'),$this->Lang_Get('error'));
|
||||
return Router::Action('error');
|
||||
}
|
||||
/**
|
||||
* Явлется ли авторизованный пользователь хозяином блога, либо его администратором
|
||||
*/
|
||||
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(),$this->oUserCurrent->getId());
|
||||
$bIsAdministratorBlog=$oBlogUser ? $oBlogUser->getIsAdministrator() : false;
|
||||
if ($oBlog->getOwnerId()!=$this->oUserCurrent->getId() and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog) {
|
||||
|
||||
/**
|
||||
* Проверка на право управлением пользователями блога
|
||||
*/
|
||||
if (!$this->ACL_IsAllowAdminBlog($oBlog, $this->oUserCurrent)) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Обрабатываем сохранение формы
|
||||
*/
|
||||
|
|
|
@ -497,7 +497,7 @@ class ActionPhotoset extends Action {
|
|||
* Принудительный вывод на главную
|
||||
*/
|
||||
$oTopic->setPublishIndex(0);
|
||||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
|
||||
if (getRequest('topic_publish_index')) {
|
||||
$oTopic->setPublishIndex(1);
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ class ActionPhotoset extends Action {
|
|||
/**
|
||||
* Принудительный вывод на главную
|
||||
*/
|
||||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
|
||||
if (getRequest('topic_publish_index')) {
|
||||
$oTopic->setPublishIndex(1);
|
||||
} else {
|
||||
|
|
|
@ -270,7 +270,7 @@ class ActionQuestion extends Action {
|
|||
* Принудительный вывод на главную
|
||||
*/
|
||||
$oTopic->setPublishIndex(0);
|
||||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
|
||||
if (getRequest('topic_publish_index')) {
|
||||
$oTopic->setPublishIndex(1);
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ class ActionQuestion extends Action {
|
|||
/**
|
||||
* Принудительный вывод на главную
|
||||
*/
|
||||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
|
||||
if (getRequest('topic_publish_index')) {
|
||||
$oTopic->setPublishIndex(1);
|
||||
} else {
|
||||
|
|
|
@ -319,7 +319,7 @@ class ActionTopic extends Action {
|
|||
* Принудительный вывод на главную
|
||||
*/
|
||||
$oTopic->setPublishIndex(0);
|
||||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
|
||||
if (getRequest('topic_publish_index')) {
|
||||
$oTopic->setPublishIndex(1);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ class ActionTopic extends Action {
|
|||
/**
|
||||
* Принудительный вывод на главную
|
||||
*/
|
||||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
|
||||
if (getRequest('topic_publish_index')) {
|
||||
$oTopic->setPublishIndex(1);
|
||||
} else {
|
||||
|
|
|
@ -397,5 +397,85 @@ class ModuleACL extends Module {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет может ли пользователь публиковать на главной
|
||||
*
|
||||
* @param Entity_User $oUser
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowPublishIndex(ModuleUser_EntityUser $oUser) {
|
||||
|
||||
if ($oUser->isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет можно или нет пользователю редактировать данный блог
|
||||
*
|
||||
* @param object $oBlog
|
||||
* @param object $oUser
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowEditBlog($oBlog,$oUser) {
|
||||
|
||||
if ($oUser->isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Разрешаем если это создатель блога
|
||||
*/
|
||||
if ($oBlog->getOwnerId() == $oUser->getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Явлется ли авторизованный пользователь администратором блога
|
||||
*/
|
||||
$oBlogUser = $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());
|
||||
|
||||
if ($oBlogUser && $oBlogUser->getIsAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет можно или нет пользователю управлять пользователями блога
|
||||
*
|
||||
* @param object $oBlog
|
||||
* @param object $oUser
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowAdminBlog($oBlog,$oUser) {
|
||||
|
||||
if ($oUser->isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Разрешаем если это создатель блога
|
||||
*/
|
||||
if ($oBlog->getOwnerId() == $oUser->getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Явлется ли авторизованный пользователь администратором блога
|
||||
*/
|
||||
$oBlogUser = $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());
|
||||
|
||||
if ($oBlogUser && $oBlogUser->getIsAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue