├── README.md ├── app └── views │ ├── hooks │ └── redmine_local_avatars │ │ └── _view_my_account_contextual.html.erb │ └── my │ ├── _avatar.html.erb │ └── avatar.html.erb ├── config ├── locales │ ├── bg.yml │ ├── de.yml │ ├── en.yml │ ├── es.yml │ ├── fr.yml │ ├── it.yml │ ├── ja.yml │ ├── pt-BR.yml │ ├── pt.yml │ ├── ru.yml │ ├── tr.yml │ ├── zh-TW.yml │ └── zh.yml └── routes.rb ├── init.rb └── lib ├── account_controller_patch.rb ├── application_helper_avatar_patch.rb ├── local_avatars.rb ├── my_controller_patch.rb ├── redmine_local_avatars └── hooks.rb ├── users_avatar_patch.rb ├── users_controller_patch.rb └── users_helper_avatar_patch.rb /README.md: -------------------------------------------------------------------------------- 1 | # RedmineLocalAvatars 2 | 3 | This plugin allows Redmine users to upload a picture to be used as 4 | an avatar (instead of depending on images from Gravatar). 5 | 6 | Users can set their image through the /my/account page. The administrator 7 | can also manage users' avatars through the /users section. 8 | 9 | ## Installation 10 | 11 | Place this plugin into the folder `plugins/` of your redmine installation. Make sure that the folder is called "redmine_local_avatars". 12 | 13 | Update the gems, run any migrations: 14 | 15 |
16 | bundle install --without development test
17 | rake redmine:plugins:migrate RAILS_ENV=production
18 | 
19 | 20 | And restart your application server. 21 | 22 | 23 | ## Authors 24 | 25 | * A.Chaika wrote the original version: 26 | * http://www.redmine.org/boards/3/topics/5365 27 | * https://github.com/Ubik/redmine_local_avatars 28 | * https://github.com/ncoders/redmine_local_avatars 29 | 30 | Luca Pireddu at CRS4 (http://www.crs4.it), 31 | contributed updates and improvements. 32 | 33 | 34 | ## Warranty. What warranty? 35 | 36 | This plugin was written for use in an intranet with simple requirements in 37 | mind. In particular, not much attention has been payed to security issues 38 | and there hasn't been any thorough testing. Use it at your own risk. 39 | Patches are welcome. 40 | 41 | 42 | ## Implementation Notes 43 | 44 | Avatar images are treated as attachments to User objects 45 | with the description 'avatar'. The AccountController is patched 46 | to provide the images, and the UsersController and MyController are 47 | patched to provide mechanisms to add/delete avatars. 48 | 49 | 50 | ## License 51 | 52 | Copyright (C) 2010 Andrew Chaika, Luca Pireddu 53 | Copyright (C) 2015 dup2 54 | 55 | This program is free software; you can redistribute it and/or 56 | modify it under the terms of the GNU General Public License 57 | as published by the Free Software Foundation; either version 2 58 | of the License, or (at your option) any later version. 59 | 60 | This program is distributed in the hope that it will be useful, 61 | but WITHOUT ANY WARRANTY; without even the implied warranty of 62 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 63 | GNU General Public License for more details. 64 | 65 | You should have received a copy of the GNU General Public License 66 | along with this program; if not, write to the Free Software 67 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 68 | -------------------------------------------------------------------------------- /app/views/hooks/redmine_local_avatars/_view_my_account_contextual.html.erb: -------------------------------------------------------------------------------- 1 | - <%= link_to(l(:button_change_avatar), :action => 'avatar') %> 2 | -------------------------------------------------------------------------------- /app/views/my/_avatar.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

<%= l(:label_avatar)%>

3 |
4 | <%= avatar(@user, :size => "128") %> 5 |

6 | <%= form_tag( { :action => 'save_avatar', :id => @user.id }, :multipart => true) do %> 7 | <%= file_field_tag "avatar" %>
8 | <%= submit_tag l(:button_save) %> 9 | <%= submit_tag l(:button_delete), :confirm => l(:are_you_sure_delete_avatar) %> 10 | <% end %> 11 |
12 | 13 | <% html_title(l(:label_avatar)) -%> 14 | -------------------------------------------------------------------------------- /app/views/my/avatar.html.erb: -------------------------------------------------------------------------------- 1 | <%= render :partial => 'avatar' %> -------------------------------------------------------------------------------- /config/locales/bg.yml: -------------------------------------------------------------------------------- 1 | # Bulgarian translation by Ivan Cenov 2 | # https://bugs.launchpad.net/redminelocalavatars/+bug/887451 3 | bg: 4 | label_avatar: "Аватар" 5 | message_avatar_uploaded: "Аватарът е зареден успешно" 6 | button_change_avatar: "Промяна на локален аватар" 7 | are_you_sure_delete_avatar: "Сигурен ли сте, че искате да изтриете Вашия аватар?" 8 | avatar_deleted: "Аватарът е изтрит" 9 | unable_to_delete_avatar: "Грешка при опит за изтриване на аватара" 10 | -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | # German translation by cforce 2 | # https://bugs.launchpad.net/redminelocalavatars/+bug/680548 3 | 4 | de: 5 | label_avatar: "Avatar" 6 | message_avatar_uploaded: "Avatar erfolgreich hochgeladen" 7 | button_change_avatar: "Avatar anpassen" 8 | are_you_sure_delete_avatar: "Wollen Sie den Avatar entfernen?" 9 | avatar_deleted: "Avatar entfernt." 10 | unable_to_delete_avatar: "Leider ist beim Löschen des Avatars ein Problem aufgetreten!" 11 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # English strings go here 2 | en: 3 | label_avatar: "Avatar" 4 | message_avatar_uploaded: "Avatar uploaded successfully" 5 | button_change_avatar: "Change local avatar" 6 | are_you_sure_delete_avatar: "Are you sure you want to delete your avatar?" 7 | avatar_deleted: "Avatar deleted" 8 | unable_to_delete_avatar: "Sorry. There was an error deleting the avatar" 9 | -------------------------------------------------------------------------------- /config/locales/es.yml: -------------------------------------------------------------------------------- 1 | # Spanish strings go here 2 | # Courtesy of Anibal Avelar 3 | # https://bugs.launchpad.net/redminelocalavatars/+bug/716663 4 | es: 5 | label_avatar: "Avatar" 6 | message_avatar_uploaded: "Avatar descargado exitosamente" 7 | button_change_avatar: "Cambiar avatar" 8 | are_you_sure_delete_avatar: "¿Estas seguro que quieres borrar tu avatar?" 9 | avatar_deleted: "Avatar borrado" 10 | unable_to_delete_avatar: "Lo sentimos. Hubo un error borrando el avatar" 11 | -------------------------------------------------------------------------------- /config/locales/fr.yml: -------------------------------------------------------------------------------- 1 | # French translation courtesy of luigifab 2 | # https://bugs.launchpad.net/redminelocalavatars/+bug/692969 3 | fr: 4 | label_avatar: "Avatar" 5 | message_avatar_uploaded: "Avatar enregistré" 6 | button_change_avatar: "Modifier l'avatar" 7 | are_you_sure_delete_avatar: "Êtes-vous certain de vouloir supprimer votre avatar?" 8 | avatar_deleted: "Avatar supprimé" 9 | unable_to_delete_avatar: "Une erreur est survenue lors de la suppression de l'avatar." 10 | -------------------------------------------------------------------------------- /config/locales/it.yml: -------------------------------------------------------------------------------- 1 | # Italian strings go here 2 | it: 3 | label_avatar: Immagine 4 | message_avatar_uploaded: Immagine salvata 5 | button_change_avatar: Cambia la tua immagine 6 | are_you_sure_delete_avatar: "Sicuro di volere eliminare l'immagine?" 7 | avatar_deleted: Immagine eliminata 8 | unable_to_delete_avatar: "Mi dispiace. C'è stato un error eliminando l'immagine" 9 | -------------------------------------------------------------------------------- /config/locales/ja.yml: -------------------------------------------------------------------------------- 1 | # Japanese strings go here 2 | ja: 3 | label_avatar: "アバター" 4 | message_avatar_uploaded: "アバターのアップロードに成功しました。" 5 | button_change_avatar: "アバターの変更" 6 | are_you_sure_delete_avatar: "アバターを削除してもよろしいですか?" 7 | avatar_deleted: "アバターは削除されました。" 8 | unable_to_delete_avatar: "アバターの削除中にエラーが発生しました。" 9 | -------------------------------------------------------------------------------- /config/locales/pt-BR.yml: -------------------------------------------------------------------------------- 1 | # Portugues Brazil strings go here 2 | # Courtesy of Felipe Pinheiro 3 | pt-BR: 4 | label_avatar: "Avatar" 5 | message_avatar_uploaded: "Avatar carregado com sucesso" 6 | button_change_avatar: "Mude sua imagem de exibição." 7 | are_you_sure_delete_avatar: "Você tem certeza que deseja apagar seu avatar?" 8 | avatar_deleted: "Avatar apagado" 9 | unable_to_delete_avatar: "Desculpe. Houve um erro apagando o avatar." 10 | -------------------------------------------------------------------------------- /config/locales/pt.yml: -------------------------------------------------------------------------------- 1 | # Portugues strings go here 2 | # Courtesy of Felipe Pinheiro 3 | pt: 4 | label_avatar: "Avatar" 5 | message_avatar_uploaded: "Avatar carregado com sucesso" 6 | button_change_avatar: "Mude sua imagem de exibição." 7 | are_you_sure_delete_avatar: "Você tem certeza que deseja apagar seu avatar?" 8 | avatar_deleted: "Avatar apagado" 9 | unable_to_delete_avatar: "Desculpe. Houve um erro apagando o avatar." 10 | -------------------------------------------------------------------------------- /config/locales/ru.yml: -------------------------------------------------------------------------------- 1 | ru: 2 | label_avatar: "Фотография" 3 | message_avatar_uploaded: "Фотография загружена на сервер" 4 | button_change_avatar: "Изменить фотографию" 5 | are_you_sure_delete_avatar: "Вы действительно хотите удалить свою фотографию?" 6 | avatar_deleted: "Фотография удалена" 7 | unable_to_delete_avatar: "При удалении фотографии произошла ошибка" 8 | -------------------------------------------------------------------------------- /config/locales/tr.yml: -------------------------------------------------------------------------------- 1 | # Turkish strings go here 2 | tr: 3 | label_avatar: "Avatar" 4 | message_avatar_uploaded: "Avatar yüklendi" 5 | button_change_avatar: "Avatarımı değiştir" 6 | are_you_sure_delete_avatar: "Avatarınızı silmek istediğinize emin misiniz?" 7 | avatar_deleted: "Avatar silindi" 8 | unable_to_delete_avatar: "Üzgünüm. Avatar silinirken bir hata oldu" 9 | -------------------------------------------------------------------------------- /config/locales/zh-TW.yml: -------------------------------------------------------------------------------- 1 | # Simplified Chinese strings go here 2 | zh-TW: 3 | label_avatar: "頭像" 4 | message_avatar_uploaded: "成功上傳頭像" 5 | button_change_avatar: "更改頭像" 6 | are_you_sure_delete_avatar: "確定刪除頭像嗎?" 7 | avatar_deleted: "頭像已刪除" 8 | unable_to_delete_avatar: "對不起,刪除頭像發生錯誤" 9 | -------------------------------------------------------------------------------- /config/locales/zh.yml: -------------------------------------------------------------------------------- 1 | # Simplified Chinese strings go here 2 | zh: 3 | label_avatar: "头像" 4 | message_avatar_uploaded: "成功上传头像" 5 | button_change_avatar: "更改头像" 6 | are_you_sure_delete_avatar: "确定删除头像吗?" 7 | avatar_deleted: "头像已删除" 8 | unable_to_delete_avatar: "对不起,删除头像发生错误" 9 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | match 'my/avatar', :to => 'my#avatar', :via => [:get, :post] 3 | match 'my/save_avatar/:id', :to => 'my#save_avatar', :via => [:get, :post] 4 | match 'account/get_avatar/:id', :to => 'account#get_avatar', :constraints => {:id=>/\d+/}, :via => [:get, :post] 5 | match 'users/save_avatar/:id', :to => 'users#save_avatar', :constraints => {:id=>/\d+/}, :via => [:get, :post] 6 | match 'users/get_avatar/:id', :to => 'users#get_avatar', :constraints => {:id=>/\d+/}, :via => [:get, :post] 7 | end 8 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | require 'redmine' 20 | 21 | Redmine::Plugin.register :redmine_local_avatars do 22 | name 'Redmine Local Avatars plugin' 23 | author 'Andrew Chaika and Luca Pireddu' 24 | author_url 'https://github.com/ncoders/redmine_local_avatars' 25 | description 'This plugin lets users upload avatars directly into Redmine' 26 | version '1.0.7' 27 | requires_redmine version_or_higher: '4.1' 28 | end 29 | 30 | receiver = Object.const_defined?('ActiveSupport::Reloader') ? ActiveSupport::Reloader : ActionDispatch::Callbacks 31 | 32 | require File.expand_path('../lib/local_avatars', __FILE__) 33 | 34 | # patches to Redmine 35 | require File.expand_path('../lib/account_controller_patch', __FILE__) 36 | require File.expand_path('../lib/application_helper_avatar_patch', __FILE__) 37 | require File.expand_path('../lib/my_controller_patch', __FILE__) 38 | require File.expand_path('../lib/users_avatar_patch', __FILE__) # User model 39 | require File.expand_path('../lib/users_controller_patch', __FILE__) 40 | require File.expand_path('../lib/users_helper_avatar_patch', __FILE__) # UsersHelper 41 | 42 | # hooks 43 | require File.expand_path('../lib/redmine_local_avatars/hooks', __FILE__) 44 | -------------------------------------------------------------------------------- /lib/account_controller_patch.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | require File.expand_path('../local_avatars', __FILE__) 21 | 22 | module AccountControllerPatch 23 | 24 | def self.included(base) # :nodoc: 25 | base.class_eval do 26 | helper :attachments 27 | include AttachmentsHelper 28 | end 29 | end 30 | 31 | include LocalAvatars 32 | 33 | def get_avatar 34 | @user = User.find(params[:id]) 35 | send_avatar(@user) 36 | end 37 | 38 | end 39 | 40 | AccountController.include(AccountControllerPatch) -------------------------------------------------------------------------------- /lib/application_helper_avatar_patch.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | module ApplicationHelperAvatarPatch 21 | 22 | def self.included(base) # :nodoc: 23 | base.class_eval do 24 | alias_method :avatar_without_local, :avatar 25 | alias_method :avatar, :avatar_with_local 26 | end 27 | end 28 | 29 | 30 | def avatar_with_local(user, options = { }) 31 | if user.is_a?(User)then 32 | av = user.attachments.find_by_description 'avatar' 33 | if av then 34 | image_url = url_for :only_path => true, :controller => 'account', :action => 'get_avatar', :id => user 35 | options[:size] = "24" unless options[:size] 36 | title = "#{user.name}" 37 | return "".html_safe 38 | end 39 | end 40 | avatar_without_local(user, options) 41 | end 42 | 43 | 44 | end 45 | 46 | AvatarsHelper.include(ApplicationHelperAvatarPatch) -------------------------------------------------------------------------------- /lib/local_avatars.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | module LocalAvatars 21 | def send_avatar(user) 22 | av = user.attachments.find_by_description 'avatar' 23 | send_file(av.diskfile, :filename => filename_for_content_disposition(av.filename), 24 | :type => av.content_type, 25 | :disposition => (av.image? ? 'inline' : 'attachment')) if av 26 | end 27 | 28 | # expects @user to be set. 29 | # In case of error, raises an exception and sets @possible_error 30 | def save_or_delete 31 | # clear the attachments. Then, save if 32 | # we have to delete. Otherwise add the new 33 | # avatar and then save 34 | # TODO: This doesn't play nice with any other possible 35 | # attachments on the user (just because there aren't any 36 | # now doesn't mean there won't be in the future. It should 37 | # be changed to only remove an attachment with description == 'avatar' 38 | @user.attachments.clear 39 | if params[:commit] == l(:button_delete) then 40 | @possible_error = l(:unable_to_delete_avatar) 41 | @user.save! 42 | flash[:notice] = l(:avatar_deleted) 43 | else # take anything else as save 44 | file_field = params[:avatar] 45 | Attachment.attach_files(@user, {'first' => {'file' => file_field, 'description' => 'avatar'}}) 46 | @possible_error = l(:error_saving_avatar) 47 | @user.save! 48 | flash[:notice] = l(:message_avatar_uploaded) 49 | end 50 | end 51 | end 52 | 53 | -------------------------------------------------------------------------------- /lib/my_controller_patch.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | require File.expand_path('../local_avatars', __FILE__) 20 | 21 | module MyControllerPatch 22 | def self.included(base) # :nodoc: 23 | base.class_eval do 24 | helper :attachments 25 | include AttachmentsHelper 26 | end 27 | end 28 | 29 | include LocalAvatars 30 | 31 | def avatar 32 | @user = User.current 33 | end 34 | 35 | def save_avatar 36 | @user = User.current 37 | begin 38 | save_or_delete # see the LocalAvatars module 39 | redirect_to :action => 'account', :id => @user 40 | rescue => e 41 | $stderr.puts("save_or_delete raise an exception. exception: #{e.class}: #{e.message}") 42 | flash[:error] = @possible_error || e.message 43 | redirect_to :action => 'avatar' 44 | end 45 | end 46 | end 47 | 48 | 49 | MyController.include(MyControllerPatch) -------------------------------------------------------------------------------- /lib/redmine_local_avatars/hooks.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | require 'redmine' 21 | 22 | module RedmineLocalAvatars 23 | class Hooks < Redmine::Hook::ViewListener 24 | # This just renders the partial in 25 | # app/views/hooks/redmine_local_avatars/_view_my_account_contextual.rhtml 26 | render_on :view_my_account_contextual, 27 | :partial => 'hooks/redmine_local_avatars/view_my_account_contextual' 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/users_avatar_patch.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | 21 | 22 | module UsersAvatarPatch 23 | def self.included(base) # :nodoc: 24 | base.class_eval do 25 | acts_as_attachable 26 | end 27 | end 28 | end 29 | 30 | 31 | User.include(UsersAvatarPatch) -------------------------------------------------------------------------------- /lib/users_controller_patch.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | require File.expand_path('../local_avatars', __FILE__) 21 | 22 | module UsersControllerPatch 23 | 24 | def self.included(base) # :nodoc: 25 | base.class_eval do 26 | helper :attachments 27 | include AttachmentsHelper 28 | end 29 | end 30 | 31 | include LocalAvatars 32 | 33 | def get_avatar 34 | @user = User.find(params[:id]) 35 | send_avatar(@user) 36 | end 37 | 38 | def save_avatar 39 | @user = User.find(params[:id]) 40 | 41 | begin 42 | save_or_delete # see the LocalAvatars module 43 | rescue 44 | flash[:error] = @possible_error 45 | end 46 | redirect_to :action => 'edit', :id => @user 47 | end 48 | end 49 | 50 | UsersController.include(UsersControllerPatch) 51 | -------------------------------------------------------------------------------- /lib/users_helper_avatar_patch.rb: -------------------------------------------------------------------------------- 1 | # Redmine Local Avatars plugin 2 | # 3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | 20 | 21 | 22 | module UsersHelperAvatarPatch 23 | def self.included(base) # :nodoc: 24 | base.class_eval do 25 | alias_method :user_settings_tabs_without_avatar, :user_settings_tabs 26 | alias_method :user_settings_tabs, :user_settings_tabs_with_avatar 27 | end 28 | end 29 | 30 | def user_settings_tabs_with_avatar 31 | tabs = user_settings_tabs_without_avatar 32 | tabs << {:name => 'avatar', :partial => 'my/avatar', :label => :label_avatar} 33 | end 34 | end 35 | 36 | 37 | UsersHelper.include(UsersHelperAvatarPatch) --------------------------------------------------------------------------------