mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-05-19 09:18:18 +03:00
Наброски функционала жалоб
This commit is contained in:
parent
2e61c2944f
commit
1cf0396715
|
@ -63,6 +63,8 @@ class ActionProfile extends Action {
|
|||
$this->AddEvent('ajaxfriendaccept', 'EventAjaxFriendAccept');
|
||||
$this->AddEvent('ajax-note-save', 'EventAjaxNoteSave');
|
||||
$this->AddEvent('ajax-note-remove', 'EventAjaxNoteRemove');
|
||||
$this->AddEvent('ajax-modal-complaint', 'EventAjaxModalComplaint');
|
||||
$this->AddEvent('ajax-complaint-add', 'EventAjaxComplaintAdd');
|
||||
|
||||
$this->AddEventPreg('/^.+$/i','/^(whois)?$/i','EventWhois');
|
||||
|
||||
|
@ -106,6 +108,61 @@ class ActionProfile extends Action {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Показывает модальное окно для жалобы
|
||||
*/
|
||||
protected function EventAjaxModalComplaint() {
|
||||
/**
|
||||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
if (!$this->oUserCurrent) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
|
||||
$oViewer=$this->Viewer_GetLocalViewer();
|
||||
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("modals/modal.complaint_user.tpl"));
|
||||
}
|
||||
/**
|
||||
* Показывает модальное окно для жалобы
|
||||
*/
|
||||
protected function EventAjaxComplaintAdd() {
|
||||
/**
|
||||
* Устанавливаем формат Ajax ответа
|
||||
*/
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
if (!$this->oUserCurrent) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
/**
|
||||
* Создаем жалобу и проводим валидацию
|
||||
*/
|
||||
$oComplaint=Engine::GetEntity('ModuleUser_EntityComplaint');
|
||||
$oComplaint->setTargetUserId(getRequestStr('user_id'));
|
||||
$oComplaint->setUserId($this->oUserCurrent->getId());
|
||||
$oComplaint->setText(getRequestStr('text'));
|
||||
$oComplaint->setType(getRequestStr('type'));
|
||||
$oComplaint->setCaptcha(getRequestStr('captcha'));
|
||||
|
||||
if ($oComplaint->_Validate()) {
|
||||
/**
|
||||
* Экранируем текст и добавляем запись в БД
|
||||
*/
|
||||
$oComplaint->setText(htmlspecialchars($oComplaint->getText()));
|
||||
if ($this->User_AddComplaint($oComplaint)) {
|
||||
/**
|
||||
* Убиваем каптчу
|
||||
*/
|
||||
$this->Message_AddNotice($this->Lang_Get('user_complaint_submit_result'),$this->Lang_Get('attention'));
|
||||
unset($_SESSION['captcha_keystring_complaint_user']);
|
||||
return true;
|
||||
} else {
|
||||
$this->Message_AddError($this->Lang_Get('user_note_save_error'),$this->Lang_Get('error'));
|
||||
}
|
||||
} else {
|
||||
$this->Message_AddError($oComplaint->_getValidateError(),$this->Lang_Get('error'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Чтение активности пользователя (stream)
|
||||
*/
|
||||
|
|
|
@ -1482,6 +1482,17 @@ class ModuleUser extends Module {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public function AddComplaint($oComplaint) {
|
||||
if (!$oComplaint->getDateAdd()) {
|
||||
$oComplaint->setDateAdd(date("Y-m-d H:i:s"));
|
||||
}
|
||||
|
||||
if ($iId=$this->oMapper->AddComplaint($oComplaint)) {
|
||||
$oComplaint->setId($iId);
|
||||
return $oComplaint;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Возвращает список префиксов логинов пользователей (для алфавитного указателя)
|
||||
*
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Сущность жалобы о пользователе
|
||||
*
|
||||
* @package modules.user
|
||||
* @since 1.0
|
||||
*/
|
||||
class ModuleUser_EntityComplaint extends Entity {
|
||||
/**
|
||||
* Определяем правила валидации
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aValidateRules=array(
|
||||
array('target_user_id','target'),
|
||||
array('type','type'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*/
|
||||
public function Init() {
|
||||
parent::Init();
|
||||
$this->aValidateRules[]=array('text','string','max'=>Config::Get('module.user.complaint_text_max'),'min'=>1,'allowEmpty'=>!Config::Get('module.user.complaint_text_required'),'label'=>$this->Lang_Get('user_complaint_text_title'));
|
||||
if (Config::Get('module.user.complaint_captcha')){
|
||||
$this->aValidateRules[] = array('captcha','captcha','name'=>'complaint_user');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Валидация пользователя
|
||||
*
|
||||
* @param string $sValue Значение
|
||||
* @param array $aParams Параметры
|
||||
* @return bool
|
||||
*/
|
||||
public function ValidateTarget($sValue,$aParams) {
|
||||
if ($oUserTarget=$this->User_GetUserById($sValue) and $this->getUserId()!=$oUserTarget->getId()) {
|
||||
return true;
|
||||
}
|
||||
return $this->Lang_Get('user_complaint_target_error');
|
||||
}
|
||||
/**
|
||||
* Валидация типа жалобы
|
||||
*
|
||||
* @param string $sValue Значение
|
||||
* @param array $aParams Параметры
|
||||
* @return bool
|
||||
*/
|
||||
public function ValidateType($sValue,$aParams) {
|
||||
$aTypes=(array)Config::Get('module.user.complaint_type');
|
||||
if (in_array($sValue,$aTypes)) {
|
||||
return true;
|
||||
}
|
||||
return $this->Lang_Get('user_complaint_type_error');
|
||||
}
|
||||
|
||||
}
|
|
@ -1096,6 +1096,20 @@ class ModuleUser_MapperUser extends Mapper {
|
|||
$oNote->getId());
|
||||
return $res===false or is_null($res) ? false : true;
|
||||
}
|
||||
/**
|
||||
* Добавляет жалобу
|
||||
*
|
||||
* @param ModuleUser_EntityComplaint $oComplaint
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public function AddComplaint($oComplaint) {
|
||||
$sql = "INSERT INTO ".Config::Get('db.table.user_complaint')." SET ?a ";
|
||||
if ($iId=$this->oDb->query($sql,$oComplaint->_getData(array('type','target_user_id','user_id','text','date_add')))) {
|
||||
return $iId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Добавляет запись о смене емайла
|
||||
*
|
||||
|
|
|
@ -395,6 +395,11 @@ ls.user = (function ($) {
|
|||
return false;
|
||||
};
|
||||
|
||||
this.addComplaint = function(form) {
|
||||
ls.ajax.submit(aRouter.profile+'ajax-complaint-add/', form, function(result){
|
||||
$('#modal-complaint-user').modal('hide');
|
||||
});
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.user || {},jQuery);
|
||||
|
|
|
@ -582,6 +582,20 @@ return array(
|
|||
'user_note_save_error' => 'Error saving note',
|
||||
'user_note_target_error' => 'Bad user for note',
|
||||
'user_note_list_empty' => 'Nothing here',
|
||||
/**
|
||||
* User complaint
|
||||
*/
|
||||
'user_complaint_title' => 'Complain',
|
||||
'user_complaint_type_title' => 'Reason',
|
||||
'user_complaint_text_title' => 'Description of complaint',
|
||||
'user_complaint_target_error' => 'Wrong user to complain',
|
||||
'user_complaint_type_error' => 'Wrong type of complaint',
|
||||
'user_complaint_submit_result' => 'Your complaint is sent to the Administration',
|
||||
'user_complaint_type_list' => array(
|
||||
'spam'=>'Spam',
|
||||
'obscene'=>'Obscene',
|
||||
'other'=>'Other',
|
||||
),
|
||||
/**
|
||||
* Wall
|
||||
*/
|
||||
|
|
|
@ -584,6 +584,20 @@ return array(
|
|||
'user_note_save_error' => 'Ошибка сохранения заметки',
|
||||
'user_note_target_error' => 'Неверный пользователь для заметки',
|
||||
'user_note_list_empty' => 'Тут ничего нет',
|
||||
/**
|
||||
* Жалобы на пользователя
|
||||
*/
|
||||
'user_complaint_title' => 'Пожаловаться',
|
||||
'user_complaint_type_title' => 'Причина',
|
||||
'user_complaint_text_title' => 'Текст жалобы',
|
||||
'user_complaint_target_error' => 'Неверный пользователь для жалобы',
|
||||
'user_complaint_type_error' => 'Неверный тип жалобы',
|
||||
'user_complaint_submit_result' => 'Ваша жалоба отправлена администрации',
|
||||
'user_complaint_type_list' => array(
|
||||
'spam'=>'Спам',
|
||||
'obscene'=>'Непристойное поведение',
|
||||
'other'=>'Другое',
|
||||
),
|
||||
/**
|
||||
* Стена
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
<a href="#" onclick="ls.user.followToggle(this, {$oUserProfile->getId()}); return false;" class="{if $oUserProfile->isFollow()}followed{/if}">
|
||||
{if $oUserProfile->isFollow()}{$aLang.profile_user_unfollow}{else}{$aLang.profile_user_follow}{/if}
|
||||
</a>
|
||||
</li>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-type="modal-toggle" data-modal-url="{router page='profile/ajax-modal-complaint'}" data-param-user_id="{$oUserProfile->getId()}">{$aLang.user_complaint_title}</a>
|
||||
</li>
|
||||
</ul>
|
||||
{/block}
|
|
@ -0,0 +1,48 @@
|
|||
{**
|
||||
* Жалоба на пользователя
|
||||
*
|
||||
* @styles css/modals.css
|
||||
*}
|
||||
|
||||
{extends file='modals/modal_base.tpl'}
|
||||
|
||||
{block name='modal_id'}modal-complaint-user{/block}
|
||||
{block name='modal_class'}modal-complaint-user js-modal-default{/block}
|
||||
{block name='modal_title'}{$aLang.user_complaint_title}{/block}
|
||||
|
||||
{block name='modal_content'}
|
||||
<form action="" method="post" onsubmit="return false;" id="form-complaint-user">
|
||||
{foreach Config::Get('module.user.complaint_type') as $sType}
|
||||
{$aTypes[] = [
|
||||
'value' => $sType,
|
||||
'text' => $aLang.user_complaint_type_list.{$sType}
|
||||
]}
|
||||
{/foreach}
|
||||
|
||||
{include file='forms/fields/form.field.select.tpl'
|
||||
sFieldName = 'type'
|
||||
sFieldLabel = $aLang.user_complaint_type_title
|
||||
sFieldClasses = 'width-full'
|
||||
aFieldItems = $aTypes }
|
||||
|
||||
{include file='forms/fields/form.field.textarea.tpl'
|
||||
sFieldName = 'text'
|
||||
iFieldRows = 5
|
||||
sFieldLabel = $aLang.user_complaint_text_title
|
||||
sFieldClasses = 'width-full'}
|
||||
|
||||
{* Каптча *}
|
||||
{if Config::Get('module.user.complaint_captcha')}
|
||||
{include file='forms/fields/form.field.captcha_new.tpl'
|
||||
sCaptchaName = 'complaint_user'
|
||||
sFieldName = 'captcha'
|
||||
sFieldLabel = $aLang.registration_captcha}
|
||||
{/if}
|
||||
|
||||
{include file='forms/fields/form.field.hidden.tpl' sFieldName='user_id' sFieldValue=$_aRequest.user_id}
|
||||
</form>
|
||||
{/block}
|
||||
|
||||
{block name='modal_footer_begin'}
|
||||
<button type="submit" class="button button-primary" onclick="ls.user.addComplaint('#form-complaint-user');">{$aLang.user_complaint_title}</button>
|
||||
{/block}
|
|
@ -226,7 +226,7 @@ ADD INDEX ( `sort` ) ;
|
|||
-- 12.01.2014
|
||||
ALTER TABLE `prefix_property` ADD `description` VARCHAR( 500 ) NOT NULL AFTER `title` ;
|
||||
|
||||
--23.01.2014
|
||||
-- 23.01.2014
|
||||
--
|
||||
-- Структура таблицы `prefix_property_target`
|
||||
--
|
||||
|
@ -244,3 +244,33 @@ CREATE TABLE IF NOT EXISTS `prefix_property_target` (
|
|||
KEY `date_update` (`date_update`),
|
||||
KEY `state` (`state`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
-- 25.01.2014
|
||||
--
|
||||
-- Структура таблицы `prefix_user_complaint`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `prefix_user_complaint` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`target_user_id` int(11) unsigned NOT NULL,
|
||||
`user_id` int(11) unsigned NOT NULL,
|
||||
`type` varchar(50) NOT NULL,
|
||||
`text` text NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
KEY `target_user_id` (`target_user_id`),
|
||||
KEY `type` (`type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Ограничения внешнего ключа сохраненных таблиц
|
||||
--
|
||||
|
||||
--
|
||||
-- Ограничения внешнего ключа таблицы `prefix_user_complaint`
|
||||
--
|
||||
ALTER TABLE `prefix_user_complaint`
|
||||
ADD CONSTRAINT `prefix_user_complaint_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `prefix_user_complaint_ibfk_1` FOREIGN KEY (`target_user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
Loading…
Reference in a new issue