mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Media: передача пользователя в параметрах #404
This commit is contained in:
parent
bd00d19ba8
commit
5e5aed6e71
|
@ -458,7 +458,7 @@ class ActionAjax extends Action {
|
|||
$sTargetTmp=empty($_COOKIE['media_target_tmp_'.$sTargetType]) ? getRequestStr('target_tmp') : $_COOKIE['media_target_tmp_'.$sTargetType];
|
||||
if ($sTargetId) {
|
||||
$sTargetTmp=null;
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,$sTargetId,ModuleMedia::TYPE_CHECK_ALLOW_ADD)) {
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,$sTargetId,ModuleMedia::TYPE_CHECK_ALLOW_ADD,array('user'=>$this->oUserCurrent))) {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('system_error'), $this->Lang_Get('error'));
|
||||
return false;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ class ActionAjax extends Action {
|
|||
if (!$sTargetTmp) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,null,ModuleMedia::TYPE_CHECK_ALLOW_ADD)) {
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,null,ModuleMedia::TYPE_CHECK_ALLOW_ADD,array('user'=>$this->oUserCurrent))) {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('system_error'), $this->Lang_Get('error'));
|
||||
return false;
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ class ActionAjax extends Action {
|
|||
if (!$oMedia=$this->Media_GetMediaById($sId)) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (true===$res=$this->Media_CheckTarget($oMedia->getTargetType(),null,ModuleMedia::TYPE_CHECK_ALLOW_REMOVE,array('media'=>$oMedia))) {
|
||||
if (true===$res=$this->Media_CheckTarget($oMedia->getTargetType(),null,ModuleMedia::TYPE_CHECK_ALLOW_REMOVE,array('media'=>$oMedia,'user'=>$this->oUserCurrent))) {
|
||||
$oMedia->Delete();
|
||||
} else {
|
||||
$this->Message_AddErrorSingle(is_string($res) ? $res : $this->Lang_Get('system_error'));
|
||||
|
@ -655,7 +655,7 @@ class ActionAjax extends Action {
|
|||
$sTargetTmp=empty($_COOKIE['media_target_tmp_'.$sTargetType]) ? getRequestStr('target_tmp') : $_COOKIE['media_target_tmp_'.$sTargetType];
|
||||
if ($sTargetId) {
|
||||
$sTargetTmp=null;
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,$sTargetId,ModuleMedia::TYPE_CHECK_ALLOW_ADD)) {
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,$sTargetId,ModuleMedia::TYPE_CHECK_ALLOW_ADD,array('user'=>$this->oUserCurrent))) {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('system_error'), $this->Lang_Get('error'));
|
||||
return false;
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ class ActionAjax extends Action {
|
|||
if (!$sTargetTmp) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,null,ModuleMedia::TYPE_CHECK_ALLOW_ADD)) {
|
||||
if (true!==$res=$this->Media_CheckTarget($sTargetType,null,ModuleMedia::TYPE_CHECK_ALLOW_ADD,array('user'=>$this->oUserCurrent))) {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('system_error'), $this->Lang_Get('error'));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,9 @@ class ModuleMedia extends ModuleORM {
|
|||
}
|
||||
$sMethod = 'CheckTarget'.func_camelize($sTargetType);
|
||||
if (method_exists($this,$sMethod)) {
|
||||
if (!array_key_exists('user',$aParams)) {
|
||||
$aParams['user']=$this->oUserCurrent;
|
||||
}
|
||||
return $this->$sMethod($iTargetId,$sAllowType,$aParams);
|
||||
}
|
||||
return false;
|
||||
|
@ -727,11 +730,14 @@ class ModuleMedia extends ModuleORM {
|
|||
*
|
||||
* @param int|null $iTargetId ID владельца, для новых объектов может быть не определен
|
||||
* @param string $sAllowType Тип доступа, константа self::TYPE_CHECK_ALLOW_*
|
||||
* @param array $aParams Дополнительные параметры
|
||||
* @param array $aParams Дополнительные параметры, всегда есть ключ 'user'
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckTargetTopic($iTargetId,$sAllowType,$aParams) {
|
||||
if (!$oUser=$aParams['user']) {
|
||||
return false;
|
||||
}
|
||||
if ($sAllowType==self::TYPE_CHECK_ALLOW_ADD) {
|
||||
if (is_null($iTargetId)) {
|
||||
/**
|
||||
|
@ -743,7 +749,7 @@ class ModuleMedia extends ModuleORM {
|
|||
/**
|
||||
* Проверяем права на редактирование топика
|
||||
*/
|
||||
if ($this->ACL_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
|
||||
if ($this->ACL_IsAllowEditTopic($oTopic,$oUser)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -752,7 +758,7 @@ class ModuleMedia extends ModuleORM {
|
|||
* Доступ на удаление файла
|
||||
*/
|
||||
$oMedia=$aParams['media'];
|
||||
if ($oMedia->getUserId()==$this->oUserCurrent->getId()) {
|
||||
if ($oMedia->getUserId()==$oUser->getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -764,11 +770,14 @@ class ModuleMedia extends ModuleORM {
|
|||
*
|
||||
* @param int|null $iTargetId ID владельца, для новых объектов может быть не определен
|
||||
* @param string $sAllowType Тип доступа, константа self::TYPE_CHECK_ALLOW_*
|
||||
* @param array $aParams Дополнительные параметры
|
||||
* @param array $aParams Дополнительные параметры, всегда есть ключ 'user'
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckTargetComment($iTargetId,$sAllowType,$aParams) {
|
||||
if (!$oUser=$aParams['user']) {
|
||||
return false;
|
||||
}
|
||||
if ($sAllowType==self::TYPE_CHECK_ALLOW_ADD) {
|
||||
if (is_null($iTargetId)) {
|
||||
/**
|
||||
|
@ -780,7 +789,7 @@ class ModuleMedia extends ModuleORM {
|
|||
/**
|
||||
* Проверяем права на редактирование комментария
|
||||
*/
|
||||
if ($this->ACL_IsAllowEditComment($oComment,$this->oUserCurrent)) {
|
||||
if ($this->ACL_IsAllowEditComment($oComment,$oUser)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -789,7 +798,7 @@ class ModuleMedia extends ModuleORM {
|
|||
* Доступ на удаление файла
|
||||
*/
|
||||
$oMedia=$aParams['media'];
|
||||
if ($oMedia->getUserId()==$this->oUserCurrent->getId()) {
|
||||
if ($oMedia->getUserId()==$oUser->getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue