| 
									
										
										
										
											2019-03-16 09:37:35 +00:00
										 |  |  | # frozen_string_literal: true | 
					
						
							| 
									
										
										
										
											2019-03-15 01:32:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-27 05:49:47 +00:00
										 |  |  | # Redmine - project management software | 
					
						
							| 
									
										
										
										
											2022-01-02 05:29:10 +00:00
										 |  |  | # Copyright (C) 2006-2022  Jean-Philippe Lang | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | # | 
					
						
							|  |  |  | # 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. | 
					
						
							| 
									
										
										
										
											2011-08-27 05:49:47 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | # 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. | 
					
						
							| 
									
										
										
										
											2011-08-27 05:49:47 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2009-12-17 18:21:02 +00:00
										 |  |  |   layout 'admin' | 
					
						
							| 
									
										
										
										
											2016-11-19 10:30:02 +00:00
										 |  |  |   self.main_menu = false | 
					
						
							| 
									
										
										
										
											2012-01-20 20:02:04 +00:00
										 |  |  |   menu_item :projects, :only => :projects | 
					
						
							|  |  |  |   menu_item :plugins, :only => :plugins | 
					
						
							|  |  |  |   menu_item :info, :only => :info | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-14 07:27:31 +00:00
										 |  |  |   before_action :require_admin | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-05 11:33:49 +00:00
										 |  |  |   def index | 
					
						
							|  |  |  |     @no_configuration_data = Redmine::DefaultData::Loader::no_data? | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-02-17 10:14:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   def projects | 
					
						
							| 
									
										
										
										
											2011-12-04 22:31:02 +00:00
										 |  |  |     @status = params[:status] || 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-02 20:44:11 +00:00
										 |  |  |     scope = Project.status(@status).sorted | 
					
						
							| 
									
										
										
										
											2011-12-04 22:31:02 +00:00
										 |  |  |     scope = scope.like(params[:name]) if params[:name].present? | 
					
						
							| 
									
										
										
										
											2016-08-30 20:10:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     @project_count = scope.count | 
					
						
							|  |  |  |     @project_pages = Paginator.new @project_count, per_page_option, params['page'] | 
					
						
							|  |  |  |     @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     render :action => "projects", :layout => false if request.xhr? | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-04-25 23:21:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-16 11:58:41 +00:00
										 |  |  |   def plugins | 
					
						
							| 
									
										
										
										
											2008-11-16 15:38:37 +00:00
										 |  |  |     @plugins = Redmine::Plugin.all | 
					
						
							| 
									
										
										
										
											2008-11-16 11:58:41 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-04-25 23:21:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-05 11:33:49 +00:00
										 |  |  |   # Loads the default configuration | 
					
						
							|  |  |  |   # (roles, trackers, statuses, workflow, enumerations) | 
					
						
							|  |  |  |   def default_configuration | 
					
						
							|  |  |  |     if request.post? | 
					
						
							|  |  |  |       begin | 
					
						
							|  |  |  |         Redmine::DefaultData::Loader::load(params[:lang]) | 
					
						
							|  |  |  |         flash[:notice] = l(:notice_default_data_loaded) | 
					
						
							| 
									
										
										
										
											2019-05-25 06:50:25 +00:00
										 |  |  |       rescue => e | 
					
						
							| 
									
										
										
										
											2015-02-17 17:47:36 +00:00
										 |  |  |         flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message)) | 
					
						
							| 
									
										
										
										
											2008-01-05 11:33:49 +00:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-12-11 17:51:30 +00:00
										 |  |  |     redirect_to admin_path | 
					
						
							| 
									
										
										
										
											2008-01-05 11:33:49 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-04-25 23:21:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-14 10:36:19 +00:00
										 |  |  |   def test_email | 
					
						
							|  |  |  |     begin | 
					
						
							| 
									
										
										
										
											2018-10-10 17:13:09 +00:00
										 |  |  |       Mailer.deliver_test_email(User.current) | 
					
						
							| 
									
										
										
										
											2015-02-17 17:47:36 +00:00
										 |  |  |       flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail)) | 
					
						
							| 
									
										
										
										
											2019-05-25 06:50:25 +00:00
										 |  |  |     rescue => e | 
					
						
							| 
									
										
										
										
											2015-02-17 17:47:36 +00:00
										 |  |  |       flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup))) | 
					
						
							| 
									
										
										
										
											2007-08-14 10:36:19 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-12-11 17:51:30 +00:00
										 |  |  |     redirect_to settings_path(:tab => 'notifications') | 
					
						
							| 
									
										
										
										
											2007-08-14 10:36:19 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-04-25 23:21:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   def info | 
					
						
							| 
									
										
										
										
											2009-12-19 20:33:24 +00:00
										 |  |  |     @checklist = [ | 
					
						
							| 
									
										
										
										
											2012-04-09 15:53:48 +00:00
										 |  |  |       [:text_default_administrator_account_changed, User.default_admin_account_changed?], | 
					
						
							| 
									
										
										
										
											2009-12-19 20:33:24 +00:00
										 |  |  |       [:text_file_repository_writable, File.writable?(Attachment.storage_path)], | 
					
						
							| 
									
										
										
										
											2014-10-22 19:10:12 +00:00
										 |  |  |       ["#{l :text_plugin_assets_writable} (./public/plugin_assets)",   File.writable?(Redmine::Plugin.public_directory)], | 
					
						
							| 
									
										
										
										
											2021-07-30 03:51:19 +00:00
										 |  |  |       [:text_all_migrations_have_been_run, !ActiveRecord::Base.connection.migration_context.needs_migration?], | 
					
						
							| 
									
										
										
										
											2019-08-14 02:40:56 +00:00
										 |  |  |       [:text_minimagick_available,     Object.const_defined?(:MiniMagick)], | 
					
						
							| 
									
										
										
										
											2019-05-12 03:55:56 +00:00
										 |  |  |       [:text_convert_available,        Redmine::Thumbnail.convert_available?], | 
					
						
							|  |  |  |       [:text_gs_available,             Redmine::Thumbnail.gs_available?] | 
					
						
							| 
									
										
										
										
											2009-12-19 20:33:24 +00:00
										 |  |  |     ] | 
					
						
							| 
									
										
										
										
											2011-04-25 23:21:34 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2006-06-28 18:11:03 +00:00
										 |  |  | end |