Revision 443:350acce374a2 app/controllers
| app/controllers/application_controller.rb | ||
|---|---|---|
| 267 | 267 |
uri = URI.parse(back_url) |
| 268 | 268 |
# do not redirect user to another host or to the login or register page |
| 269 | 269 |
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
|
| 270 |
# soundsoftware: if back_url is the home page, |
|
| 271 |
# change it to My Page (#125) |
|
| 272 |
if (uri.path == home_path) |
|
| 273 |
uri.path = uri.path + "/my" |
|
| 274 |
end |
|
| 270 | 275 |
# soundsoftware: if login page is https but back_url http, |
| 271 | 276 |
# switch back_url to https to ensure cookie validity (#83) |
| 272 | 277 |
if (uri.scheme == "http") && (URI.parse(request.url).scheme == "https") |
| 273 | 278 |
uri.scheme = "https" |
| 274 |
back_url = uri.to_s |
|
| 275 | 279 |
end |
| 280 |
back_url = uri.to_s |
|
| 276 | 281 |
redirect_to(back_url) |
| 277 | 282 |
return |
| 278 | 283 |
end |
| app/controllers/attachments_controller.rb | ||
|---|---|---|
| 16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | 17 |
|
| 18 | 18 |
class AttachmentsController < ApplicationController |
| 19 |
|
|
| 19 | 20 |
before_filter :find_project |
| 20 | 21 |
before_filter :file_readable, :read_authorize, :except => :destroy |
| 21 | 22 |
before_filter :delete_authorize, :only => :destroy |
| 23 |
before_filter :active_authorize, :only => :toggle_active |
|
| 22 | 24 |
|
| 23 | 25 |
verify :method => :post, :only => :destroy |
| 24 | 26 |
|
| ... | ... | |
| 54 | 56 |
redirect_to :controller => 'projects', :action => 'show', :id => @project |
| 55 | 57 |
end |
| 56 | 58 |
|
| 59 |
def toggle_active |
|
| 60 |
@attachment.active = !@attachment.active? |
|
| 61 |
@attachment.save! |
|
| 62 |
render :layout => false |
|
| 63 |
end |
|
| 64 |
|
|
| 57 | 65 |
private |
| 58 | 66 |
def find_project |
| 59 | 67 |
@attachment = Attachment.find(params[:id]) |
| ... | ... | |
| 77 | 85 |
@attachment.deletable? ? true : deny_access |
| 78 | 86 |
end |
| 79 | 87 |
|
| 88 |
def active_authorize |
|
| 89 |
true |
|
| 90 |
end |
|
| 91 |
|
|
| 80 | 92 |
def detect_content_type(attachment) |
| 81 | 93 |
content_type = attachment.content_type |
| 82 | 94 |
if content_type.blank? |
| app/controllers/files_controller.rb | ||
|---|---|---|
| 8 | 8 |
include SortHelper |
| 9 | 9 |
|
| 10 | 10 |
def index |
| 11 |
sort_init 'filename', 'asc'
|
|
| 11 |
sort_init 'active', 'desc'
|
|
| 12 | 12 |
sort_update 'filename' => "#{Attachment.table_name}.filename",
|
| 13 |
'active' => "#{Attachment.table_name}.active",
|
|
| 13 | 14 |
'created_on' => "#{Attachment.table_name}.created_on",
|
| 14 | 15 |
'size' => "#{Attachment.table_name}.filesize",
|
| 15 | 16 |
'downloads' => "#{Attachment.table_name}.downloads"
|
| ... | ... | |
| 33 | 34 |
end |
| 34 | 35 |
redirect_to project_files_path(@project) |
| 35 | 36 |
end |
| 37 |
|
|
| 36 | 38 |
end |
| app/controllers/members_controller.rb | ||
|---|---|---|
| 28 | 28 |
attrs = params[:member].dup |
| 29 | 29 |
if (user_ids = attrs.delete(:user_ids)) |
| 30 | 30 |
user_ids.each do |user_id| |
| 31 |
members << Member.new(attrs.merge(:user_id => user_id)) |
|
| 31 |
@new_member = Member.new(attrs.merge(:user_id => user_id)) |
|
| 32 |
members << @new_member |
|
| 33 |
|
|
| 34 |
# send notification to member |
|
| 35 |
Mailer.deliver_added_to_project(@new_member, @project) |
|
| 36 |
|
|
| 32 | 37 |
end |
| 33 | 38 |
else |
| 34 |
members << Member.new(attrs) |
|
| 39 |
@new_member = Member.new(attrs) |
|
| 40 |
members << @new_member |
|
| 41 |
|
|
| 42 |
# send notification to member |
|
| 43 |
Mailer.deliver_added_to_project(@new_member, @project) |
|
| 44 |
|
|
| 35 | 45 |
end |
| 46 |
|
|
| 36 | 47 |
@project.members << members |
| 48 |
|
|
| 37 | 49 |
end |
| 38 | 50 |
respond_to do |format| |
| 39 | 51 |
if members.present? && members.all? {|m| m.valid? }
|
| ... | ... | |
| 54 | 66 |
errors = members.collect {|m|
|
| 55 | 67 |
m.errors.full_messages |
| 56 | 68 |
}.flatten.uniq |
| 57 |
|
|
| 58 |
page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
|
|
| 69 |
|
|
| 70 |
# page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
|
|
| 59 | 71 |
} |
| 60 | 72 |
} |
| 61 | 73 |
|
| app/controllers/my_controller.rb | ||
|---|---|---|
| 25 | 25 |
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
| 26 | 26 |
'issuesreportedbyme' => :label_reported_issues, |
| 27 | 27 |
'issueswatched' => :label_watched_issues, |
| 28 |
'activitymyprojects' => :label_activity_my_recent, |
|
| 28 | 29 |
'news' => :label_news_latest, |
| 30 |
'tipoftheday' => :label_tipoftheday, |
|
| 29 | 31 |
'calendar' => :label_calendar, |
| 30 | 32 |
'documents' => :label_document_plural, |
| 31 | 33 |
'timelog' => :label_spent_time |
| 32 | 34 |
}.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze |
| 33 | 35 |
|
| 34 |
DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'],
|
|
| 35 |
'right' => ['issuesreportedbyme']
|
|
| 36 |
DEFAULT_LAYOUT = { 'left' => ['tipoftheday', 'activitymyprojects'],
|
|
| 37 |
'right' => ['issueswatched','calendar']
|
|
| 36 | 38 |
}.freeze |
| 37 | 39 |
|
| 38 | 40 |
verify :xhr => true, |
| app/controllers/projects_controller.rb | ||
|---|---|---|
| 56 | 56 |
@offset ||= @project_pages.current.offset |
| 57 | 57 |
@projects = Project.visible_roots.all(:offset => @offset, :limit => @limit, :order => sort_clause) |
| 58 | 58 |
if User.current.logged? |
| 59 |
@user_projects = User.current.projects.sort_by(&:name) |
|
| 59 |
# seems sort_by gives us case-sensitive ordering, which we don't want |
|
| 60 |
# @user_projects = User.current.projects.sort_by(&:name) |
|
| 61 |
@user_projects = User.current.projects.all(:order => :name) |
|
| 60 | 62 |
end |
| 61 | 63 |
render :template => 'projects/index.rhtml', :layout => !request.xhr? |
| 62 | 64 |
} |
| ... | ... | |
| 215 | 217 |
end |
| 216 | 218 |
|
| 217 | 219 |
verify :method => :post, :only => :modules, :render => {:nothing => true, :status => :method_not_allowed }
|
| 220 |
|
|
| 221 |
def overview |
|
| 222 |
@project.has_welcome_page = params[:has_welcome_page] |
|
| 223 |
if @project.save |
|
| 224 |
flash[:notice] = l(:notice_successful_update) |
|
| 225 |
end |
|
| 226 |
redirect_to :action => 'settings', :id => @project, :tab => 'overview' |
|
| 227 |
end |
|
| 228 |
|
|
| 218 | 229 |
def modules |
| 219 | 230 |
@project.enabled_module_names = params[:enabled_module_names] |
| 220 | 231 |
flash[:notice] = l(:notice_successful_update) |
| app/controllers/repositories_controller.rb | ||
|---|---|---|
| 36 | 36 |
|
| 37 | 37 |
def edit |
| 38 | 38 |
@repository = @project.repository |
| 39 |
if !@repository && !params[:repository_scm].blank? |
|
| 39 |
|
|
| 40 |
if !@repository |
|
| 41 |
|
|
| 42 |
params[:repository_scm]='Mercurial' |
|
| 43 |
|
|
| 40 | 44 |
@repository = Repository.factory(params[:repository_scm]) |
| 41 | 45 |
@repository.project = @project if @repository |
| 42 | 46 |
end |
| ... | ... | |
| 55 | 59 |
@repository.merge_extra_info(p_extra) |
| 56 | 60 |
@repository.save |
| 57 | 61 |
end |
| 62 |
|
|
| 58 | 63 |
render(:update) do |page| |
| 59 | 64 |
page.replace_html "tab-content-repository", |
| 60 | 65 |
:partial => 'projects/settings/repository' |
| app/controllers/sys_controller.rb | ||
|---|---|---|
| 55 | 55 |
render :nothing => true, :status => 404 |
| 56 | 56 |
end |
| 57 | 57 |
|
| 58 |
def get_external_repo_url |
|
| 59 |
project = Project.find(params[:id]) |
|
| 60 |
if project.repository |
|
| 61 |
repo = project.repository |
|
| 62 |
if repo.is_external? |
|
| 63 |
render :text => repo.external_url, :status => 200 |
|
| 64 |
else |
|
| 65 |
render :nothing => true, :status => 200 |
|
| 66 |
end |
|
| 67 |
end |
|
| 68 |
rescue ActiveRecord::RecordNotFound |
|
| 69 |
render :nothing => true, :status => 404 |
|
| 70 |
end |
|
| 71 |
|
|
| 72 |
def clear_repository_cache |
|
| 73 |
project = Project.find(params[:id]) |
|
| 74 |
if project.repository |
|
| 75 |
project.repository.clear_cache |
|
| 76 |
end |
|
| 77 |
render :nothing => true, :status => 200 |
|
| 78 |
rescue ActiveRecord::RecordNotFound |
|
| 79 |
render :nothing => true, :status => 404 |
|
| 80 |
end |
|
| 81 |
|
|
| 58 | 82 |
def set_embedded_active |
| 59 | 83 |
project = Project.find(params[:id]) |
| 60 | 84 |
mods = project.enabled_modules |
| app/controllers/welcome_controller.rb | ||
|---|---|---|
| 18 | 18 |
class WelcomeController < ApplicationController |
| 19 | 19 |
caches_action :robots |
| 20 | 20 |
|
| 21 |
include ProjectsHelper |
|
| 22 |
helper :projects |
|
| 23 |
|
|
| 21 | 24 |
def index |
| 22 |
@news = News.latest User.current |
|
| 25 |
@site_project = Project.find_by_identifier "soundsoftware-site" |
|
| 26 |
@site_news = [] |
|
| 27 |
@site_news = News.latest_for @site_project if @site_project |
|
| 23 | 28 |
@projects = Project.latest User.current |
| 24 | 29 |
|
| 25 |
# tests if user is logged in to gfenerate the tips of the day list
|
|
| 30 |
# tests if user is logged in to generate the tips of the day list |
|
| 26 | 31 |
if User.current.logged? |
| 27 | 32 |
@tipsoftheday = Setting.tipoftheday_text |
| 28 | 33 |
else |
Also available in: Unified diff