Merge branch 'various_bugs' into nccu_master
Conflicts: Gemfile.lock app/assets/javascripts/ajax_form.js.erb app/assets/stylesheets/style.css.erb app/controllers/application_controller.rb app/controllers/sessions_controller.rb app/helpers/admin/web_link_helper.rb app/views/admin/attributes/_attribute_field.html.erb app/views/admin/designs/_form.html.erb app/views/admin/pages/_form.html.erb app/views/admin/sites/_side_bar.html.erb app/views/layouts/_orbit_bar.html.erb app/views/layouts/_side_bar.html.erb config/locales/en.yml config/locales/zh_tw.yml config/mongoid.yml vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_filter.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_filter_status.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_news_bulletin.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/index.html.erb vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb
This commit is contained in:
commit
65ac6980c4
2087 files changed
+80434
-3692
No files matched your search
@@ -1,8 +1,10 @@
|
||||
class Admin::AdBannersController < OrbitBackendController
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :force_order_for_visitor,:only=>[:index]
|
||||
#before_filter :force_order_for_user,:except => [:index]
|
||||
before_filter :for_app_sub_manager,:except => [:index]
|
||||
before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview]
|
||||
before_filter :for_app_sub_manager
|
||||
|
||||
|
||||
def rename
|
||||
@ad_banner = AdBanner.find(params[:id])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Admin::DashboardsController < ApplicationController
|
||||
|
||||
class Admin::DashboardsController < OrbitBackendController
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
#before_filter :set_current_user
|
||||
#before_filter :authenticate_user!, :except => [:index]
|
||||
# before_filter :is_admin?
|
||||
|
||||
def index
|
||||
|
||||
@@ -34,14 +34,37 @@ class Admin::DesignsController < OrbitBackendController
|
||||
|
||||
def update
|
||||
@design = Design.find(params[:id])
|
||||
if @design.update_attributes(params[:design])
|
||||
flash[:notice] = "Successfully updated design and tasks."
|
||||
redirect_to admin_designs_url(@design)
|
||||
else
|
||||
render :action => 'edit'
|
||||
@design.update_attributes(params[:design])
|
||||
# if @design.update_attributes(params[:design])
|
||||
# flash[:notice] = "Successfully updated design and tasks."
|
||||
# redirect_to admin_designs_url(@design)
|
||||
# else
|
||||
# render :action => 'edit'
|
||||
# end
|
||||
|
||||
respond_to do |format|
|
||||
format.js {nil}
|
||||
end
|
||||
end
|
||||
|
||||
def update_file
|
||||
@design = Design.find(params[:id])
|
||||
case params[:type]
|
||||
when 'layout', 'css_default', 'css_reset'
|
||||
@object = @design.send(params[:type])
|
||||
when 'image', 'javascript', 'theme'
|
||||
@object = @design.send(params[:type]).find(params[:object_id])
|
||||
end
|
||||
|
||||
Dir.mktmpdir('f_path') { |dir|
|
||||
temp_file = File.new(dir + '/' + File.basename(@object.file.url), 'w+')
|
||||
temp_file.write(params[:file][:content].force_encoding('UTF-8'))
|
||||
@object.remove_file!
|
||||
@object.file = temp_file
|
||||
@object.save
|
||||
}
|
||||
end
|
||||
|
||||
def edit_file
|
||||
@design = Design.find(params[:id])
|
||||
filename = params[:filename]
|
||||
@@ -91,6 +114,13 @@ class Admin::DesignsController < OrbitBackendController
|
||||
end
|
||||
redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
|
||||
end
|
||||
|
||||
def upload_image
|
||||
@design = Design.find(params[:id])
|
||||
@image = @design.images.build(params[:image])
|
||||
@image.save
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -98,7 +128,6 @@ class Admin::DesignsController < OrbitBackendController
|
||||
Zip::ZipFile.open(file) { |zip_file|
|
||||
design = Design.new.from_json(zip_file.read("#{zip_name}/info.json"))
|
||||
Dir.mktmpdir('f_path') { |dir|
|
||||
design.build_layout
|
||||
themes_entries = []
|
||||
javascripts_entries = []
|
||||
images_entries = []
|
||||
@@ -106,25 +135,11 @@ class Admin::DesignsController < OrbitBackendController
|
||||
zip_file.entries.each do |entry|
|
||||
case (path = entry.to_s)
|
||||
when /\A(#{zip_name})\/(default\.css)\z/ #for default css
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
default_css = design.build_default_css
|
||||
default_css.file = temp_file
|
||||
default_css.to_save = true
|
||||
design.build_css_default(:file => get_temp_file(zip_file, dir, entry))
|
||||
when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
reset_css = design.build_reset_css
|
||||
reset_css.file = temp_file
|
||||
reset_css.to_save = true
|
||||
design.build_css_reset(:file => get_temp_file(zip_file, dir, entry))
|
||||
when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
design.layout.file = temp_file
|
||||
design.layout.to_save=true
|
||||
design.build_layout(:file => get_temp_file(zip_file, dir, entry))
|
||||
when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/ #for themes css
|
||||
themes_entries << entry
|
||||
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
|
||||
@@ -136,12 +151,7 @@ class Admin::DesignsController < OrbitBackendController
|
||||
|
||||
['themes', 'javascripts', 'images'].each do |type|
|
||||
eval("#{type}_entries").each do |entry|
|
||||
filename = File.basename entry.to_s
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry).force_encoding('UTF-8')
|
||||
build_and_store = eval("design.#{type}").build
|
||||
build_and_store.file = temp_file
|
||||
build_and_store.to_save = true
|
||||
eval("design.#{type}").build(:file => get_temp_file(zip_file, dir, entry))
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -149,4 +159,11 @@ class Admin::DesignsController < OrbitBackendController
|
||||
}
|
||||
end
|
||||
|
||||
def get_temp_file(zip_file, dir, entry)
|
||||
filename = File.basename(entry.to_s)
|
||||
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||
temp_file
|
||||
end
|
||||
|
||||
end
|
||||
@@ -32,6 +32,7 @@ class Admin::InfosController < ApplicationController
|
||||
|
||||
def update
|
||||
@attribute = Info.find(params[:id])
|
||||
# binding.pry
|
||||
@attribute.update_attributes(params[:info])
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :action => :index }
|
||||
|
||||
@@ -12,6 +12,11 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
def reload_frontend_pages
|
||||
@categories =[]
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
|
||||
@frontend_path = @module_app.widgets.keys[0] if ( !@module_app.widgets.blank? && @module_app.widgets[0].blank? )
|
||||
|
||||
@frontend_style = @module_app.widgets[@frontend_path] if ( !@frontend_path.blank? )
|
||||
|
||||
case @module_app.key
|
||||
when 'announcement'
|
||||
@categories = BulletinCategory.all
|
||||
@@ -22,6 +27,9 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
when 'archive'
|
||||
@categories = ArchiveFileCategory.all
|
||||
@tags = ArchiveTag.all
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
|
||||
@@ -6,7 +6,7 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController
|
||||
layout "new_admin"
|
||||
|
||||
def setting
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
@module_app = ModuleApp.find(params[:module_app_id])
|
||||
@options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] }
|
||||
# if params.has_key? :category
|
||||
|
||||
@@ -4,6 +4,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
|
||||
|
||||
def setting
|
||||
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
@ob_auth = ObjectAuth.find params[:object_auth_id]
|
||||
@options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] }
|
||||
|
||||
@@ -26,6 +26,13 @@ class Admin::PagePartsController < ApplicationController
|
||||
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
|
||||
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
|
||||
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
|
||||
|
||||
if @module_app.widgets.any?{|b| b.class == Array}
|
||||
@widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
|
||||
end
|
||||
|
||||
case @module_app.key
|
||||
when 'announcement'
|
||||
@categories = BulletinCategory.all
|
||||
@@ -36,6 +43,9 @@ class Admin::PagePartsController < ApplicationController
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
when 'archive'
|
||||
@categories = ArchiveFileCategory.all
|
||||
@tags = ArchiveTag.all
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,6 +55,10 @@ class Admin::PagePartsController < ApplicationController
|
||||
|
||||
def update
|
||||
@part = PagePart.find(params[:id])
|
||||
|
||||
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type] ) if params[:page_part][:widget_field]
|
||||
params[:page_part][:widget_field_type] = nil
|
||||
|
||||
if @part.update_attributes(params[:page_part])
|
||||
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
|
||||
flash.now[:notice] = t('update.success.content')
|
||||
@@ -76,7 +90,11 @@ class Admin::PagePartsController < ApplicationController
|
||||
def reload_widgets
|
||||
@categories =[]
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
|
||||
|
||||
@widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? )
|
||||
|
||||
@widget_style = @module_app.widgets[@widget_path] if ( !@widget_path.blank? )
|
||||
|
||||
case @module_app.key
|
||||
when 'announcement'
|
||||
@categories = BulletinCategory.all
|
||||
@@ -87,12 +105,25 @@ class Admin::PagePartsController < ApplicationController
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
when 'archive'
|
||||
@categories = ArchiveFileCategory.all
|
||||
@tags = ArchiveTag.all
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_widget_styles
|
||||
@module_app = ModuleApp.find(params[:module_app_id])
|
||||
|
||||
@widget_style = @module_app.widgets[params[:id]]
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_r_tag_options
|
||||
@r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id]
|
||||
|
||||
@@ -28,10 +28,22 @@ class Admin::PagesController < ApplicationController
|
||||
def edit
|
||||
@item = Page.find(params[:id])
|
||||
@apps = ModuleApp.excludes(app_pages: nil).entries
|
||||
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
|
||||
@designs = Design.all.entries
|
||||
@design = @item.design ? @item.design : @designs.first
|
||||
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
|
||||
|
||||
if @item.module_app
|
||||
@module_app = @item.module_app
|
||||
|
||||
@frontend_path = @item.app_frontend_url ? @item.app_frontend_url : @module_app.widgets.keys[0]
|
||||
|
||||
if @module_app.widgets.any?{|b| b.class == Array}
|
||||
@frontend_style = @module_app.widgets[@frontend_path] if !@frontend_path.blank? && !@module_app.widgets.blank?
|
||||
end
|
||||
|
||||
case @item.module_app.key
|
||||
when 'announcement'
|
||||
@categories = BulletinCategory.all
|
||||
@@ -42,9 +54,13 @@ class Admin::PagesController < ApplicationController
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
when 'archive'
|
||||
@categories = ArchiveFileCategory.all
|
||||
@tags = ArchiveTag.all
|
||||
end
|
||||
else
|
||||
@categories = nil
|
||||
@module_app = @module_apps[0]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,6 +95,9 @@ class Admin::PagesController < ApplicationController
|
||||
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
||||
end
|
||||
|
||||
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) if params[:page][:frontend_field]
|
||||
params[:page][:frontend_field_type] = nil
|
||||
|
||||
if @item.update_attributes(params[:page])
|
||||
flash[:notice] = t('update.success.page')
|
||||
respond_to do |format|
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class Admin::PluginsController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
|
||||
def index
|
||||
|
||||
@plugins = OrbitApp::Module::Registration.all
|
||||
|
||||
if(!params[:show_plugin_profile].nil?)
|
||||
@right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary'
|
||||
else
|
||||
@right_partial = "admin/users_new_interface/plugin_summary"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -71,8 +71,8 @@ class Admin::PurchasesController < ApplicationController
|
||||
Dir.mktmpdir('f_path') { |dir|
|
||||
|
||||
build_file(orig_zip, zip_name, dir, design.layout) if design.layout
|
||||
build_file(orig_zip, zip_name, dir, design.default_css) if design.default_css
|
||||
build_file(orig_zip, zip_name, dir, design.reset_css) if design.reset_css
|
||||
build_file(orig_zip, zip_name, dir, design.css_default) if design.css_default
|
||||
build_file(orig_zip, zip_name, dir, design.css_reset) if design.css_reset
|
||||
|
||||
['themes', 'javascripts', 'images'].each do |type|
|
||||
design.send(type).each do |object|
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
class Admin::TagsController < ApplicationController
|
||||
class Admin::TagsController < OrbitBackendController
|
||||
before_filter :force_order_for_visitor,:only=>[:index]
|
||||
before_filter :force_order_for_user,:except => [:index]
|
||||
before_filter :for_app_sub_manager,:except => [:index]
|
||||
|
||||
layout 'new_admin'
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :set_module_app
|
||||
|
||||
# layout 'new_admin'
|
||||
# before_filter :authenticate_user!
|
||||
# before_filter :is_admin?
|
||||
# before_filter :set_module_app
|
||||
|
||||
def index
|
||||
get_tags
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
class Admin::UsersNewInterfaceController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
||||
|
||||
def index
|
||||
get_tags
|
||||
get_sub_roles
|
||||
|
||||
page_num = params[:page] || 1
|
||||
@users = []
|
||||
|
||||
render case params[:at]
|
||||
when 'summary'
|
||||
@users=User.page(page_num).per(12).includes('avatar')
|
||||
"index_summary"
|
||||
when 'thumbnail'
|
||||
@users=User.page(page_num).per(36).includes('avatar')
|
||||
"index_thumbnail"
|
||||
else
|
||||
@users=User.page(page_num).per(10).includes('avatar')
|
||||
"index"
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
@plugins = OrbitApp::Module::Registration.all
|
||||
|
||||
@profile_data = []
|
||||
@teacher_data = []
|
||||
@student_data = []
|
||||
@staff_data = []
|
||||
|
||||
|
||||
attribute_values = @user.attribute_values.reject{|att_val|
|
||||
# binding.pry if(att_val.id.to_s == '507fa1295789b52a540000e0')
|
||||
!att_val.attribute_field.locale and (att_val.attribute_field.neutral_for != I18n.locale.to_s)
|
||||
}
|
||||
|
||||
attribute_values.each{|att_val|
|
||||
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false
|
||||
}
|
||||
|
||||
|
||||
if(!params[:show_plugin_profile].nil?)
|
||||
@right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary'
|
||||
else
|
||||
@right_partial = "plugin_summary"
|
||||
end
|
||||
|
||||
# @user.attribute_values.each{|att_val|
|
||||
# @teacher_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
|
||||
# }
|
||||
|
||||
# @user.attribute_values.each{|att_val|
|
||||
# @student_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
|
||||
# }
|
||||
|
||||
# @user.attribute_values.each{|att_val|
|
||||
# @staff_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]})
|
||||
# }
|
||||
|
||||
# [ {:name=> "1",:value =>"Matt"},{:name=> "2",:value =>"Mark"},{:name=> "3",:value =>"Luke"},{:name=> "4",:value =>"John"} ]
|
||||
|
||||
get_info_and_roles
|
||||
end
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
# @disable_all_field = true
|
||||
@form_index = 0
|
||||
get_info_and_roles
|
||||
end
|
||||
|
||||
def create
|
||||
binding.pry
|
||||
puts params.to_yaml
|
||||
# attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values'
|
||||
# attribute_values = params[:user].delete(attribute_values_key)
|
||||
@user = User.new(params["user"])
|
||||
# attribute_values.to_hash.each{|key,value|
|
||||
# @user.attribute_values.build(value)
|
||||
# }
|
||||
# @user.rebuild_sub_roles_from_attribute_values!(attribute_values)
|
||||
if @user.save
|
||||
flash[:notice] = t('create.success.user')
|
||||
redirect_to :action => :index
|
||||
else
|
||||
@form_index = 0
|
||||
render :action => :new
|
||||
end
|
||||
end
|
||||
|
||||
def temp_edit
|
||||
@user = User.find(params[:id])
|
||||
@form_index = 0
|
||||
get_info_and_roles
|
||||
end
|
||||
|
||||
def edit
|
||||
# @disable_all_field = false
|
||||
@user = User.find(params[:id])
|
||||
@form_index = 0
|
||||
get_info_and_roles
|
||||
end
|
||||
|
||||
def update
|
||||
@user = User.find(params[:id])
|
||||
@user.update_attributes(params[:user])
|
||||
attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values'
|
||||
attribute_values = params[:user].delete(attribute_values_key)
|
||||
# @user.rebuild_sub_roles_from_attribute_values!(attribute_values)
|
||||
@user.save
|
||||
redirect_to :action => :show
|
||||
# # Update changes to the avatar
|
||||
# @user.remove_avatar! if params[:file]
|
||||
# @user.avatar = params[:file] if params[:file]
|
||||
|
||||
# if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
|
||||
# flash.now[:error] = t(:cant_revoke_self_admin)
|
||||
# end
|
||||
# if !flash[:error] && @user.update_attributes(params[:user])
|
||||
# flash[:notice] = t('update.success.user')
|
||||
# redirect_to :action => :index
|
||||
# else
|
||||
# get_info_and_roles
|
||||
# render :action => :edit
|
||||
# end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if params[:id].eql?(session['warden.user.user.key'][1].to_s)
|
||||
flash[:error] = t(:cant_delete_self)
|
||||
else
|
||||
@user = User.find(params[:id])
|
||||
@user.destroy
|
||||
end
|
||||
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
protected
|
||||
def get_tags
|
||||
@sub_role_tags = SubRoleTag.all
|
||||
end
|
||||
|
||||
def get_sub_roles
|
||||
@sub_roles = SubRole.all
|
||||
end
|
||||
|
||||
def get_info_and_roles
|
||||
@infos = Info.excludes('disabled' => true)
|
||||
@roles = Role.excludes('disabled' => true)
|
||||
end
|
||||
|
||||
def set_attribute
|
||||
@class = 'users'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,15 +1,15 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
include ParserFrontEnd, ParserBackEnd
|
||||
|
||||
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
|
||||
|
||||
layout :layout_by_resource
|
||||
|
||||
helper :all
|
||||
helper :admin
|
||||
before_filter :set_locale, :set_site
|
||||
|
||||
def set_current_user
|
||||
User.current = current_user
|
||||
User.current = current_or_guest_user
|
||||
end
|
||||
|
||||
def front_end_available(module_app_title='')
|
||||
@@ -48,14 +48,29 @@ class ApplicationController < ActionController::Base
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
# Check if the current_user is admin
|
||||
# Check if the current_user is admin,if not redirect
|
||||
def is_admin?
|
||||
current_user.admin? ? true : auth_failed_in_backend
|
||||
current_or_guest_user.admin? ? true : auth_failed_in_backend
|
||||
end
|
||||
|
||||
def is_manager?
|
||||
@module_app.managing_users.include?(current_user) || is_admin?
|
||||
end
|
||||
# def is_manager?
|
||||
# @module_app.is_manager?(current_or_guest_user) || is_admin?
|
||||
# end
|
||||
|
||||
# # Check if the current_user is admin
|
||||
# def is_member?
|
||||
# if (current_user rescue false)
|
||||
# return true
|
||||
# end
|
||||
# return false
|
||||
# end
|
||||
|
||||
# def is_guest?
|
||||
# if session[:guest_user_id]
|
||||
# return true
|
||||
# end
|
||||
# return false
|
||||
# end
|
||||
|
||||
def for_admin_only
|
||||
if is_admin?
|
||||
@@ -76,7 +91,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def for_app_sub_manager
|
||||
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
|
||||
if (@module_app.sub_managing_users.include?(current_or_guest_user) || is_manager?)
|
||||
true
|
||||
else
|
||||
flash[:error] = t("access.denied.app.not_sub_manager")
|
||||
@@ -85,7 +100,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def for_app_user
|
||||
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
|
||||
if (@module_app.app_auth.auth_users.include?(current_or_guest_user) || for_app_sub_manager )
|
||||
true
|
||||
else
|
||||
flash[:error] = t("access.denied.app.not_authed_user")
|
||||
@@ -95,7 +110,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def check_object_premission(obj,title)
|
||||
flash[:error] = t("access.denied.object")
|
||||
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
|
||||
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_or_guest_user) || is_manager? || is_admin? )
|
||||
end
|
||||
|
||||
# Render the page
|
||||
@@ -191,6 +206,17 @@ class ApplicationController < ActionController::Base
|
||||
[shift_out] + a
|
||||
end
|
||||
end
|
||||
# called (once) when the user logs in, insert any code your application needs
|
||||
# to hand off from guest_user to current_user.
|
||||
def logging_in
|
||||
# For example:
|
||||
# guest_comments = guest_user.comments.all
|
||||
# guest_comments.each do |comment|
|
||||
# comment.user_id = current_user.id
|
||||
# comment.save
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
def render_main_rss
|
||||
ret = ''
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
class DesktopAppstoreController< ApplicationController
|
||||
|
||||
def appstore
|
||||
render "desktop/appstore", :layout => false
|
||||
end
|
||||
|
||||
def widgets
|
||||
render "desktop/appstore/widgets", :layout => false
|
||||
end
|
||||
|
||||
def onlinestore
|
||||
render "desktop/appstore/onlinestore", :layout => false
|
||||
end
|
||||
|
||||
def getuserwidgets
|
||||
@widgets = current_user.desktop.desktop_widgets
|
||||
@groups = Array.new
|
||||
@sections = current_user.desktop.sections
|
||||
|
||||
@sections.each do |section|
|
||||
@groups << section.groups
|
||||
end
|
||||
|
||||
@widgets.each do |widget|
|
||||
@count = 0;
|
||||
@sectionids = Array.new
|
||||
@groups.each do |group|
|
||||
group.each do |grp|
|
||||
@widge = 0
|
||||
@gid = widget.id.to_s
|
||||
@widge = grp.tiles.where(:data_content.all => [@gid]).count
|
||||
@count = @count + @widge
|
||||
if @widge > 0
|
||||
@sectionids << grp.section_id
|
||||
end
|
||||
end
|
||||
end
|
||||
if @count > 0
|
||||
widget.status = "Installed"
|
||||
widget.section = @sectionids
|
||||
else
|
||||
widget.status = "Downloaded"
|
||||
end
|
||||
end
|
||||
render :json=>@widgets.to_json
|
||||
end
|
||||
|
||||
def widgets_settings
|
||||
what = params["what"]
|
||||
@widgetid = params["widget"]
|
||||
@sectionid = params["section"]
|
||||
@msg = Array.new
|
||||
case what
|
||||
when "remove"
|
||||
@section = Section.find(@sectionid)
|
||||
@groups = @section.groups
|
||||
@groups.each do |group|
|
||||
@tile = group.tiles.where(:data_content.all => [@widgetid])
|
||||
if @tile.count > 0
|
||||
@thistile = @tile
|
||||
end
|
||||
end
|
||||
@t = Tile.find(@thistile.first.id)
|
||||
@t.delete
|
||||
@msg << {"success"=>true}
|
||||
when "add"
|
||||
@widget = current_user.desktop.desktop_widgets.find(@widgetid)
|
||||
@section = Section.find(@sectionid)
|
||||
@groups = @section.groups
|
||||
@totalwidgets = 0
|
||||
@groups.each do |group|
|
||||
@tile = group.tiles.where(:data_content.all => [@widgetid]).count
|
||||
if @tile > 0
|
||||
@msg << {"success"=>false,"error"=>"Duplicate widget"}
|
||||
else
|
||||
no_of_widgets = group.tiles.where(:data_category.all => ["widget"]).count
|
||||
@totalwidgets = @totalwidgets + no_of_widgets
|
||||
end
|
||||
end
|
||||
if @totalwidgets >= 12
|
||||
@msg << {"success"=>false,"error"=>"Section full"}
|
||||
else
|
||||
wshape = @widget.shape
|
||||
wdata_content = @widgetid
|
||||
wdata_category = "widget"
|
||||
wname = @widget.name
|
||||
if @groups.first.tiles.where(:data_category.all => ["widget"]).count >= 6
|
||||
groupid = @groups.last.id
|
||||
else
|
||||
groupid = @groups.first.id
|
||||
end
|
||||
Tile.create(data_category: wdata_category,data_content: wdata_content, group_id: groupid, position: 10, title: wname, shape: wshape)
|
||||
@msg << {"success"=>true}
|
||||
end
|
||||
end
|
||||
|
||||
render :json=>@msg.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
class DesktopController< ApplicationController
|
||||
layout 'desktop'
|
||||
before_filter :authenticate_user!
|
||||
|
||||
#to load pages...
|
||||
|
||||
def index
|
||||
@desktop = current_user.desktop
|
||||
@currentusername = current_user.name
|
||||
@title = "Desktop - " + @currentusername
|
||||
@section = @desktop.sections.first
|
||||
end
|
||||
|
||||
def desktop
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def app_manager
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def sections
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def settings
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def settingthemes
|
||||
@themes = DesktopTheme.all
|
||||
# raise @themes.inspect
|
||||
render "desktop/settings/themes", :layout => false
|
||||
end
|
||||
|
||||
def settingsections
|
||||
render "desktop/settings/sections", :layout => false
|
||||
end
|
||||
|
||||
def settingconnection
|
||||
render "desktop/settings/connections", :layout => false
|
||||
end
|
||||
|
||||
|
||||
#ajax data load....
|
||||
|
||||
def save_desktop_settings
|
||||
@desktop = Desktop.find(params["desktopid"])
|
||||
@savewhat = params["save"]
|
||||
case @savewhat
|
||||
when "theme"
|
||||
@desktop.update_attributes(:theme => params["theme"])
|
||||
@desktop.update_attributes(:wallpaper => nil)
|
||||
when "desktopnames"
|
||||
@sections = @desktop.sections
|
||||
x = 0;
|
||||
@sections.each do |section|
|
||||
@desktopnewnames = params["desktopnms"]
|
||||
section.update_attributes(:name => @desktopnewnames[x] )
|
||||
x = x+1
|
||||
end
|
||||
when "appnewsection"
|
||||
@section = Section.find(params["newsectionid"])
|
||||
@groups = @section.groups
|
||||
@app = Tile.find(params["appid"])
|
||||
@groups.each do |group|
|
||||
@tiles = group.tiles.where(:data_category.all => ["app"])
|
||||
if @tiles.length < 12
|
||||
@app.update_attributes(:group_id => group.id)
|
||||
break
|
||||
end
|
||||
end
|
||||
when "customtheme"
|
||||
@desktop.update_attributes(:theme => "custom")
|
||||
@desktop.update_attributes(:customtheme => params['theme'])
|
||||
when "wallpaper"
|
||||
@desktop.update_attributes(:wallpaper => params["wallpapernm"])
|
||||
end
|
||||
a = Array.new
|
||||
a << {"success"=>"true"}
|
||||
render :json=>a.to_json
|
||||
end
|
||||
|
||||
def get_desktop_settings
|
||||
@desktop = Desktop.find(params["desktopid"])
|
||||
@getwhat = params["get"]
|
||||
case @getwhat
|
||||
when "desktop"
|
||||
render :json => @desktop.to_json
|
||||
when "sectionnames"
|
||||
secnames = Array.new
|
||||
@sections = @desktop.sections
|
||||
@sections.each do |section|
|
||||
secnames << section.name
|
||||
end
|
||||
render :json => secnames.to_json
|
||||
when "theme"
|
||||
@theme = @desktop.theme
|
||||
render :json => @theme.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def getgroups
|
||||
@section = Section.find(params["sectionid"])
|
||||
@groups = @section.groups
|
||||
a = Array.new
|
||||
@groups.each do |group|
|
||||
a << group.tiles
|
||||
end
|
||||
render :json =>a.to_json
|
||||
end
|
||||
|
||||
def getsectionlist
|
||||
@desktop = Desktop.find(params["desktopid"])
|
||||
@sections = @desktop.sections
|
||||
render :json => @sections.to_json
|
||||
end
|
||||
|
||||
def temp_func
|
||||
@section = Section.find(params["sectionid"])
|
||||
@groups = @section.groups
|
||||
|
||||
@groups.each do |group|
|
||||
a = 1;
|
||||
@tiles = group.tiles
|
||||
@tiles.each do |tile|
|
||||
tile.update_attributes({:data_category => "widget",:data_content => "temp", :position => a})
|
||||
a = a+1;
|
||||
end
|
||||
end
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def getapplist
|
||||
@desktop = Desktop.find(params["desktopid"])
|
||||
@sections = @desktop.sections
|
||||
a = Array.new
|
||||
@sections.each do |section|
|
||||
@groups = section.groups
|
||||
@groups.each do |group|
|
||||
@tiles = group.tiles.where(:data_category.all => ["app"])
|
||||
a << @tiles
|
||||
end
|
||||
end
|
||||
render :json=>a.to_json
|
||||
end
|
||||
|
||||
def newpositions
|
||||
@newpositions = params["newpos"]
|
||||
@section = Section.find(params["sectionid"])
|
||||
@groupids = params["groupids"]
|
||||
@groups = @section.groups
|
||||
z = 0
|
||||
@newpositions.each do |grp|
|
||||
x = 1
|
||||
grp.each do |tileid|
|
||||
if x != 1
|
||||
y = 1
|
||||
tileid.each do |id|
|
||||
@tile = Tile.find(id)
|
||||
@tile.update_attributes({:position => y})
|
||||
if @tile.group_id != @groupids[z]
|
||||
@tile.update_attributes({:group_id => @groupids[z]})
|
||||
end
|
||||
y = y + 1
|
||||
end
|
||||
z = z + 1
|
||||
end
|
||||
x = x + 1
|
||||
end
|
||||
end
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def forgmail
|
||||
|
||||
feed = Net::HTTP.get_response(URI.parse("https://mail.google.com/mail/feed/atom")).body
|
||||
render :xml=>feed
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
class DesktopOrbitController< ApplicationController
|
||||
|
||||
def orbit
|
||||
render "desktop/orbit", :layout => false
|
||||
end
|
||||
|
||||
def gettimelinespan
|
||||
@get = params['get']
|
||||
case @get
|
||||
when "papers"
|
||||
firstpaper = current_user.papers.all.first
|
||||
lastpaper = current_user.papers.all.desc(:created_at).last
|
||||
endyear = Integer(lastpaper.created_at.strftime("%Y"))
|
||||
startyear = Integer(firstpaper.created_at.strftime("%Y"))
|
||||
end
|
||||
render :json=>{"startyear"=>startyear,"endyear"=>endyear}.to_json
|
||||
end
|
||||
|
||||
def eventajaxload
|
||||
@limit = 15
|
||||
@fromdate = params["from"]
|
||||
@fromdate[0] = Integer(@fromdate[0])
|
||||
@fromdate[1] = Integer(@fromdate[1])
|
||||
@totalpapers = 0
|
||||
@lastpaper = current_user.papers.all.desc(:created_at).last
|
||||
@date = Date.new(Integer(@lastpaper.created_at.strftime("%Y")),Integer(@lastpaper.created_at.strftime("%m")))
|
||||
@data = Array.new
|
||||
while @totalpapers < @limit
|
||||
if Date.new(@date.year,@date.month-1) > Date.new(@fromdate[0],@fromdate[1])
|
||||
break
|
||||
end
|
||||
if(@fromdate[1] == 12)
|
||||
@papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0]+1,1)).desc(:created_at)
|
||||
else
|
||||
@papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0],@fromdate[1]+1)).desc(:created_at)
|
||||
end
|
||||
if(@papers.length > 0)
|
||||
@data << {"papers" => @papers}
|
||||
end
|
||||
@totalpapers = @totalpapers + @papers.length
|
||||
|
||||
@fromdate[1] = @fromdate[1]-1
|
||||
if(@fromdate[1] == 0)
|
||||
@fromdate[1] = 12
|
||||
@fromdate[0] = @fromdate[0] - 1
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
render :json=>@data.to_json
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,74 @@
|
||||
class DesktopPublicationsController< ApplicationController
|
||||
def journal_p
|
||||
render "desktop/journal_p", :layout => false
|
||||
end
|
||||
|
||||
def journal_p_list
|
||||
render "desktop/journal_pages/list", :layout => false
|
||||
end
|
||||
|
||||
def journal_p_add
|
||||
render "desktop/journal_pages/add", :layout => false
|
||||
end
|
||||
|
||||
def books
|
||||
render "desktop/books", :layout => false
|
||||
end
|
||||
|
||||
def books_list
|
||||
render "desktop/books/list", :layout => false
|
||||
end
|
||||
|
||||
def books_add
|
||||
render "desktop/books/add", :layout => false
|
||||
end
|
||||
|
||||
def seminar_p
|
||||
render "desktop/seminar_p", :layout => false
|
||||
end
|
||||
|
||||
def seminar_p_list
|
||||
render "desktop/seminar_pages/list", :layout => false
|
||||
end
|
||||
|
||||
def seminar_p_add
|
||||
render "desktop/seminar_pages/add", :layout => false
|
||||
end
|
||||
|
||||
def create_journal
|
||||
Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich")
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def getjournals
|
||||
@journals = current_user.journals
|
||||
data = Array.new
|
||||
@journals.each do |journal|
|
||||
@papers = journal.papers.all
|
||||
data << {"title" => journal.title, "papers" => @papers}
|
||||
end
|
||||
render :json=>data.to_json
|
||||
end
|
||||
|
||||
def delete_journal
|
||||
@journals = Journal.find("")
|
||||
@journals.delete
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def update_journal
|
||||
@journal = Journal.find("4ff2d6ebbd98eb02b9000017")
|
||||
@papers = @journal.papers
|
||||
@papers.each do |paper|
|
||||
paper.update_attributes(:user_id => current_user.id)
|
||||
end
|
||||
b = Array.new
|
||||
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,26 @@
|
||||
class DesktopResearchController< ApplicationController
|
||||
|
||||
def research_d
|
||||
render "desktop/research_d", :layout=>false
|
||||
end
|
||||
def research_d_list
|
||||
render "desktop/research_domain/list", :layout=>false
|
||||
end
|
||||
|
||||
def research_d_add
|
||||
render "desktop/research_domain/add", :layout=>false
|
||||
end
|
||||
|
||||
def research_p
|
||||
render "desktop/research_p", :layout=>false
|
||||
end
|
||||
def research_p_list
|
||||
render "desktop/research_project/list", :layout=>false
|
||||
end
|
||||
|
||||
def research_p_add
|
||||
render "desktop/research_project/add", :layout=>false
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
class OrbitBackendController< ApplicationController
|
||||
before_filter :force_order,:except => [:public]
|
||||
before_filter :setup_vars
|
||||
before_filter :set_current_user
|
||||
#before_filter :setup_vars
|
||||
#before_filter :set_current_user
|
||||
|
||||
# before_filter {|c| c.front_end_available(@app_title)}
|
||||
# before_filter :check_user_can_use
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
include AdminHelper
|
||||
include ApplicationHelper
|
||||
|
||||
layout 'new_admin'
|
||||
|
||||
@@ -18,8 +18,16 @@ class OrbitBackendController< ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def force_order
|
||||
|
||||
def force_order_for_visitor
|
||||
setup_vars
|
||||
set_current_user
|
||||
end
|
||||
|
||||
|
||||
def force_order_for_user
|
||||
setup_vars
|
||||
set_current_user
|
||||
authenticate_user!
|
||||
check_user_can_use
|
||||
end
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
class OtheraccountsController< ApplicationController
|
||||
require 'open-uri'
|
||||
require 'rexml/document'
|
||||
require 'net/http'
|
||||
require 'net/https'
|
||||
# require 'twitter'
|
||||
include REXML
|
||||
|
||||
def saveaccountinfo
|
||||
@dowhat = params['dowhat']
|
||||
@email = params['email']
|
||||
@password = params['password']
|
||||
@account = params['account']
|
||||
case @dowhat
|
||||
when "new"
|
||||
OtherAccount.create(user_id: current_user.id, email: @email, encrypted_password: @password, type: @account)
|
||||
when "edit"
|
||||
@otheraccount = OtherAccount.where(:type.all => [@account],:user_id.all => [current_user.id]) rescue nil
|
||||
@otheraccount.first.update_attributes(:email => @email, :encrypted_password => @password)
|
||||
when "delete"
|
||||
@otheraccount = OtherAccount.where(:type.all => [@account], :user_id.all => [current_user.id]) rescue nil
|
||||
@otheraccount.destroy_all
|
||||
end
|
||||
a = Array.new
|
||||
a << {"success"=>"true"}
|
||||
render :json=>a.to_json
|
||||
end
|
||||
|
||||
def gmail
|
||||
@gmailaccount = OtherAccount.where(:type.all => ["gmail"],:user_id.all => [current_user.id]) rescue nil
|
||||
if @gmailaccount.first != nil
|
||||
@decrypted_password = @gmailaccount.first.encrypted_password.decrypt
|
||||
@email = @gmailaccount.first.email
|
||||
url = URI.parse("https://mail.google.com/mail/feed/atom")
|
||||
#url = URI.parse("https://www.google.com/m8/feeds/contacts/default/full")
|
||||
req = Net::HTTP::Get.new(url.path)
|
||||
req.basic_auth @email, @decrypted_password
|
||||
req.content_type = 'text/xml'
|
||||
|
||||
http = Net::HTTP.new(url.host, url.port)
|
||||
http.use_ssl = true
|
||||
response = http.start { |http| http.request(req) }
|
||||
|
||||
root = Document.new(response.read_body).root
|
||||
render :text=>root
|
||||
else
|
||||
msg = "<HEAD><ERROR>true</ERROR><ERRORMSG>Account setting problem.</ERRORMSG></HEAD>"
|
||||
respond_to do |m|
|
||||
m.xml {render :xml=>msg}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def twitter
|
||||
# token = "Yh9qYe0lhWk27TZJamnhrA"
|
||||
# secret = "iBgxJ5BrxfGFLkp7aB6pyCSzd0zcJiYDqJGFBK6Wdo"
|
||||
# oauth = Twitter::OAuth.new(token,secret)
|
||||
|
||||
# oauth_token = oauth.request_token.token
|
||||
# oauth_secret = oauth.request_token.secret
|
||||
#require File.dirname(__FILE__)+"/../lib/contacts"
|
||||
@gmailaccount = OtherAccount.where(:type.all => ["gmail"],:user_id.all => [current_user.id]) rescue nil
|
||||
if @gmailaccount.first != nil
|
||||
login = @gmailaccount.first.encrypted_password.decrypt
|
||||
password = @gmailaccount.first.email
|
||||
|
||||
@contacts = Contacts::Gmail.new(login, password).contacts
|
||||
|
||||
render :json => @contacts.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def getaccounts
|
||||
@accounts = OtherAccount.where(:user_id.all => [current_user.id]).without(:encrypted_password)
|
||||
render :json => @accounts.to_json
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,8 @@ class PagesController < ApplicationController
|
||||
def show
|
||||
#begin
|
||||
@item = Item.first(:conditions => {:path => params[:page_name]})
|
||||
if @item && @item.is_published #&& (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
||||
#binding.pry
|
||||
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
||||
impressionist(@item)
|
||||
case @item.class.to_s
|
||||
when 'Page'
|
||||
@@ -36,7 +37,7 @@ class PagesController < ApplicationController
|
||||
def index_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
||||
@@ -47,11 +48,13 @@ class PagesController < ApplicationController
|
||||
end
|
||||
|
||||
def show_from_link
|
||||
url = "/#{@item.path}?id=#{params[:id]}"
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}id=#{params[:id]}" unless params[:id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "&preview=#{params[:preview]}" unless params[:preview].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}preview=#{params[:preview]}" unless params[:preview].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}controller_action=#{params[:controller_action]}" unless params[:controller_action].blank?
|
||||
redirect_to(url + options) unless save_from_no_lang_for_page
|
||||
end
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
class SessionsController < Devise::SessionsController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
||||
include Devise::Controllers::InternalHelpers
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
# login_password = params[:user][:password]
|
||||
# login_uid = params[:user][:nccu_ldap_uid]
|
||||
login_password = params[:user][:password]
|
||||
login_uid = params[:user][:nccu_ldap_uid]
|
||||
result = false
|
||||
ldap_filter = "(uid=#{login_uid})"
|
||||
if /@rulingcom.com$/.match(login_uid).nil?
|
||||
MiddleSiteConnection.establish
|
||||
NccuLdapConnection.establish
|
||||
|
||||
if ($nccu_ldap_connection.bind rescue false)
|
||||
logger.info "=LDAP Binded password ok..."
|
||||
result =check_auth_with_ldap(login_uid,login_password)
|
||||
if result #&& login_password!=''
|
||||
logger.info "==LDAP password passed..."
|
||||
nccu_id = get_nccu_id_from_mid_site(login_uid)
|
||||
resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id }))
|
||||
# resource = env['warden'].authenticate!(:check_nccu_ldap)
|
||||
# resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
if (resource.nil? || nccu_id.nil?)
|
||||
logger.error "===LDAP passed local block... resource:#{resource.inspect}\n nccu_id:#{nccu_id} \t login_uid:#{login_uid}"
|
||||
flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit')
|
||||
render :action => "new"
|
||||
else
|
||||
logger.info "===ALL passed"
|
||||
resource_name = resource.class.to_s.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
end
|
||||
else
|
||||
logger.error "==password LDAP fail..."
|
||||
flash[:notice] = t('devise.failure.ldap_invalid')
|
||||
render :action => "new"
|
||||
end
|
||||
else
|
||||
logger.error "=LDAP fail..."
|
||||
flash[:notice] = t('devise.failure.ldap_connection_failed')
|
||||
render :action => "new"
|
||||
end
|
||||
else #if rulingcom account
|
||||
logger.info "=======Rulingcom account======"
|
||||
resource = User.first(conditions:{email: login_uid})
|
||||
if resource.valid_password?(login_password)
|
||||
resource_name = resource.class.to_s.downcase
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
else
|
||||
logger.error "==password Local fail..."
|
||||
flash[:notice] = t('devise.failure.invalid')
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
logger.info "=======End Debugging======"
|
||||
|
||||
end
|
||||
private
|
||||
def check_auth_with_ldap(login_uid,login_password)
|
||||
ldap_filter = "(uid=#{login_uid})"
|
||||
$nccu_ldap_connection.bind_as(:base => NccuLdapConnection::BASE,:filter => ldap_filter,:password=> login_password) rescue false
|
||||
end
|
||||
|
||||
def get_nccu_id_from_mid_site(ldap_id)
|
||||
nccu_id = $mid_site_connection.query("SELECT nccu_id FROM rss_aaldap_view WHERE ldap_id='#{ldap_id}' LIMIT 1").first['nccu_id'] rescue nil
|
||||
#
|
||||
# if nccu_id.nil?
|
||||
# #show_error
|
||||
# p 'account not exist'
|
||||
# #should return?
|
||||
# end
|
||||
# # User.first(conditions: { })
|
||||
# rss_pautlst_ut = $mid_site_connection.query("SELECT * FROM rss_pautlst_ut WHERE nccu_id='#{nccu_id}' LIMIT 1").first rescue nil
|
||||
# # rss_paunit = client.query("SELECT * FROM rss_paunit LIMIT 1").first rescue nil
|
||||
# user = User.find_or_create_by(:nccu_id => nccu_id)
|
||||
# p user
|
||||
# # p rss_paunit
|
||||
#
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user