1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-01 05:55:02 +03:00
This commit is contained in:
Mzhelskiy Maxim 2012-12-18 21:29:15 +04:00
parent 23f1b0b2ef
commit d997b52c36
4 changed files with 73 additions and 19 deletions

View file

@ -311,10 +311,20 @@ class ModuleACL extends Module {
/**
* Если модер или админ блога
*/
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$oUser->getId());
if ($oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
return true;
if ($this->User_GetUserCurrent() and $this->User_GetUserCurrent()->getId()==$oUser->getId()) {
/**
* Для авторизованного пользователя данный код будет работать быстрее
*/
if ($oTopic->getBlog()->getUserIsAdministrator() or $oTopic->getBlog()->getUserIsModerator()) {
return true;
}
} else {
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$oUser->getId());
if ($oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
return true;
}
}
return false;
}
/**
@ -340,9 +350,18 @@ class ModuleACL extends Module {
/**
* Если модер или админ блога
*/
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$oUser->getId());
if ($oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
return true;
if ($this->User_GetUserCurrent() and $this->User_GetUserCurrent()->getId()==$oUser->getId()) {
/**
* Для авторизованного пользователя данный код будет работать быстрее
*/
if ($oTopic->getBlog()->getUserIsAdministrator() or $oTopic->getBlog()->getUserIsModerator()) {
return true;
}
} else {
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$oUser->getId());
if ($oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
return true;
}
}
return false;
}

View file

@ -394,6 +394,39 @@ class ModuleTopic_EntityTopic extends Entity {
}
return false;
}
/**
* Проверяет разрешение на удаление топика у текущего пользователя
*
* @return bool
*/
public function getIsAllowDelete() {
if ($oUser=$this->User_GetUserCurrent()) {
return $this->ACL_IsAllowDeleteTopic($this,$oUser);
}
return false;
}
/**
* Проверяет разрешение на редактирование топика у текущего пользователя
*
* @return bool
*/
public function getIsAllowEdit() {
if ($oUser=$this->User_GetUserCurrent()) {
return $this->ACL_IsAllowEditTopic($this,$oUser);
}
return false;
}
/**
* Проверяет разрешение на какое-либо действие для топика у текущего пользователя
*
* @return bool
*/
public function getIsAllowAction() {
if ($this->User_GetUserCurrent()) {
return $this->getIsAllowEdit() || $this->getIsAllowDelete();
}
return false;
}
/**
* Возвращает количество добавивших топик в избранное
*

View file

@ -35,15 +35,17 @@
<time datetime="{date_format date=$oTopic->getDateAdd() format='c'}" title="{date_format date=$oTopic->getDateAdd() format='j F Y, H:i'}">
{date_format date=$oTopic->getDateAdd() format="j F Y, H:i"}
</time>
<ul class="actions">
{if $oUserCurrent and ($oUserCurrent->getId()==$oTopic->getUserId() or $oUserCurrent->isAdministrator() or $oBlog->getUserIsAdministrator() or $oBlog->getUserIsModerator() or $oBlog->getOwnerId()==$oUserCurrent->getId())}
<li><a href="{$oTopic->getUrlEdit()}" title="{$aLang.topic_edit}" class="actions-edit">{$aLang.topic_edit}</a></li>
{/if}
{if $oUserCurrent and ($oUserCurrent->isAdministrator() or $oBlog->getUserIsAdministrator() or $oBlog->getOwnerId()==$oUserCurrent->getId())}
<li><a href="{router page='topic'}delete/{$oTopic->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" title="{$aLang.topic_delete}" onclick="return confirm('{$aLang.topic_delete_confirm}');" class="actions-delete">{$aLang.topic_delete}</a></li>
{/if}
</ul>
{if $oTopic->getIsAllowAction()}
<ul class="actions">
{if $oTopic->getIsAllowEdit()}
<li><a href="{$oTopic->getUrlEdit()}" title="{$aLang.topic_edit}" class="actions-edit">{$aLang.topic_edit}</a></li>
{/if}
{if $oTopic->getIsAllowDelete()}
<li><a href="{router page='topic'}delete/{$oTopic->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" title="{$aLang.topic_delete}" onclick="return confirm('{$aLang.topic_delete_confirm}');" class="actions-delete">{$aLang.topic_delete}</a></li>
{/if}
</ul>
{/if}
</div>
</header>

View file

@ -29,13 +29,13 @@
{/if}
</div>
{if $oUserCurrent and ($oUserCurrent->getId()==$oTopic->getUserId() or $oUserCurrent->isAdministrator() or $oBlog->getUserIsAdministrator() or $oBlog->getUserIsModerator() or $oBlog->getOwnerId()==$oUserCurrent->getId())}
{if $oTopic->getIsAllowAction()}
<ul class="topic-actions">
{if $oUserCurrent and ($oUserCurrent->getId()==$oTopic->getUserId() or $oUserCurrent->isAdministrator() or $oBlog->getUserIsAdministrator() or $oBlog->getUserIsModerator() or $oBlog->getOwnerId()==$oUserCurrent->getId())}
{if $oTopic->getIsAllowEdit()}
<li class="edit"><i class="icon-synio-actions-edit"></i><a href="{$oTopic->getUrlEdit()}" title="{$aLang.topic_edit}" class="actions-edit">{$aLang.topic_edit}</a></li>
{/if}
{if $oUserCurrent and ($oUserCurrent->isAdministrator() or $oBlog->getUserIsAdministrator() or $oBlog->getOwnerId()==$oUserCurrent->getId())}
{if $oTopic->getIsAllowDelete()}
<li class="delete"><i class="icon-synio-actions-delete"></i><a href="{router page='topic'}delete/{$oTopic->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" title="{$aLang.topic_delete}" onclick="return confirm('{$aLang.topic_delete_confirm}');" class="actions-delete">{$aLang.topic_delete}</a></li>
{/if}
</ul>