Merge branch 'design_team' into ldap

Conflicts:
	config/locales/zh_tw.yml
	vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
This commit is contained in:
Christophe Vilayphiou committed 2012-05-08 11:40:38 +08:00
commit 2b9190a49e
101 files changed
+1269 -689

No files matched your search

@@ -1,7 +1,7 @@
class Admin::AdBannersController < ApplicationController
class Admin::AdBannersController < OrbitBackendController
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :for_app_manager
def destroy
@ad_banner = AdBanner.find(params[:id])
@@ -2,7 +2,7 @@ class Admin::DashboardsController < ApplicationController
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
# before_filter :is_admin?
def index
end
+11 -3
View File
@@ -1,11 +1,12 @@
class Admin::DesignsController < ApplicationController
class Admin::DesignsController < OrbitBackendController
require "net/http"
require "uri"
require 'zip/zip'
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :is_admin?
before_filter :for_admin_only
def upload_package
if !params[:design].nil?
@@ -24,7 +25,7 @@ class Admin::DesignsController < ApplicationController
end
def index
@designs = Design.all.entries
@designs = params[:sort] ? get_sorted_and_filtered("designs") : Design.all
end
def new
@@ -83,6 +84,13 @@ class Admin::DesignsController < ApplicationController
render :action => 'new'
end
end
def delete
if params[:to_delete]
designs = Design.any_in(:_id => params[:to_delete]).delete_all
end
redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
protected
+39 -7
View File
@@ -1,16 +1,48 @@
class Admin::SitesController < ApplicationController
layout "admin"
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :get_site
def index
@site = Site.first
redirect_to :action => :new unless @site
# def index
# @site = Site.first
# # redirect_to :action => :new unless @site
# end
# def new
# @site = Site.new
# end
def update
@site.update_attributes(params[:site])
redirect_to :back
end
def new
@site = Site.new
def site_info
end
def system_info
end
def language
end
def mail_setting
end
def ui_theme
end
private
def get_site
@site ||= Site.first
end
end
+65 -5
View File
@@ -39,15 +39,65 @@ class ApplicationController < ActionController::Base
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
end
def auth_failed_in_backend
#redirect_to admin_dashboards_url
redirect_to root_path
end
# Check if the current_user is admin
def is_admin?
redirect_to root_url unless current_user.admin?
current_user.admin? ? true : auth_failed_in_backend
end
def is_manager?
@module_app.managing_users.include?(current_user) || is_admin?
end
def for_admin_only
if is_admin?
true
else
flash[:error] = t("admin.access.denied.not_admin")
auth_failed_in_backend
end
end
def for_app_manager
if is_manager?
true
else
flash[:error] = t("admin.access.denied.app.not_manager")
auth_failed_in_backend
end
end
def for_app_sub_manager
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
true
else
flash[:error] = t("admin.access.denied.app.not_sub_manager")
auth_failed_in_backend
end
end
def for_app_user
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
true
else
flash[:error] = t("admin.access.denied.app.not_authed_user")
auth_failed_in_backend
end
end
def check_object_premission(obj,title)
flash[:error] = t("admin.access.denied.object")
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
end
# Render the page
def render_page(id = nil)
def render_page(param={})
if @item
render :text => process_page(@item, id), :layout => 'page_layout'
render :text => process_page(@item, param[:id], param), :layout => 'page_layout'
else
render :text => '404 Not Found'
end
@@ -78,8 +128,8 @@ class ApplicationController < ActionController::Base
# set site if exist or create site
@site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []})
session[:site] = @site.id
@site_in_use_locales = @site.in_use_locales
@site_valid_locales = @site.valid_locales
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
@site_valid_locales = site_locales_default_head(@site.valid_locales)
end
def set_current_item
@@ -114,4 +164,14 @@ class ApplicationController < ActionController::Base
end
end
def site_locales_default_head(locales)
if locales[0].eql? I18n.locale.to_s
locales
else
a = Array.new(locales)
shift_out = a.delete(I18n.locale.to_s)
[shift_out] + a
end
end
end
+14 -17
View File
@@ -27,9 +27,13 @@ class OrbitBackendController< ApplicationController
end
end
def get_sorted_and_filtered(object_class)
def get_sorted_and_filtered(object_class, query=nil)
object_class = object_class.classify.constantize
objects = object_class.all
if query
objects = object_class.all.where(query)
else
objects = object_class.all
end
if !params[:sort].blank?
options = params[:sort_options]
@@ -62,30 +66,23 @@ class OrbitBackendController< ApplicationController
case key
when 'status'
a = Array.new
objects.each do |bulletin|
objects.each do |object|
value.each do |v|
case v
when 'pending'
a << bulletin if bulletin.is_checked.nil?
when 'rejected'
a << bulletin if bulletin.is_checked.eql?(false)
else
a << bulletin if bulletin[v]
end
a << object if object[v]
end
end
objects = a.uniq
when 'categories'
a = Array.new
objects.each do |bulletin|
a << bulletin if value.include?(bulletin.bulletin_category.id.to_s)
objects.each do |object|
a << object if value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s)
end
objects = a.uniq
when 'tags'
a = Array.new
objects.each do |bulletin|
bulletin.tags.each do |tag|
a << bulletin if value.include?(tag.id.to_s)
objects.each do |object|
object.tags.each do |tag|
a << object if value.include?(tag.id.to_s)
end
end
objects = a.uniq
@@ -150,7 +147,7 @@ class OrbitBackendController< ApplicationController
def get_with_nil(objects, option, sorted_objects)
tmp = Array.new
objects.each { |object| tmp << [get_string_value_from_object(object), object] if (object.send(option).count == 0) }
objects.each { |object| tmp << [get_string_value_from_object(object), object] if (object.send(option).blank? || (object.send(option).size == 0 rescue nil)) }
sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse!
sorted_tmp = sorted.collect {|a| a[1] }
a = params[:direction].eql?('asc') ? (sorted_tmp + sorted_objects) : (sorted_objects + sorted_tmp)
+5 -3
View File
@@ -16,10 +16,10 @@ class PagesController < ApplicationController
def show
#begin
@item = Item.first(:conditions => {:full_name => params[:page_name]})
if @item && @item.is_published
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
case @item._type
when 'Page'
render_page(params[:id])
render_page(params)
when 'Link'
redirect_to "http://#{@item[:url]}"
end
@@ -40,7 +40,9 @@ class PagesController < ApplicationController
end
def show_from_link
redirect_to "/#{@item.full_name}?id=#{params[:id]}"
# debugger
# a=1
redirect_to "/#{@item.full_name}?id=#{params[:id]}&preview=#{params[:preview]}"
end
def load_orbit_bar