mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 14:50:48 +03:00
fix media #708
This commit is contained in:
parent
a273b5ab22
commit
c57923d618
|
@ -145,7 +145,7 @@ class ActionAjax extends Action
|
|||
$oViewer = $this->Viewer_GetLocalViewer();
|
||||
|
||||
// Получаем переменные
|
||||
$bSelectable = (bool) getRequest('selectable');
|
||||
$bSelectable = (bool)getRequest('selectable');
|
||||
|
||||
// Получаем список друзей
|
||||
$aUsersFriend = $this->User_GetUsersFriend($this->oUserCurrent->getId());
|
||||
|
@ -547,7 +547,7 @@ class ActionAjax extends Action
|
|||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (true !== $res = $this->Media_CheckTarget($sTargetType, null, ModuleMedia::TYPE_CHECK_ALLOW_ADD,
|
||||
array('user' => $this->oUserCurrent))
|
||||
array('user' => $this->oUserCurrent), $sTargetTmp)
|
||||
) {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('common.error.system.base'),
|
||||
$this->Lang_Get('common.error.error'));
|
||||
|
@ -932,7 +932,7 @@ class ActionAjax extends Action
|
|||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (true !== $res = $this->Media_CheckTarget($sTargetType, null, ModuleMedia::TYPE_CHECK_ALLOW_ADD,
|
||||
array('user' => $this->oUserCurrent))
|
||||
array('user' => $this->oUserCurrent), $sTargetTmp)
|
||||
) {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('common.error.system.base'),
|
||||
$this->Lang_Get('common.error.error'));
|
||||
|
@ -1772,7 +1772,7 @@ class ActionAjax extends Action
|
|||
if (!($sValue = getRequest('value', null, 'post')) or !is_string($sValue)) {
|
||||
return;
|
||||
}
|
||||
$bReturnExtended=getRequest('extended') ?: false;
|
||||
$bReturnExtended = getRequest('extended') ?: false;
|
||||
$aItems = array();
|
||||
/**
|
||||
* Формируем список пользователей
|
||||
|
@ -1782,7 +1782,7 @@ class ActionAjax extends Action
|
|||
if ($bReturnExtended) {
|
||||
$aItems[] = array(
|
||||
'value' => $oUser->getId(),
|
||||
'text' => $oUser->getLogin(),
|
||||
'text' => $oUser->getLogin(),
|
||||
);
|
||||
} else {
|
||||
$aItems[] = $oUser->getLogin();
|
||||
|
|
|
@ -214,13 +214,32 @@ class ModuleMedia extends ModuleORM
|
|||
* @param int $iTargetId ID владельца
|
||||
* @param string $sAllowType
|
||||
* @param array $aParams
|
||||
* @param string|null $sTargetTmp
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckTarget($sTargetType, $iTargetId = null, $sAllowType = null, $aParams = array())
|
||||
public function CheckTarget($sTargetType, $iTargetId = null, $sAllowType = null, $aParams = array(), $sTargetTmp = null)
|
||||
{
|
||||
if (!$this->IsAllowTargetType($sTargetType)) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверка на максимальное количество файлов
|
||||
*/
|
||||
if ($sAllowType == self::TYPE_CHECK_ALLOW_ADD and ($iTargetId or $sTargetTmp)) {
|
||||
$iCountAllow = $this->GetConfigParam('max_count_files', $sTargetType);
|
||||
if (is_numeric($iCountAllow)) {
|
||||
$aFilterCount = array('target_type' => $sTargetType);
|
||||
if ($iTargetId) {
|
||||
$aFilterCount['target_id'] = $iTargetId;
|
||||
} else {
|
||||
$aFilterCount['target_tmp'] = $sTargetTmp;
|
||||
}
|
||||
$iCount = $this->getCountFromTargetByFilter($aFilterCount);
|
||||
if ($iCount >= $iCountAllow) {
|
||||
return $this->Lang_Get('media.error.max_count_files');
|
||||
}
|
||||
}
|
||||
}
|
||||
$sMethod = 'CheckTarget' . func_camelize($sTargetType);
|
||||
if (method_exists($this, $sMethod)) {
|
||||
if (!array_key_exists('user', $aParams)) {
|
||||
|
|
|
@ -282,6 +282,7 @@ $config['module']['image']['params']['blog_avatar']['size_max_height'] = 1000;
|
|||
* Модуль Media
|
||||
*/
|
||||
$config['module']['media']['max_size'] = 3*1024; // Максимальный размер файла в kB
|
||||
$config['module']['media']['max_count_files'] = 30; // Максимальное количество файлов медиа у одного объекта
|
||||
$config['module']['media']['image']['max_size'] = 5*1024; // Максимальный размер файла изображения в kB
|
||||
$config['module']['media']['image']['autoresize'] = true; // Разрешает автоматическое создание изображений нужного размера при их запросе
|
||||
$config['module']['media']['image']['original'] = '1500x'; // Размер для хранения оригинала. Если true, то будет сохраняться исходный оригинал без ресайза. Если false, то оригинал сохраняться не будет
|
||||
|
|
|
@ -1550,6 +1550,7 @@ return array(
|
|||
'not_image' => 'Файл не является изображением',
|
||||
'too_large' => 'Превышен максимальный размер файла: %%size%%Кб',
|
||||
'incorrect_type' => 'Неверный тип файла',
|
||||
'max_count_files' => 'Превышено максимальное число файлов',
|
||||
),
|
||||
'nav' => array(
|
||||
'insert' => 'Вставить',
|
||||
|
|
Loading…
Reference in a new issue