Revision 1298:4f746d8966dd .svn/pristine/3d

View differences:

.svn/pristine/3d/3d264827557eaf8b65d3068714787c51e68d02b2.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class DocumentCategoryCustomField < CustomField
19
  def type_name
20
    :enumeration_doc_categories
21
  end
22
end
.svn/pristine/3d/3d3b405886b53d97a18acfbd6ee1f68a9fd0e1c4.svn-base
1
<h2><%=l(:button_change_password)%></h2>
2

  
3
<%= error_messages_for 'user' %>
4

  
5
<% form_tag({}, :class => "tabular") do %>
6
<div class="box">
7
<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
8
<%= password_field_tag 'password', nil, :size => 25 %></p>
9

  
10
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
11
<%= password_field_tag 'new_password', nil, :size => 25 %><br />
12
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
13

  
14
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
15
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
16
</div>
17
<%= submit_tag l(:button_apply) %>
18
<% end %>
19

  
20
<% content_for :sidebar do %>
21
<%= render :partial => 'sidebar' %>
22
<% end %>
.svn/pristine/3d/3d503edadd13a313e0e3661d47e1156ded0be542.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class Watcher < ActiveRecord::Base
19
  belongs_to :watchable, :polymorphic => true
20
  belongs_to :user
21

  
22
  validates_presence_of :user
23
  validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
24

  
25
  # Unwatch things that users are no longer allowed to view
26
  def self.prune(options={})
27
    if options.has_key?(:user)
28
      prune_single_user(options[:user], options)
29
    else
30
      pruned = 0
31
      User.find(:all, :conditions => "id IN (SELECT DISTINCT user_id FROM #{table_name})").each do |user|
32
        pruned += prune_single_user(user, options)
33
      end
34
      pruned
35
    end
36
  end
37

  
38
  protected
39

  
40
  def validate
41
    errors.add :user_id, :invalid unless user.nil? || user.active?
42
  end
43

  
44
  private
45

  
46
  def self.prune_single_user(user, options={})
47
    return unless user.is_a?(User)
48
    pruned = 0
49
    find(:all, :conditions => {:user_id => user.id}).each do |watcher|
50
      next if watcher.watchable.nil?
51

  
52
      if options.has_key?(:project)
53
        next unless watcher.watchable.respond_to?(:project) && watcher.watchable.project == options[:project]
54
      end
55

  
56
      if watcher.watchable.respond_to?(:visible?)
57
        unless watcher.watchable.visible?(user)
58
          watcher.destroy
59
          pruned += 1
60
        end
61
      end
62
    end
63
    pruned
64
  end
65
end
.svn/pristine/3d/3d6522340e1723225cb18ddbafc5c9dc0b5f8799.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class IssueCategory < ActiveRecord::Base
19
  include Redmine::SafeAttributes
20
  belongs_to :project
21
  belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
22
  has_many :issues, :foreign_key => 'category_id', :dependent => :nullify
23

  
24
  validates_presence_of :name
25
  validates_uniqueness_of :name, :scope => [:project_id]
26
  validates_length_of :name, :maximum => 30
27

  
28
  safe_attributes 'name', 'assigned_to_id'
29

  
30
  scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
31

  
32
  alias :destroy_without_reassign :destroy
33

  
34
  # Destroy the category
35
  # If a category is specified, issues are reassigned to this category
36
  def destroy(reassign_to = nil)
37
    if reassign_to && reassign_to.is_a?(IssueCategory) && reassign_to.project == self.project
38
      Issue.update_all({:category_id => reassign_to.id}, {:category_id => id})
39
    end
40
    destroy_without_reassign
41
  end
42

  
43
  def <=>(category)
44
    name <=> category.name
45
  end
46

  
47
  def to_s; name end
48
end
.svn/pristine/3d/3d7003238eceffbbaba3bf34003b59ea441ffc00.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
module Redmine
19
  module Activity
20

  
21
    mattr_accessor :available_event_types, :default_event_types, :providers
22

  
23
    @@available_event_types = []
24
    @@default_event_types = []
25
    @@providers = Hash.new {|h,k| h[k]=[] }
26

  
27
    class << self
28
      def map(&block)
29
        yield self
30
      end
31

  
32
      # Registers an activity provider
33
      def register(event_type, options={})
34
        options.assert_valid_keys(:class_name, :default)
35

  
36
        event_type = event_type.to_s
37
        providers = options[:class_name] || event_type.classify
38
        providers = ([] << providers) unless providers.is_a?(Array)
39

  
40
        @@available_event_types << event_type unless @@available_event_types.include?(event_type)
41
        @@default_event_types << event_type unless options[:default] == false
42
        @@providers[event_type] += providers
43
      end
44
    end
45
  end
46
end

Also available in: Unified diff