From dc111bd39e819e618bf02d23c4182dc37f3b891f Mon Sep 17 00:00:00 2001 From: Denis Shakhov Date: Wed, 12 Nov 2014 20:36:53 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../classes/actions/ActionProfile.class.php | 15 +++- application/frontend/i18n/ru.php | 16 ++-- .../developer/components/report/js/report.js | 74 +++++++++++++++++++ .../components/report/modal.report.tpl | 21 ++---- .../developer/components/user/actions.tpl | 4 +- 5 files changed, 107 insertions(+), 23 deletions(-) create mode 100644 application/frontend/skin/developer/components/report/js/report.js diff --git a/application/classes/actions/ActionProfile.class.php b/application/classes/actions/ActionProfile.class.php index bfa5a190..ea1e60fc 100644 --- a/application/classes/actions/ActionProfile.class.php +++ b/application/classes/actions/ActionProfile.class.php @@ -134,7 +134,20 @@ class ActionProfile extends Action return parent::EventNotFound(); } + /** + * Получаем список типов жалоб + */ + $types = array(); + + foreach ( Config::Get('module.user.complaint_type') as $type ) { + $types[] = array( + 'value' => $type, + 'text' => $this->Lang_Get( 'user.report.types.' . $type ) + ); + } + $oViewer = $this->Viewer_GetLocalViewer(); + $oViewer->Assign('types', $types, true); $this->Viewer_AssignAjax('sText', $oViewer->Fetch("components/report/modal.report.tpl")); } @@ -154,7 +167,7 @@ class ActionProfile extends Action * Создаем жалобу и проводим валидацию */ $oComplaint = Engine::GetEntity('ModuleUser_EntityComplaint'); - $oComplaint->setTargetUserId(getRequestStr('user_id')); + $oComplaint->setTargetUserId(getRequestStr('target_id')); $oComplaint->setUserId($this->oUserCurrent->getId()); $oComplaint->setText(getRequestStr('text')); $oComplaint->setType(getRequestStr('type')); diff --git a/application/frontend/i18n/ru.php b/application/frontend/i18n/ru.php index 946bf2f5..5fa9c2da 100644 --- a/application/frontend/i18n/ru.php +++ b/application/frontend/i18n/ru.php @@ -1151,6 +1151,14 @@ return array( 'was_online_male' => 'Заходил %%date%%', 'was_online_female' => 'Заходила %%date%%' ), + // Жалоба + 'report' => array( + 'types' => array( + 'spam' => 'Спам', + 'obscene' => 'Непристойное поведение', + 'other' => 'Другое' + ) + ), // Друзья 'friends' => array( 'title' => 'Друзья', @@ -1542,14 +1550,8 @@ return array( ), 'submit' => '___common.send___' ), - // TODO: Move to 'user' - 'type_list' => array( - 'spam' => 'Спам', - 'obscene' => 'Непристойное поведение', - 'other' => 'Другое', - ), 'notices' => array( - 'target_error' => 'Неверный пользователь для жалобы', // TODO: Move to 'user' + 'target_error' => 'Неверный id объекта', // TODO: Remove? 'error_type' => 'Неверный тип жалобы', // TODO: Remove? 'success' => 'Ваша жалоба отправлена администрации', ) diff --git a/application/frontend/skin/developer/components/report/js/report.js b/application/frontend/skin/developer/components/report/js/report.js new file mode 100644 index 00000000..5aa42ea0 --- /dev/null +++ b/application/frontend/skin/developer/components/report/js/report.js @@ -0,0 +1,74 @@ +/** + * Report + * + * @module ls/report + * + * @license GNU General Public License, version 2 + * @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com} + * @author Denis Shakhov + */ + +(function($) { + "use strict"; + + $.widget( "livestreet.lsReport", { + /** + * Дефолтные опции + */ + options: { + params: {}, + + // Ссылки + urls: { + modal: null, + add: null, + }, + + // Селекторы + selectors: { + form: 'form' + } + }, + + /** + * Конструктор + * + * @constructor + * @private + */ + _create: function () { + this.option( 'params', $.extend( {}, this.option( 'params' ), ls.utils.getDataOptions( this.element, 'param' ) ) ); + + this._on({ click: this.showModal }); + }, + + /** + * Показывает модальное окно с формой + */ + showModal: function( event ) { + var _this = this, form; + + ls.modal.load( this.option( 'urls.modal' ), this.option( 'params' ), { + aftershow: function ( e, modal ) { + form = modal.element.find( _this.option( 'selectors.form' ) ); + + // Отправка формы + form.on( 'submit', function ( event ) { + ls.ajax.submit( _this.option( 'urls.add' ), form, function( response ) { + modal.hide(); + }); + + event.preventDefault(); + }); + }, + afterhide: function () { + form.off(); + form = null; + }, + center: false + }); + + event.preventDefault(); + } + }); +})(jQuery); \ No newline at end of file diff --git a/application/frontend/skin/developer/components/report/modal.report.tpl b/application/frontend/skin/developer/components/report/modal.report.tpl index da428dc8..dbeba27f 100644 --- a/application/frontend/skin/developer/components/report/modal.report.tpl +++ b/application/frontend/skin/developer/components/report/modal.report.tpl @@ -1,34 +1,27 @@ {** * Жалоба на пользователя * - * TODO: Универсализировать + * @param array $types *} {extends 'components/modal/modal.tpl'} {block 'modal_id'}modal-complaint-user{/block} {block 'modal_class'}modal-complaint-user js-modal-default{/block} -{block 'modal_title'}{lang name='report.form.title'}{/block} +{block 'modal_title'}{lang 'report.form.title'}{/block} {block 'modal_content'} -
- {foreach Config::Get('module.user.complaint_type') as $type} - {$aTypes[] = [ - 'value' => $type, - 'text' => $aLang.report.type_list.{$type} - ]} - {/foreach} - + {include 'components/field/field.select.tpl' name = 'type' - label = {lang name='report.form.fields.type.label'} + label = {lang 'report.form.fields.type.label'} classes = 'width-full' - items = $aTypes} + items = $smarty.local.types} {include 'components/field/field.textarea.tpl' name = 'text' rows = 5 - label = {lang name='report.form.fields.text.label'} + label = {lang 'report.form.fields.text.label'} classes = 'width-full'} {* Каптча *} @@ -38,7 +31,7 @@ name = 'captcha'} {/if} - {include 'components/field/field.hidden.tpl' name='user_id' value=$_aRequest.user_id} + {include 'components/field/field.hidden.tpl' name='target_id' value=$_aRequest.target_id}
{/block} diff --git a/application/frontend/skin/developer/components/user/actions.tpl b/application/frontend/skin/developer/components/user/actions.tpl index 92d54abe..80dab9bf 100644 --- a/application/frontend/skin/developer/components/user/actions.tpl +++ b/application/frontend/skin/developer/components/user/actions.tpl @@ -25,6 +25,8 @@ {* Пожаловаться *}
  • - {lang 'user.actions.report'} + + {lang 'user.actions.report'} +
  • \ No newline at end of file