1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-20 17:58:24 +03:00

fix install module, перенос ACL-функций из модулей Blog и Topic

This commit is contained in:
Alexey Kachayev 2009-11-19 23:23:49 +00:00
parent 84038a154b
commit a5dd2440bc
8 changed files with 109 additions and 91 deletions

View file

@ -130,7 +130,7 @@ class ActionLink extends Action {
/**
* Если права на редактирование
*/
if (!$this->Topic_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
return parent::EventNotFound();
}
/**
@ -242,7 +242,7 @@ class ActionLink extends Action {
/**
* Проверяем права на постинг в блог
*/
if (!$this->Blog_IsAllowBlog($oBlog,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowBlog($oBlog,$this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'),$this->Lang_Get('error'));
return false;
}
@ -346,7 +346,7 @@ class ActionLink extends Action {
/**
* Проверяем права на постинг в блог
*/
if (!$this->Blog_IsAllowBlog($oBlog,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowBlog($oBlog,$this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'),$this->Lang_Get('error'));
return false;
}

View file

@ -98,7 +98,7 @@ class ActionQuestion extends Action {
/**
* Если права на редактирование
*/
if (!$this->Topic_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
return parent::EventNotFound();
}
/**
@ -210,7 +210,7 @@ class ActionQuestion extends Action {
/**
* Проверяем права на постинг в блог
*/
if (!$this->Blog_IsAllowBlog($oBlog,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowBlog($oBlog,$this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'),$this->Lang_Get('error'));
return false;
}
@ -320,7 +320,7 @@ class ActionQuestion extends Action {
/**
* Проверяем права на постинг в блог
*/
if (!$this->Blog_IsAllowBlog($oBlog,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowBlog($oBlog,$this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'),$this->Lang_Get('error'));
return false;
}

View file

@ -100,7 +100,7 @@ class ActionTopic extends Action {
/**
* Если права на редактирование
*/
if (!$this->Topic_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
return parent::EventNotFound();
}
/**
@ -265,7 +265,7 @@ class ActionTopic extends Action {
/**
* Проверяем права на постинг в блог
*/
if (!$this->Blog_IsAllowBlog($oBlog,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowBlog($oBlog,$this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'),$this->Lang_Get('error'));
return false;
}
@ -397,7 +397,7 @@ class ActionTopic extends Action {
/**
* Проверяем права на постинг в блог
*/
if (!$this->Blog_IsAllowBlog($oBlog,$this->oUserCurrent)) {
if (!$this->ACL_IsAllowBlog($oBlog,$this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'),$this->Lang_Get('error'));
return false;
}

View file

@ -269,5 +269,56 @@ class LsACL extends Module {
}
return true;
}
/**
* Проверяет можно или нет юзеру постить в данный блог
*
* @param object $oBlog
* @param object $oUser
*/
public function IsAllowBlog($oBlog,$oUser) {
if ($oUser->isAdministrator()) {
return true;
}
if ($oBlog->getOwnerId()==$oUser->getId()) {
return true;
}
if ($oBlogUser=$this->GetBlogUserByBlogIdAndUserId($oBlog->getId(),$oUser->getId())) {
if ($this->ACL_CanAddTopic($oUser,$oBlog) or $oBlogUser->getIsAdministrator() or $oBlogUser->getIsModerator()) {
return true;
}
}
return false;
}
/**
* Проверяет можно или нет пользователю редактировать данный топик
*
* @param object $oTopic
* @param object $oUser
* @return bool
*/
public function IsAllowEditTopic($oTopic,$oUser) {
/**
* Разрешаем если это админ сайта или автор топика
*/
if ($oTopic->getUserId()==$oUser->getId() or $oUser->isAdministrator()) {
return true;
}
/**
* Если автор(смотритель) блога
*/
if ($oTopic->getBlog()->getOwnerId()==$oUser->getId()) {
return true;
}
/**
* Если модер или админ блога
*/
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$oUser->getId());
if ($oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
return true;
}
return false;
}
}
?>

View file

@ -620,27 +620,7 @@ class LsBlog extends Module {
return $aAllowBlogsUser;
}
}
/**
* Проверяет можно или нет юзеру постить в данный блог
*
* @param unknown_type $oBlog
* @param unknown_type $oUser
* @param unknown_type $sBlogIdAllow
*/
public function IsAllowBlog($oBlog,$oUser) {
if ($oUser->isAdministrator()) {
return true;
}
if ($oBlog->getOwnerId()==$oUser->getId()) {
return true;
}
if ($oBlogUser=$this->GetBlogUserByBlogIdAndUserId($oBlog->getId(),$oUser->getId())) {
if ($this->ACL_CanAddTopic($oUser,$oBlog) or $oBlogUser->getIsAdministrator() or $oBlogUser->getIsModerator()) {
return true;
}
}
return false;
}
/**
* Получаем массив блогов,
* которые являются открытыми для пользователя

View file

@ -1221,34 +1221,6 @@ class LsTopic extends Module {
$sId=$this->oMapperTopic->GetTopicUnique($sUserId,$sHash);
return $this->GetTopicById($sId);
}
/**
* Проверяет можно или нет пользователю редактировать данный топик
*
* @param unknown_type $oTopic
* @param unknown_type $oUser
*/
public function IsAllowEditTopic($oTopic,$oUser) {
/**
* Разрешаем если это админ сайта или автор топика
*/
if ($oTopic->getUserId()==$oUser->getId() or $oUser->isAdministrator()) {
return true;
}
/**
* Если автор(смотритель) блога
*/
if ($oTopic->getBlog()->getOwnerId()==$oUser->getId()) {
return true;
}
/**
* Если модер или админ блога
*/
$oBlogUser=$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$oUser->getId());
if ($oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
return true;
}
return false;
}
/**
* Проверяет можно или нет пользователю удалять данный топик
*

View file

@ -1,33 +1,48 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
/**
* Настройки для локального сервера.
* Для использования - переименовать файл в config.local.php
*/
/**
* Настройка базы данных
*/
$config['db']['params']['host'] = 'localhost';
$config['db']['params']['port'] = '3306';
$config['db']['params']['user'] = 'root';
$config['db']['params']['pass'] = '';
$config['db']['params']['type'] = 'mysql';
$config['db']['params']['dbname'] = 'social';
return $config;
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
/**
* Настройки для локального сервера.
* Для использования - переименовать файл в config.local.php
*/
/**
* Настройка базы данных
*/
$config['db']['params']['host'] = 'localhost';
$config['db']['params']['port'] = '3306';
$config['db']['params']['user'] = 'root';
$config['db']['params']['pass'] = '';
$config['db']['params']['type'] = 'mysql';
$config['db']['params']['dbname'] = 'social';
$config['db']['table']['prefix'] = 'prefix_';
$config['view']['name'] = 'LiveStreet - бесплатный движок социальной сети';
$config['view']['description'] = 'LiveStreet - официальный сайт бесплатного движка социальной сети';
$config['view']['keywords'] = 'движок, livestreet, блоги, социальная сеть, бесплатный, php';
$config['view']['skin'] = 'new';
$config['sys']['mail']['from_email'] = 'rus.engine@gmail.com';
$config['sys']['mail']['from_name'] = 'Почтовик LiveStreet';
$config['general']['close'] = false;
$config['general']['reg']['activation'] = false;
$config['general']['reg']['invite'] = false;
$config['lang']['current'] = 'russian';
$config['lang']['default'] = 'russian';
$config['path']['root']['web'] = 'http://trunk.ls.core';
$config['path']['root']['server'] = 'Z:/home/ls.core/trunk';
$config['db']['tables']['engine'] = 'InnoDB';
return $config;
?>

View file

@ -1087,7 +1087,7 @@ class Install {
'{$aRow['talk_id']}',
'talk',
'{$aRow['user_id']}',
'{$aRow['talk_comment_text']}',
'".mysql_real_escape_string($aRow['talk_comment_text'])."',
'".md5($aRow['talk_comment_text'])."',
'{$aRow['talk_comment_date']}',
'{$aRow['talk_comment_user_ip']}',