2021-07-15 09:08:06 +00:00
class Admin :: OfficialModuleController < OrbitAdminController
2021-07-15 10:59:12 +00:00
2021-07-15 09:08:06 +00:00
def set_master_key
@master_password = MasterPassword . first rescue nil
if @master_password . nil?
@master_password = MasterPassword . new
end
2021-07-19 11:52:42 +00:00
render :layout = > " structure "
2021-07-15 09:08:06 +00:00
end
def update_master_password
master_password = MasterPassword . first rescue nil
if master_password . nil?
master_password = MasterPassword . create ( password_params )
else
master_password . update_attributes ( password_params )
master_password . save
end
# emails = User.all.collect{|u| u.member_profile.email rescue nil}
# emails.delete(nil)
# Email.new({
# "mail_to" => emails,
# "mail_subject" => "Master password changed.",
# "mail_content" => "Master password has been changed for all the sites. Please login with the new password. The new password is : <h3>#{password_params[:password]}</h3>"
# }).deliver
redirect_to admin_site_set_master_key_path ( current_site )
end
2021-07-19 11:52:42 +00:00
def index
@managers = ServerAbilityManager . all . order_by ( sort )
. with_categories ( filters ( " category " ) )
. with_tags ( filters ( " tag " ) ) . desc ( :created_at )
@table_fields = [ " site_name_layout " , " max_site_ability " , " site_num " , " site_ip " ]
@tags = @module_app . tags
@categories = @module_app . categories . enabled
@filter_fields = filter_fields_without_status ( @categories , @tags )
@managers = search_data ( @managers , [ :title , :site_domain ] ) . page ( params [ :page ] ) . per ( 10 )
if request . xhr?
render :partial = > " index "
end
end
def set_server_ability
store_token = params [ :official_module_id ]
@manager = ServerAbilityManager . where ( store_token : store_token ) . first || ServerAbilityManager . new ( id : nil )
end
def update_server_ability
manager_params = params . require ( :server_ability_manager ) . permit!
store_token = manager_params [ :store_token ]
manager = ServerAbilityManager . where ( store_token : store_token ) . first
if manager . nil?
r_site = RegisteredSite . where ( uid : store_token ) . first
manager = ServerAbilityManager . create ( store_token : store_token , site_name : r_site . title , site_url : r_site . site_domain , site_ip : r_site . real_ip || r_site . ip [ 0 ] )
end
manager . update_attributes ( manager_params )
redirect_to :action = > " index "
end
def delete
store_token = params [ :official_module_id ]
ServerAbilityManager . where ( store_token : store_token ) . first . destroy
redirect_to :action = > " index "
end
2021-07-15 09:08:06 +00:00
private
def password_params
params . require ( :master_password ) . permit!
end
end