2009-05-10 10:50:39 +03:00
|
|
|
|
<?php
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/*-------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*
|
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Экшен обрабтки настроек профиля юзера (/settings/)
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @package actions
|
|
|
|
|
* @since 1.0
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
|
|
|
|
class ActionSettings extends Action {
|
2008-10-14 21:36:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Какое меню активно
|
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @var string
|
2008-10-14 21:36:36 +03:00
|
|
|
|
*/
|
|
|
|
|
protected $sMenuItemSelect='settings';
|
|
|
|
|
/**
|
|
|
|
|
* Какое подменю активно
|
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @var string
|
2008-10-14 21:36:36 +03:00
|
|
|
|
*/
|
|
|
|
|
protected $sMenuSubItemSelect='profile';
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Текущий юзер
|
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @var ModuleUser_EntityUser|null
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
|
|
|
|
protected $oUserCurrent=null;
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2011-06-22 12:11:05 +03:00
|
|
|
|
* Инициализация
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
2010-02-06 11:04:36 +02:00
|
|
|
|
public function Init() {
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Проверяем авторизован ли юзер
|
|
|
|
|
*/
|
|
|
|
|
if (!$this->User_IsAuthorization()) {
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('not_access'),$this->Lang_Get('error'));
|
2011-06-22 12:11:05 +03:00
|
|
|
|
return Router::Action('error');
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем текущего юзера
|
|
|
|
|
*/
|
|
|
|
|
$this->oUserCurrent=$this->User_GetUserCurrent();
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->SetDefaultEvent('profile');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем title страницы
|
|
|
|
|
*/
|
2010-02-06 02:09:44 +02:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Регистрация евентов
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
protected function RegisterEvent() {
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^upload-avatar/i','/^$/i','EventUploadAvatar');
|
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^resize-avatar/i','/^$/i','EventResizeAvatar');
|
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^remove-avatar/i','/^$/i','EventRemoveAvatar');
|
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^cancel-avatar/i','/^$/i','EventCancelAvatar');
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^upload-foto/i','/^$/i','EventUploadFoto');
|
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^resize-foto/i','/^$/i','EventResizeFoto');
|
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^remove-foto/i','/^$/i','EventRemoveFoto');
|
|
|
|
|
$this->AddEventPreg('/^profile$/i','/^cancel-foto/i','/^$/i','EventCancelFoto');
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->AddEvent('profile','EventProfile');
|
|
|
|
|
$this->AddEvent('invite','EventInvite');
|
|
|
|
|
$this->AddEvent('tuning','EventTuning');
|
2012-04-04 17:51:58 +03:00
|
|
|
|
$this->AddEvent('account','EventAccount');
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
|
|
|
|
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**********************************************************************************
|
|
|
|
|
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
|
|
|
|
|
**********************************************************************************
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2012-03-17 16:53:37 +02:00
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Загрузка временной картинки фото для последущего ресайза
|
2012-03-17 16:53:37 +02:00
|
|
|
|
*/
|
|
|
|
|
protected function EventUploadFoto() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-04-12 16:23:36 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('jsonIframe',false);
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
|
|
|
|
if(!isset($_FILES['foto']['tmp_name'])) {
|
2014-01-28 09:47:36 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Копируем загруженный файл
|
|
|
|
|
*/
|
|
|
|
|
$sFileTmp=Config::Get('sys.cache.dir').func_generator();
|
|
|
|
|
if (!move_uploaded_file($_FILES['foto']['tmp_name'],$sFileTmp)) {
|
2014-01-28 09:47:36 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Ресайзим и сохраняем именьшенную копию
|
|
|
|
|
* Храним две копии - мелкую для показа пользователю и крупную в качестве исходной для ресайза
|
|
|
|
|
*/
|
|
|
|
|
$sDir=Config::Get('path.uploads.images')."/tmp/fotos/{$this->oUserCurrent->getId()}";
|
|
|
|
|
if ($sFile=$this->Image_Resize($sFileTmp,$sDir,'original',Config::Get('view.img_max_width'),Config::Get('view.img_max_height'),1000,null,true)) {
|
|
|
|
|
if ($sFilePreview=$this->Image_Resize($sFileTmp,$sDir,'preview',Config::Get('view.img_max_width'),Config::Get('view.img_max_height'),200,null,true)) {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Сохраняем в сессии временный файл с изображением
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->Session_Set('sFotoFileTmp',$sFile);
|
|
|
|
|
$this->Session_Set('sFotoFilePreviewTmp',$sFilePreview);
|
|
|
|
|
$this->Viewer_AssignAjax('sTmpFile',$this->Image_GetWebPath($sFilePreview));
|
2012-04-08 17:37:43 +03:00
|
|
|
|
unlink($sFileTmp);
|
2012-03-17 16:53:37 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->Message_AddError($this->Image_GetLastError(),$this->Lang_Get('error'));
|
2012-04-08 17:37:43 +03:00
|
|
|
|
unlink($sFileTmp);
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Вырезает из временной фотки область нужного размера, ту что задал пользователь
|
|
|
|
|
*/
|
|
|
|
|
protected function EventResizeFoto() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Достаем из сессии временный файл
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$sFile=$this->Session_Get('sFotoFileTmp');
|
|
|
|
|
$sFilePreview=$this->Session_Get('sFotoFilePreviewTmp');
|
|
|
|
|
if (!file_exists($sFile)) {
|
2014-01-28 09:47:36 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Определяем размер большого фото для подсчета множителя пропорции
|
|
|
|
|
*/
|
|
|
|
|
$fRation=1;
|
|
|
|
|
if ($aSizeFile=getimagesize($sFile) and isset($aSizeFile[0])) {
|
|
|
|
|
$fRation=$aSizeFile[0]/200; // 200 - размер превью по которой пользователь определяет область для ресайза
|
|
|
|
|
if ($fRation<1) {
|
|
|
|
|
$fRation=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем размер области из параметров
|
|
|
|
|
*/
|
|
|
|
|
$aSize=array();
|
|
|
|
|
$aSizeTmp=getRequest('size');
|
2012-07-08 11:50:36 +03:00
|
|
|
|
if (isset($aSizeTmp['x']) and is_numeric($aSizeTmp['x'])
|
|
|
|
|
and isset($aSizeTmp['y']) and is_numeric($aSizeTmp['y'])
|
|
|
|
|
and isset($aSizeTmp['x2']) and is_numeric($aSizeTmp['x2'])
|
|
|
|
|
and isset($aSizeTmp['y2']) and is_numeric($aSizeTmp['y2'])) {
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$aSize=array('x1'=>round($fRation*$aSizeTmp['x']),'y1'=>round($fRation*$aSizeTmp['y']),'x2'=>round($fRation*$aSizeTmp['x2']),'y2'=>round($fRation*$aSizeTmp['y2']));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Вырезаем аватарку
|
|
|
|
|
*/
|
|
|
|
|
if ($sFileWeb=$this->User_UploadFoto($sFile,$this->oUserCurrent,$aSize)) {
|
|
|
|
|
/**
|
|
|
|
|
* Удаляем старые аватарки
|
|
|
|
|
*/
|
|
|
|
|
$this->oUserCurrent->setProfileFoto($sFileWeb);
|
|
|
|
|
$this->User_Update($this->oUserCurrent);
|
|
|
|
|
|
2012-04-08 17:37:43 +03:00
|
|
|
|
$this->Image_RemoveFile($sFilePreview);
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаляем из сессии
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->Session_Drop('sFotoFileTmp');
|
|
|
|
|
$this->Session_Drop('sFotoFilePreviewTmp');
|
|
|
|
|
$this->Viewer_AssignAjax('sFile',$this->oUserCurrent->getProfileFoto());
|
2012-04-14 12:13:17 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sTitleUpload',$this->Lang_Get('settings_profile_photo_change'));
|
2012-03-17 16:53:37 +02:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_avatar_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Удаляет фото
|
|
|
|
|
*/
|
|
|
|
|
protected function EventRemoveFoto() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаляем
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->User_DeleteFoto($this->oUserCurrent);
|
|
|
|
|
$this->oUserCurrent->setProfileFoto(null);
|
|
|
|
|
$this->User_Update($this->oUserCurrent);
|
|
|
|
|
/**
|
|
|
|
|
* Возвращает дефолтную аватарку
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_AssignAjax('sFile',$this->oUserCurrent->getProfileFotoDefault());
|
2012-04-14 12:13:17 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sTitleUpload',$this->Lang_Get('settings_profile_photo_upload'));
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Отмена ресайза фотки, необходимо удалить временный файл
|
|
|
|
|
*/
|
|
|
|
|
protected function EventCancelFoto() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
/**
|
|
|
|
|
* Достаем из сессии файл и удаляем
|
|
|
|
|
*/
|
|
|
|
|
$sFile=$this->Session_Get('sFotoFileTmp');
|
2012-04-08 17:37:43 +03:00
|
|
|
|
$this->Image_RemoveFile($sFile);
|
|
|
|
|
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$sFile=$this->Session_Get('sFotoFilePreviewTmp');
|
2012-04-08 17:37:43 +03:00
|
|
|
|
$this->Image_RemoveFile($sFile);
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаляем из сессии
|
|
|
|
|
*/
|
2012-03-17 16:53:37 +02:00
|
|
|
|
$this->Session_Drop('sFotoFileTmp');
|
|
|
|
|
$this->Session_Drop('sFotoFilePreviewTmp');
|
|
|
|
|
}
|
2012-03-17 13:48:29 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загрузка временной картинки для аватара
|
|
|
|
|
*/
|
|
|
|
|
protected function EventUploadAvatar() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-04-12 16:23:36 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('jsonIframe',false);
|
2012-03-17 13:48:29 +02:00
|
|
|
|
|
|
|
|
|
if(!isset($_FILES['avatar']['tmp_name'])) {
|
2014-01-28 09:47:36 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Копируем загруженный файл
|
|
|
|
|
*/
|
|
|
|
|
$sFileTmp=Config::Get('sys.cache.dir').func_generator();
|
|
|
|
|
if (!move_uploaded_file($_FILES['avatar']['tmp_name'],$sFileTmp)) {
|
2014-01-28 09:47:36 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Ресайзим и сохраняем уменьшенную копию
|
2012-03-17 13:48:29 +02:00
|
|
|
|
*/
|
|
|
|
|
$sDir=Config::Get('path.uploads.images')."/tmp/avatars/{$this->oUserCurrent->getId()}";
|
|
|
|
|
if ($sFileAvatar=$this->Image_Resize($sFileTmp,$sDir,'original',Config::Get('view.img_max_width'),Config::Get('view.img_max_height'),200,null,true)) {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Зписываем в сессию
|
|
|
|
|
*/
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Session_Set('sAvatarFileTmp',$sFileAvatar);
|
|
|
|
|
$this->Viewer_AssignAjax('sTmpFile',$this->Image_GetWebPath($sFileAvatar));
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Image_GetLastError(),$this->Lang_Get('error'));
|
|
|
|
|
}
|
2012-04-08 17:37:43 +03:00
|
|
|
|
unlink($sFileTmp);
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Вырезает из временной аватарки область нужного размера, ту что задал пользователь
|
|
|
|
|
*/
|
|
|
|
|
protected function EventResizeAvatar() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем файл из сессии
|
|
|
|
|
*/
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$sFileAvatar=$this->Session_Get('sAvatarFileTmp');
|
|
|
|
|
if (!file_exists($sFileAvatar)) {
|
2014-01-28 09:47:36 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем размер области из параметров
|
|
|
|
|
*/
|
|
|
|
|
$aSize=array();
|
|
|
|
|
$aSizeTmp=getRequest('size');
|
2012-07-08 11:50:36 +03:00
|
|
|
|
if (isset($aSizeTmp['x']) and is_numeric($aSizeTmp['x'])
|
|
|
|
|
and isset($aSizeTmp['y']) and is_numeric($aSizeTmp['y'])
|
|
|
|
|
and isset($aSizeTmp['x2']) and is_numeric($aSizeTmp['x2'])
|
|
|
|
|
and isset($aSizeTmp['y2']) and is_numeric($aSizeTmp['y2'])) {
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$aSize=array('x1'=>$aSizeTmp['x'],'y1'=>$aSizeTmp['y'],'x2'=>$aSizeTmp['x2'],'y2'=>$aSizeTmp['y2']);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Вырезаем аватарку
|
|
|
|
|
*/
|
|
|
|
|
if ($sFileWeb=$this->User_UploadAvatar($sFileAvatar,$this->oUserCurrent,$aSize)) {
|
|
|
|
|
/**
|
|
|
|
|
* Удаляем старые аватарки
|
|
|
|
|
*/
|
|
|
|
|
if ($sFileWeb!=$this->oUserCurrent->getProfileAvatar()) {
|
|
|
|
|
$this->User_DeleteAvatar($this->oUserCurrent);
|
|
|
|
|
}
|
|
|
|
|
$this->oUserCurrent->setProfileAvatar($sFileWeb);
|
|
|
|
|
|
|
|
|
|
$this->User_Update($this->oUserCurrent);
|
|
|
|
|
$this->Session_Drop('sAvatarFileTmp');
|
2012-04-12 05:13:31 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sFile',$this->oUserCurrent->getProfileAvatarPath(100));
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sTitleUpload',$this->Lang_Get('settings_profile_avatar_change'));
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_avatar_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Удаляет аватар
|
|
|
|
|
*/
|
|
|
|
|
protected function EventRemoveAvatar() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаляем
|
|
|
|
|
*/
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->User_DeleteAvatar($this->oUserCurrent);
|
|
|
|
|
$this->oUserCurrent->setProfileAvatar(null);
|
|
|
|
|
$this->User_Update($this->oUserCurrent);
|
|
|
|
|
/**
|
|
|
|
|
* Возвращает дефолтную аватарку
|
|
|
|
|
*/
|
2012-04-12 05:13:31 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sFile',$this->oUserCurrent->getProfileAvatarPath(100));
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sTitleUpload',$this->Lang_Get('settings_profile_avatar_upload'));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Отмена ресайза аватарки, необходимо удалить временный файл
|
|
|
|
|
*/
|
|
|
|
|
protected function EventCancelAvatar() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
/**
|
|
|
|
|
* Достаем из сессии файл и удаляем
|
|
|
|
|
*/
|
|
|
|
|
$sFileAvatar=$this->Session_Get('sAvatarFileTmp');
|
2012-04-08 17:37:43 +03:00
|
|
|
|
$this->Image_RemoveFile($sFileAvatar);
|
2012-03-17 13:48:29 +02:00
|
|
|
|
$this->Session_Drop('sAvatarFileTmp');
|
|
|
|
|
}
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Дополнительные настройки сайта
|
|
|
|
|
*/
|
2008-10-14 21:36:36 +03:00
|
|
|
|
protected function EventTuning() {
|
|
|
|
|
$this->sMenuItemSelect='settings';
|
|
|
|
|
$this->sMenuSubItemSelect='tuning';
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_tuning'));
|
2012-07-27 08:36:55 +03:00
|
|
|
|
$aTimezoneList=array('-12','-11','-10','-9.5','-9','-8','-7','-6','-5','-4.5','-4','-3.5','-3','-2','-1','0','1','2','3','3.5','4','4.5','5','5.5','5.75','6','6.5','7','8','8.75','9','9.5','10','10.5','11','11.5','12','12.75','13','14');
|
|
|
|
|
$this->Viewer_Assign('aTimezoneList',$aTimezoneList);
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если отправили форму с настройками - сохраняем
|
|
|
|
|
*/
|
2009-10-17 03:27:22 +03:00
|
|
|
|
if (isPost('submit_settings_tuning')) {
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
|
|
|
|
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (in_array(getRequestStr('settings_general_timezone'),$aTimezoneList)) {
|
|
|
|
|
$this->oUserCurrent->setSettingsTimezone(getRequestStr('settings_general_timezone'));
|
2012-07-27 08:36:55 +03:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-14 21:36:36 +03:00
|
|
|
|
$this->oUserCurrent->setSettingsNoticeNewTopic( getRequest('settings_notice_new_topic') ? 1 : 0 );
|
|
|
|
|
$this->oUserCurrent->setSettingsNoticeNewComment( getRequest('settings_notice_new_comment') ? 1 : 0 );
|
|
|
|
|
$this->oUserCurrent->setSettingsNoticeNewTalk( getRequest('settings_notice_new_talk') ? 1 : 0 );
|
|
|
|
|
$this->oUserCurrent->setSettingsNoticeReplyComment( getRequest('settings_notice_reply_comment') ? 1 : 0 );
|
2008-10-28 21:24:35 +02:00
|
|
|
|
$this->oUserCurrent->setSettingsNoticeNewFriend( getRequest('settings_notice_new_friend') ? 1 : 0 );
|
2008-10-14 21:36:36 +03:00
|
|
|
|
$this->oUserCurrent->setProfileDate(date("Y-m-d H:i:s"));
|
2012-06-10 14:00:51 +03:00
|
|
|
|
/**
|
|
|
|
|
* Запускаем выполнение хуков
|
|
|
|
|
*/
|
|
|
|
|
$this->Hook_Run('settings_tuning_save_before', array('oUser'=>$this->oUserCurrent));
|
2008-10-14 21:36:36 +03:00
|
|
|
|
if ($this->User_Update($this->oUserCurrent)) {
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('settings_tuning_submit_ok'));
|
2012-06-10 14:00:51 +03:00
|
|
|
|
$this->Hook_Run('settings_tuning_save_after', array('oUser'=>$this->oUserCurrent));
|
2008-10-14 21:36:36 +03:00
|
|
|
|
} else {
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
|
2008-10-14 21:36:36 +03:00
|
|
|
|
}
|
2012-07-27 08:36:55 +03:00
|
|
|
|
} else {
|
|
|
|
|
if (is_null($this->oUserCurrent->getSettingsTimezone())) {
|
|
|
|
|
$_REQUEST['settings_general_timezone']=(strtotime(date("Y-m-d H:i:s"))-strtotime(gmdate("Y-m-d H:i:s")))/3600 - date('I');
|
|
|
|
|
} else {
|
|
|
|
|
$_REQUEST['settings_general_timezone']=$this->oUserCurrent->getSettingsTimezone();
|
|
|
|
|
}
|
2008-10-14 21:36:36 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Показ и обработка формы приглаешний
|
|
|
|
|
*
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
protected function EventInvite() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Только при активном режиме инвайтов
|
|
|
|
|
*/
|
2009-08-20 10:43:06 +03:00
|
|
|
|
if (!Config::Get('general.reg.invite')) {
|
2009-04-11 14:50:42 +03:00
|
|
|
|
return parent::EventNotFound();
|
2008-10-11 17:51:38 +03:00
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2008-10-16 07:29:15 +03:00
|
|
|
|
$this->sMenuItemSelect='invite';
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->sMenuSubItemSelect='';
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_invite'));
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если отправили форму
|
|
|
|
|
*/
|
2009-10-17 03:27:22 +03:00
|
|
|
|
if (isPost('submit_invite')) {
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
|
|
|
|
|
2008-10-21 07:58:03 +03:00
|
|
|
|
$bError=false;
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Есть права на отправку инфайтов?
|
|
|
|
|
*/
|
2008-10-21 07:58:03 +03:00
|
|
|
|
if (!$this->ACL_CanSendInvite($this->oUserCurrent) and !$this->oUserCurrent->isAdministrator()) {
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_invite_available_no'),$this->Lang_Get('error'));
|
|
|
|
|
$bError=true;
|
2008-10-21 07:58:03 +03:00
|
|
|
|
}
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Емайл корректен?
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!func_check(getRequestStr('invite_mail'),'mail')) {
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_invite_mail_error'),$this->Lang_Get('error'));
|
|
|
|
|
$bError=true;
|
2008-10-21 07:58:03 +03:00
|
|
|
|
}
|
2012-06-10 14:00:51 +03:00
|
|
|
|
/**
|
|
|
|
|
* Запускаем выполнение хуков
|
|
|
|
|
*/
|
|
|
|
|
$this->Hook_Run('settings_invate_send_before', array('oUser'=>$this->oUserCurrent));
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если нет ошибок, то отправляем инвайт
|
|
|
|
|
*/
|
2008-10-21 07:58:03 +03:00
|
|
|
|
if (!$bError) {
|
|
|
|
|
$oInvite=$this->User_GenerateInvite($this->oUserCurrent);
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$this->Notify_SendInvite($this->oUserCurrent,getRequestStr('invite_mail'),$oInvite);
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('settings_invite_submit_ok'));
|
2012-06-10 14:00:51 +03:00
|
|
|
|
$this->Hook_Run('settings_invate_send_after', array('oUser'=>$this->oUserCurrent));
|
2008-10-21 07:58:03 +03:00
|
|
|
|
}
|
2008-10-11 17:51:38 +03:00
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2008-10-21 07:58:03 +03:00
|
|
|
|
$this->Viewer_Assign('iCountInviteAvailable',$this->User_GetCountInviteAvailable($this->oUserCurrent));
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->Viewer_Assign('iCountInviteUsed',$this->User_GetCountInviteUsed($this->oUserCurrent->getId()));
|
2008-10-11 17:51:38 +03:00
|
|
|
|
}
|
2012-04-04 17:51:58 +03:00
|
|
|
|
/**
|
|
|
|
|
* Форма смены пароля, емайла
|
|
|
|
|
*/
|
|
|
|
|
protected function EventAccount() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем title страницы
|
|
|
|
|
*/
|
2012-04-04 17:51:58 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_profile'));
|
|
|
|
|
$this->sMenuSubItemSelect='account';
|
|
|
|
|
/**
|
|
|
|
|
* Если нажали кнопку "Сохранить"
|
|
|
|
|
*/
|
|
|
|
|
if (isPost('submit_account_edit')) {
|
|
|
|
|
$this->Security_ValidateSendForm();
|
|
|
|
|
|
|
|
|
|
$bError=false;
|
|
|
|
|
/**
|
|
|
|
|
* Проверка мыла
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (func_check(getRequestStr('mail'),'mail')) {
|
|
|
|
|
if ($oUserMail=$this->User_GetUserByMail(getRequestStr('mail')) and $oUserMail->getId()!=$this->oUserCurrent->getId()) {
|
2012-04-04 17:51:58 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_mail_error_used'),$this->Lang_Get('error'));
|
|
|
|
|
$bError=true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_mail_error'),$this->Lang_Get('error'));
|
|
|
|
|
$bError=true;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Проверка на смену пароля
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (getRequestStr('password','')!='') {
|
|
|
|
|
if (func_check(getRequestStr('password'),'password',5)) {
|
|
|
|
|
if (getRequestStr('password')==getRequestStr('password_confirm')) {
|
|
|
|
|
if (func_encrypt(getRequestStr('password_now'))==$this->oUserCurrent->getPassword()) {
|
|
|
|
|
$this->oUserCurrent->setPassword(func_encrypt(getRequestStr('password')));
|
2012-04-04 17:51:58 +03:00
|
|
|
|
} else {
|
|
|
|
|
$bError=true;
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_password_current_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$bError=true;
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_password_confirm_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$bError=true;
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('settings_profile_password_new_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Ставим дату последнего изменения
|
|
|
|
|
*/
|
|
|
|
|
$this->oUserCurrent->setProfileDate(date("Y-m-d H:i:s"));
|
2012-06-10 14:00:51 +03:00
|
|
|
|
/**
|
|
|
|
|
* Запускаем выполнение хуков
|
|
|
|
|
*/
|
|
|
|
|
$this->Hook_Run('settings_account_save_before', array('oUser'=>$this->oUserCurrent,'bError'=>&$bError));
|
2012-04-04 17:51:58 +03:00
|
|
|
|
/**
|
|
|
|
|
* Сохраняем изменения
|
|
|
|
|
*/
|
|
|
|
|
if (!$bError) {
|
|
|
|
|
if ($this->User_Update($this->oUserCurrent)) {
|
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('settings_account_submit_ok'));
|
2012-07-27 20:29:10 +03:00
|
|
|
|
/**
|
|
|
|
|
* Подтверждение смены емайла
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (getRequestStr('mail') and getRequestStr('mail')!=$this->oUserCurrent->getMail()) {
|
|
|
|
|
if ($oChangemail=$this->User_MakeUserChangemail($this->oUserCurrent,getRequestStr('mail'))) {
|
2012-08-25 06:49:28 +03:00
|
|
|
|
if ($oChangemail->getMailFrom()) {
|
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('settings_profile_mail_change_from_notice'));
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('settings_profile_mail_change_to_notice'));
|
|
|
|
|
}
|
2012-07-27 20:29:10 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 14:00:51 +03:00
|
|
|
|
$this->Hook_Run('settings_account_save_after', array('oUser'=>$this->oUserCurrent));
|
2012-04-04 17:51:58 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Выводит форму для редактирования профиля и обрабатывает её
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventProfile() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем title страницы
|
|
|
|
|
*/
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_profile'));
|
2012-03-15 11:05:27 +02:00
|
|
|
|
$this->Viewer_Assign('aUserFields',$this->User_getUserFields(''));
|
|
|
|
|
$this->Viewer_Assign('aUserFieldsContact',$this->User_getUserFields(array('contact','social')));
|
2012-04-24 14:01:13 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон JS текстовки
|
|
|
|
|
*/
|
|
|
|
|
$this->Lang_AddLangJs(array(
|
|
|
|
|
'settings_profile_field_error_max'
|
|
|
|
|
));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если нажали кнопку "Сохранить"
|
|
|
|
|
*/
|
2009-10-17 03:27:22 +03:00
|
|
|
|
if (isPost('submit_profile_edit')) {
|
2009-10-20 02:42:23 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
|
|
|
|
$bError=false;
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Заполняем профиль из полей формы
|
|
|
|
|
*/
|
2012-03-23 06:46:13 +02:00
|
|
|
|
/**
|
|
|
|
|
* Определяем гео-объект
|
|
|
|
|
*/
|
|
|
|
|
if (getRequest('geo_city')) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$oGeoObject=$this->Geo_GetGeoObject('city',getRequestStr('geo_city'));
|
2012-03-23 06:46:13 +02:00
|
|
|
|
} elseif (getRequest('geo_region')) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$oGeoObject=$this->Geo_GetGeoObject('region',getRequestStr('geo_region'));
|
2012-03-23 06:46:13 +02:00
|
|
|
|
} elseif (getRequest('geo_country')) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$oGeoObject=$this->Geo_GetGeoObject('country',getRequestStr('geo_country'));
|
2012-03-23 06:46:13 +02:00
|
|
|
|
} else {
|
|
|
|
|
$oGeoObject=null;
|
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Проверяем имя
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (func_check(getRequestStr('profile_name'),'text',2,Config::Get('module.user.name_max'))) {
|
|
|
|
|
$this->oUserCurrent->setProfileName(getRequestStr('profile_name'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileName(null);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем пол
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (in_array(getRequestStr('profile_sex'),array('man','woman','other'))) {
|
|
|
|
|
$this->oUserCurrent->setProfileSex(getRequestStr('profile_sex'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileSex('other');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем дату рождения
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (func_check(getRequestStr('profile_birthday_day'),'id',1,2) and func_check(getRequestStr('profile_birthday_month'),'id',1,2) and func_check(getRequestStr('profile_birthday_year'),'id',4,4)) {
|
|
|
|
|
$this->oUserCurrent->setProfileBirthday(date("Y-m-d H:i:s",mktime(0,0,0,getRequestStr('profile_birthday_month'),getRequestStr('profile_birthday_day'),getRequestStr('profile_birthday_year'))));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileBirthday(null);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем информацию о себе
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (func_check(getRequestStr('profile_about'),'text',1,3000)) {
|
|
|
|
|
$this->oUserCurrent->setProfileAbout($this->Text_Parser(getRequestStr('profile_about')));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileAbout(null);
|
2011-06-22 12:11:05 +03:00
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Ставим дату последнего изменения профиля
|
|
|
|
|
*/
|
|
|
|
|
$this->oUserCurrent->setProfileDate(date("Y-m-d H:i:s"));
|
2012-06-10 14:00:51 +03:00
|
|
|
|
/**
|
|
|
|
|
* Запускаем выполнение хуков
|
|
|
|
|
*/
|
|
|
|
|
$this->Hook_Run('settings_profile_save_before', array('oUser'=>$this->oUserCurrent,'bError'=>&$bError));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Сохраняем изменения профиля
|
2012-05-04 13:12:21 +03:00
|
|
|
|
*/
|
2008-09-21 09:36:57 +03:00
|
|
|
|
if (!$bError) {
|
|
|
|
|
if ($this->User_Update($this->oUserCurrent)) {
|
2008-11-01 08:16:18 +02:00
|
|
|
|
/**
|
2012-03-23 06:46:13 +02:00
|
|
|
|
* Создаем связь с гео-объектом
|
2008-11-01 08:16:18 +02:00
|
|
|
|
*/
|
2012-03-23 06:46:13 +02:00
|
|
|
|
if ($oGeoObject) {
|
|
|
|
|
$this->Geo_CreateTarget($oGeoObject,'user',$this->oUserCurrent->getId());
|
|
|
|
|
if ($oCountry=$oGeoObject->getCountry()) {
|
|
|
|
|
$this->oUserCurrent->setProfileCountry($oCountry->getName());
|
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileCountry(null);
|
2008-11-01 08:16:18 +02:00
|
|
|
|
}
|
2012-03-23 06:46:13 +02:00
|
|
|
|
if ($oRegion=$oGeoObject->getRegion()) {
|
|
|
|
|
$this->oUserCurrent->setProfileRegion($oRegion->getName());
|
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileRegion(null);
|
|
|
|
|
}
|
|
|
|
|
if ($oCity=$oGeoObject->getCity()) {
|
|
|
|
|
$this->oUserCurrent->setProfileCity($oCity->getName());
|
|
|
|
|
} else {
|
|
|
|
|
$this->oUserCurrent->setProfileCity(null);
|
2008-11-01 08:16:18 +02:00
|
|
|
|
}
|
2012-03-23 06:46:13 +02:00
|
|
|
|
} else {
|
|
|
|
|
$this->Geo_DeleteTargetsByTarget('user',$this->oUserCurrent->getId());
|
|
|
|
|
$this->oUserCurrent->setProfileCountry(null);
|
|
|
|
|
$this->oUserCurrent->setProfileRegion(null);
|
|
|
|
|
$this->oUserCurrent->setProfileCity(null);
|
2008-11-01 08:16:18 +02:00
|
|
|
|
}
|
2012-03-23 06:46:13 +02:00
|
|
|
|
$this->User_Update($this->oUserCurrent);
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2012-03-15 11:05:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Обрабатываем дополнительные поля, type = ''
|
|
|
|
|
*/
|
|
|
|
|
$aFields = $this->User_getUserFields('');
|
|
|
|
|
$aData = array();
|
|
|
|
|
foreach ($aFields as $iId => $aField) {
|
|
|
|
|
if (isset($_REQUEST['profile_user_field_'.$iId])) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$aData[$iId] = getRequestStr('profile_user_field_'.$iId);
|
2012-03-15 11:05:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->User_setUserFieldsValues($this->oUserCurrent->getId(), $aData);
|
|
|
|
|
/**
|
|
|
|
|
* Динамические поля контактов, type = array('contact','social')
|
|
|
|
|
*/
|
|
|
|
|
$aType=array('contact','social');
|
|
|
|
|
$aFields = $this->User_getUserFields($aType);
|
|
|
|
|
/**
|
|
|
|
|
* Удаляем все поля с этим типом
|
|
|
|
|
*/
|
|
|
|
|
$this->User_DeleteUserFieldValues($this->oUserCurrent->getId(),$aType);
|
|
|
|
|
$aFieldsContactType=getRequest('profile_user_field_type');
|
|
|
|
|
$aFieldsContactValue=getRequest('profile_user_field_value');
|
|
|
|
|
if (is_array($aFieldsContactType)) {
|
|
|
|
|
foreach($aFieldsContactType as $k=>$v) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$v=(string)$v;
|
2012-07-08 11:50:36 +03:00
|
|
|
|
if (isset($aFields[$v]) and isset($aFieldsContactValue[$k]) and is_string($aFieldsContactValue[$k])) {
|
2012-04-24 14:01:13 +03:00
|
|
|
|
$this->User_setUserFieldsValues($this->oUserCurrent->getId(), array($v=>$aFieldsContactValue[$k]), Config::Get('module.user.userfield_max_identical'));
|
2012-03-15 11:05:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('settings_profile_submit_ok'));
|
2012-06-10 14:00:51 +03:00
|
|
|
|
$this->Hook_Run('settings_profile_save_after', array('oUser'=>$this->oUserCurrent));
|
2012-05-04 13:12:21 +03:00
|
|
|
|
} else {
|
2009-04-11 14:50:42 +03:00
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-23 06:46:13 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем гео-объект привязки
|
|
|
|
|
*/
|
|
|
|
|
$oGeoTarget=$this->Geo_GetTargetByTarget('user',$this->oUserCurrent->getId());
|
|
|
|
|
$this->Viewer_Assign('oGeoTarget',$oGeoTarget);
|
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон список стран, регионов, городов
|
|
|
|
|
*/
|
|
|
|
|
$aCountries=$this->Geo_GetCountries(array(),array('sort'=>'asc'),1,300);
|
|
|
|
|
$this->Viewer_Assign('aGeoCountries',$aCountries['collection']);
|
|
|
|
|
if ($oGeoTarget) {
|
|
|
|
|
if ($oGeoTarget->getCountryId()) {
|
|
|
|
|
$aRegions=$this->Geo_GetRegions(array('country_id'=>$oGeoTarget->getCountryId()),array('sort'=>'asc'),1,500);
|
|
|
|
|
$this->Viewer_Assign('aGeoRegions',$aRegions['collection']);
|
|
|
|
|
}
|
|
|
|
|
if ($oGeoTarget->getRegionId()) {
|
|
|
|
|
$aCities=$this->Geo_GetCities(array('region_id'=>$oGeoTarget->getRegionId()),array('sort'=>'asc'),1,500);
|
|
|
|
|
$this->Viewer_Assign('aGeoCities',$aCities['collection']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-22 12:11:05 +03:00
|
|
|
|
}
|
2008-10-14 21:36:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Выполняется при завершении работы экшена
|
|
|
|
|
*
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
public function EventShutdown() {
|
2012-04-07 18:11:07 +03:00
|
|
|
|
$iCountTopicFavourite=$this->Topic_GetCountTopicsFavouriteByUserId($this->oUserCurrent->getId());
|
|
|
|
|
$iCountTopicUser=$this->Topic_GetCountTopicsPersonalByUser($this->oUserCurrent->getId(),1);
|
|
|
|
|
$iCountCommentUser=$this->Comment_GetCountCommentsByUserId($this->oUserCurrent->getId(),'topic');
|
|
|
|
|
$iCountCommentFavourite=$this->Comment_GetCountCommentsFavouriteByUserId($this->oUserCurrent->getId());
|
|
|
|
|
$iCountNoteUser=$this->User_GetCountUserNotesByUserId($this->oUserCurrent->getId());
|
|
|
|
|
|
|
|
|
|
$this->Viewer_Assign('oUserProfile',$this->oUserCurrent);
|
|
|
|
|
$this->Viewer_Assign('iCountWallUser',$this->Wall_GetCountWall(array('wall_user_id'=>$this->oUserCurrent->getId(),'pid'=>null)));
|
|
|
|
|
/**
|
|
|
|
|
* Общее число публикация и избранного
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('iCountCreated',$iCountNoteUser+$iCountTopicUser+$iCountCommentUser);
|
|
|
|
|
$this->Viewer_Assign('iCountFavourite',$iCountCommentFavourite+$iCountTopicFavourite);
|
|
|
|
|
$this->Viewer_Assign('iCountFriendsUser',$this->User_GetCountUsersFriend($this->oUserCurrent->getId()));
|
2012-05-04 13:12:21 +03:00
|
|
|
|
|
2008-10-14 21:36:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон необходимые переменные
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
|
2010-02-06 02:09:44 +02:00
|
|
|
|
$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
|
|
|
|
$this->Hook_Run('action_shutdown_settings');
|
2008-10-14 21:36:36 +03:00
|
|
|
|
}
|
2014-01-28 09:47:36 +02:00
|
|
|
|
}
|