OSDN Git Service

settings are now stored in the database (config_custom.rb no more used) and editable...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 21 Jan 2007 11:50:22 +0000 (11:50 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 21 Jan 2007 11:50:22 +0000 (11:50 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@167 e93f8b46-1217-0410-a6f0-8f06a7374b81

44 files changed:
app/controllers/account_controller.rb
app/controllers/application.rb
app/controllers/settings_controller.rb [new file with mode: 0644]
app/controllers/users_controller.rb
app/helpers/application_helper.rb
app/helpers/settings_helper.rb [new file with mode: 0644]
app/models/attachment.rb
app/models/mailer.rb
app/models/setting.rb [new file with mode: 0644]
app/models/user.rb
app/views/account/login.rhtml
app/views/admin/index.rhtml
app/views/documents/_form.rhtml
app/views/documents/show.rhtml
app/views/feeds/news.rxml
app/views/issues/edit.rhtml
app/views/issues/show.rhtml
app/views/layouts/base.rhtml
app/views/mailer/_issue.rhtml
app/views/mailer/lost_password_de.rhtml
app/views/mailer/lost_password_en.rhtml
app/views/mailer/lost_password_es.rhtml
app/views/mailer/lost_password_fr.rhtml
app/views/mailer/register_de.rhtml
app/views/mailer/register_en.rhtml
app/views/mailer/register_es.rhtml
app/views/mailer/register_fr.rhtml
app/views/news/_form.rhtml
app/views/projects/add_document.rhtml
app/views/projects/add_file.rhtml
app/views/projects/add_issue.rhtml
app/views/settings/edit.rhtml [new file with mode: 0644]
app/views/welcome/index.rhtml
config/config_custom.example.rb [deleted file]
config/environment.rb
config/settings.yml [new file with mode: 0644]
db/migrate/017_create_settings.rb [new file with mode: 0644]
doc/CHANGELOG
doc/INSTALL
doc/UPGRADING
lib/tasks/load_default_data.rake
public/images/22x22/settings.png [new file with mode: 0644]
public/stylesheets/application.css
test/unit/project_test.rb

index fb775d1..c3b0ebd 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
@@ -95,7 +95,7 @@ class AccountController < ApplicationController
   \r
   # User self-registration\r
   def register\r
-    redirect_to :controller => '' and return if $RDM_SELF_REGISTRATION == false\r
+    redirect_to :controller => '' and return unless Setting.self_registration?\r
     if params[:token]\r
       token = Token.find_by_action_and_value("register", params[:token])\r
       redirect_to :controller => '' and return unless token and !token.expired?\r
@@ -110,7 +110,7 @@ class AccountController < ApplicationController
       end      \r
     else\r
       if request.get?\r
-        @user = User.new(:language => $RDM_DEFAULT_LANG)\r
+        @user = User.new(:language => Setting.default_language)\r
         @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }\r
       else\r
         @user = User.new(params[:user])\r
index da01e09..bae05ce 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
@@ -33,7 +33,7 @@ class ApplicationController < ActionController::Base
   \r
   # check if login is globally required to access the application\r
   def check_if_login_required\r
-    require_login if $RDM_LOGIN_REQUIRED\r
+    require_login if Setting.login_required?\r
   end \r
   \r
   def set_localization\r
@@ -48,7 +48,7 @@ class ApplicationController < ActionController::Base
       end\r
     rescue\r
       nil\r
-    end || $RDM_DEFAULT_LANG\r
+    end || Setting.default_language\r
     set_language_if_valid(lang)    \r
   end\r
   \r
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
new file mode 100644 (file)
index 0000000..229a4ab
--- /dev/null
@@ -0,0 +1,33 @@
+# redMine - project management software
+# Copyright (C) 2006-2007  Jean-Philippe Lang
+#
+# 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.
+
+class SettingsController < ApplicationController
+  layout 'base'        
+  before_filter :require_admin
+  
+  def index
+    edit
+    render :action => 'edit'
+  end
+
+  def edit
+    if request.post? and params[:settings] and params[:settings].is_a? Hash
+      params[:settings].each { |name, value| Setting[name] = value }
+      redirect_to :action => 'edit' and return
+    end
+  end
+end
index 4c403a8..14f8ecf 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
@@ -45,7 +45,7 @@ class UsersController < ApplicationController
 
   def add
     if request.get?\r
-      @user = User.new(:language => $RDM_DEFAULT_LANG)\r
+      @user = User.new(:language => Setting.default_language)\r
       @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }\r
     else
       @user = User.new(params[:user])\r
index 0f0d577..748a1d7 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
@@ -93,7 +93,7 @@ module ApplicationHelper
   end\r
   \r
   def textilizable(text)\r
-    $RDM_TEXTILE_DISABLED ? simple_format(auto_link(h(text))) : RedCloth.new(h(text)).to_html\r
+    (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? RedCloth.new(h(text)).to_html : simple_format(auto_link(h(text)))\r
   end\r
   \r
   def error_messages_for(object_name, options = {})\r
@@ -131,8 +131,9 @@ module ApplicationHelper
     end\r
   end\r
   \r
-  def lang_options_for_select\r
-    [["(auto)", ""]] + (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}\r
+  def lang_options_for_select(blank=true)\r
+    (blank ? [["(auto)", ""]] : []) + \r
+      (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}\r
   end\r
   \r
   def label_tag_for(name, option_tags = nil, options = {})\r
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
new file mode 100644 (file)
index 0000000..f53314c
--- /dev/null
@@ -0,0 +1,19 @@
+# redMine - project management software
+# Copyright (C) 2006-2007  Jean-Philippe Lang
+#
+# 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 SettingsHelper
+end
index cdf5a3e..773f2eb 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
@@ -21,12 +21,15 @@ class Attachment < ActiveRecord::Base
   belongs_to :container, :polymorphic => true\r
   belongs_to :author, :class_name => "User", :foreign_key => "author_id"\r
   \r
-  @@max_size = $RDM_ATTACHMENT_MAX_SIZE || 5*1024*1024\r
-  cattr_reader :max_size\r
-\r
   validates_presence_of :container, :filename\r
-  validates_inclusion_of :filesize, :in => 1..@@max_size\r
   \r
+  cattr_accessor :storage_path\r
+  @@storage_path = "#{RAILS_ROOT}/files"\r
+  \r
+  def validate\r
+    errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes\r
+  end\r
+\r
        def file=(incomming_file)\r
                unless incomming_file.nil?\r
                        @temp_file = incomming_file\r
@@ -63,7 +66,7 @@ class Attachment < ActiveRecord::Base
        \r
        # Returns file's location on disk\r
        def diskfile\r
-               "#{$RDM_STORAGE_PATH}/#{self.disk_filename}"\r
+               "#{@@storage_path}/#{self.disk_filename}"\r
        end\r
   \r
   def increment_download\r
index 968beb4..ba93b5b 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
 \r
 class Mailer < ActionMailer::Base\r
-\r
   helper IssuesHelper
 
   def issue_add(issue)
     # Sends to all project members
     @recipients     = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
-    @from           = $RDM_MAIL_FROM
+    @from           = Setting.mail_from
     @subject        = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
     @body['issue']  = issue\r
   end\r
@@ -31,7 +30,7 @@ class Mailer < ActionMailer::Base
     # Sends to all project members\r
     issue = journal.journalized\r
     @recipients     = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact\r
-    @from           = $RDM_MAIL_FROM\r
+    @from           = Setting.mail_from\r
     @subject        = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"\r
     @body['issue']  = issue\r
     @body['journal']= journal\r
@@ -39,14 +38,14 @@ class Mailer < ActionMailer::Base
   \r
   def lost_password(token)\r
     @recipients     = token.user.mail\r
-    @from           = $RDM_MAIL_FROM\r
+    @from           = Setting.mail_from\r
     @subject        = l(:mail_subject_lost_password)\r
     @body['token']  = token\r
   end  
 \r
   def register(token)\r
     @recipients     = token.user.mail\r
-    @from           = $RDM_MAIL_FROM\r
+    @from           = Setting.mail_from\r
     @subject        = l(:mail_subject_register)\r
     @body['token']  = token\r
   end\r
diff --git a/app/models/setting.rb b/app/models/setting.rb
new file mode 100644 (file)
index 0000000..7350d91
--- /dev/null
@@ -0,0 +1,61 @@
+# redMine - project management software
+# Copyright (C) 2006-2007  Jean-Philippe Lang
+#
+# 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.
+
+class Setting < ActiveRecord::Base
+
+  cattr_accessor :available_settings
+  @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml"))
+
+  validates_uniqueness_of :name
+  validates_inclusion_of :name, :in => @@available_settings.keys
+  validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' }  
+  
+  def self.get(name)
+    name = name.to_s
+    setting = find_by_name(name)
+    setting ||= new(:name => name, :value => @@available_settings[name]['default']) if @@available_settings.has_key? name
+    setting
+  end
+  
+  def self.[](name)
+    get(name).value
+  end
+  
+  def self.[]=(name, value)
+    setting = get(name)
+    setting.value = value
+    setting.save
+    setting.value
+  end
+  
+  @@available_settings.each do |name, params|
+    src = <<-END_SRC
+    def self.#{name}
+      self[:#{name}]
+    end
+
+    def self.#{name}?
+      self[:#{name}].to_s == "1"
+    end
+
+    def self.#{name}=(value)
+      self[:#{name}] = values
+    end
+    END_SRC
+    class_eval src, __FILE__, __LINE__
+  end
+end
index b798860..8a59616 100644 (file)
@@ -1,5 +1,5 @@
 # redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
 #\r
 # This program is free software; you can redistribute it and/or\r
 # modify it under the terms of the GNU General Public License\r
@@ -69,7 +69,7 @@ class User < ActiveRecord::Base
       if attrs\r
         onthefly = new(*attrs)\r
         onthefly.login = login\r
-        onthefly.language = $RDM_DEFAULT_LANG\r
+        onthefly.language = Setting.default_language\r
         if onthefly.save\r
           user = find(:first, :conditions => ["login=?", login])\r
           logger.info("User '#{user.login}' created on the fly.") if logger\r
index 8f092b5..346f7d5 100644 (file)
@@ -12,7 +12,7 @@
 <p><center><input type="submit" name="login" value="<%=l(:button_login)%> &#187;" class="primary" /></center>
 <%= end_form_tag %>\r
 \r
-<br><% unless $RDM_SELF_REGISTRATION == false %><%= link_to l(:label_register), :action => 'register' %> |<% end %>\r
+<br><% if Setting.self_registration? %><%= link_to l(:label_register), :action => 'register' %> |<% end %>\r
 <%= link_to l(:label_password_lost), :action => 'lost_password' %></p>
 </div>\r
 </center>
\ No newline at end of file
index 901134c..535a90b 100644 (file)
 <%= link_to l(:label_authentication), :controller => 'auth_sources' %>\r
 </p>\r
 \r
+<p class="icon22 icon22-settings">\r
+<%= link_to l(:label_settings), :controller => 'settings' %>\r
+</p>\r
+\r
 <p class="icon22 icon22-info">\r
 <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>\r
 </p>
\ No newline at end of file
index 873c963..b075b46 100644 (file)
@@ -14,7 +14,7 @@
 <!--[eoform:document]-->
 </div>
 
-<% unless $RDM_TEXTILE_DISABLED %>
+<% if Setting.text_formatting == 'textile' %>
 <%= javascript_include_tag 'jstoolbar' %>
 <script type="text/javascript">
 //<![CDATA[
index dab360e..d756aad 100644 (file)
@@ -31,7 +31,7 @@
   <%= start_form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") %>\r
     <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>\r
     <%= image_to_function "add.png", "addFileField();return false" %></label>\r
-    <%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p>\r
+    <%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>\r
   <%= submit_tag l(:button_add) %>\r
   <%= end_form_tag %> \r
 <% end %>\r
index 50d4a9a..41fb0ca 100644 (file)
@@ -1,10 +1,10 @@
 xml.instruct!\r
 xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do\r
   xml.channel do\r
-    xml.title "#{$RDM_HEADER_TITLE}: #{l(:label_news_latest)}"\r
+    xml.title "#{Setting.header_title}: #{l(:label_news_latest)}"\r
     xml.link url_for(:controller => '', :only_path => false)\r
     xml.pubDate CGI.rfc1123_date(@news.first.created_on)\r
-    xml.description "#{$RDM_HEADER_TITLE}: #{l(:label_news_latest)}"\r
+    xml.description l(:label_news_latest)\r
     @news.each do |news|\r
       xml.item do\r
         xml.title "#{news.project.name}: #{news.title}"\r
index da3805c..78fc4a7 100644 (file)
@@ -34,7 +34,7 @@
 <%= submit_tag l(:button_save) %>
 <% end %>
 
-<% unless $RDM_TEXTILE_DISABLED %>
+<% if Setting.text_formatting == 'textile' %>
 <%= javascript_include_tag 'jstoolbar' %>
 <script type="text/javascript">
 //<![CDATA[
index f2441f9..29adf66 100644 (file)
@@ -93,7 +93,7 @@ end %>
   <%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %>\r
   <p id="attachments_p"><label><%=l(:label_attachment_new)%>\r
   <%= image_to_function "add.png", "addFileField();return false" %></label>\r
-  <%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p>\r
+  <%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>\r
   <%= submit_tag l(:button_add) %>\r
   <%= end_form_tag %> \r
 <% end %>\r
index 4768f29..e4c35b6 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
 <head>\r
-<title><%= $RDM_HEADER_TITLE + (@html_title ? ": #{@html_title}" : "") %></title>\r
+<title><%= Setting.header_title + (@html_title ? ": #{@html_title}" : "") %></title>\r
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />\r
 <meta name="description" content="redMine" />\r
 <meta name="keywords" content="issue,bug,tracker" />\r
@@ -23,8 +23,8 @@
 \r
     <div id="header">\r
     <div style="float: left;">\r
-        <h1><%= $RDM_HEADER_TITLE %></h1>\r
-        <h2><%= $RDM_HEADER_SUBTITLE %></h2>\r
+        <h1><%= Setting.header_title %></h1>\r
+        <h2><%= Setting.header_subtitle %></h2>\r
     </div>\r
     <div style="float: right; padding-right: 1em; padding-top: 0.2em;">\r
       <% if loggedin? %><small><%=l(:label_logged_as)%> <b><%= @logged_in_user.login %></b></small><% end %>\r
@@ -69,6 +69,7 @@
         <a class="menuItem" href="/enumerations"><%=l(:label_enumerations)%></a>\r
         <a class="menuItem" href="/admin/mail_options"><%=l(:field_mail_notification)%></a>\r
         <a class="menuItem" href="/auth_sources"><%=l(:label_authentication)%></a>\r
+        <a class="menuItem" href="/settings"><%=l(:label_settings)%></a>\r
         <a class="menuItem" href="/admin/info"><%=l(:label_information_plural)%></a>\r
     </div>\r
     <div id="menuTrackers" class="menu">\r
        </div>\r
        \r
        <div id="footer">\r
-               <p>\r
-               <%= auto_link $RDM_FOOTER_SIG %> |\r
-               <a href="http://redmine.rubyforge.org/"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %>\r
-               </p>\r
+               <p><a href="http://redmine.rubyforge.org/"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %></p>\r
        </div>\r
 \r
 </div>\r
index c123ae3..4c5255d 100644 (file)
@@ -4,4 +4,4 @@
 
 <%= issue.description %>\r
 \r
-http://<%= $RDM_HOST_NAME %>/issues/show/<%= issue.id %>
\ No newline at end of file
+http://<%= Setting.host_name %>/issues/show/<%= issue.id %>
\ No newline at end of file
index 2593edb..0b39149 100644 (file)
@@ -1,3 +1,3 @@
 To change your password, use the following link:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
index 2593edb..0b39149 100644 (file)
@@ -1,3 +1,3 @@
 To change your password, use the following link:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
index 2593edb..0b39149 100644 (file)
@@ -1,3 +1,3 @@
 To change your password, use the following link:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
index 30996f1..18b6bf6 100644 (file)
@@ -1,3 +1,3 @@
 Pour changer votre mot de passe, utilisez le lien suivant:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %>
\ No newline at end of file
index 2c0341b..95cc7c4 100644 (file)
@@ -1,3 +1,3 @@
 To activate your redMine account, use the following link:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/register?token=<%= @token.value %>
\ No newline at end of file
index 2c0341b..95cc7c4 100644 (file)
@@ -1,3 +1,3 @@
 To activate your redMine account, use the following link:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/register?token=<%= @token.value %>
\ No newline at end of file
index 2c0341b..95cc7c4 100644 (file)
@@ -1,3 +1,3 @@
 To activate your redMine account, use the following link:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/register?token=<%= @token.value %>
\ No newline at end of file
index 3f5d0cc..402b2a5 100644 (file)
@@ -1,3 +1,3 @@
 Pour activer votre compte sur redMine, utilisez le lien suivant:\r
 \r
-http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %>
\ No newline at end of file
+http://<%= Setting.host_name %>/account/register?token=<%= @token.value %>
\ No newline at end of file
index 2dcdc9f..497c071 100644 (file)
@@ -5,7 +5,7 @@
 <p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15 %></p>
 </div>
 
-<% unless $RDM_TEXTILE_DISABLED %>
+<% if Setting.text_formatting == 'textile' %>
 <%= javascript_include_tag 'jstoolbar' %>
 <script type="text/javascript">
 //<![CDATA[
index b570eab..57a6275 100644 (file)
@@ -6,7 +6,7 @@
 <div class="box">\r
 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
 <%= image_to_function "add.png", "addFileField();return false" %></label>
-<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p>
+<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
 </div>
 \r
 <%= submit_tag l(:button_create) %>
index baffbe8..6efc1d2 100644 (file)
@@ -9,7 +9,7 @@
 \r
 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>\r
 <%= image_to_function "add.png", "addFileField();return false" %></label>\r
-<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p>\r
+<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>\r
 </div>\r
 <%= submit_tag l(:button_add) %>\r
 <%= end_form_tag %> 
\ No newline at end of file
index 951b53b..fd463b5 100644 (file)
@@ -27,7 +27,7 @@
 \r
 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
 <%= image_to_function "add.png", "addFileField();return false" %></label>
-<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p>
+<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
 
 </div>
 <!--[eoform:issue]-->
@@ -35,7 +35,7 @@
 <%= submit_tag l(:button_create) %>\r
 <% end %>
 
-<% unless $RDM_TEXTILE_DISABLED %>
+<% if Setting.text_formatting == 'textile' %>
 <%= javascript_include_tag 'jstoolbar' %>
 <script type="text/javascript">
 //<![CDATA[
diff --git a/app/views/settings/edit.rhtml b/app/views/settings/edit.rhtml
new file mode 100644 (file)
index 0000000..fcbb40f
--- /dev/null
@@ -0,0 +1,37 @@
+<h2><%= l(:label_settings) %></h2>
+
+<%= start_form_tag({:action => 'edit'}, :class => "tabular") %>
+<div class="box">
+<p><label>header_title</label>
+<%= text_field_tag 'settings[header_title]', Setting.header_title, :size => 30 %></p>
+
+<p><label>header_subtitle</label>
+<%= text_field_tag 'settings[header_subtitle]', Setting.header_subtitle, :size => 60 %></p>
+
+<p><label>welcome_text</label>
+<%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5 %></p>
+
+<p><label>default_language</label>
+<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
+
+<p><label>login_required</label>
+<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p>
+
+<p><label>self_registration</label>
+<%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p>
+
+<p><label>attachment_max_size</label>
+<%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %></p>
+
+<p><label>mail_from</label>
+<%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p>
+
+<p><label>host_name</label>
+<%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p>
+
+<p><label>text_formatting</label>
+<%= select_tag 'settings[text_formatting]', options_for_select( [[l(:label_none), 0], ["textile", "textile"]], Setting.text_formatting) %></p>
+
+</div>
+<%= submit_tag l(:button_save) %>
+<%= end_form_tag %>
\ No newline at end of file
index d32771c..95683c8 100644 (file)
@@ -1,7 +1,7 @@
-<h2><%= $RDM_WELCOME_TITLE || l(:label_home) %></h2>\r
+<h2><%= l(:label_home) %></h2>\r
 \r
 <div class="splitcontentleft">\r
-  <% if $RDM_WELCOME_TEXT %><p><%= $RDM_WELCOME_TEXT %></p><br /><% end %>\r
+  <p><%= Setting.welcome_text %></p>\r
   <div class="box">\r
        <h3><%=l(:label_news_latest)%></h3>
                <%= render :partial => 'news/news', :collection => @news %>\r
diff --git a/config/config_custom.example.rb b/config/config_custom.example.rb
deleted file mode 100644 (file)
index b00e716..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-# redMine - project management software\r
-# Copyright (C) 2006  Jean-Philippe Lang\r
-#\r
-# This program is free software; you can redistribute it and/or\r
-# modify it under the terms of the GNU General Public License\r
-# as published by the Free Software Foundation; either version 2\r
-# of the License, or (at your option) any later version.\r
-# \r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-# GNU General Public License for more details.\r
-# \r
-# You should have received a copy of the GNU General Public License\r
-# along with this program; if not, write to the Free Software\r
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
-\r
-\r
-# To set your own configuration, rename this file to config_custom.rb\r
-# and edit parameters below\r
-# Don't forget to restart the application after any change.\r
-\r
-\r
-# Application host name\r
-# Used to provide absolute links in mail notifications\r
-# $RDM_HOST_NAME = "somenet.foo"\r
-\r
-# File storage path\r
-# Directory used to store uploaded files\r
-# #{RAILS_ROOT} represents application's home directory\r
-# $RDM_STORAGE_PATH = "#{RAILS_ROOT}/files"\r
-\r
-# Set $RDM_LOGIN_REQUIRED to true if you want to force users to login\r
-# to access any page of the application\r
-# $RDM_LOGIN_REQUIRED = false\r
-\r
-# Uncomment to disable user self-registration\r
-# $RDM_SELF_REGISTRATION = false\r
-\r
-# Default langage ('en', 'es', 'de', 'fr' are available)\r
-# $RDM_DEFAULT_LANG = 'en'\r
-\r
-# Email adress used to send mail notifications\r
-# $RDM_MAIL_FROM = "redmine@somenet.foo"\r
-\r
-# Page title\r
-# $RDM_HEADER_TITLE = "Title"\r
-\r
-# Page sub-title\r
-# $RDM_HEADER_SUBTITLE = "Sub title"\r
-\r
-# Welcome page title\r
-# $RDM_WELCOME_TITLE = "Welcome"\r
-\r
-# Welcome page text\r
-# $RDM_WELCOME_TEXT = ""\r
-\r
-# Signature displayed in footer\r
-# Email adresses will be automatically displayed as a mailto link\r
-# $RDM_FOOTER_SIG = "admin@somenet.foo"\r
-\r
-# Textile formatting (only available if RedCloth is installed)\r
-# Textile formatting is automativaly disabled if RedCloth is not available\r
-# Set to true to manually disable.\r
-# $RDM_TEXTILE_DISABLED = true\r
-\r
-# Maximum size for attachments (in bytes)\r
-# Default to 5 MB\r
-# $RDM_ATTACHMENT_MAX_SIZE = 5*1024*1024\r
index 201051b..3edc93e 100644 (file)
@@ -68,47 +68,11 @@ end
 #   inflect.uncountable %w( fish sheep )
 # end
 
-if File.exist? File.join(File.dirname(__FILE__), 'config_custom.rb')
-  begin
-    print "=> Loading config_custom.rb... "
-    require File.join(File.dirname(__FILE__), 'config_custom') 
-    puts "done."
-  rescue Exception => detail
-    puts
-    puts detail
-    puts detail.backtrace.join("\n")
-    puts "=> Error in config_custom.rb. Check your configuration."
-    exit
-  end
-end
-
 # IMPORTANT !!! DO NOT MODIFY PARAMETERS HERE
 # Instead, rename config_custom.example.rb to config_custom.rb 
 # and set your own configuration in that file
 # Parameters defined in config_custom.rb override those defined below
 
-# application host name\r
-$RDM_HOST_NAME ||= "localhost:3000"\r
-# file storage path\r
-$RDM_STORAGE_PATH ||= "#{RAILS_ROOT}/files"
-# if RDM_LOGIN_REQUIRED is set to true, login is required to access the application\r
-$RDM_LOGIN_REQUIRED ||= false\r
-# default langage\r
-$RDM_DEFAULT_LANG ||= 'en'\r
-# email sender adress
-$RDM_MAIL_FROM ||= "redmine@somenet.foo"
-
-# page title
-$RDM_HEADER_TITLE ||= "redMine"
-# page sub-title\r
-$RDM_HEADER_SUBTITLE ||= "Project management"
-# footer signature
-$RDM_FOOTER_SIG = "admin@somenet.foo"
-
-# textile formatting
-# automaticaly disabled if 'textile' method is not defined (RedCloth unavailable)
-$RDM_TEXTILE_DISABLED = true unless ActionView::Helpers::TextHelper.method_defined? "textilize"
-
 # application name
 RDM_APP_NAME = "redMine" 
 # application version
@@ -131,7 +95,7 @@ ActiveRecord::Errors.default_error_messages = {
 
 ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
     
-GLoc.set_config :default_language => $RDM_DEFAULT_LANG
+GLoc.set_config :default_language => :en
 GLoc.clear_strings
 GLoc.set_kcode
 GLoc.load_localized_strings
diff --git a/config/settings.yml b/config/settings.yml
new file mode 100644 (file)
index 0000000..d6b3dfc
--- /dev/null
@@ -0,0 +1,42 @@
+# redMine - project management software\r
+# Copyright (C) 2006-2007  Jean-Philippe Lang\r
+#\r
+# This program is free software; you can redistribute it and/or\r
+# modify it under the terms of the GNU General Public License\r
+# as published by the Free Software Foundation; either version 2\r
+# of the License, or (at your option) any later version.\r
+# \r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+# GNU General Public License for more details.\r
+# \r
+# You should have received a copy of the GNU General Public License\r
+# along with this program; if not, write to the Free Software\r
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
+\r
+\r
+# DO NOT MODIFY THIS FILE !!!\r
+# Settings can be defined through the application in Admin -> Settings\r
+\r
+header_title:\r
+  default: redMine\r
+header_subtitle:\r
+  default: Project management\r
+welcome_text:\r
+  default:\r
+login_required:\r
+  default: 0\r
+self_registration:\r
+  default: 1\r
+attachment_max_size:\r
+  format: int\r
+  default: 5120\r
+mail_from:\r
+  default: redmine@somenet.foo\r
+text_formatting:\r
+  default: textile\r
+default_language:\r
+  default: en\r
+host_name:\r
+  default: localhost:3000
\ No newline at end of file
diff --git a/db/migrate/017_create_settings.rb b/db/migrate/017_create_settings.rb
new file mode 100644 (file)
index 0000000..99f96ad
--- /dev/null
@@ -0,0 +1,12 @@
+class CreateSettings < ActiveRecord::Migration
+  def self.up
+    create_table :settings, :force => true do |t|
+      t.column "name", :string, :limit => 30, :default => "", :null => false
+      t.column "value", :text
+    end
+  end
+
+  def self.down
+    drop_table :settings
+  end
+end
index bbd824d..0373e46 100644 (file)
@@ -5,7 +5,16 @@ Copyright (C) 2006-2007  Jean-Philippe Lang
 http://redmine.rubyforge.org/\r
 \r
 \r
-== 03/02/2006 v0.4.1\r
+== xx/xx/2006 v0.4.2\r
+\r
+* settings are now stored in the database (config_custom.rb no more used) and editable through the application in: Admin -> Settings\r
+* tooltips added on Gantt chart and calender to view the details of the issues\r
+* all icons replaced (new icons are based on GPL icon set: "KDE Crystal Diamond 2.5" -by paolino- and "kNeu! Alpha v0.1" -by Pablo Fabregat-)\r
+* added back "fixed version" field on issue screen and in filters\r
+* fixed: subprojects count is always 0 on projects list\r
+\r
+\r
+== 01/03/2006 v0.4.1\r
 \r
 * fixed: emails have no recipient when one of the project members has notifications disabled\r
 \r
index f55b81a..4afe11a 100644 (file)
@@ -13,6 +13,7 @@ http://redmine.rubyforge.org/
 \r
 Optional:\r
 * RedCloth (to enable textile formatting)\r
+* SVN binaries (needed for repository browsing, must be available in PATH)\r
 \r
 Supported databases:\r
 * MySQL (tested with MySQL 5)\r
@@ -57,14 +58,12 @@ Supported databases:
 \r
 == Configuration\r
 \r
-A sample configuration file is provided: "config/config_custom.example.rb"\r
-Rename it to config_custom.rb and set your parameters.\r
-Don't forget to restart the application after any change.\r
-\r
 In config/environment.rb, you can set parameters for your SMTP server:\r
 config.action_mailer.server_settings: SMTP server configuration\r
 config.action_mailer.perform_deliveries: set to false to disable mail delivering\r
 \r
+Don't forget to restart the application after any change.\r
+\r
 \r
 == Upgrading\r
 \r
index cc4008a..f42b5b3 100644 (file)
@@ -4,19 +4,19 @@ redMine - project management software
 Copyright (C) 2006-2007  Jean-Philippe Lang\r
 http://redmine.rubyforge.org/\r
 \r
-== From 0.3.0\r
+\r
+== From 0.3.0 and above\r
 \r
 1. Uncompress program archive in a new directory:\r
    tar zxvf <filename>\r
    \r
-3. Copy your database (database.yml) and configuration settings (config_custom.rb)\r
-   into the new config directory\r
+3. Copy your database settings (database.yml) into the new config directory\r
    \r
 4. Migrate your database:\r
    rake migrate RAILS_ENV="production"\r
    \r
    \r
-== From 0.2.x and previous\r
+== From 0.2.x and below\r
 \r
 Due to major database changes since 0.2.x, there is no migration support\r
 from 0.2.x and previous versions.\r
index f5a1605..12e0efd 100644 (file)
@@ -2,7 +2,7 @@ desc 'Load default configuration data'
 \r
 task :load_default_data => :environment do\r
   include GLoc\r
-  set_language_if_valid($RDM_DEFAULT_LANG)\r
+  set_language_if_valid('en')\r
   puts\r
   \r
   while true\r
diff --git a/public/images/22x22/settings.png b/public/images/22x22/settings.png
new file mode 100644 (file)
index 0000000..54a3b47
Binary files /dev/null and b/public/images/22x22/settings.png differ
index bb18b5f..0a3a3f4 100644 (file)
@@ -176,6 +176,7 @@ vertical-align: middle;
 .icon22-info { background-image: url(../images/22x22/info.png); }\r
 .icon22-comment { background-image: url(../images/22x22/comment.png); }\r
 .icon22-package { background-image: url(../images/22x22/package.png); }\r
+.icon22-settings { background-image: url(../images/22x22/settings.png); }\r
 \r
 /**************** Content styles ****************/\r
 \r
index 9c8f0c9..d8d29c6 100644 (file)
@@ -42,7 +42,7 @@ class ProjectTest < Test::Unit::TestCase
     @ecookbook.name = ""
     assert !@ecookbook.save
     assert_equal 1, @ecookbook.errors.count
-    assert_equal l(:activerecord_error_blank), @ecookbook.errors.on(:name)
+    assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name)
   end
   
   def test_public_projects