/**
  * Обновляет юзера
  *
  * @param ModuleUser_EntityUser $oUser Объект пользователя
  * @return bool
  */
 public function Update(ModuleUser_EntityUser $oUser)
 {
     $sql = "UPDATE " . Config::Get('db.table.user') . "\n      SET\n        user_password = ? ,\n        user_mail = ? ,\n        user_skill = ? ,\n        user_date_activate = ? ,\n        user_date_comment_last = ? ,\n        user_rating = ? ,\n        user_count_vote = ? ,\n        user_activate = ? ,\n                user_activate_key = ? ,\n        user_profile_name = ? ,\n        user_profile_sex = ? ,\n        user_profile_country = ? ,\n        user_profile_region = ? ,\n        user_profile_city = ? ,\n        user_profile_birthday = ? ,\n        user_profile_about = ? ,\n        user_profile_date = ? ,\n        user_profile_avatar = ?  ,\n        user_profile_foto = ? ,\n        user_settings_notice_new_topic = ?  ,\n        user_settings_notice_new_comment = ? ,\n        user_settings_notice_new_talk = ?  ,\n        user_settings_notice_reply_comment = ? ,\n        user_settings_notice_new_friend = ? ,\n        user_settings_timezone = ?\n      WHERE user_id = ?\n    ";
     if ($this->oDb->query($sql, $oUser->getPassword(), $oUser->getMail(), $oUser->getSkill(), $oUser->getDateActivate(), $oUser->getDateCommentLast(), $oUser->getRating(), $oUser->getCountVote(), $oUser->getActivate(), $oUser->getActivateKey(), $oUser->getProfileName(), $oUser->getProfileSex(), $oUser->getProfileCountry(), $oUser->getProfileRegion(), $oUser->getProfileCity(), $oUser->getProfileBirthday(), $oUser->getProfileAbout(), $oUser->getProfileDate(), $oUser->getProfileAvatar(), $oUser->getProfileFoto(), $oUser->getSettingsNoticeNewTopic(), $oUser->getSettingsNoticeNewComment(), $oUser->getSettingsNoticeNewTalk(), $oUser->getSettingsNoticeReplyComment(), $oUser->getSettingsNoticeNewFriend(), $oUser->getSettingsTimezone(), $oUser->getId())) {
         return true;
     }
     return false;
 }
 /**
  * Вырезает из временной аватарки область нужного размера, ту что задал пользователь
  */
 protected function EventResizeAvatar()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     /**
      * Получаем файл из сессии
      */
     $sFileAvatar = $this->Session_Get('sAvatarFileTmp');
     if (!file_exists($sFileAvatar)) {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
         return;
     }
     /**
      * Получаем размер области из параметров
      */
     $aSize = array();
     $aSizeTmp = getRequest('size');
     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'])) {
         $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');
         $this->Viewer_AssignAjax('sFile', $this->oUserCurrent->getProfileAvatarPath(100));
         $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'));
     }
 }
예제 #3
0
 /**
  * Удаляет аватары производных размеров (основной не трогает)
  *
  * @param ModuleUser_EntityUser $oUser
  *
  * @return bool
  */
 public function DeleteAvatarSizes($oUser)
 {
     // * Если аватар есть, удаляем его и его рейсайзы
     if ($sAvatar = $oUser->getProfileAvatar()) {
         $sFile = E::ModuleUploader()->Url2Dir($sAvatar);
         return E::ModuleUploader()->DeleteAs($sFile . '-*.*');
     }
     return true;
 }
예제 #4
0
 /**
  * Delete avatar from server
  *
  * @param ModuleUser_EntityUser $oUser
  */
 public function DeleteAvatar($oUser)
 {
     /**
      * Если аватар есть, удаляем его и его рейсайзы
      */
     if ($oUser->getProfileAvatar()) {
         $aSize = array_merge(Config::Get('module.user.avatar_size'), array(100));
         foreach ($aSize as $iSize) {
             @unlink($this->Image_GetServerPath($oUser->getProfileAvatarPath($iSize)));
         }
     }
 }
예제 #5
0
 /**
  * Удаляет аватар пользователя
  *
  * @param ModuleUser_EntityUser $oUser
  */
 public function DeleteProfileAvatar($oUser)
 {
     if ($oUser->getProfileAvatar()) {
         $this->Media_RemoveImageBySizes($oUser->getProfileAvatar(), Config::Get('module.user.avatar_size'));
         $oUser->setProfileAvatar(null);
     }
 }