forked from edavis10/redmine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@4 e93f8b46-1217-0410-a6f0-8f06a7374b81
- Loading branch information
Showing
284 changed files
with
12,752 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. | ||
|
||
require(File.join(File.dirname(__FILE__), 'config', 'boot')) | ||
|
||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
require 'tasks/rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# redMine - project management software | ||
# Copyright (C) 2006 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 AccountController < ApplicationController | ||
layout 'base' | ||
# prevents login action to be filtered by check_if_login_required application scope filter | ||
skip_before_filter :check_if_login_required, :only => :login | ||
before_filter :require_login, :except => [:show, :login] | ||
|
||
def show | ||
@user = User.find(params[:id]) | ||
end | ||
|
||
# Login request and validation | ||
def login | ||
if request.get? | ||
session[:user] = nil | ||
@user = User.new | ||
else | ||
@user = User.new(params[:user]) | ||
logged_in_user = @user.try_to_login | ||
if logged_in_user | ||
session[:user] = logged_in_user | ||
redirect_back_or_default :controller => 'account', :action => 'my_page' | ||
else | ||
flash[:notice] = _('Invalid user/password') | ||
end | ||
end | ||
end | ||
|
||
# Log out current user and redirect to welcome page | ||
def logout | ||
session[:user] = nil | ||
redirect_to(:controller => '') | ||
end | ||
|
||
def my_page | ||
@user = session[:user] | ||
@reported_issues = Issue.find(:all, :conditions => ["author_id=?", @user.id], :limit => 10, :include => [ :status, :project, :tracker ], :order => 'issues.updated_on DESC') | ||
@assigned_issues = Issue.find(:all, :conditions => ["assigned_to_id=?", @user.id], :limit => 10, :include => [ :status, :project, :tracker ], :order => 'issues.updated_on DESC') | ||
end | ||
|
||
# Edit current user's account | ||
def my_account | ||
@user = User.find(session[:user].id) | ||
if request.post? and @user.update_attributes(@params[:user]) | ||
flash[:notice] = 'Account was successfully updated.' | ||
session[:user] = @user | ||
set_localization | ||
end | ||
end | ||
|
||
# Change current user's password | ||
def change_password | ||
@user = User.find(session[:user].id) | ||
if @user.check_password?(@params[:old_password]) | ||
if @params[:new_password] == @params[:new_password_confirmation] | ||
if @user.change_password(@params[:old_password], @params[:new_password]) | ||
flash[:notice] = 'Password was successfully updated.' | ||
end | ||
else | ||
flash[:notice] = 'Password confirmation doesn\'t match!' | ||
end | ||
else | ||
flash[:notice] = 'Wrong password' | ||
end | ||
render :action => 'my_account' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# redMine - project management software | ||
# Copyright (C) 2006 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 AdminController < ApplicationController | ||
layout 'base' | ||
before_filter :require_admin | ||
|
||
helper :sort | ||
include SortHelper | ||
|
||
def index | ||
end | ||
|
||
def projects | ||
sort_init 'projects.name', 'asc' | ||
sort_update | ||
@project_pages, @projects = paginate :projects, :per_page => 15, :order => sort_clause | ||
end | ||
|
||
def mail_options | ||
@actions = Permission.find(:all, :conditions => ["mail_option=?", true]) || [] | ||
if request.post? | ||
@actions.each { |a| | ||
a.mail_enabled = params[:action_ids].include? a.id.to_s | ||
a.save | ||
} | ||
flash[:notice] = "Mail options were successfully updated." | ||
end | ||
end | ||
|
||
def info | ||
@adapter_name = ActiveRecord::Base.connection.adapter_name | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# redMine - project management software | ||
# Copyright (C) 2006 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 ApplicationController < ActionController::Base | ||
before_filter :check_if_login_required, :set_localization | ||
|
||
# check if login is globally required to access the application | ||
def check_if_login_required | ||
require_login if RDM_LOGIN_REQUIRED | ||
end | ||
|
||
def set_localization | ||
Localization.lang = session[:user].nil? ? RDM_DEFAULT_LANG : (session[:user].language || RDM_DEFAULT_LANG) | ||
end | ||
|
||
def require_login | ||
unless session[:user] | ||
store_location | ||
redirect_to(:controller => "account", :action => "login") | ||
end | ||
end | ||
|
||
def require_admin | ||
if session[:user].nil? | ||
store_location | ||
redirect_to(:controller => "account", :action => "login") | ||
else | ||
unless session[:user].admin? | ||
flash[:notice] = "Acces not allowed" | ||
redirect_to(:controller => "projects", :action => "list") | ||
end | ||
end | ||
end | ||
|
||
# authorizes the user for the requested action. | ||
def authorize | ||
# check if action is allowed on public projects | ||
if @project.public? and Permission.allowed_to_public "%s/%s" % [ @params[:controller], @params[:action] ] | ||
return true | ||
end | ||
# if user is not logged in, he is redirect to login form | ||
unless session[:user] | ||
store_location | ||
redirect_to(:controller => "account", :action => "login") | ||
return false | ||
end | ||
# check if user is authorized | ||
if session[:user].admin? or Permission.allowed_to_role( "%s/%s" % [ @params[:controller], @params[:action] ], session[:user].role_for_project(@project.id) ) | ||
return true | ||
end | ||
flash[:notice] = "Acces denied" | ||
redirect_to(:controller => "") | ||
return false | ||
end | ||
|
||
# store current uri in the session. | ||
# we can return to this location by calling redirect_back_or_default | ||
def store_location | ||
session[:return_to] = @request.request_uri | ||
end | ||
|
||
# move to the last store_location call or to the passed default one | ||
def redirect_back_or_default(default) | ||
if session[:return_to].nil? | ||
redirect_to default | ||
else | ||
redirect_to_url session[:return_to] | ||
session[:return_to] = nil | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# redMine - project management software | ||
# Copyright (C) 2006 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 CustomFieldsController < ApplicationController | ||
layout 'base' | ||
before_filter :require_admin | ||
|
||
def index | ||
list | ||
render :action => 'list' | ||
end | ||
|
||
def list | ||
@custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 10 | ||
end | ||
|
||
def new | ||
if request.get? | ||
@custom_field = CustomField.new | ||
else | ||
@custom_field = CustomField.new(params[:custom_field]) | ||
if @custom_field.save | ||
flash[:notice] = 'CustomField was successfully created.' | ||
redirect_to :action => 'list' | ||
end | ||
end | ||
end | ||
|
||
def edit | ||
@custom_field = CustomField.find(params[:id]) | ||
if request.post? and @custom_field.update_attributes(params[:custom_field]) | ||
flash[:notice] = 'CustomField was successfully updated.' | ||
redirect_to :action => 'list' | ||
end | ||
end | ||
|
||
def destroy | ||
CustomField.find(params[:id]).destroy | ||
redirect_to :action => 'list' | ||
rescue | ||
flash[:notice] = "Unable to delete custom field" | ||
redirect_to :action => 'list' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# redMine - project management software | ||
# Copyright (C) 2006 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 DocumentsController < ApplicationController | ||
layout 'base' | ||
before_filter :find_project, :authorize | ||
|
||
def show | ||
end | ||
|
||
def edit | ||
@categories = Enumeration::get_values('DCAT') | ||
if request.post? and @document.update_attributes(params[:document]) | ||
flash[:notice] = 'Document was successfully updated.' | ||
redirect_to :action => 'show', :id => @document | ||
end | ||
end | ||
|
||
def destroy | ||
@document.destroy | ||
redirect_to :controller => 'projects', :action => 'list_documents', :id => @project | ||
end | ||
|
||
def download | ||
@attachment = @document.attachments.find(params[:attachment_id]) | ||
@attachment.increment_download | ||
send_file @attachment.diskfile, :filename => @attachment.filename | ||
end | ||
|
||
def add_attachment | ||
# Save the attachment | ||
if params[:attachment][:file].size > 0 | ||
@attachment = @document.attachments.build(params[:attachment]) | ||
@attachment.author_id = session[:user].id unless session[:user].nil? | ||
@attachment.save | ||
end | ||
render :action => 'show' | ||
end | ||
|
||
def destroy_attachment | ||
@document.attachments.find(params[:attachment_id]).destroy | ||
render :action => 'show' | ||
end | ||
|
||
private | ||
def find_project | ||
@document = Document.find(params[:id]) | ||
@project = @document.project | ||
end | ||
|
||
end |
Oops, something went wrong.