72 lines
2.6 KiB
Ruby
72 lines
2.6 KiB
Ruby
class Admin::OfficialModuleController < OrbitAdminController
|
|
|
|
def set_master_key
|
|
@master_password = MasterPassword.first rescue nil
|
|
if @master_password.nil?
|
|
@master_password = MasterPassword.new
|
|
end
|
|
render :layout => "structure"
|
|
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
|
|
|
|
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
|
|
private
|
|
|
|
def password_params
|
|
params.require(:master_password).permit!
|
|
end
|
|
|
|
end |