pax_global_header00006660000000000000000000000064125447235760014531gustar00rootroot0000000000000052 comment=c374fd79614807c0d2c9888220550a75148d7676 redmine_local_avatars-1.0.1/000077500000000000000000000000001254472357600160465ustar00rootroot00000000000000redmine_local_avatars-1.0.1/README.md000066400000000000000000000053251254472357600173320ustar00rootroot00000000000000# RedmineLocalAvatars This plugin allows Redmine users to upload a picture to be used as an avatar (instead of depending on images from Gravatar). Users can set their image through the /my/account page. The administrator can also manage users' avatars through the /users section. ## Installation Place this plugin into the folder `plugins/` of your redmine installation. Make sure that the folder is called "redmine_local_avatars". Update the gems, run any migrations:
bundle install --without development test
rake redmine:plugins:migrate RAILS_ENV=production
And restart your application server. ## Compatibility This current version on github is compatible with Redmine 2.1 - 2.6. It has been imported from lp:redminelocalavatars incorporating the patch for 2.1 from chrisy at [https://bugs.launchpad.net/redminelocalavatars/+bug/1069808/comments/4](https://bugs.launchpad.net/redminelocalavatars/+bug/1069808/comments/4) ### Old version on launchpad Tested on Redmine trunk r4388 (version 1.0.3). Should be compatible with all Redmine versions 1.0.x. At the moment the plugin doesn't work when running in development mode. ## Authors * A.Chaika wrote the original version: * http://www.redmine.org/boards/3/topics/5365 * https://github.com/Ubik/redmine_local_avatars * https://github.com/ncoders/redmine_local_avatars Luca Pireddu at CRS4 (http://www.crs4.it), contributed updates and improvements. ## Warranty. What warranty? This plugin was written for use in an intranet with simple requirements in mind. In particular, not much attention has been payed to security issues and there hasn't been any thorough testing. Use it at your own risk. Patches are welcome. ## Implementation Notes Avatar images are treated as attachments to User objects with the description 'avatar'. The AccountController is patched to provide the images, and the UsersController and MyController are patched to provide mechanisms to add/delete avatars. ## License Copyright (C) 2010 Andrew Chaika, Luca Pireddu Copyright (C) 2015 dup2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. redmine_local_avatars-1.0.1/app/000077500000000000000000000000001254472357600166265ustar00rootroot00000000000000redmine_local_avatars-1.0.1/app/views/000077500000000000000000000000001254472357600177635ustar00rootroot00000000000000redmine_local_avatars-1.0.1/app/views/hooks/000077500000000000000000000000001254472357600211065ustar00rootroot00000000000000redmine_local_avatars-1.0.1/app/views/hooks/redmine_local_avatars/000077500000000000000000000000001254472357600254245ustar00rootroot00000000000000_view_my_account_contextual.html.erb000066400000000000000000000001011254472357600345720ustar00rootroot00000000000000redmine_local_avatars-1.0.1/app/views/hooks/redmine_local_avatars- <%= link_to(l(:button_change_avatar), :action => 'avatar') %> redmine_local_avatars-1.0.1/app/views/my/000077500000000000000000000000001254472357600204105ustar00rootroot00000000000000redmine_local_avatars-1.0.1/app/views/my/_avatar.html.erb000066400000000000000000000007251254472357600234660ustar00rootroot00000000000000

<%= l(:label_avatar)%>

<%= avatar(@user, :size => "128") %>

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