mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Доработка медиа файлов, теперь можно подгружать файлы к комментариям
This commit is contained in:
parent
95aca97dd6
commit
f20c886e02
|
@ -1230,7 +1230,10 @@ class ActionBlog extends Action {
|
|||
*/
|
||||
$this->oUserCurrent->setDateCommentLast(date("Y-m-d H:i:s"));
|
||||
$this->User_Update($this->oUserCurrent);
|
||||
|
||||
/**
|
||||
* Фиксируем ID у media файлов комментария
|
||||
*/
|
||||
$this->Media_ReplaceTargetTmpById('comment',$oCommentNew->getId());
|
||||
/**
|
||||
* Список емайлов на которые не нужно отправлять уведомление
|
||||
*/
|
||||
|
|
|
@ -420,15 +420,7 @@ class ActionContent extends Action {
|
|||
/**
|
||||
* Фиксируем ID у media файлов топика
|
||||
*/
|
||||
if (isset($_COOKIE['media_target_tmp_topic']) and is_string($_COOKIE['media_target_tmp_topic'])) {
|
||||
$aTargetItems=$this->Media_GetTargetItemsByTargetTmpAndTargetType($_COOKIE['media_target_tmp_topic'],'topic');
|
||||
foreach($aTargetItems as $oTarget) {
|
||||
$oTarget->setTargetTmp(null);
|
||||
$oTarget->setTargetId($oTopic->getId());
|
||||
$oTarget->Update();
|
||||
}
|
||||
}
|
||||
setcookie('media_target_tmp_topic',null);
|
||||
$this->Media_ReplaceTargetTmpById('topic',$oTopic->getId());
|
||||
/**
|
||||
* Добавляем автора топика в подписчики на новые комментарии к этому топику
|
||||
*/
|
||||
|
|
|
@ -356,6 +356,21 @@ class ModuleACL extends Module {
|
|||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param ModuleComment_EntityComment $oComment
|
||||
* @param ModuleUser_EntityUser $oUser
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowEditComment($oComment,$oUser) {
|
||||
/**
|
||||
* Разрешаем если это админ сайта или автор комментария
|
||||
*/
|
||||
if ($oComment->getUserId()==$oUser->getId() or $oUser->isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверяет можно или нет пользователю удалять данный топик
|
||||
*
|
||||
|
|
|
@ -41,6 +41,7 @@ class ModuleMedia extends ModuleORM {
|
|||
|
||||
protected $aTargetTypes=array(
|
||||
'topic'=>array(),
|
||||
'comment'=>array(),
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -313,25 +314,6 @@ class ModuleMedia extends ModuleORM {
|
|||
return Config::Get('path.uploads.base')."/media/{$sTargetType}/".date('Y/m/d/H/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка владельца с типом "topic"
|
||||
* Название метода формируется автоматически
|
||||
*
|
||||
* @param int $iTargetId ID владельца
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckTargetTopic($iTargetId) {
|
||||
if ($oTopic=$this->Topic_GetTopicById($iTargetId)) {
|
||||
/**
|
||||
* Проверяем права на редактирование топика
|
||||
*/
|
||||
if ($this->ACL_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function BuildCodeForEditor($oMedia,$aParams) {
|
||||
$sCode='';
|
||||
if ($oMedia->getType()==self::TYPE_IMAGE) {
|
||||
|
@ -510,4 +492,65 @@ class ModuleMedia extends ModuleORM {
|
|||
$sTextResult.="</div>\r\n";
|
||||
return $sTextResult;
|
||||
}
|
||||
/**
|
||||
* Заменяет временный идентификатор на необходимый ID объекта
|
||||
*
|
||||
* @param string $sTargetType
|
||||
* @param string $sTargetId
|
||||
* @param null|string $sTargetTmp Если не задан, то берется их куки "media_target_tmp_{$sTargetType}"
|
||||
*/
|
||||
public function ReplaceTargetTmpById($sTargetType,$sTargetId,$sTargetTmp=null) {
|
||||
$sCookieKey='media_target_tmp_'.$sTargetType;
|
||||
if (is_null($sTargetTmp) and isset($_COOKIE[$sCookieKey])) {
|
||||
$sTargetTmp=$_COOKIE[$sCookieKey];
|
||||
setcookie($sCookieKey,null,-1,Config::Get('sys.cookie.path'),Config::Get('sys.cookie.host'));
|
||||
}
|
||||
if (is_string($sTargetTmp)) {
|
||||
$aTargetItems=$this->Media_GetTargetItemsByTargetTmpAndTargetType($sTargetTmp,$sTargetType);
|
||||
foreach($aTargetItems as $oTarget) {
|
||||
$oTarget->setTargetTmp(null);
|
||||
$oTarget->setTargetId($sTargetId);
|
||||
$oTarget->Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Проверка владельца с типом "topic"
|
||||
* Название метода формируется автоматически
|
||||
*
|
||||
* @param int $iTargetId ID владельца
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckTargetTopic($iTargetId) {
|
||||
if ($oTopic=$this->Topic_GetTopicById($iTargetId)) {
|
||||
/**
|
||||
* Проверяем права на редактирование топика
|
||||
*/
|
||||
if ($this->ACL_IsAllowEditTopic($oTopic,$this->oUserCurrent)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверка владельца с типом "comment"
|
||||
* Название метода формируется автоматически
|
||||
*
|
||||
* @param int $iTargetId ID владельца
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckTargetComment($iTargetId) {
|
||||
if ($oComment=$this->Comment_GetCommentById($iTargetId)) {
|
||||
/**
|
||||
* Проверяем права на редактирование топика
|
||||
*/
|
||||
if ($this->ACL_IsAllowEditComment($oComment,$this->oUserCurrent)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -191,11 +191,31 @@ ls.media = (function ($) {
|
|||
this.saveDataFile($(e.currentTarget).attr('name'),$(e.currentTarget).val());
|
||||
}.bind(this));
|
||||
|
||||
// Инициализация фоторамы при предпросмотре
|
||||
// Инициализация фоторамы при предпросмотре топика
|
||||
ls.hook.add('ls_topic_preview_after',function(){
|
||||
$('.fotorama').fotorama();
|
||||
});
|
||||
|
||||
// Инициализация фоторамы после обновления комментов
|
||||
ls.hook.add('ls_comments_load_after',function(){
|
||||
$('.fotorama').fotorama();
|
||||
}.bind(this));
|
||||
|
||||
// После добавления комментария необходимо получить новый временный идентификатор и очистить галлерею
|
||||
ls.hook.add('ls_comments_add_after',function(){
|
||||
this.options.target_id='';
|
||||
this.options.target_tmp='';
|
||||
ls.media.generateTargetTmp(this.options.target_type);
|
||||
this.clearSelected();
|
||||
this.elements.gallery.fileList.empty();
|
||||
this.markAsEmpty();
|
||||
}.bind(this));
|
||||
|
||||
// Инициализация фоторамы при предпросмотре
|
||||
ls.hook.inject([ls.utilities,'textPreview'], function() {
|
||||
$('.fotorama').fotorama();
|
||||
},'textPreviewDisplayAfter');
|
||||
|
||||
// Проверка корректности урла при вставке ссылки на медиа-объект
|
||||
this.elements.link.url.on('input', function() {
|
||||
this.checkLinkUrl(this.elements.link.url.val());
|
||||
|
@ -387,6 +407,7 @@ ls.media = (function ($) {
|
|||
* Подгрузка списка файлов
|
||||
*/
|
||||
this.loadImageList = function() {
|
||||
this.clearSelected();
|
||||
this.elements.gallery.fileList.empty().addClass( ls.options.classes.states.loading );
|
||||
|
||||
ls.ajax.load(this.options.routers.load_gallery, { target_type: this.options.target_type, target_id: this.options.target_id, target_tmp: this.options.target_tmp }, function(result) {
|
||||
|
@ -524,6 +545,11 @@ ls.media = (function ($) {
|
|||
}
|
||||
};
|
||||
|
||||
this.clearSelected = function() {
|
||||
this.getSelected().removeClass(this.options.classes.selected);
|
||||
this.getActive().removeClass(ls.options.classes.states.active);
|
||||
this.hideDetail();
|
||||
}
|
||||
/**
|
||||
* Получает выделенные файлы
|
||||
*
|
||||
|
|
|
@ -57,7 +57,7 @@ ls.settings = (function ($) {
|
|||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#window_upload_img').jqmShow(); } },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
{else}
|
||||
{if $oUserCurrent}
|
||||
{* Подключение редактора *}
|
||||
{include file='forms/editor.init.tpl' sEditorType='comment'}
|
||||
{include file='forms/editor.init.tpl' sEditorType='comment' sMediaTargetType='comment' }
|
||||
|
||||
{* Ссылка открывающая форму *}
|
||||
<h4 class="comment-reply-header" id="comment_id_0">
|
||||
|
|
Loading…
Reference in a new issue