mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Доработка пополняемого списка пользователей
This commit is contained in:
parent
1a0755cd1e
commit
d30325baae
|
@ -1352,7 +1352,7 @@ class ActionBlog extends Action {
|
|||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$sUsers=getRequest('sUserList',null,'post');
|
||||
$aUsers=getRequest('aUserList',null,'post');
|
||||
$sBlogId=getRequestStr('iTargetId',null,'post');
|
||||
/**
|
||||
* Если пользователь не авторизирован, возвращаем ошибку
|
||||
|
@ -1365,7 +1365,7 @@ class ActionBlog extends Action {
|
|||
/**
|
||||
* Проверяем существование блога
|
||||
*/
|
||||
if(!$oBlog=$this->Blog_GetBlogById($sBlogId) or !is_string($sUsers)) {
|
||||
if(!$oBlog=$this->Blog_GetBlogById($sBlogId) or !is_array($aUsers)) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
|
@ -1392,7 +1392,6 @@ class ActionBlog extends Action {
|
|||
),null // пока костылем
|
||||
);
|
||||
$aBlogUsers=$aBlogUsersResult['collection'];
|
||||
$aUsers=explode(',',$sUsers);
|
||||
|
||||
$aResult=array();
|
||||
/**
|
||||
|
@ -1451,7 +1450,7 @@ class ActionBlog extends Action {
|
|||
'sUserWebPath'=>$oUser->getUserWebPath(),
|
||||
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48),
|
||||
'iUserId'=>$oUser->getId(),
|
||||
'sUserHtml'=>$oViewer->Fetch("user_list_small_item.blog_invite.tpl")
|
||||
'sHtml'=>$oViewer->Fetch("user_list_small_item.blog_invite.tpl")
|
||||
);
|
||||
$this->SendBlogInvite($oBlog,$oUser);
|
||||
} else {
|
||||
|
@ -1492,7 +1491,7 @@ class ActionBlog extends Action {
|
|||
/**
|
||||
* Передаем во вьевер массив с результатами обработки по каждому пользователю
|
||||
*/
|
||||
$this->Viewer_AssignAjax('aUsers',$aResult);
|
||||
$this->Viewer_AssignAjax('aUserList',$aResult);
|
||||
}
|
||||
/**
|
||||
* Обработка ajax запроса на отправку
|
||||
|
@ -1503,8 +1502,8 @@ class ActionBlog extends Action {
|
|||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$sUserId=getRequestStr('idUser',null,'post');
|
||||
$sBlogId=getRequestStr('idBlog',null,'post');
|
||||
$sUserId=getRequestStr('iUserId',null,'post');
|
||||
$sBlogId=getRequestStr('iTargetId',null,'post');
|
||||
/**
|
||||
* Если пользователь не авторизирован, возвращаем ошибку
|
||||
*/
|
||||
|
|
|
@ -301,7 +301,13 @@ class ActionStream extends Action {
|
|||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$sUsers=getRequestStr('sUserList',null,'post');
|
||||
$aUsers=getRequest('aUserList',null,'post');
|
||||
/**
|
||||
* Валидация
|
||||
*/
|
||||
if ( ! is_array($aUsers) ) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Если пользователь не авторизирован, возвращаем ошибку
|
||||
*/
|
||||
|
@ -309,7 +315,6 @@ class ActionStream extends Action {
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('need_authorization'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
$aUsers=explode(',',$sUsers);
|
||||
|
||||
$aResult=array();
|
||||
/**
|
||||
|
@ -337,7 +342,7 @@ class ActionStream extends Action {
|
|||
'sUserLogin'=>htmlspecialchars($sUser),
|
||||
'sUserWebPath'=>$oUser->getUserWebPath(),
|
||||
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48),
|
||||
'sUserHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
'sHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
);
|
||||
} else {
|
||||
$aResult[]=array(
|
||||
|
@ -351,7 +356,7 @@ class ActionStream extends Action {
|
|||
/**
|
||||
* Передаем во вьевер массив с результатами обработки по каждому пользователю
|
||||
*/
|
||||
$this->Viewer_AssignAjax('aUsers',$aResult);
|
||||
$this->Viewer_AssignAjax('aUserList',$aResult);
|
||||
}
|
||||
/**
|
||||
* Отписка от пользователя
|
||||
|
|
|
@ -723,7 +723,14 @@ class ActionTalk extends Action {
|
|||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$sUsers=getRequestStr('sUserList',null,'post');
|
||||
$aUsers=getRequest('aUserList',null,'post');
|
||||
|
||||
/**
|
||||
* Валидация
|
||||
*/
|
||||
if ( ! is_array($aUsers) ) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Если пользователь не авторизирован, возвращаем ошибку
|
||||
*/
|
||||
|
@ -731,7 +738,6 @@ class ActionTalk extends Action {
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('need_authorization'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
$aUsers=explode(',',$sUsers);
|
||||
/**
|
||||
* Получаем блекслист пользователя
|
||||
*/
|
||||
|
@ -776,7 +782,7 @@ class ActionTalk extends Action {
|
|||
'sUserLogin'=>htmlspecialchars($sUser),
|
||||
'sUserWebPath'=>$oUser->getUserWebPath(),
|
||||
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48),
|
||||
'sUserHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
'sHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
);
|
||||
} else {
|
||||
$aResult[]=array(
|
||||
|
@ -810,7 +816,7 @@ class ActionTalk extends Action {
|
|||
/**
|
||||
* Передаем во вьевер массив с результатами обработки по каждому пользователю
|
||||
*/
|
||||
$this->Viewer_AssignAjax('aUsers',$aResult);
|
||||
$this->Viewer_AssignAjax('aUserList',$aResult);
|
||||
}
|
||||
/**
|
||||
* Удаление пользователя из блек листа (ajax)
|
||||
|
@ -956,8 +962,14 @@ class ActionTalk extends Action {
|
|||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$sUsers=getRequestStr('sUserList',null,'post');
|
||||
$aUsers=getRequest('aUserList',null,'post');
|
||||
$idTalk=getRequestStr('iTargetId',null,'post');
|
||||
/**
|
||||
* Валидация
|
||||
*/
|
||||
if ( ! is_array($aUsers) ) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Если пользователь не авторизирован, возвращаем ошибку
|
||||
*/
|
||||
|
@ -983,7 +995,6 @@ class ActionTalk extends Action {
|
|||
* Получаем список всех участников разговора
|
||||
*/
|
||||
$aTalkUsers=$oTalk->getTalkUsers();
|
||||
$aUsers=explode(',',$sUsers);
|
||||
/**
|
||||
* Получаем список пользователей, которые не принимают письма
|
||||
*/
|
||||
|
@ -1045,12 +1056,12 @@ class ActionTalk extends Action {
|
|||
'bStateError'=>false,
|
||||
'sMsgTitle'=>$this->Lang_Get('attention'),
|
||||
'sMsg'=>$this->Lang_Get('talk_speaker_add_ok',array('login',htmlspecialchars($sUser))),
|
||||
'sUserId'=>$oUser->getId(),
|
||||
'iUserId'=>$oUser->getId(),
|
||||
'sUserLogin'=>$oUser->getLogin(),
|
||||
'sUserLink'=>$oUser->getUserWebPath(),
|
||||
'sUserWebPath'=>$oUser->getUserWebPath(),
|
||||
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48),
|
||||
'sUserHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
'sHtml'=>$oViewer->Fetch("user_list_small_item.message.tpl")
|
||||
);
|
||||
$bState=true;
|
||||
} else {
|
||||
|
@ -1102,15 +1113,17 @@ class ActionTalk extends Action {
|
|||
)
|
||||
) {
|
||||
$this->Notify_SendTalkNew($oUser,$this->oUserCurrent,$oTalk);
|
||||
|
||||
$oViewer = $this->Viewer_GetLocalViewer();
|
||||
$oViewer->Assign('oUser', $oUser);
|
||||
$oViewer->Assign('bUserListSmallShowActions', true);
|
||||
|
||||
$aResult[]=array(
|
||||
'bStateError'=>false,
|
||||
'sMsgTitle'=>$this->Lang_Get('attention'),
|
||||
'sMsg'=>$this->Lang_Get('talk_speaker_add_ok',array('login',htmlspecialchars($sUser))),
|
||||
'sUserId'=>$oUser->getId(),
|
||||
'sUserLogin'=>$oUser->getLogin(),
|
||||
'sUserLink'=>$oUser->getUserWebPath(),
|
||||
'sUserWebPath'=>$oUser->getUserWebPath(),
|
||||
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48)
|
||||
'iUserId'=>$oUser->getId(),
|
||||
'sHtml'=>$oViewer->Fetch("user_list_small_item.message.tpl")
|
||||
);
|
||||
$bState=true;
|
||||
} else {
|
||||
|
@ -1144,7 +1157,7 @@ class ActionTalk extends Action {
|
|||
/**
|
||||
* Передаем во вьевер массив результатов обработки по каждому пользователю
|
||||
*/
|
||||
$this->Viewer_AssignAjax('aUsers',$aResult);
|
||||
$this->Viewer_AssignAjax('aUserList',$aResult);
|
||||
}
|
||||
/**
|
||||
* Возвращает количество новых сообщений
|
||||
|
|
|
@ -181,7 +181,13 @@ class ActionUserfeed extends Action {
|
|||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$sUsers=getRequestStr('sUserList',null,'post');
|
||||
$aUsers=getRequest('aUserList',null,'post');
|
||||
/**
|
||||
* Валидация
|
||||
*/
|
||||
if ( ! is_array($aUsers) ) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Если пользователь не авторизирован, возвращаем ошибку
|
||||
*/
|
||||
|
@ -189,7 +195,6 @@ class ActionUserfeed extends Action {
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('need_authorization'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
$aUsers=explode(',',$sUsers);
|
||||
|
||||
$aResult=array();
|
||||
/**
|
||||
|
@ -218,7 +223,7 @@ class ActionUserfeed extends Action {
|
|||
'sUserLogin'=>htmlspecialchars($sUser),
|
||||
'sUserWebPath'=>$oUser->getUserWebPath(),
|
||||
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48),
|
||||
'sUserHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
'sHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
||||
);
|
||||
} else {
|
||||
$aResult[]=array(
|
||||
|
@ -232,7 +237,7 @@ class ActionUserfeed extends Action {
|
|||
/**
|
||||
* Передаем во вьевер массив с результатами обработки по каждому пользователю
|
||||
*/
|
||||
$this->Viewer_AssignAjax('aUsers',$aResult);
|
||||
$this->Viewer_AssignAjax('aUserList',$aResult);
|
||||
}
|
||||
/**
|
||||
* Отписка от блога или пользователя
|
||||
|
|
|
@ -470,14 +470,15 @@ $config['head']['default']['js'] = array(
|
|||
"___path.framework.frontend.web___/js/vendor/colorbox/jquery.colorbox.js",
|
||||
|
||||
/* Core */
|
||||
"___path.framework.frontend.web___/js/core/polyfills.js",
|
||||
"___path.framework.frontend.web___/js/core/main.js",
|
||||
"___path.framework.frontend.web___/js/core/dev.js",
|
||||
"___path.framework.frontend.web___/js/core/hook.js",
|
||||
"___path.framework.frontend.web___/js/core/i18n.js",
|
||||
"___path.framework.frontend.web___/js/core/ie.js",
|
||||
"___path.framework.frontend.web___/js/core/ajax.js",
|
||||
"___path.framework.frontend.web___/js/core/registry.js",
|
||||
"___path.framework.frontend.web___/js/core/swfupload.js",
|
||||
"___path.framework.frontend.web___/js/core/utilities.js",
|
||||
"___path.framework.frontend.web___/js/core/utils.js",
|
||||
"___path.framework.frontend.web___/js/core/timer.js",
|
||||
|
||||
/* User Interface */
|
||||
|
@ -518,6 +519,8 @@ $config['head']['default']['js'] = array(
|
|||
"___path.application.web___/frontend/common/js/tags.js",
|
||||
"___path.application.web___/frontend/common/js/content.js",
|
||||
"___path.application.web___/frontend/common/js/user_list_add.js",
|
||||
"___path.application.web___/frontend/common/js/blog_invite_users.js",
|
||||
"___path.application.web___/frontend/common/js/message_users.js",
|
||||
"___path.application.web___/frontend/common/js/search.js",
|
||||
"___path.application.web___/frontend/common/js/more.js",
|
||||
"___path.application.web___/frontend/common/js/init.js",
|
||||
|
|
|
@ -25,9 +25,6 @@ ls.blog = (function ($) {
|
|||
categories: aRouter['ajax'] + 'blogs/get-by-category/',
|
||||
info: aRouter['blog'] + 'ajaxbloginfo/',
|
||||
search: aRouter['blogs'] + 'ajax-search/',
|
||||
invite: {
|
||||
repeat: aRouter['blog'] + 'ajaxrebloginvite/',
|
||||
}
|
||||
},
|
||||
|
||||
// Селекторы
|
||||
|
@ -37,9 +34,6 @@ ls.blog = (function ($) {
|
|||
users_number: '.js-blog-users-number',
|
||||
info: '.js-blog-info',
|
||||
blog_add_type_note: '#blog_type_note',
|
||||
invite: {
|
||||
user_repeat: '.js-blog-invite-user-repeat',
|
||||
},
|
||||
nav: {
|
||||
categories: '.js-blog-nav-categories',
|
||||
blogs: '.js-blog-nav-blogs',
|
||||
|
@ -80,21 +74,6 @@ ls.blog = (function ($) {
|
|||
e.preventDefault();
|
||||
});
|
||||
|
||||
/**
|
||||
* Инвайты
|
||||
*/
|
||||
|
||||
// Повторно отправить инвайт
|
||||
$(document).on('click', this.options.selectors.invite.user_repeat, function (e) {
|
||||
var oButton = $(this),
|
||||
oContainer = oButton.closest(ls.user_list_add.options.selectors.container),
|
||||
oUserList = oContainer.find(ls.user_list_add.options.selectors.user_list);
|
||||
|
||||
_this.invite.repeat(oButton.data('user-id'), oContainer.data('target-id'));
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
/**
|
||||
* Блок навигации по категориям и блогам
|
||||
*/
|
||||
|
@ -212,34 +191,5 @@ ls.blog = (function ($) {
|
|||
window.location.href = this.elements.nav.blogs.find('option:selected').data('url') || '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Приглашения
|
||||
*/
|
||||
this.invite = function(_this) {
|
||||
/**
|
||||
* Повторно отправляет приглашение
|
||||
*/
|
||||
this.repeat = function(iUserId,iBlogId) {
|
||||
var sUrl = _this.options.routers.invite.repeat,
|
||||
oParams = { idUser: iUserId, idBlog: iBlogId };
|
||||
|
||||
ls.hook.marker('repeatInviteBefore');
|
||||
|
||||
ls.ajax.load(sUrl, oParams, function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
ls.msg.notice(null, result.sMsg);
|
||||
|
||||
ls.hook.run('ls_blog_repeat_invite_after', [iUserId, iBlogId, result]);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
return this;
|
||||
}.call({}, this);
|
||||
|
||||
return this;
|
||||
}).call(ls.blog || {},jQuery);
|
66
application/frontend/common/js/blog_invite_users.js
Normal file
66
application/frontend/common/js/blog_invite_users.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* Приглашение пользователей в закрытый блог
|
||||
*
|
||||
* @module blog_invite_users
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "livestreet.blog_invite_users", $.livestreet.user_list_add, {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
urls: {
|
||||
add: aRouter['blog'] + 'ajaxaddbloginvite/',
|
||||
remove: aRouter['blog'] + 'ajaxremovebloginvite/',
|
||||
reinvite: aRouter['blog'] + 'ajaxrebloginvite/'
|
||||
},
|
||||
selectors: {
|
||||
// Кнопка повторного отправления инвайта
|
||||
item_reinvite: '.js-blog-invite-user-repeat'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this;
|
||||
|
||||
this._super();
|
||||
|
||||
// Повторная отправка инвайта
|
||||
this.elements.list.on('click', this.options.selectors.item_reinvite, function (e) {
|
||||
_this.reinvite( $(this).data('user-id') );
|
||||
e.preventDefault();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Отправляет инвайт заново
|
||||
*/
|
||||
reinvite: function (iUserId) {
|
||||
var _this = this,
|
||||
oParams = {
|
||||
iUserId: iUserId
|
||||
};
|
||||
|
||||
oParams = $.extend({}, oParams, this.options.params);
|
||||
|
||||
ls.ajax.load(this.options.urls.reinvite, oParams, function(oResponse) {
|
||||
ls.msg.notice(null, oResponse.sMsg);
|
||||
|
||||
this._trigger("afterreinvite", null, { context: this, response: oResponse, oParams: oParams });
|
||||
}.bind(this));
|
||||
},
|
||||
});
|
||||
})(jQuery);
|
97
application/frontend/common/js/message_users.js
Normal file
97
application/frontend/common/js/message_users.js
Normal file
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
* Добавление / удаление пользователей из личных сообщений
|
||||
*
|
||||
* @module message_users
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "livestreet.message_users", $.livestreet.user_list_add, {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
urls: {
|
||||
add: aRouter['talk'] + 'ajaxaddtalkuser/',
|
||||
inactivate: aRouter['talk'] + 'ajaxdeletetalkuser/'
|
||||
},
|
||||
selectors: {
|
||||
// Кнопка отключения пользователя от диалога
|
||||
item_inactivate: '.js-message-users-user-inactivate',
|
||||
// Кнопка повторного приглашения пользователя в диалог
|
||||
item_activate: '.js-message-users-user-activate'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this;
|
||||
|
||||
this._super();
|
||||
|
||||
// Отключение пользователя от диалога
|
||||
this.elements.list.on('click', this.options.selectors.item_inactivate, function (e) {
|
||||
_this.inactivate( $(this) );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Повторное приглашение пользователя в диалог
|
||||
this.elements.list.on('click', this.options.selectors.item_activate, function (e) {
|
||||
_this.add( [ $(this).data('user-login') ] );
|
||||
e.preventDefault();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Активирует пользователя при его повторном добавлении
|
||||
*/
|
||||
_onUserAdd: function (oUser) {
|
||||
this.userActivate(oUser.iUserId);
|
||||
},
|
||||
|
||||
/**
|
||||
* Повторное приглашение пользователя в диалог
|
||||
*/
|
||||
inactivate: function (oButton) {
|
||||
var _this = this,
|
||||
iUserId = oButton.data('user-id'),
|
||||
oParams = {
|
||||
iUserId: iUserId
|
||||
};
|
||||
|
||||
oParams = $.extend({}, oParams, this.options.params);
|
||||
|
||||
ls.ajax.load(this.options.urls.inactivate, oParams, function(oResponse) {
|
||||
ls.msg.notice(null, oResponse.sMsg);
|
||||
|
||||
this.userInactivate(iUserId);
|
||||
|
||||
this._trigger("afterinactivate", null, { context: this, response: oResponse, oParams: oParams });
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Активирует пользователя при его повторном добавлении
|
||||
*/
|
||||
userActivate: function (iUserId) {
|
||||
this._getUserById( iUserId ).removeClass('inactive');
|
||||
},
|
||||
|
||||
/**
|
||||
* Отключения пользователя от диалога
|
||||
*/
|
||||
userInactivate: function (iUserId) {
|
||||
this._getUserById( iUserId ).addClass('inactive');
|
||||
},
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,207 +1,206 @@
|
|||
/**
|
||||
* Пополняемый список пользователей
|
||||
*
|
||||
*
|
||||
* @module ls/user_list_add
|
||||
*
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
|
||||
ls.user_list_add = (function ($) {
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
// Селекторы
|
||||
selectors: {
|
||||
container: '.js-user-list-add',
|
||||
user_list: '.js-user-list-add-users',
|
||||
user_item: '.js-user-list-small-item',
|
||||
user_list_empty: '.js-user-list-small-empty',
|
||||
form: {
|
||||
form: '.js-user-list-add-form',
|
||||
users: '.js-user-list-add-form-users',
|
||||
submit: '.js-user-list-add-form-submit'
|
||||
$.widget( "livestreet.user_list_add", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
urls: {
|
||||
add: null,
|
||||
remove: null
|
||||
},
|
||||
actions: {
|
||||
remove: '.js-user-list-add-user-remove'
|
||||
}
|
||||
// Селекторы
|
||||
selectors: {
|
||||
// Блок со списком объектов
|
||||
list: '.js-user-list-add-users',
|
||||
// Объект
|
||||
item: '.js-user-list-small-item',
|
||||
// Кнопка удаления объекта
|
||||
item_remove: '.js-user-list-add-user-remove',
|
||||
// Сообщение о пустом списке
|
||||
empty: '.js-user-list-small-empty',
|
||||
// Форма добавления
|
||||
form: '.js-user-list-add-form'
|
||||
},
|
||||
// Анимация при скрытии объекта
|
||||
hide: {
|
||||
effect: 'slide',
|
||||
duration: 200,
|
||||
direction: 'left'
|
||||
},
|
||||
// Кастомные аякс параметры
|
||||
params: {}
|
||||
},
|
||||
|
||||
// Типы списков
|
||||
type: {
|
||||
// Приглашение пользователей в блог
|
||||
blog_invite: {
|
||||
url: {
|
||||
add: aRouter['blog'] + 'ajaxaddbloginvite/',
|
||||
remove: aRouter['blog'] + 'ajaxremovebloginvite/'
|
||||
}
|
||||
},
|
||||
// Добавление участников личного сообщения
|
||||
message: {
|
||||
url: {
|
||||
add: aRouter['talk'] + 'ajaxaddtalkuser/',
|
||||
remove: aRouter['talk'] + 'ajaxdeletetalkuser/'
|
||||
}
|
||||
},
|
||||
// Черный список
|
||||
blacklist: {
|
||||
url: {
|
||||
add: aRouter['talk'] + 'ajaxaddtoblacklist/',
|
||||
remove: aRouter['talk'] + 'ajaxdeletefromblacklist/'
|
||||
}
|
||||
},
|
||||
// Добавление пользователей в свою активность
|
||||
activity: {
|
||||
url: {
|
||||
add: aRouter['stream'] + 'ajaxadduser/',
|
||||
remove: aRouter['stream'] + 'ajaxremoveuser/'
|
||||
}
|
||||
},
|
||||
// Добавление пользователей в свою ленту
|
||||
userfeed: {
|
||||
url: {
|
||||
add: aRouter['feed'] + 'ajaxadduser/',
|
||||
remove: aRouter['feed'] + 'unsubscribe/'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this;
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
* @param {Object} options Опции
|
||||
*/
|
||||
this.init = function(options) {
|
||||
var _this = this;
|
||||
// Получаем список элементов
|
||||
this.elements = {};
|
||||
this.elements.container = this.element;
|
||||
this.elements.list = this.elements.container.find(this.options.selectors.list);
|
||||
this.elements.empty = this.elements.container.find(this.options.selectors.empty);
|
||||
this.elements.form = this.elements.container.find(this.options.selectors.form);
|
||||
this.elements.form_text = this.elements.form.find('input[type=text]');
|
||||
|
||||
this.options = $.extend({}, defaults, options);
|
||||
// Получаем кастомные аякс параметры
|
||||
this.options.params = $.extend({}, this.options.params, ls.utils.getDataOptions(this.elements.container, 'param'));
|
||||
|
||||
this.elements = {
|
||||
form: $(this.options.selectors.form.form),
|
||||
actions: {
|
||||
remove: $(this.options.selectors.actions.remove)
|
||||
}
|
||||
}
|
||||
|
||||
// Добавление
|
||||
this.elements.form.on('submit', function(e) {
|
||||
var oForm = $(this),
|
||||
oContainer = oForm.closest(_this.options.selectors.container),
|
||||
oFormUsers = oForm.find(_this.options.selectors.form.users),
|
||||
oButton = oForm.find(_this.options.selectors.form.submit),
|
||||
oUserList = oContainer.find(_this.options.selectors.user_list),
|
||||
sUserList = oFormUsers.val(),
|
||||
oEmptyAlert = oContainer.find(_this.options.selectors.user_list_empty);
|
||||
|
||||
if ( ! sUserList ) return false;
|
||||
|
||||
// Блокируем форму
|
||||
oButton.prop('disabled', true).addClass(ls.options.classes.states.loading);
|
||||
oFormUsers.prop('disabled', true);
|
||||
|
||||
_this.add(oContainer.data('type'), oContainer.data('target-id'), sUserList, {
|
||||
add_success: function (oResponse) {
|
||||
oFormUsers.val('');
|
||||
},
|
||||
add_user_success: function (oUser) {
|
||||
oUserList.show().prepend(oUser.sUserHtml);
|
||||
oEmptyAlert.hide();
|
||||
},
|
||||
add_after: function (oResponse) {
|
||||
// Разблокировываем форму
|
||||
oButton.prop('disabled', false).removeClass(ls.options.classes.states.loading);
|
||||
oFormUsers.prop('disabled', false).focus();
|
||||
}
|
||||
// Ивент удаления
|
||||
this.elements.list.on('click', this.options.selectors.item_remove, function (e) {
|
||||
_this.remove( $(this).data('user-id') );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
// Ивент добавления
|
||||
this.elements.form.on('submit', function (e) {
|
||||
var aItemList = _this.getItems();
|
||||
|
||||
// Удаление
|
||||
$(document).on('click', this.options.selectors.actions.remove, function(e) {
|
||||
var oButton = $(this),
|
||||
oContainer = oButton.closest(_this.options.selectors.container),
|
||||
oUserList = oContainer.find(_this.options.selectors.user_list),
|
||||
oEmptyAlert = oContainer.find(_this.options.selectors.user_list_empty);
|
||||
if ( aItemList.length ) {
|
||||
ls.utils.formLock(_this.elements.form);
|
||||
_this.add( aItemList );
|
||||
}
|
||||
|
||||
_this.remove(oContainer.data('type'), oContainer.data('target-id'), oButton.data('user-id'), oContainer, function (oResponse, iUserId) {
|
||||
oContainer.find(this.options.selectors.user_item + '[data-user-id=' + iUserId + ']').fadeOut(300, function () {
|
||||
$(this).remove();
|
||||
|
||||
// Скрываем список если пользователей в нем нет
|
||||
if ( ! oUserList.find(_this.options.selectors.user_item).length ) {
|
||||
oUserList.hide();
|
||||
oEmptyAlert.show();
|
||||
}
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
},
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Получает объекты для добавления
|
||||
*
|
||||
* @return {Array} Массив с объектами
|
||||
*/
|
||||
getItems: function () {
|
||||
var sValue = this.elements.form_text.val();
|
||||
|
||||
/**
|
||||
* Добавление пользователя
|
||||
*/
|
||||
this.add = function(sType, iTargetId, sUserList, aCallbacks) {
|
||||
if ( ! sUserList ) return false;
|
||||
return $.map(sValue.split(','), function(sItem, iIndex) {
|
||||
return $.trim(sItem) || null;
|
||||
});
|
||||
},
|
||||
|
||||
var sUrl = this.options.type[sType].url.add,
|
||||
oParams = {
|
||||
iTargetId: iTargetId,
|
||||
sUserList: sUserList
|
||||
/**
|
||||
* Добавление объекта
|
||||
*/
|
||||
add: function(aUserList) {
|
||||
if ( ! aUserList ) return;
|
||||
|
||||
var oParams = {
|
||||
aUserList: aUserList,
|
||||
};
|
||||
|
||||
ls.ajax.load(sUrl, oParams, function(oResponse) {
|
||||
if (oResponse.bStateError) {
|
||||
ls.msg.error(null, oResponse.sMsg);
|
||||
} else {
|
||||
$.each(oResponse.aUsers, function (iIndex, oUser) {
|
||||
if (oUser.bStateError) {
|
||||
ls.msg.error(null, oUser.sMsg);
|
||||
oParams = $.extend({}, oParams, this.options.params);
|
||||
|
||||
ls.ajax.load(this.options.urls.add, oParams, function(oResponse) {
|
||||
this._onAdd(oResponse);
|
||||
|
||||
this._trigger("afteradd", null, { context: this, response: oResponse });
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_onUserAdd: function (oItem) {
|
||||
return;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
_onAdd: function (oResponse) {
|
||||
var aUsers = this._getUsersAll();
|
||||
|
||||
// Составляем список добавляемых объектов
|
||||
var sItemsHtml = $.map(oResponse.aUserList, function (oItem, iIndex) {
|
||||
if (oItem.bStateError) {
|
||||
ls.msg.error(null, oItem.sMsg);
|
||||
} else {
|
||||
ls.msg.notice(null, ls.lang.get('common.success.add'));
|
||||
|
||||
this._trigger("afterobjectadd", null, { context: this, oItem: oItem, response: oResponse });
|
||||
|
||||
this._onUserAdd(oItem);
|
||||
|
||||
// Не добавляем юзера если он уже есть в списке
|
||||
if ( aUsers.filter('[data-user-id=' + oItem.iUserId + ']').length ) {
|
||||
return null;
|
||||
} else {
|
||||
ls.msg.notice(null, ls.lang.get('common.success.add'));
|
||||
return oItem.sHtml;
|
||||
}
|
||||
}
|
||||
}.bind(this)).join('');
|
||||
|
||||
if (typeof aCallbacks.add_user_success === 'function') aCallbacks.add_user_success.call(this, oUser);
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof aCallbacks.add_success === 'function') aCallbacks.add_success.call(this, oResponse);
|
||||
if ( sItemsHtml ) {
|
||||
// Скрываем сообщение о пустом списке
|
||||
this.elements.empty.hide();
|
||||
// Добавляем объекты
|
||||
this.elements.list.show().prepend(sItemsHtml);
|
||||
}
|
||||
|
||||
if (typeof aCallbacks.add_after === 'function') aCallbacks.add_after.call(this, oResponse);
|
||||
}.bind(this));
|
||||
};
|
||||
ls.utils.formUnlock( this.elements.form );
|
||||
this.elements.form_text.focus().val('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Удаление пользователя
|
||||
*/
|
||||
this.remove = function(sType, iTargetId, iUserId, oContainer,fCallbackSuccess) {
|
||||
var sUrl = this.options.type[sType].url.remove,
|
||||
oParams = {
|
||||
iTargetId: iTargetId,
|
||||
iUserId: iUserId
|
||||
};
|
||||
/**
|
||||
* Удаление объекта
|
||||
*/
|
||||
remove: function(iUserId) {
|
||||
if ( ! this.options.urls.remove ) return;
|
||||
|
||||
oParams = $.extend({}, oParams, ls.utilities.getDataOptions(oContainer, 'param'));
|
||||
var _this = this,
|
||||
oParams = {
|
||||
iUserId: iUserId
|
||||
};
|
||||
|
||||
ls.ajax.load(sUrl, oParams, function(oResponse) {
|
||||
if (oResponse.bStateError) {
|
||||
ls.msg.error(null, oResponse.sMsg);
|
||||
} else {
|
||||
oParams = $.extend({}, oParams, this.options.params);
|
||||
|
||||
ls.ajax.load(this.options.urls.remove, oParams, function(oResponse) {
|
||||
ls.msg.notice(null, ls.lang.get('common.success.remove'));
|
||||
|
||||
if (typeof fCallbackSuccess === 'function') fCallbackSuccess.call(this, oResponse, iUserId);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
this._hide( this._getUserById( iUserId ), this.options.hide, function () {
|
||||
$(this).remove();
|
||||
|
||||
return this;
|
||||
}).call(ls.user_list_add || {}, jQuery);
|
||||
// Скрываем список если объектов в нем больше нет
|
||||
if ( ! _this.elements.list.find(_this.options.selectors.item).length ) {
|
||||
_this.elements.list.hide();
|
||||
_this.elements.empty.show();
|
||||
}
|
||||
});
|
||||
|
||||
this._trigger("afterremove", null, { context: this, response: oResponse, oParams: oParams });
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Получает пользователя по ID
|
||||
*
|
||||
* @private
|
||||
* @param {Number} iUserId , ID объекта
|
||||
* @return {jQuery} Объект
|
||||
*/
|
||||
_getUserById: function(iUserId) {
|
||||
return this.elements.list.find(this.options.selectors.item + '[data-user-id=' + iUserId + ']');
|
||||
},
|
||||
|
||||
/**
|
||||
* Получает всех пользователей
|
||||
*/
|
||||
_getUsersAll: function() {
|
||||
return this.elements.list.find(this.options.selectors.item);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
|
@ -5,5 +5,5 @@
|
|||
{extends 'layouts/layout.user.messages.tpl'}
|
||||
|
||||
{block 'layout_content'}
|
||||
{include 'user_list_add.tpl' sUserListType='blacklist' iUserListId=$oUserCurrent->getId() aUserList=$aUsersBlacklist}
|
||||
{include 'user_list_add.tpl' sUserListAddClasses='js-user-list-add-blacklist' iUserListId=$oUserCurrent->getId() aUserList=$aUsersBlacklist}
|
||||
{/block}
|
|
@ -9,11 +9,12 @@
|
|||
{* Участники личного сообщения *}
|
||||
{if $oTalk->getUserId() == $oUserCurrent->getId() or $oUserCurrent->isAdministrator()}
|
||||
{include 'user_list_add.tpl'
|
||||
sUserListType = 'message'
|
||||
iUserListId = $oTalk->getId()
|
||||
sUserListAddClasses = "message-users js-message-users"
|
||||
sUserListAddAttributes = "data-param-i-target-id=\"{$oTalk->getId()}\""
|
||||
aUserList = $oTalk->getTalkUsers()
|
||||
sUserListTitle = $aLang.talk_speaker_title
|
||||
aUserListSmallExcludeRemove = [ $oUserCurrent->getId() ]
|
||||
sUserItemInactiveTitle = $aLang.talk_speaker_not_found}
|
||||
sUserItemInactiveTitle = $aLang.talk_speaker_not_found
|
||||
sUserListSmallItemPath = 'user_list_small_item.message.tpl'}
|
||||
{/if}
|
||||
{/block}
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
{block 'block_content'}
|
||||
{include 'user_list_add.tpl'
|
||||
iUserListId = $oUserCurrent->getId()
|
||||
sUserListType = 'activity'
|
||||
sUserListAddClasses = 'js-user-list-add-activity'
|
||||
aUserList = $aStreamSubscribedUsers
|
||||
sUserListNote = $aLang.stream_settings_note_follow_user}
|
||||
{/block}
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
{block 'block_content'}
|
||||
{include 'user_list_add.tpl'
|
||||
sUserListType = 'blog_invite'
|
||||
iUserListId = $oBlogEdit->getId()
|
||||
sUserListAddClasses = "js-user-list-add-blog-invite"
|
||||
sUserListAddAttributes = "data-param-i-target-id=\"{$oBlogEdit->getId()}\""
|
||||
aUserList = $aBlogUsersInvited
|
||||
sUserListSmallItemPath = 'user_list_small_item.blog_invite.tpl'}
|
||||
{/block}
|
|
@ -23,11 +23,15 @@
|
|||
|
||||
<ul class="profile-actions" id="profile_actions">
|
||||
{include file='actions/ActionProfile/friend_item.tpl' oUserFriend=$oUserProfile->getUserFriend()}
|
||||
|
||||
<li><a href="{router page='talk'}add/?talk_users={$oUserProfile->getLogin()}">{$aLang.user_write_prvmsg}</a></li>
|
||||
|
||||
<li><a href="{router page='talk'}add/?talk_users={$oUserProfile->getLogin()}">{$aLang.user_write_prvmsg}</a></li>
|
||||
<li>
|
||||
<a href="#" class="js-user-follow {if $oUserProfile->isFollow()}active{/if}" data-user-id="{$oUserProfile->getId()}">
|
||||
{if $oUserProfile->isFollow()}{$aLang.profile_user_unfollow}{else}{$aLang.profile_user_follow}{/if}
|
||||
<a href="#" class="js-user-follow {if $oUserProfile->isFollow()}active{/if}" data-user-id="{$oUserProfile->getId()}" data-user-login="{$oUserProfile->getLogin()}">
|
||||
{if $oUserProfile->isFollow()}
|
||||
{$aLang.profile_user_unfollow}
|
||||
{else}
|
||||
{$aLang.profile_user_follow}
|
||||
{/if}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
{block 'block_content'}
|
||||
{include 'user_list_add.tpl'
|
||||
iUserListId = $oUserCurrent->getId()
|
||||
sUserListType = 'userfeed'
|
||||
sUserListAddClasses = 'js-user-list-add-userfeed'
|
||||
aUserList = $aUserfeedSubscribedUsers
|
||||
sUserListAddAttributes = 'data-param-type="users"'
|
||||
sUserListNote = $aLang.userfeed_settings_note_follow_user}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*}
|
||||
|
||||
{* Форма добавления *}
|
||||
<div class="user-list-add js-user-list-add" data-type="{$sUserListType}" data-target-id="{$iUserListId}" {$sUserListAddAttributes}>
|
||||
<div class="user-list-add js-user-list-add {$sUserListAddClasses}" {$sUserListAddAttributes}>
|
||||
{* Заголовок *}
|
||||
{if $sUserListTitle}
|
||||
<h3 class="user-list-add-title">{$sUserListTitle}</h3>
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
{if $aUserList || ! $bUserListDisplay|default:true}
|
||||
<ul class="user-list-small js-user-list-small {$sUserListSmallClasses}" {if ! $bUserListDisplay|default:true}style="display: none"{/if}>
|
||||
{foreach $aUserList as $oUser}
|
||||
{if $oUser->getUser()}{$oUser = $oUser->getUser()}{/if}
|
||||
{if $oUser->getUser()}
|
||||
{$oUserContainer = $oUser}
|
||||
{$oUser = $oUser->getUser()}
|
||||
{/if}
|
||||
|
||||
{if ! $aUserListSmallExclude || ! in_array($oUser->getId(), $aUserListSmallExclude)}
|
||||
{include $sUserListSmallItemPath|default:'user_list_small_item.tpl' bUserListItemShowRemove=! $aUserListSmallExcludeRemove || ! in_array($iUserId, $aUserListSmallExcludeRemove)}
|
||||
|
|
|
@ -7,4 +7,6 @@
|
|||
|
||||
{block 'user_list_small_item_actions'}
|
||||
<li class="icon-repeat js-blog-invite-user-repeat" title="{$aLang.common.remove}" data-user-id="{$iUserId}"></li>
|
||||
|
||||
{$smarty.block.parent}
|
||||
{/block}
|
|
@ -0,0 +1,19 @@
|
|||
{**
|
||||
* Список пользователей с элементами управления / Пользователь
|
||||
* Расширяет основной шаблон с пользователем добавляя кнопку "Повторно отправить приглашение" в блоке "Пригласить пользователей в блог"
|
||||
*}
|
||||
|
||||
{extends 'user_list_small_item.tpl'}
|
||||
|
||||
{block 'user_list_small_item_classes'}
|
||||
{if $oUserContainer && $oUserContainer->getUserActive() != $TALK_USER_ACTIVE}inactive{/if}
|
||||
{/block}
|
||||
|
||||
{block 'user_list_small_item_attributes'}
|
||||
{if $oUserContainer && $oUserContainer->getUserActive() != $TALK_USER_ACTIVE}title="Пользователь не участвует в разговоре"{/if}
|
||||
{/block}
|
||||
|
||||
{block 'user_list_small_item_actions'}
|
||||
<li class="icon-minus js-message-users-user-inactivate" title="{$aLang.common.remove}" data-user-id="{$iUserId}"></li>
|
||||
<li class="icon-plus js-message-users-user-activate" title="{$aLang.common.add}" data-user-id="{$iUserId}" data-user-login="{$oUser->getLogin()}"></li>
|
||||
{/block}
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
{$iUserId = $oUser->getId()}
|
||||
|
||||
<li class="user-list-small-item js-user-list-small-item {$sUserListSmallItemClasses}" data-user-id="{$iUserId}">
|
||||
<li class="user-list-small-item js-user-list-small-item {$sUserListSmallItemClasses} {block 'user_list_small_item_classes'}{/block}" {block 'user_list_small_item_attributes'}{/block} data-user-id="{$iUserId}">
|
||||
{* Чекбокс *}
|
||||
{if $bUserListSmallSelectable}
|
||||
<input type="checkbox" class="js-user-list-small-checkbox" data-user-id="{$iUserId}" data-user-login="{$oUser->getLogin()}" />
|
||||
|
@ -16,10 +16,11 @@
|
|||
{* Действия *}
|
||||
{if $bUserListSmallShowActions}
|
||||
<ul class="user-list-small-item-actions js-user-list-small-actions">
|
||||
{if $bUserListItemShowRemove|default:true}
|
||||
{block 'user_list_small_item_actions'}{/block}
|
||||
<li class="icon-remove js-user-list-add-user-remove" title="{$aLang.common.remove}" data-user-id="{$iUserId}"></li>
|
||||
{/if}
|
||||
{block 'user_list_small_item_actions'}
|
||||
{if $bUserListItemShowRemove|default:true}
|
||||
<li class="icon-remove js-user-list-add-user-remove" title="{$aLang.common.remove}" data-user-id="{$iUserId}"></li>
|
||||
{/if}
|
||||
{/block}
|
||||
</ul>
|
||||
{/if}
|
||||
</li>
|
Loading…
Reference in a new issue