1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 11:40:48 +03:00

fix контактов пользователей

This commit is contained in:
Mzhelskiy Maxim 2012-04-24 15:01:13 +04:00
parent b4501c3146
commit a66b1d642d
7 changed files with 54 additions and 6 deletions

View file

@ -433,6 +433,12 @@ class ActionSettings extends Action {
$this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_profile'));
$this->Viewer_Assign('aUserFields',$this->User_getUserFields(''));
$this->Viewer_Assign('aUserFieldsContact',$this->User_getUserFields(array('contact','social')));
/**
* Загружаем в шаблон JS текстовки
*/
$this->Lang_AddLangJs(array(
'settings_profile_field_error_max'
));
/**
* Если нажали кнопку "Сохранить"
*/
@ -549,7 +555,7 @@ class ActionSettings extends Action {
if (is_array($aFieldsContactType)) {
foreach($aFieldsContactType as $k=>$v) {
if (isset($aFields[$v]) and isset($aFieldsContactValue[$k])) {
$this->User_setUserFieldsValues($this->oUserCurrent->getId(), array($v=>$aFieldsContactValue[$k]), 2);
$this->User_setUserFieldsValues($this->oUserCurrent->getId(), array($v=>$aFieldsContactValue[$k]), Config::Get('module.user.userfield_max_identical'));
}
}
}

View file

@ -190,6 +190,7 @@ $config['module']['user']['login']['max_size'] = 30; // Максимальное
$config['module']['user']['time_active'] = 60*60*24*7; // Число секунд с момента последнего посещения пользователем сайта, в течение которых он считается активным
$config['module']['user']['usernote_text_max'] = 250; // Максимальный размер заметки о пользователе
$config['module']['user']['usernote_per_page'] = 20; // Число заметок на одну страницу
$config['module']['user']['userfield_max_identical'] = 2; // Максимальное число контактов одного типа
// Модуль Comment
$config['module']['comment']['per_page'] = 20; // Число комментариев на одну страницу(это касается только полного списка комментариев прямого эфира)
$config['module']['comment']['bad'] = -5; // Рейтинг комментария, начиная с которого он будет скрыт

View file

@ -1,6 +1,9 @@
var ls = ls || {};
ls.userfield =( function ($) {
this.iCountMax = 2;
this.showAddForm = function(){
$('#user_fields_form_name').val('');
$('#user_fields_form_title').val('');
@ -107,10 +110,44 @@ ls.userfield =( function ($) {
};
this.addFormField = function() {
$('#user-field-contact-contener').append($('#profile_user_field_template').clone().show());
var tpl=$('#profile_user_field_template').clone();
/**
* Находим доступный тип контакта
*/
var value;
tpl.find('select').find('option').each(function(k,v){
if (this.getCountFormField($(v).val())<this.iCountMax) {
value=$(v).val();
return false;
}
}.bind(this));
if (value) {
tpl.find('select').val(value);
$('#user-field-contact-contener').append(tpl.show());
} else {
ls.msg.error('',ls.lang.get('settings_profile_field_error_max',{count: this.iCountMax}));
}
return false;
};
this.changeFormField = function(obj) {
var iCount=this.getCountFormField($(obj).val());
if (iCount>this.iCountMax) {
ls.msg.error('',ls.lang.get('settings_profile_field_error_max',{count: this.iCountMax}));
}
};
this.getCountFormField = function(value) {
var iCount=0;
$('#user-field-contact-contener').find('select').each(function(k,v){
if (value==$(v).val()) {
iCount++;
}
});
return iCount;
};
this.removeFormField = function(obj) {
$(obj).parent('.js-user-field-item').detach();
return false;

View file

@ -637,6 +637,7 @@ return array(
'settings_profile_foto_delete' => 'delete',
'settings_profile_photo_change' => 'Channge photo',
'settings_profile_photo_upload' => 'Upload photo',
'settings_profile_field_error_max' => 'You can not add more than %%count%% identical contacts',
'settings_profile_submit' => 'save profile',
'settings_profile_submit_ok' => 'Profile successfully saved',
'settings_invite' => 'Invitations management',

View file

@ -637,6 +637,7 @@ return array(
'settings_profile_foto_delete' => 'Удалить',
'settings_profile_photo_change' => 'Изменить фотографию',
'settings_profile_photo_upload' => 'Загрузить фотографию',
'settings_profile_field_error_max' => 'Нельзя добавить больше %%count%% одинаковых контактов',
'settings_profile_submit' => 'Сохранить',
'settings_profile_submit_ok' => 'Профиль успешно сохранён',
'settings_invite' => 'Управление приглашениями',

View file

@ -13,12 +13,13 @@
jQuery(document).ready(function($){
ls.lang.load({lang_load name="geo_select_city,geo_select_region"});
ls.geo.initSelect();
ls.userfield.iCountMax='{cfg name="module.user.userfield_max_identical"}';
});
</script>
<p id="profile_user_field_template" style="display:none;" class="js-user-field-item">
<select name="profile_user_field_type[]">
<select name="profile_user_field_type[]" onchange="ls.userfield.changeFormField(this);">
{foreach from=$aUserFieldsContact item=oFieldAll}
<option value="{$oFieldAll->getId()}">{$oFieldAll->getTitle()|escape:'html'}</option>
{/foreach}
@ -146,7 +147,7 @@
<div id="user-field-contact-contener">
{foreach from=$aUserFieldContactValues item=oField}
<p class="js-user-field-item">
<select name="profile_user_field_type[]">
<select name="profile_user_field_type[]" onchange="ls.userfield.changeFormField(this);">
{foreach from=$aUserFieldsContact item=oFieldAll}
<option value="{$oFieldAll->getId()}" {if $oFieldAll->getId()==$oField->getId()}selected="selected"{/if}>{$oFieldAll->getTitle()|escape:'html'}</option>
{/foreach}

View file

@ -13,12 +13,13 @@
jQuery(document).ready(function($){
ls.lang.load({lang_load name="geo_select_city,geo_select_region"});
ls.geo.initSelect();
ls.userfield.iCountMax='{cfg name="module.user.userfield_max_identical"}';
});
</script>
<p id="profile_user_field_template" style="display:none;" class="js-user-field-item">
<select name="profile_user_field_type[]">
<select name="profile_user_field_type[]" onchange="ls.userfield.changeFormField(this);">
{foreach from=$aUserFieldsContact item=oFieldAll}
<option value="{$oFieldAll->getId()}">{$oFieldAll->getTitle()|escape:'html'}</option>
{/foreach}
@ -146,7 +147,7 @@
<div id="user-field-contact-contener">
{foreach from=$aUserFieldContactValues item=oField}
<p class="js-user-field-item">
<select name="profile_user_field_type[]">
<select name="profile_user_field_type[]" onchange="ls.userfield.changeFormField(this);">
{foreach from=$aUserFieldsContact item=oFieldAll}
<option value="{$oFieldAll->getId()}" {if $oFieldAll->getId()==$oField->getId()}selected="selected"{/if}>{$oFieldAll->getTitle()|escape:'html'}</option>
{/foreach}