From 1a9a4d0112d3f8bd41ecf87cef24b88212a4da0b Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 19 Jul 2013 16:03:14 +0800 Subject: [PATCH 01/21] Changes for ntue (mail app) --- Gemfile | 2 + app/controllers/sessions_controller.rb | 35 ++ config/environments/development.rb | 18 +- config/routes.rb | 5 + .../back_end/approvals_controller.rb | 73 ++++ .../back_end/bulletins_controller.rb | 85 +++++ .../announcement/app/models/bulletin.rb | 44 +++ .../announcement_mailer/cron_mail.html.erb | 29 ++ .../approvals/_modal_approve.html.erb | 6 + .../back_end/bulletins/_form.html.erb | 49 +++ .../announcement/config/locales/en.yml | 19 +- .../announcement/config/locales/zh_tw.yml | 20 +- vendor/built_in_modules/er_email/.gitignore | 7 + vendor/built_in_modules/er_email/Gemfile | 17 + vendor/built_in_modules/er_email/MIT-LICENSE | 20 ++ vendor/built_in_modules/er_email/README.rdoc | 3 + vendor/built_in_modules/er_email/Rakefile | 40 +++ .../app/assets/images/er_email/.gitkeep | 0 .../app/assets/javascripts/er_email/.gitkeep | 0 .../app/assets/stylesheets/er_email/.gitkeep | 0 .../er_email/app/controllers/.gitkeep | 0 .../app/controllers/application_controller.rb | 23 ++ .../er_email/back_end/approvals_controller.rb | 145 ++++++++ .../back_end/email_er_categorys_controller.rb | 128 +++++++ .../er_email/back_end/email_ers_controller.rb | 318 ++++++++++++++++++ .../er_email/app/helpers/.gitkeep | 0 .../back_end/email_er_categorys_helper.rb | 16 + .../er_email/back_end/email_ers_helper.rb | 58 ++++ .../er_email/app/mailers/.gitkeep | 0 .../er_email/app/models/.gitkeep | 0 .../er_email/app/models/email_er.rb | 123 +++++++ .../er_email/app/models/email_er_category.rb | 47 +++ .../er_email/app/models/email_er_file.rb | 23 ++ .../er_email/app/views/.gitkeep | 0 .../approvals/_modal_approve.html.erb | 68 ++++ .../back_end/approvals/_modal_list.html.erb | 44 +++ .../approvals/preview_and_approve.js.erb | 5 + .../back_end/approvals/setting.html.erb | 53 +++ .../back_end/approvals/setting.js.erb | 2 + .../back_end/approvals/update_setting.js.erb | 1 + .../back_end/approvals/user_list.js.erb | 2 + .../_email_er_category.html.erb | 19 ++ .../email_er_categorys/_form.html.erb | 30 ++ .../back_end/email_er_categorys/create.js.erb | 2 + .../email_er_categorys/destroy.js.erb | 1 + .../back_end/email_er_categorys/edit.js.erb | 1 + .../email_er_categorys/index.html.erb | 23 ++ .../back_end/email_er_categorys/new.js.erb | 1 + .../back_end/email_er_categorys/update.js.erb | 4 + .../email_ers/_clear_filters.html.erb | 3 + .../back_end/email_ers/_email_er.html.erb | 61 ++++ .../back_end/email_ers/_filter.html.erb | 11 + .../back_end/email_ers/_form.html.erb | 115 +++++++ .../back_end/email_ers/_form_file.html.erb | 37 ++ .../back_end/email_ers/_sort_headers.html.erb | 5 + .../back_end/email_ers/destroy.js.erb | 1 + .../er_email/back_end/email_ers/edit.html.erb | 6 + .../back_end/email_ers/index.html.erb | 28 ++ .../er_email/back_end/email_ers/index.js.erb | 4 + .../er_email/back_end/email_ers/new.html.erb | 6 + .../email_ers/realtime_preview.js.erb | 2 + .../er_email/back_end/email_ers/show.html.erb | 1 + .../fact_checks/_privilege_user.html.erb | 25 ++ .../er_email/config/locales/en.yml | 27 ++ .../er_email/config/locales/zh_tw.yml | 27 ++ .../er_email/config/routes.rb | 36 ++ .../er_email/er_email.gemspec | 23 ++ vendor/built_in_modules/er_email/init.rb | 55 +++ .../built_in_modules/er_email/lib/er_email.rb | 4 + .../er_email/lib/er_email/engine.rb | 4 + .../er_email/lib/er_email/version.rb | 3 + .../er_email/lib/tasks/er_email_tasks.rake | 4 + vendor/built_in_modules/er_email/script/rails | 8 + .../er_email/test/dummy/README.rdoc | 261 ++++++++++++++ .../er_email/test/dummy/Rakefile | 7 + .../app/assets/javascripts/application.js | 15 + .../app/assets/stylesheets/application.css | 13 + .../app/controllers/application_controller.rb | 3 + .../dummy/app/helpers/application_helper.rb | 2 + .../er_email/test/dummy/app/mailers/.gitkeep | 0 .../er_email/test/dummy/app/models/.gitkeep | 0 .../app/views/layouts/application.html.erb | 14 + .../er_email/test/dummy/config.ru | 4 + .../er_email/test/dummy/config/application.rb | 59 ++++ .../er_email/test/dummy/config/boot.rb | 10 + .../er_email/test/dummy/config/database.yml | 25 ++ .../er_email/test/dummy/config/environment.rb | 5 + .../dummy/config/environments/development.rb | 37 ++ .../dummy/config/environments/production.rb | 67 ++++ .../test/dummy/config/environments/test.rb | 37 ++ .../initializers/backtrace_silencers.rb | 7 + .../dummy/config/initializers/inflections.rb | 15 + .../dummy/config/initializers/mime_types.rb | 5 + .../dummy/config/initializers/secret_token.rb | 7 + .../config/initializers/session_store.rb | 8 + .../config/initializers/wrap_parameters.rb | 14 + .../er_email/test/dummy/config/locales/en.yml | 5 + .../er_email/test/dummy/config/routes.rb | 58 ++++ .../er_email/test/dummy/lib/assets/.gitkeep | 0 .../er_email/test/dummy/log/.gitkeep | 0 .../er_email/test/dummy/public/404.html | 26 ++ .../er_email/test/dummy/public/422.html | 26 ++ .../er_email/test/dummy/public/500.html | 25 ++ .../er_email/test/dummy/public/favicon.ico | 0 .../er_email/test/dummy/script/rails | 6 + .../er_email/test/er_email_test.rb | 7 + .../test/integration/navigation_test.rb | 10 + .../er_email/test/test_helper.rb | 15 + 108 files changed, 2887 insertions(+), 11 deletions(-) create mode 100644 app/controllers/sessions_controller.rb create mode 100644 vendor/built_in_modules/announcement/app/views/announcement_mailer/cron_mail.html.erb create mode 100644 vendor/built_in_modules/er_email/.gitignore create mode 100644 vendor/built_in_modules/er_email/Gemfile create mode 100644 vendor/built_in_modules/er_email/MIT-LICENSE create mode 100644 vendor/built_in_modules/er_email/README.rdoc create mode 100644 vendor/built_in_modules/er_email/Rakefile create mode 100644 vendor/built_in_modules/er_email/app/assets/images/er_email/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/assets/javascripts/er_email/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/assets/stylesheets/er_email/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/controllers/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/controllers/application_controller.rb create mode 100644 vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/approvals_controller.rb create mode 100644 vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb create mode 100644 vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb create mode 100644 vendor/built_in_modules/er_email/app/helpers/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_er_categorys_helper.rb create mode 100644 vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_ers_helper.rb create mode 100644 vendor/built_in_modules/er_email/app/mailers/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/models/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/models/email_er.rb create mode 100644 vendor/built_in_modules/er_email/app/models/email_er_category.rb create mode 100644 vendor/built_in_modules/er_email/app/models/email_er_file.rb create mode 100644 vendor/built_in_modules/er_email/app/views/.gitkeep create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/preview_and_approve.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/setting.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/setting.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/update_setting.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/user_list.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/_email_er_category.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/_form.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/create.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/destroy.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/edit.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/index.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/new.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_er_categorys/update.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_clear_filters.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_email_er.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_filter.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_form.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_form_file.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_sort_headers.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/destroy.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/edit.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/index.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/index.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/new.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/realtime_preview.js.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/show.html.erb create mode 100644 vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/fact_checks/_privilege_user.html.erb create mode 100644 vendor/built_in_modules/er_email/config/locales/en.yml create mode 100644 vendor/built_in_modules/er_email/config/locales/zh_tw.yml create mode 100644 vendor/built_in_modules/er_email/config/routes.rb create mode 100644 vendor/built_in_modules/er_email/er_email.gemspec create mode 100644 vendor/built_in_modules/er_email/init.rb create mode 100644 vendor/built_in_modules/er_email/lib/er_email.rb create mode 100644 vendor/built_in_modules/er_email/lib/er_email/engine.rb create mode 100644 vendor/built_in_modules/er_email/lib/er_email/version.rb create mode 100644 vendor/built_in_modules/er_email/lib/tasks/er_email_tasks.rake create mode 100755 vendor/built_in_modules/er_email/script/rails create mode 100644 vendor/built_in_modules/er_email/test/dummy/README.rdoc create mode 100644 vendor/built_in_modules/er_email/test/dummy/Rakefile create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/assets/javascripts/application.js create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/assets/stylesheets/application.css create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/controllers/application_controller.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/helpers/application_helper.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/mailers/.gitkeep create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/models/.gitkeep create mode 100644 vendor/built_in_modules/er_email/test/dummy/app/views/layouts/application.html.erb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config.ru create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/application.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/boot.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/database.yml create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/environment.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/environments/development.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/environments/production.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/environments/test.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/initializers/inflections.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/initializers/mime_types.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/initializers/secret_token.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/initializers/session_store.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/initializers/wrap_parameters.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/locales/en.yml create mode 100644 vendor/built_in_modules/er_email/test/dummy/config/routes.rb create mode 100644 vendor/built_in_modules/er_email/test/dummy/lib/assets/.gitkeep create mode 100644 vendor/built_in_modules/er_email/test/dummy/log/.gitkeep create mode 100644 vendor/built_in_modules/er_email/test/dummy/public/404.html create mode 100644 vendor/built_in_modules/er_email/test/dummy/public/422.html create mode 100644 vendor/built_in_modules/er_email/test/dummy/public/500.html create mode 100644 vendor/built_in_modules/er_email/test/dummy/public/favicon.ico create mode 100755 vendor/built_in_modules/er_email/test/dummy/script/rails create mode 100644 vendor/built_in_modules/er_email/test/er_email_test.rb create mode 100644 vendor/built_in_modules/er_email/test/integration/navigation_test.rb create mode 100644 vendor/built_in_modules/er_email/test/test_helper.rb diff --git a/Gemfile b/Gemfile index 16c820c9a..b5b5a9912 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source 'http://rubygems.org' gem 'rails', "~> 3.2.9" +gem 'savon', '~> 2.2.0' + gem "brakeman" gem 'mime-types' diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..c1a027d17 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,35 @@ +# encoding: utf-8 + +class SessionsController < Devise::SessionsController + prepend_before_filter :require_no_authentication, :only => [ :new, :create ] + + require 'savon' + + def create + + @sys_id = params["sys_id"] + + client = Savon.client(wsdl: 'http://sso.ntue.edu.tw/soap/soapserver.php?wsdl') + + client.operations + + response = client.call(:chkidno, message: { sys_id: @sys_id }) + + @id = response.body[:chkidno_response][:return][:id] + + login_uid = @id + + resource = User.first(conditions:{user_id: login_uid}) + + if !resource.blank? + resource_name = resource.class.to_s.downcase + sign_in(resource_name, resource) + redirect_to after_sign_in_path_for(resource) + else + flash[:error] = "很抱歉,您無此權限或帳號登入本站,請洽本站管理員
Sorry, you don't have the account or authority to login. Please contact the website administrator." + redirect_to :root + end + + end + +end \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 7daa02fc8..ba4f6fd1f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -34,15 +34,15 @@ Orbit::Application.configure do # :sender_address => %{"notifier" }, # :exception_recipients => %w{chris@rulingcom.com} - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { - :enable_starttls_auto => true, - :address => "smtp.gmail.com", - :port => '587', - :domain => "smtp.gmail.com", - :authentication => "plain", - :user_name => "redmine@rulingcom.com", - :password => "rulingredmine" } + # config.action_mailer.delivery_method = :smtp + # config.action_mailer.smtp_settings = { + # :enable_starttls_auto => true, + # :address => "smtp.gmail.com", + # :port => '587', + # :domain => "smtp.gmail.com", + # :authentication => "plain", + # :user_name => "redmine@rulingcom.com", + # :password => "rulingredmine" } end diff --git a/config/routes.rb b/config/routes.rb index 716918775..25e488432 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,11 @@ Orbit::Application.routes.draw do match "/users_passwd" => "desktop/registrations#update", :as => :users_passwd, :via => :put end + devise_scope :user do + get 'soap_login' => 'sessions#create' + end + + mount Resque::Server, :at => "/admin/resque" mount Rack::GridFS::Endpoint.new(:db => Mongoid.database,:lookup=>:path), :at => "gridfs" diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index cb8da5db1..d2320fb02 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController before_filter :authenticate_user! before_filter :is_admin? @@ -6,6 +7,7 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle def preview_and_approve + email_group_data @bulletin = Bulletin.find params[:bulletin_id] end @@ -15,6 +17,14 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle @bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason]) @bulletin.de_pending if @bulletin.save + + if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected + send_email_data(@bulletin) + + @bulletin.email_sent = false + @bulletin.save + end + notice = t('announcement.approve_bulletin_success') else notice = t('announcement.approve_bulletin_fail') @@ -61,6 +71,69 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle object_auth.privilege_users = privilege_users object_auth end + + def send_email_data(bulletin) + + @site = Site.first + @user = User.find(bulletin.create_user_id) + @host = request.host_with_port + + email_group_data + + @group_mail = Array.new + + bulletin.email_group.each do |egroup| + + if @email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') + + @group_mail << @email_group_data[egroup]["email"] + + elsif @email_group_data.include?(egroup) and egroup == '4' + + @group_mail << bulletin.other_mailaddress + + end + + end + + if !@group_mail.join.blank? + + @mail_content = { + "host" => @host, + "site_title" => @site.title, + "title" => bulletin.title, + "template" => 'announcement_mailer/cron_mail', + "url" => "http://#{@host}#{panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id)}" + } + + @mail_cron = { + :mail_from_app => 'announcement', + :mail_from => @user.email, + :mail_reply_to => @user.email, + :mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}:#{bulletin.title}", + :mail_to => @group_mail.join(','), + :mail_content => @mail_content , + # :mail_sentdate => bulletin.email_sentdate, + :mail_sentdate => DateTime.now, + :create_user_id => bulletin.create_user_id, + :update_user_id => bulletin.create_user_id + } + + @mail_cron = MailCron.new(@mail_cron) + + @mail_cron.save + + MailCron.send_mail_now(@mail_cron.id) + + end + + end + + def email_group_data + + @email_group_data = Bulletin.email_group_data + + end # def get_categorys(id = nil) # @bulletin_categorys = [] diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index e45ced1d6..edc7c012b 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController include OrbitControllerLib::DivisionForDisable @@ -77,6 +78,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # GET /bulletins/new # GET /bulletins/new.xml def new + + email_group_data + if(session[:in_validate_object].blank?) @bulletin = Bulletin.new(:postdate => DateTime.now) else @@ -94,6 +98,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # GET /bulletins/1/edit def edit + + email_group_data + @bulletin = Bulletin.find(params[:id]) if !current_user.admin? && (@bulletin.is_rejected? || @bulletin.is_checked?) redirect_to :action => :index @@ -146,6 +153,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController respond_to do |format| if @bulletin.save + # if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected + # send_email_data(@bulletin) + + # @bulletin.email_sent = false + # @bulletin.save + # end + format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) } format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin } # format.js @@ -226,6 +240,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin.is_rejected = false @bulletin.de_pending! end + + # if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected + # send_email_data(@bulletin) + + # @bulletin.email_sent = false + # @bulletin.save + # end + # if (params[:bulletin][:is_checked] == "false") # @bulletin.is_rejected = true # @bulletin.save! @@ -293,6 +315,69 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController protected + def send_email_data(bulletin) + + @site = Site.first + @user = User.find(bulletin.create_user_id) + @host = request.host_with_port + + email_group_data + + @group_mail = Array.new + + bulletin.email_group.each do |egroup| + + if @email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') + + @group_mail << @email_group_data[egroup]["email"] + + elsif @email_group_data.include?(egroup) and egroup == '4' + + @group_mail << bulletin.other_mailaddress + + end + + end + + if !@group_mail.join.blank? + + @mail_content = { + "host" => @host, + "site_title" => @site.title, + "title" => bulletin.title, + "template" => 'announcement_mailer/cron_mail', + "url" => "http://#{@host}#{panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id)}" + } + + @mail_cron = { + :mail_from_app => 'announcement', + :mail_from => @user.email, + :mail_reply_to => @user.email, + :mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}:#{bulletin.title}", + :mail_to => @group_mail.join(','), + :mail_content => @mail_content , + # :mail_sentdate => bulletin.email_sentdate, + :mail_sentdate => DateTime.now, + :create_user_id => bulletin.create_user_id, + :update_user_id => bulletin.create_user_id + } + + @mail_cron = MailCron.new(@mail_cron) + + @mail_cron.save + + MailCron.send_mail_now(@mail_cron.id) + + end + + end + + def email_group_data + + @email_group_data = Bulletin.email_group_data + + end + def delete_out_invalid_date_from_params if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?)) params[:bulletin].delete("deadline(1i)") diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 1771e2a69..5259a8d2e 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -40,6 +40,12 @@ class Bulletin field :not_checked_reason field :public, :type => Boolean, :default => true + + + field :email_sent, :type => Boolean, :default => false + field :email_sentdate , :type => DateTime + field :email_group, :type => Array + field :other_mailaddress scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false) scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -215,8 +221,46 @@ class Bulletin preview_object end + def get_email_group_data(email_group_data) + + group_mail = Array.new + + self.email_group.each do |egroup| + + if email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') + + group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})" + + elsif email_group_data.include?(egroup) and egroup == '4' + + self.other_mailaddress.split(",").each do |otmail| + + group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})" + + end + + end + + end + + group_mail.join("
").html_safe + + end + protected + + def self.email_group_data + + @email_group_data = { + '0'=> {"name"=>I18n.t('announcement.email_group_data_0'), "email"=>"alluser@tea.ntue.edu.tw"}, + '1'=> {"name"=>I18n.t('announcement.email_group_data_1'), "email"=>"allstu@tea.ntue.edu.tw"}, + '2'=> {"name"=>I18n.t('announcement.email_group_data_2'), "email"=>"allgrad@tea.ntue.edu.tw"}, + '3'=> {"name"=>I18n.t('announcement.email_group_data_3'), "email"=>"allad@tea.ntue.edu.tw"}, + '4'=> {"name"=>I18n.t('announcement.email_group_data_4')} + } + + end def check_deadline if(!self.deadline.nil? and (self.deadline < self.postdate )) diff --git a/vendor/built_in_modules/announcement/app/views/announcement_mailer/cron_mail.html.erb b/vendor/built_in_modules/announcement/app/views/announcement_mailer/cron_mail.html.erb new file mode 100644 index 000000000..fbf7e0b1c --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/announcement_mailer/cron_mail.html.erb @@ -0,0 +1,29 @@ +<% # encoding: utf-8 %> + + + + + + +
+
+ + <%= t('announcement.mail_hi') %>

+ <%= t('announcement.mail_url_view') %>

+ " target="_blank"> <%= @data.mail_content["title"] %>

+ + --
+ <%= t('announcement.mail_source') %> :" target="_blank"> <%= @data.mail_content["site_title"] %>
+ <%= t('announcement.mail_time') %> <%= DateTime.now %> +
+ + + + + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb index 797757a58..bed04d202 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -14,6 +14,12 @@ <%# preview_block_ad_images_helper(bulletin).each do |ad_image| -%> <%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || bulletin.context || " ")) %> <%# end -%> + + <% if !@bulletin.email_group.blank? %> + <%= label_tag 'group_mail' %> + <%= @bulletin.get_email_group_data(@email_group_data) %> + <% end %> +

+ + +
+
+ +
+

<%= t('announcement.email_eminder')%>

+
+
+ +
+
+ + <%#= f.datetime_picker :email_sentdate, :picker_type => 'separated', :label => t("announcement.email_sentdate") %> + +
+ + <%= f.label :email_group ,t("announcement.email_group")%> +
+ +
+ + + <%= f.label :other_mailaddress ,"#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> + <%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %> + +
+ + + + +
+
+
+ + @@ -300,6 +344,11 @@ $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); }); $('.for_preview').popover({ html : true }); + + $('#remind-check').prop('checked') ? '':$('#content-box').addClass('hide') + $('#remind-check').on('change', function() { + $(this).prop('checked') ? $('#content-box').removeClass('hide'):$('#content-box').addClass('hide') + }) }); <% end %> diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index ce6569678..b6a747a4e 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -37,4 +37,21 @@ en: widget: bulletins_and_web_links: Differential Nav. index: Index - search: Search \ No newline at end of file + search: Search + email_eminder: Email Reminder + activate_email_eminder: Activate Email Reminder + email_sentdate: Email Time + email_group: Email Group + email_group_data_0: All Faculty + email_group_data_1: Undergraduates + email_group_data_2: Postgraduates + email_group_data_3: Continuing Ed. Postgraduates + email_group_data_4: Other + mail_subject: this is an announcement reminder from【%{site_title}】 + other_mailaddress: Other Email + other_mailaddress_note: Divide different email accounts with "," + mail_hi: Hi + mail_url_view: This email is the reminder of an announcement, please click the link for the details + mail_source: Source + mail_time: Time + diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index b3bf356f9..7c29cab3d 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -37,4 +37,22 @@ zh_tw: widget: bulletins_and_web_links: 分眾頁籤 index: 索引 - search: 搜尋 \ No newline at end of file + search: 搜尋 + email_eminder: 寄送提醒 + activate_email_eminder: 開啟寄送提醒 + email_sentdate: 寄送時間 + email_group: 寄送群組 + other_mailaddress: 其他Mail + other_mailaddress_note: 輸入多組mail時,請用","逗號隔開 + email_group_data_0: 全校教職員 + email_group_data_1: 大學部學生 + email_group_data_2: 日間部研究生 + email_group_data_3: 進修部研究生 + email_group_data_4: 其他 + mail_subject: 來自【%{site_title}】的公告事件提醒 + mail_hi: 您好 + mail_url_view: 此封信件為公告事件提醒,請點選以下連結詳細觀看 + mail_source: 來源 + mail_time: 時間 + + diff --git a/vendor/built_in_modules/er_email/.gitignore b/vendor/built_in_modules/er_email/.gitignore new file mode 100644 index 000000000..1dfe31e60 --- /dev/null +++ b/vendor/built_in_modules/er_email/.gitignore @@ -0,0 +1,7 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/log/*.log +test/dummy/tmp/ +test/dummy/.sass-cache diff --git a/vendor/built_in_modules/er_email/Gemfile b/vendor/built_in_modules/er_email/Gemfile new file mode 100644 index 000000000..e9d2bcf38 --- /dev/null +++ b/vendor/built_in_modules/er_email/Gemfile @@ -0,0 +1,17 @@ +source "http://rubygems.org" + +# Declare your gem's dependencies in er_email.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# jquery-rails is used by the dummy application +gem "jquery-rails" + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/vendor/built_in_modules/er_email/MIT-LICENSE b/vendor/built_in_modules/er_email/MIT-LICENSE new file mode 100644 index 000000000..5146945d9 --- /dev/null +++ b/vendor/built_in_modules/er_email/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2013 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/built_in_modules/er_email/README.rdoc b/vendor/built_in_modules/er_email/README.rdoc new file mode 100644 index 000000000..5e75970bb --- /dev/null +++ b/vendor/built_in_modules/er_email/README.rdoc @@ -0,0 +1,3 @@ += ErEmail + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/vendor/built_in_modules/er_email/Rakefile b/vendor/built_in_modules/er_email/Rakefile new file mode 100644 index 000000000..a021c8b42 --- /dev/null +++ b/vendor/built_in_modules/er_email/Rakefile @@ -0,0 +1,40 @@ +#!/usr/bin/env rake +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'ErEmail' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task :default => :test diff --git a/vendor/built_in_modules/er_email/app/assets/images/er_email/.gitkeep b/vendor/built_in_modules/er_email/app/assets/images/er_email/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/assets/javascripts/er_email/.gitkeep b/vendor/built_in_modules/er_email/app/assets/javascripts/er_email/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/assets/stylesheets/er_email/.gitkeep b/vendor/built_in_modules/er_email/app/assets/stylesheets/er_email/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/controllers/.gitkeep b/vendor/built_in_modules/er_email/app/controllers/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/controllers/application_controller.rb b/vendor/built_in_modules/er_email/app/controllers/application_controller.rb new file mode 100644 index 000000000..307a4acd8 --- /dev/null +++ b/vendor/built_in_modules/er_email/app/controllers/application_controller.rb @@ -0,0 +1,23 @@ +class ApplicationController < ActionController::Base + protect_from_forgery + before_filter :set_locale + + # Set I18n.locale + def set_locale + # update session if passed + session[:locale] = params[:locale] if params[:locale] + + # set locale based on session or default + begin + # check if locale is valid for non site pages + if !VALID_LOCALES.include?(session[:locale]) + I18n.locale = I18n.default_locale + else + I18n.locale = session[:locale] + end + rescue + I18n.locale = I18n.default_locale + end + end + +end diff --git a/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/approvals_controller.rb b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/approvals_controller.rb new file mode 100644 index 000000000..70883ce7f --- /dev/null +++ b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/approvals_controller.rb @@ -0,0 +1,145 @@ +class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController + before_filter :authenticate_user! + before_filter :is_admin? + include AdminHelper + # layout 'admin' + + + def preview_and_approve + email_group_data + @email_er = EmailEr.find params[:email_er_id] + end + + def approve + notice = "" + @email_er = EmailEr.find params[:email_er_id] + @email_er.proc_check(params[:email_er][:is_checked],params[:email_er][:not_checked_reason]) + @email_er.de_pending + if @email_er.save + + if @email_er.is_checked == true and !@email_er.is_rejected + send_email_data(@email_er) + end + + notice = t('er_email.approve_email_er_success') + else + notice = t('er_email.approve_email_er_fail') + end + redirect_to(panel_er_email_back_end_email_ers_url,:notice => notice) + end + + def setting + @sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user + @email_er_categorys = EmailErCategory.all + @options_from_collection_for_select_email_er_categorys = @email_er_categorys.collect{|bc| [bc.title,bc.id] } + if params.has_key? :category + @email_er_category = EmailErCategory.find params[:category][:id] + else + @email_er_category = @email_er_categorys.first + end + preload_object_auth = @email_er_category.get_object_auth_by_title('fact_check') + @users_array = preload_object_auth.privilege_users rescue [] + respond_to do |format| + format.html + format.js + end + end + + def update_setting + object_auth = update_setting_by_params + if object_auth.save! + flash[:notice] = t('update.success_') + else + flash[:notice] = t('update.fail') + end + end + + def user_list + @email_er_category = EmailErCategory.find params[:category][:id] + end + + protected + def update_setting_by_params + category = EmailErCategory.find params[:category][:id] + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check') + object_auth = object_auth_ary.first + object_auth.privilege_users = privilege_users + object_auth + end + + def send_email_data(email_er) + + @user = User.find(email_er.create_user_id) + + email_group_data + + @group_mail = Array.new + + email_er.email_group.each do |egroup| + + if @email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') + + @group_mail << @email_group_data[egroup]["email"] + + elsif @email_group_data.include?(egroup) and egroup == '4' + + @group_mail << email_er.other_mailaddress + + end + + end + + if !@group_mail.join.blank? + + @mail_content = { + "text" => email_er.mail_content + } + + @mail_cron = { + :mail_from_app => 'er_email', + :mail_from => @user.email, + :mail_reply_to => @user.email, + :mail_subject => email_er.mail_subject, + :mail_to => @group_mail.join(','), + :mail_content => @mail_content , + # :mail_sentdate => email_er.mail_sentdate, + :mail_sentdate => DateTime.now, + :create_user_id => email_er.create_user_id, + :update_user_id => email_er.create_user_id + } + + @mail_cron = MailCron.new(@mail_cron) + + email_er.email_er_files.each do | mrfile | + + @mcfile = @mail_cron.mail_cron_files.build + + tmp_file = File.new(mrfile.file_identifier, 'w+') + + tmp_file.write(Mongo::GridFileSystem.new(Mongoid.database).open(mrfile.file.url.gsub("/gridfs/", ""), 'r').read.force_encoding("UTF-8")) + + @mcfile.file = tmp_file + + @mcfile.title = mrfile.title + + # delete file + FileUtils.rm_f(tmp_file) + + end + + @mail_cron.save + + MailCron.send_mail_now(@mail_cron.id) + + end + + end + + def email_group_data + + @email_group_data = EmailEr.email_group_data + + end + +end diff --git a/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb new file mode 100644 index 000000000..e1bd71c4f --- /dev/null +++ b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb @@ -0,0 +1,128 @@ +class Panel::ErEmail::BackEnd::EmailErCategorysController < OrbitBackendController + include OrbitControllerLib::DivisionForDisable + + before_filter :for_app_manager,:except => [:index,:get_categorys_json] + before_filter :force_order_for_visitor,:only=>[:index,:get_categorys_json] + before_filter :force_order_for_user,:except => [:index,:get_categorys_json] + before_filter :for_app_sub_manager,:except => [:index,:get_categorys_json] + + + def index + @email_er_categorys = get_categories_for_index("EmailErCategory") + @email_er_category = EmailErCategory.new(:display => 'List') + + @url = panel_er_email_back_end_email_er_categorys_path + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + def get_categorys_json + categorys = EmailErCategory.all + data = Array.new + + categorys.each do |c| + data << { + category: c.title, + link: "#{url_for( :action => "index", + :controller => "panel/er_email/back_end/email_ers", + :format => :rss, + :only_path => false, + :inner=>true, + :category_id => c )}" + } + end + render :json => JSON.pretty_generate(data) + end + + # GET /email_ers/1 + # GET /email_ers/1.xml + def show + @email_er_category = EmailErCategory.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + end + end + + # GET /email_ers/new + # GET /email_ers/new.xml + def new + @email_er_category = EmailErCategory.new(:display => 'List') + + respond_to do |format| + format.html # new.html.erb + format.js + end + end + + # GET /email_ers/1/edit + def edit + @email_er_category = EmailErCategory.find(params[:id]) + + @url = panel_er_email_back_end_email_er_category_path(@email_er_category) + + respond_to do |format| + format.html + format.js + end + end + + # POST /email_ers + # POST /email_ers.xml + def create + @email_er_category = EmailErCategory.new(params[:email_er_category]) + + respond_to do |format| + if @email_er_category.save + format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url, :notice => t('email_er_category.create_email_er_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /email_ers/1 + # PUT /email_ers/1.xml + def update + @email_er_category = EmailErCategory.find(params[:id]) + + @url = panel_er_email_back_end_email_er_category_path(@email_er_category) + + respond_to do |format| + if @email_er_category.update_attributes(params[:email_er_category]) + format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url, :notice => t('email_er_category.update_email_er_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + # DELETE /email_ers/1 + # DELETE /email_ers/1.xml + def destroy + @email_er_category = EmailErCategory.find(params[:id]) + @email_er_category.disable = @email_er_category.disable ? false : true + + if @email_er_category.save! + respond_to do |format| + flash[:notice] = t("update.success_") + # flash[:error] += @email_er_category.disable ? t(:enable) : t(disable) + format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("update.fail") + format.html { render :action => "index" } + end + end +end diff --git a/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb new file mode 100644 index 000000000..d2d2fb863 --- /dev/null +++ b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb @@ -0,0 +1,318 @@ +class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController + # before_filter :for_app_manager,:except => [:index,:show] + include OrbitControllerLib::DivisionForDisable + + + before_filter :force_order_for_user + + + before_filter :only => [ :new,:edit,:update,:create] do |controller| + controller.get_categorys('EmailErCategory') + end + + def preview + email_er = EmailEr.new params + @preview_obj = email_er.to_preview + @preview_obj.save + render '/shared/preview/preview.html.erb',:layout=>false + end + + def index + + get_categorys("EmailErCategory",params[:email_er_category_id]) + + email_group_data + + @filter = params[:filter] + new_filter = params[:new_filter] + + if @filter && params[:clear] + @filter.delete(params[:type]) + elsif @filter && new_filter + if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) + @filter[new_filter[:type]].delete(new_filter[:id].to_s) + elsif @filter.has_key?(new_filter[:type]) + @filter[new_filter[:type]] << new_filter[:id].to_s + else + @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) + end + elsif new_filter + @filter = {new_filter[:type] => [new_filter[:id].to_s]} + end + + @email_er_categories = get_categories_for_index("EmailErCategory") + @email_er_category_ids = @email_er_categories.collect{|t| t.id.to_s} + [nil] + + @email_ers = (params[:sort] || @filter) ? get_sorted_and_filtered("email_er",:email_er_category_id.in => @email_er_category_ids) : get_viewable("email_er",:email_er_category_id.in => @email_er_category_ids) + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @email_ers } + format.js + end + end + + # GET /email_ers/1 + # GET /email_ers/1.xml + + def show + + email_group_data + + @item = Page.find(params[:page_id]) rescue nil + if params[:preview] == "true" + preview_content + else + @email_er = EmailEr.all.can_display.where(_id: params[:id]).first + if @email_er and !@email_er.disable? and !@email_er.is_rejected + if @email_er.enabled_for_lang(I18n.locale.to_s) + delayed_impressionist(@email_er) + # get_categorys + else + render :text => "
#{t('sys.can_not_display_due_to_no_context')}
".html_safe + end + else + render :nothing => true, :status => 403 + end + end + + end + + def preview_content + @email_er = EmailEr.find params[:id] rescue nil + @email_er = Preview.find(params[:id]).get_virtual_object if @email_er.nil? + # get_categorys + end + + # GET /email_ers/new + # GET /email_ers/new.xml + def new + + email_group_data + + @email_er = EmailEr.new(:mail_sentdate => DateTime.now) + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @email_er } + end + end + + # GET /email_ers/1/edit + def edit + + email_group_data + + @email_er = EmailEr.find(params[:id]) + + end + + # POST /email_ers + # POST /email_ers.xml + def create + + email_group_data + + @email_er = EmailEr.new(params[:email_er]) + @email_er.create_user_id = current_user.id + @email_er.update_user_id = current_user.id + + if(is_manager? || is_admin?) + @email_er.is_checked = true + @email_er.is_rejected = false + @email_er.de_pending + end + + respond_to do |format| + if @email_er.save + + # if @email_er.is_checked == true and !@email_er.is_rejected + # send_email_data(@email_er) + # end + + format.html { redirect_to(panel_er_email_back_end_email_ers_url) } + format.xml { render :xml => @email_er, :status => :created, :location => @email_er } + # format.js + format.js { + @info = {"success"=>"true","redirect_url"=>panel_er_email_back_end_email_ers_url} + flash[:notice] = t('er_email.create_er_email_success') + render "/shared/preview/after_create.js.erb" + } + else + format.html { render :action => "new" } + format.xml { render :xml => @email_er.errors, :status => :unprocessable_entity } + format.js { + @info = {"success"=>"false","redirect_url"=>new_panel_er_email_back_end_email_er_url(:email_er => @email_er)} + session[:in_validate_object] = @email_er + render "/shared/preview/after_create.js.erb" + } + end + end + end + + # PUT /email_ers/1 + # PUT /email_ers/1.xml + def update + + email_group_data + + @email_er = EmailEr.find(params[:id]) + + @email_er.update_user_id = current_user.id + + respond_to do |format| + if @email_er.update_attributes(params[:email_er]) + + if(is_manager? || is_admin?) + @email_er.is_checked = true + @email_er.is_rejected = false + @email_er.de_pending! + end + + if @email_er.is_checked == true and !@email_er.is_rejected + send_email_data(@email_er) + end + + format.html { redirect_to(panel_er_email_back_end_email_ers_url(:page => params[:page])) } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @email_er.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /email_ers/1 + # DELETE /email_ers/1.xml + def destroy + @email_er = EmailEr.find(params[:id]) + @email_er.destroy + + respond_to do |format| + format.html { redirect_to(panel_er_email_back_end_email_ers_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + # email_ers = EmailEr.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def email_resend + if params[:id] + @email_er = EmailEr.find(params[:id]) + + @email_er.is_checked = false + @email_er.is_pending = true + + @email_er.save + + end + redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def test_send_email + if params[:id] + @email_er = EmailEr.find(params[:id]) + + if (@email_er.create_user_id == current_or_guest_user.id) || is_manager? + if current_or_guest_user.admin? || (!@email_er.is_rejected? && !@email_er.is_checked?) + if @email_er.is_pending + send_email_data( @email_er , true ) + end + end + end + end + redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + protected + + def send_email_data(email_er , test_send = false) + + @user = User.find(email_er.create_user_id) + + if !test_send + + email_group_data + + @group_mail = Array.new + + email_er.email_group.each do |egroup| + + if @email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') + + @group_mail << @email_group_data[egroup]["email"] + + elsif @email_group_data.include?(egroup) and egroup == '4' + + @group_mail << email_er.other_mailaddress + + end + + end + + else + + # @group_mail = ["spen@rulingcom.com"] + @group_mail = [@user.email] + + end + + if !@group_mail.join.blank? + + @mail_content = { + "text" => email_er.mail_content + } + + @mail_cron = { + :mail_from_app => 'er_email', + :mail_from => @user.email, + :mail_reply_to => @user.email, + :mail_subject => email_er.mail_subject, + :mail_to => @group_mail.join(','), + :mail_content => @mail_content , + # :mail_sentdate => email_er.mail_sentdate, + :mail_sentdate => DateTime.now, + :create_user_id => email_er.create_user_id, + :update_user_id => email_er.create_user_id + } + + @mail_cron = MailCron.new(@mail_cron) + + email_er.email_er_files.each do | mrfile | + + @mcfile = @mail_cron.mail_cron_files.build + + tmp_file = File.new(mrfile.file_identifier, 'w+') + + tmp_file.write(Mongo::GridFileSystem.new(Mongoid.database).open(mrfile.file.url.gsub("/gridfs/", ""), 'r').read.force_encoding("UTF-8")) + + @mcfile.file = tmp_file + + @mcfile.title = mrfile.title + + # delete file + FileUtils.rm_f(tmp_file) + + end + + @mail_cron.save + + MailCron.send_mail_now(@mail_cron.id) + + end + + end + + def email_group_data + + @email_group_data = EmailEr.email_group_data + + end + +end diff --git a/vendor/built_in_modules/er_email/app/helpers/.gitkeep b/vendor/built_in_modules/er_email/app/helpers/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_er_categorys_helper.rb b/vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_er_categorys_helper.rb new file mode 100644 index 000000000..ceeaf9cdc --- /dev/null +++ b/vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_er_categorys_helper.rb @@ -0,0 +1,16 @@ +module Panel::ErEmail::BackEnd::EmailErCategorysHelper +include ActionView::Helpers::UrlHelper + + + def show_anc_cate_permission_link(email_er_category) + type = 'submit' + oa = email_er_category.get_object_auth_by_title(type) + if oa.nil? + email_er_category.object_auths.new(title: type ).save + oa = email_er_category.get_object_auth_by_title(type) + end +# link_to t(:category_auth), edit_admin_object_auth_path(oa) + link_to t(:category_auth),admin_object_auth_ob_auth_path(oa) + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_ers_helper.rb b/vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_ers_helper.rb new file mode 100644 index 000000000..9b9df0a71 --- /dev/null +++ b/vendor/built_in_modules/er_email/app/helpers/panel/er_email/back_end/email_ers_helper.rb @@ -0,0 +1,58 @@ +module Panel::ErEmail::BackEnd::EmailErsHelper + def show_reject_reason(email_er) + by_email_er = email_er.is_rejected + by_user = (((email_er.create_user_id == current_user.id) rescue nil) or is_manager? or is_admin?) + by_email_er && by_user + end + + def show_form_status_field(email_er) + #by_email_er = (!email_er.is_expired? and email_er.is_pending?) + by_user = ((email_er.email_er_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?) + by_user + end + + def show_approval_link(email_er) + by_email_er = (email_er.is_pending?) + by_user = ((email_er.email_er_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?) + by_email_er and by_user + end + + def show_delete_link(email_er) + if !current_user.nil? + by_email_er = (email_er.create_user_id == current_user.id ) + by_user = (is_manager? or is_admin?) + by_email_er or by_user + else + false + end + + end + + def show_email_er_title_at_index (email_er) + if email_er.is_checked? + link_to email_er.title, panel_er_email_front_end_email_er_path(email_er, :category_id => email_er.email_er_category.id) rescue '' + else + email_er.title + end + end + + def file_picture_preview_setting(file_path) + ext = File.extname(file_path)[1..-1].downcase + unless file_path.nil? + case ext + when "jpg","jpeg","png","gif" + {"data-content" => "#{image_tag file_path}" } + when "pdf", "zip", "rar" + {"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/#{ext}/#{ext}-64_32.png")}"} + when "doc", "docx" + {"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/docx_mac/docx_mac-64_32.png")}"} + when "xls", "xlsx" + {"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/xlsx_mac/xlsx_mac-64_32.png")}"} + when "ppt", "pptx" + {"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/pptx_mac/pptx_mac-64_32.png")}"} + else + {"data-content" => t("sys.not_previewable") } + end + end + end +end diff --git a/vendor/built_in_modules/er_email/app/mailers/.gitkeep b/vendor/built_in_modules/er_email/app/mailers/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/models/.gitkeep b/vendor/built_in_modules/er_email/app/models/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/models/email_er.rb b/vendor/built_in_modules/er_email/app/models/email_er.rb new file mode 100644 index 000000000..a3faaa180 --- /dev/null +++ b/vendor/built_in_modules/er_email/app/models/email_er.rb @@ -0,0 +1,123 @@ +# encoding: utf-8 + +class EmailEr + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + include OrbitCoreLib::Preview + + BelongsToCategory = :email_er_category + include OrbitCoreLib::BelongsToCategoryMayDisable + + PAYMENT_TYPES = @site_valid_locales + + field :mail_subject + field :mail_sentdate , :type => DateTime + field :mail_content + + field :create_user_id + field :update_user_id + + field :is_checked, :type => Boolean, :default => false + field :is_pending, :type => Boolean, :default => true + field :is_rejected, :type => Boolean, :default => false + + field :not_checked_reason + + field :email_group, :type => Array + field :other_mailaddress + + scope :can_display,where(is_hidden: false) + + has_many :email_er_files, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :email_er_files, :allow_destroy => true + + validates :mail_subject,presence:{message:'blank is not allowed'} + validates :other_mailaddress, + :length => {:maximum => 1000, :message => I18n.t("er_email.other_mailaddress_note_limit")} + + def proc_check(check,not_pass_info = "") + self.is_checked = true + if check =="true" + self.is_rejected = false + elsif check == "false" + self.is_rejected = true + self.not_checked_reason = not_pass_info + end + end + + def de_pending + self.is_pending = false + end + + def de_pending! + de_pending + self.save! + end + + def is_checked? + !self.is_pending && self.is_checked && (self.is_rejected == false) + end + + def is_pending? + self.is_pending + end + + def is_rejected? + !self.is_pending && self.is_rejected && (self.is_rejected == true) + end + + def get_email_group_data(email_group_data) + + group_mail = Array.new + + self.email_group.each do |egroup| + + if email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') + + group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})" + + elsif email_group_data.include?(egroup) and egroup == '4' + + self.other_mailaddress.split(",").each do |otmail| + + group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})" + + end + + end + + end + + group_mail.join("
").html_safe + + end + + def to_preview + preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_er_email_back_end_email_er_path",:object_class_type=>"EmailEr") + + self.email_er["email_er_files_attributes"].each_with_index do |atr,idx| + preview_object.preview_files.build(:file=>self.email_er["email_er_files_attributes"][idx.to_s],:field_name_for_rebuild=>'email_er_files',:file_in_array=>true) + end unless self.email_er["email_er_files_attributes"].nil? + + preview_object.object = self.email_er.except("email_er_files_attributes") + preview_object + end + + protected + + def self.email_group_data + + @email_group_data = { + '0'=> {"name"=>I18n.t('er_email.email_group_data_0'), "email"=>"alluser@tea.ntue.edu.tw"}, + '1'=> {"name"=>I18n.t('er_email.email_group_data_1'), "email"=>"allstu@tea.ntue.edu.tw"}, + '2'=> {"name"=>I18n.t('er_email.email_group_data_2'), "email"=>"allgrad@tea.ntue.edu.tw"}, + '3'=> {"name"=>I18n.t('er_email.email_group_data_3'), "email"=>"allad@tea.ntue.edu.tw"}, + '4'=> {"name"=>I18n.t('er_email.email_group_data_4')} + } + + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/er_email/app/models/email_er_category.rb b/vendor/built_in_modules/er_email/app/models/email_er_category.rb new file mode 100644 index 000000000..ff392e0e0 --- /dev/null +++ b/vendor/built_in_modules/er_email/app/models/email_er_category.rb @@ -0,0 +1,47 @@ +# encoding: utf-8 + +class EmailErCategory + include Mongoid::Document + include Mongoid::Timestamps + include OrbitCoreLib::ObjectAuthable + include OrbitCoreLib::ObjectDisable + include Sunspot::Mongo + # include Mongoid::MultiParameterAttributes + APP_NAME = 'ErEmail' + ObjectAuthTitlesOptions = %W{submit_new fact_check} + AfterObjectAuthUrl = '/panel/er_email/back_end/email_er_categorys' + + field :disable, type: Boolean, :default => false + field :display + field :key + field :title, localize: true + + has_many :email_ers + + validates :title, :at_least_one => true + + searchable do + text :titles do + title_translations.to_a.collect{|t| t[1]} + end + + boolean :frontend_search do + !disable + end + + text :files do + email_ers.can_display.collect{|t| t.title_translations.to_a.collect{|t| t[1]}} + end + + end + + + def pp_object + title + end + + def self.from_id(id) + EmailErCategory.find(id) rescue nil + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/er_email/app/models/email_er_file.rb b/vendor/built_in_modules/er_email/app/models/email_er_file.rb new file mode 100644 index 000000000..4e5d176e2 --- /dev/null +++ b/vendor/built_in_modules/er_email/app/models/email_er_file.rb @@ -0,0 +1,23 @@ +class EmailErFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :should_destroy, :type => Boolean + field :title + + belongs_to :email_er + + validate :file_size + + private + + def file_size + if file.file.size > 1.megabytes + errors.add( :file, I18n.t("er_email.email_file_limit")) + end + end + +end diff --git a/vendor/built_in_modules/er_email/app/views/.gitkeep b/vendor/built_in_modules/er_email/app/views/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb new file mode 100644 index 000000000..29f3610dd --- /dev/null +++ b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb @@ -0,0 +1,68 @@ + <% if email_er -%> + + + + + +<% end -%> diff --git a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb new file mode 100644 index 000000000..fb84ddeed --- /dev/null +++ b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb @@ -0,0 +1,44 @@ +<% if email_er_category -%> + +
diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index b6a747a4e..4795124d2 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -17,6 +17,7 @@ en: postdate: Post Date title: Title subtitle: SubTitle + bulletin_create_dept: Unit editing_announcement: Edit Announcement editing_announcement_category: Edit Category error: diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index 7c29cab3d..133c1aae9 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -17,6 +17,7 @@ zh_tw: postdate: 張貼日期 title: 標題 subtitle: 副標題 + bulletin_create_dept: 單位 editing_announcement: 編輯類別 editing_announcement_category: 編輯類別 error: diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index b8f214efc..a3d43b7ca 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -37,6 +37,7 @@ module Announcement link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self,:preview=>true} link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}} field :subtitle + field :bulletin_create_dept link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus' end diff --git a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb index 29f3610dd..fafab9738 100644 --- a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb +++ b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb @@ -11,6 +11,14 @@ + <% if @email_er.email_er_files.size > 0 %> + <%= label_tag t('file_')%> + <% @email_er.email_er_files.each do | efile | %> + <%= link_to (!efile.title.blank? ? efile.title : t('download')), efile.file.url, {:target => '_blank', :title => efile.title} if efile.file.file %> + <% end %> +
+ <% end %> + <% if !@email_er.email_group.blank? %> <%= label_tag 'group_mail' %> <%= @email_er.get_email_group_data(@email_group_data) %> diff --git a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/show.html.erb b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/show.html.erb index 307b39233..71d7b6eda 100644 --- a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/show.html.erb +++ b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/show.html.erb @@ -1 +1,4 @@ - <%= @email_er.mail_content.html_safe %> \ No newline at end of file +
    +
  • <%= label_tag t("er_email.mail_subject") %><%= @email_er.mail_subject %>
  • +
  • <%= label_tag t("er_email.mail_content") %><%= @email_er.mail_content.html_safe %>
  • +
\ No newline at end of file From 9da9284a7f88e3006878ee8bff1d5cf325158cd2 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 16 Sep 2013 02:53:16 +0800 Subject: [PATCH 03/21] First version of new feed for announcement --- .../back_end/bulletins_controller.rb | 39 ++++++++++++++++++- .../announcement/config/routes.rb | 1 + 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index edc7c012b..3339f46de 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -7,8 +7,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # before_filter :for_admin_only,:only => [:] # before_filter :for_app_manager,:only => [:index,:show,] before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins] - before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins] - before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins] + before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins, :get_bulletins_as_json] + before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins, :get_bulletins_as_json] before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| controller.get_categorys('BulletinCategory') @@ -312,6 +312,41 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) end + # ================================================================ + # language: + # - default: zh_tw + # - specify language: locale=[string] + # category: + # - default: no category + # - specify: category_id=[ID] + # pagination: + # - default: no pagination + # - use it: paginate=true + # - specify the number of results: per=[number] + # - specify the page: page=[number] + # ================================================================ + def get_bulletins_as_json + I18n.locale = params[:locale] || :zh_tw + bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.admin_manager_all.order_by(:created_at, :desc) + bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) if params[:paginate] + + custom_bulletins = bulletins.inject([]) do |data, bulletin| + deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) + image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" + data << { + title: bulletin.title, + link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", + image: "#{request.protocol}#{request.host_with_port}#{image_url}", + category: bulletin.bulletin_category.title, + content: bulletin.text, + postdate: display_date_time(bulletin.postdate), + deadline: deadline, + tag: bulletin.sorted_tags.map{|tag| tag.name} + } + end + render json: JSON.pretty_generate(custom_bulletins) + end + protected diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index adb637038..68d11ef02 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -17,6 +17,7 @@ Rails.application.routes.draw do get 'load_quick_edit' end collection do + get "get_bulletins_as_json" post "preview" put "preview" get 'delete' From 842f072e1a3d7e89aed6c4fa591caa3da65f8f67 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 16 Sep 2013 03:16:23 +0800 Subject: [PATCH 04/21] Fix scope error --- .../panel/announcement/back_end/bulletins_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 3339f46de..b60461e1e 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -327,7 +327,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # ================================================================ def get_bulletins_as_json I18n.locale = params[:locale] || :zh_tw - bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.admin_manager_all.order_by(:created_at, :desc) + bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.all.order_by(:created_at, :desc) bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) if params[:paginate] custom_bulletins = bulletins.inject([]) do |data, bulletin| From b970103e90caedf53368d5ce52035efc8376c30f Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 17 Sep 2013 15:51:46 +0800 Subject: [PATCH 05/21] fixed external links opening in different window --- app/controllers/front_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb index 02098f8a5..da6082976 100644 --- a/app/controllers/front_controller.rb +++ b/app/controllers/front_controller.rb @@ -73,7 +73,7 @@ class FrontController < ApplicationController res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page)) res << "'>" root = "/" - res << "#{page.title}" + res << "#{page.title}" if page.visible_children.size > 0 && current < menu.levels res << "" res << menu_level(page, current_page, current + 1, menu) From 64d07a0c956fecc25d0111ce75a96f12a547dd2d Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 17 Sep 2013 18:06:20 +0800 Subject: [PATCH 06/21] link widget for ntue updated --- .../web_resource/widget/web_links/_index.html.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/_index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/_index.html.erb index 1f9f36549..95cf35c3c 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/_index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/_index.html.erb @@ -8,10 +8,12 @@ From 2d714dfa4bfb2e3f580cbf45a9a26ec5b9746182 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 19:57:54 +0800 Subject: [PATCH 07/21] Changes to have both json and rss, add categories --- .../back_end/bulletin_categorys_controller.rb | 24 ++++++++-- .../back_end/bulletins_controller.rb | 44 +++++++++++-------- .../get_bulletin_categories.rss.builder | 16 +++++++ .../bulletins/get_bulletins.rss.builder | 21 +++++++++ .../announcement/config/routes.rb | 3 +- 5 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 91f458c81..4e33dcd23 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -9,12 +9,12 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo # @module_app = ModuleApp.where(:title=>'Announcement').first # end # ======= - before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_bulletins_json] + before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_bulletins_json, :get_bulletin_categories] before_filter :force_order_for_visitor,:only=>[:index,:get_categorys_json,:get_bulletins_json] - before_filter :force_order_for_user,:except => [:index,:get_categorys_json,:get_bulletins_json] - before_filter :for_app_sub_manager,:except => [:index,:get_categorys_json,:get_bulletins_json] + before_filter :force_order_for_user,:except => [:index,:get_categorys_json,:get_bulletins_json, :get_bulletin_categories] + before_filter :for_app_sub_manager,:except => [:index,:get_categorys_json,:get_bulletins_json, :get_bulletin_categories] def index @bulletin_categorys = get_categories_for_index("BulletinCategory") @@ -53,6 +53,24 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo render :json => JSON.pretty_generate(data) end + def get_bulletin_categories + I18n.locale = params[:locale] || :zh_tw + @categories = BulletinCategory.all.order_by(:title, :asc) + respond_to do |format| + format.json { + custom_categories = @categories.inject([]) do |data, category| + data << { + title: category.title, + link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(bulletin_category_id: category.id, locale: I18n.locale)}", + link_json: "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale)}" + } + end + render json: JSON.pretty_generate(custom_categories) + } + format.rss {} + end + end + def get_bulletins_json bulletin = BulletinCategory.find(params[:bulletin_category_id]).bulletins p bulletin diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index b60461e1e..cd8fb2f23 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -7,8 +7,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # before_filter :for_admin_only,:only => [:] # before_filter :for_app_manager,:only => [:index,:show,] before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins] - before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins, :get_bulletins_as_json] - before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins, :get_bulletins_as_json] + before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins, :get_bulletins] + before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins, :get_bulletins] before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| controller.get_categorys('BulletinCategory') @@ -320,31 +320,37 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # - default: no category # - specify: category_id=[ID] # pagination: - # - default: no pagination - # - use it: paginate=true + # - default: 10 # - specify the number of results: per=[number] # - specify the page: page=[number] # ================================================================ - def get_bulletins_as_json + def get_bulletins I18n.locale = params[:locale] || :zh_tw bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.all.order_by(:created_at, :desc) - bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) if params[:paginate] + @bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) - custom_bulletins = bulletins.inject([]) do |data, bulletin| - deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) - image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" - data << { - title: bulletin.title, - link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", - image: "#{request.protocol}#{request.host_with_port}#{image_url}", - category: bulletin.bulletin_category.title, - content: bulletin.text, - postdate: display_date_time(bulletin.postdate), - deadline: deadline, - tag: bulletin.sorted_tags.map{|tag| tag.name} + respond_to do |format| + format.json { + custom_bulletins = @bulletins.inject([]) do |data, bulletin| + deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) + image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" + data << { + title: bulletin.title, + link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", + image: "#{request.protocol}#{request.host_with_port}#{image_url}", + category: bulletin.bulletin_category.title, + content: bulletin.text, + postdate: display_date_time(bulletin.postdate), + deadline: deadline, + tag: bulletin.sorted_tags.map{|tag| tag.name} + } + end + render json: JSON.pretty_generate(custom_bulletins) + } + format.rss { + @category = BulletinCategory.find(params[:category_id]) rescue nil } end - render json: JSON.pretty_generate(custom_bulletins) end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder new file mode 100644 index 000000000..d725278f7 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder @@ -0,0 +1,16 @@ +xml.instruct! :xml, :version => "1.0" +xml.rss :version => "2.0" do + xml.channel do + xml.title t('announcement.announcement') + ' ' + t('announcement.categories') + xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletin_categories_panel_announcement_back_end_bulletin_categorys_path(format: 'rss')}" + + @categories.each do |category| + xml.item do + xml.title category.title + xml.pubDate category.created_at.to_s(:rfc822) + xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: category.id, locale: I18n.locale, format: 'rss')}" + xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(bulletin_category_id: category.id)}" + end + end + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder new file mode 100644 index 000000000..aa7c1e5be --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder @@ -0,0 +1,21 @@ +xml.instruct! :xml, :version => "1.0" +xml.rss :version => "2.0" do + xml.channel do + if @category + xml.title @category.title + else + xml.title t('announcement.announcement') + end + xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: @category.try(:id))}.rss" + + @bulletins.each do |bulletin| + xml.item do + xml.title bulletin.title + xml.pubDate bulletin.postdate.to_s(:rfc822) + xml.description bulletin.text + xml.link "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}" + xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin)}" + end + end + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 68d11ef02..08cc9187e 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -17,7 +17,7 @@ Rails.application.routes.draw do get 'load_quick_edit' end collection do - get "get_bulletins_as_json" + get "get_bulletins" post "preview" put "preview" get 'delete' @@ -28,6 +28,7 @@ Rails.application.routes.draw do resources :bulletin_categorys do collection do + get "get_bulletin_categories" get 'get_categorys_json' end # if want to use json From 03189092d35723f836a97a40ec99ccc7beabfb7c Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 20:44:00 +0800 Subject: [PATCH 08/21] Do not show announcement in json and rss if no title in I18n.locale --- .../back_end/bulletins_controller.rb | 27 ++++++++++--------- .../bulletins/get_bulletins.rss.builder | 14 +++++----- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index cd8fb2f23..f0d8f496b 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -332,18 +332,21 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController respond_to do |format| format.json { custom_bulletins = @bulletins.inject([]) do |data, bulletin| - deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) - image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" - data << { - title: bulletin.title, - link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", - image: "#{request.protocol}#{request.host_with_port}#{image_url}", - category: bulletin.bulletin_category.title, - content: bulletin.text, - postdate: display_date_time(bulletin.postdate), - deadline: deadline, - tag: bulletin.sorted_tags.map{|tag| tag.name} - } + unless bulletin.title_translations[I18n.locale.to_s].blank? + deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) + image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" + data << { + title: bulletin.title, + link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", + image: "#{request.protocol}#{request.host_with_port}#{image_url}", + category: bulletin.bulletin_category.title, + content: bulletin.text, + postdate: display_date_time(bulletin.postdate), + deadline: deadline, + tag: bulletin.sorted_tags.map{|tag| tag.name} + } + end + data end render json: JSON.pretty_generate(custom_bulletins) } diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder index aa7c1e5be..ca9795632 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder @@ -9,12 +9,14 @@ xml.rss :version => "2.0" do xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: @category.try(:id))}.rss" @bulletins.each do |bulletin| - xml.item do - xml.title bulletin.title - xml.pubDate bulletin.postdate.to_s(:rfc822) - xml.description bulletin.text - xml.link "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}" - xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin)}" + unless bulletin.title_translations[I18n.locale.to_s].blank? + xml.item do + xml.title bulletin.title + xml.pubDate bulletin.postdate.to_s(:rfc822) + xml.description bulletin.text + xml.link "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}" + xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin)}" + end end end end From 20400816797c39b23ef6f05eb611cb793eea77e0 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 20:47:03 +0800 Subject: [PATCH 09/21] Revert "Do not show announcement in json and rss if no title in I18n.locale" This reverts commit 03189092d35723f836a97a40ec99ccc7beabfb7c. --- .../back_end/bulletins_controller.rb | 27 +++++++++---------- .../bulletins/get_bulletins.rss.builder | 14 +++++----- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index f0d8f496b..cd8fb2f23 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -332,21 +332,18 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController respond_to do |format| format.json { custom_bulletins = @bulletins.inject([]) do |data, bulletin| - unless bulletin.title_translations[I18n.locale.to_s].blank? - deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) - image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" - data << { - title: bulletin.title, - link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", - image: "#{request.protocol}#{request.host_with_port}#{image_url}", - category: bulletin.bulletin_category.title, - content: bulletin.text, - postdate: display_date_time(bulletin.postdate), - deadline: deadline, - tag: bulletin.sorted_tags.map{|tag| tag.name} - } - end - data + deadline = bulletin.deadline.nil? ? t(:no_deadline) : display_date_time(bulletin.deadline) + image_url = "#{'/' unless bulletin.image.url.start_with?('/')}#{bulletin.image.url}" + data << { + title: bulletin.title, + link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", + image: "#{request.protocol}#{request.host_with_port}#{image_url}", + category: bulletin.bulletin_category.title, + content: bulletin.text, + postdate: display_date_time(bulletin.postdate), + deadline: deadline, + tag: bulletin.sorted_tags.map{|tag| tag.name} + } end render json: JSON.pretty_generate(custom_bulletins) } diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder index ca9795632..aa7c1e5be 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder @@ -9,14 +9,12 @@ xml.rss :version => "2.0" do xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: @category.try(:id))}.rss" @bulletins.each do |bulletin| - unless bulletin.title_translations[I18n.locale.to_s].blank? - xml.item do - xml.title bulletin.title - xml.pubDate bulletin.postdate.to_s(:rfc822) - xml.description bulletin.text - xml.link "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}" - xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin)}" - end + xml.item do + xml.title bulletin.title + xml.pubDate bulletin.postdate.to_s(:rfc822) + xml.description bulletin.text + xml.link "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}" + xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin)}" end end end From f72697ae76feb54bd7301c9c64c20c9e07ac3a80 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 20:47:27 +0800 Subject: [PATCH 10/21] Do not show announcement in json and rss if no title in I18n.locale (fix) --- .../panel/announcement/back_end/bulletins_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index cd8fb2f23..764c8a4ca 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -327,6 +327,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def get_bulletins I18n.locale = params[:locale] || :zh_tw bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.all.order_by(:created_at, :desc) + bulletins.reject!{|b| b.title_translations[I18n.locale.to_s].blank?} @bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) respond_to do |format| From e851395f795c5b391ca5e43a20f79869c73a46d7 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 20:51:29 +0800 Subject: [PATCH 11/21] Revert "Do not show announcement in json and rss if no title in I18n.locale (fix)" This reverts commit f72697ae76feb54bd7301c9c64c20c9e07ac3a80. --- .../panel/announcement/back_end/bulletins_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 764c8a4ca..cd8fb2f23 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -327,7 +327,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def get_bulletins I18n.locale = params[:locale] || :zh_tw bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.all.order_by(:created_at, :desc) - bulletins.reject!{|b| b.title_translations[I18n.locale.to_s].blank?} @bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) respond_to do |format| From c4ca7f450af7d535b40dba6806d32392332e9637 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 20:52:02 +0800 Subject: [PATCH 12/21] Do not show announcement in json and rss if no title in I18n.locale (fix 2) --- .../panel/announcement/back_end/bulletins_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index cd8fb2f23..4e12455d0 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -327,6 +327,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def get_bulletins I18n.locale = params[:locale] || :zh_tw bulletins = params[:category_id] ? Bulletin.where(bulletin_category_id: params[:category_id]).order_by(:created_at, :desc) : Bulletin.all.order_by(:created_at, :desc) + bulletins = bulletins.reject{|b| b.title_translations[I18n.locale.to_s].blank?} @bulletins = Kaminari.paginate_array(bulletins).page(params[:page]).per(params[:per] || 10) respond_to do |format| From dfcb383e0f648661f67d5174a26cb2dc15c904a5 Mon Sep 17 00:00:00 2001 From: ruling Date: Tue, 17 Sep 2013 20:55:03 +0800 Subject: [PATCH 13/21] Fix link frontend and gallery json --- .../app/controllers/panel/gallery/back_end/albums_controller.rb | 2 +- .../views/panel/web_resource/front_end/web_links/index.html.erb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb index 177a290b4..7f9094c94 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb @@ -3,7 +3,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController # before_filter :force_order_for_user, :except => [:index,:get_album_json,:get_imgs_json] - before_filter :force_order_for_visitor,:only=>[:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs] + before_filter :force_order_for_visitor,:only=>[:index,:show,:get_albums,:imgs] before_filter :force_order_for_user,:except => [:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs] before_filter :for_app_sub_manager,:except => [:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs] # before_filter lambda diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb index 2b85372e3..e52af6a9a 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb @@ -10,11 +10,13 @@ From 663bb7776b9b8b36dba6d1b70adbab7b5c957752 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 23:11:23 +0800 Subject: [PATCH 14/21] Modification in rss feed for announcement: - subtitle instead of text - add rss link in the json for categories --- .../announcement/back_end/bulletin_categorys_controller.rb | 5 +++-- .../panel/announcement/back_end/bulletins_controller.rb | 2 +- .../back_end/bulletins/get_bulletins.rss.builder | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 4e33dcd23..9560b5165 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -61,8 +61,9 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo custom_categories = @categories.inject([]) do |data, category| data << { title: category.title, - link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(bulletin_category_id: category.id, locale: I18n.locale)}", - link_json: "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale)}" + link_html: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(bulletin_category_id: category.id, locale: I18n.locale)}", + link_json: "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale, format: 'json')}", + link_rss: "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale, format: 'rss')}" } end render json: JSON.pretty_generate(custom_categories) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 4e12455d0..ac19b4687 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -340,7 +340,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController link: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}", image: "#{request.protocol}#{request.host_with_port}#{image_url}", category: bulletin.bulletin_category.title, - content: bulletin.text, + description: bulletin.subtitle, postdate: display_date_time(bulletin.postdate), deadline: deadline, tag: bulletin.sorted_tags.map{|tag| tag.name} diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder index aa7c1e5be..ca8df5c6c 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/get_bulletins.rss.builder @@ -6,13 +6,13 @@ xml.rss :version => "2.0" do else xml.title t('announcement.announcement') end - xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: @category.try(:id))}.rss" + xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: @category.try(:id), format: 'rss')}" @bulletins.each do |bulletin| xml.item do xml.title bulletin.title xml.pubDate bulletin.postdate.to_s(:rfc822) - xml.description bulletin.text + xml.description bulletin.subtitle xml.link "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin, category_id: bulletin.bulletin_category.id, locale: I18n.locale)}" xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletin_path(bulletin)}" end From 52356d3316225ff0066030b49ff578277a68c0ec Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 27 Sep 2013 16:52:50 +0800 Subject: [PATCH 15/21] Fix params name for rss --- .../announcement/back_end/bulletin_categorys_controller.rb | 2 +- .../bulletin_categorys/get_bulletin_categories.rss.builder | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 9560b5165..66ccd3c54 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -61,7 +61,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo custom_categories = @categories.inject([]) do |data, category| data << { title: category.title, - link_html: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(bulletin_category_id: category.id, locale: I18n.locale)}", + link_html: "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(category_id: category.id, locale: I18n.locale)}", link_json: "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale, format: 'json')}", link_rss: "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale, format: 'rss')}" } diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder index d725278f7..6fad714d5 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/get_bulletin_categories.rss.builder @@ -8,8 +8,8 @@ xml.rss :version => "2.0" do xml.item do xml.title category.title xml.pubDate category.created_at.to_s(:rfc822) - xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(bulletin_category_id: category.id, locale: I18n.locale, format: 'rss')}" - xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(bulletin_category_id: category.id)}" + xml.link "#{request.protocol}#{request.host_with_port}#{get_bulletins_panel_announcement_back_end_bulletins_path(category_id: category.id, locale: I18n.locale, format: 'rss')}" + xml.guid "#{request.protocol}#{request.host_with_port}#{panel_announcement_front_end_bulletins_path(category_id: category.id)}" end end end From 4abe4f5c161cbb11d2fa688a56e2924e53676e34 Mon Sep 17 00:00:00 2001 From: Spen Date: Fri, 27 Sep 2013 17:06:12 +0800 Subject: [PATCH 16/21] ntue email_ers fix and announcement widget filed fix --- vendor/built_in_modules/announcement/init.rb | 4 ++-- .../panel/er_email/back_end/email_ers_controller.rb | 6 +++--- vendor/built_in_modules/er_email/app/models/email_er.rb | 5 +++-- .../built_in_modules/er_email/app/models/email_er_file.rb | 2 +- .../views/panel/er_email/back_end/email_ers/_form.html.erb | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index a3d43b7ca..b13043ae6 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -30,13 +30,13 @@ module Announcement widgets do default_widget do sorting 'desc(:postdate)' - query 'Bulletin.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )' + query 'Bulletin.can_display.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )' enable ["typeA","typeB_style3","typeC"] image :image field :postdate link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self,:preview=>true} link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}} - field :subtitle + link_field :subtitle,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self,:preview=>true} field :bulletin_create_dept link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus' end diff --git a/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb index d2d2fb863..c1e85acd2 100644 --- a/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb +++ b/vendor/built_in_modules/er_email/app/controllers/panel/er_email/back_end/email_ers_controller.rb @@ -126,9 +126,9 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController respond_to do |format| if @email_er.save - # if @email_er.is_checked == true and !@email_er.is_rejected - # send_email_data(@email_er) - # end + if @email_er.is_checked == true and !@email_er.is_rejected + send_email_data(@email_er) + end format.html { redirect_to(panel_er_email_back_end_email_ers_url) } format.xml { render :xml => @email_er, :status => :created, :location => @email_er } diff --git a/vendor/built_in_modules/er_email/app/models/email_er.rb b/vendor/built_in_modules/er_email/app/models/email_er.rb index a3faaa180..1819f3750 100644 --- a/vendor/built_in_modules/er_email/app/models/email_er.rb +++ b/vendor/built_in_modules/er_email/app/models/email_er.rb @@ -77,13 +77,14 @@ class EmailEr if email_group_data.include?(egroup) and (egroup == '0' or egroup == '1' or egroup == '2' or egroup == '3') - group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})" + #group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})" + group_mail << "#{email_group_data[egroup]["name"]}" elsif email_group_data.include?(egroup) and egroup == '4' self.other_mailaddress.split(",").each do |otmail| - group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})" + group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})" end diff --git a/vendor/built_in_modules/er_email/app/models/email_er_file.rb b/vendor/built_in_modules/er_email/app/models/email_er_file.rb index 4e5d176e2..fb1db3bb5 100644 --- a/vendor/built_in_modules/er_email/app/models/email_er_file.rb +++ b/vendor/built_in_modules/er_email/app/models/email_er_file.rb @@ -15,7 +15,7 @@ class EmailErFile private def file_size - if file.file.size > 1.megabytes + if file.file.size > 10.megabytes errors.add( :file, I18n.t("er_email.email_file_limit")) end end diff --git a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_form.html.erb b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_form.html.erb index cd07d2ba4..61651164f 100644 --- a/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_form.html.erb +++ b/vendor/built_in_modules/er_email/app/views/panel/er_email/back_end/email_ers/_form.html.erb @@ -105,7 +105,7 @@ $(document).ready(function() { $('#add_plugin_file a.add').live('click', function(){ var new_id = $(this).prev().attr('value'); - var old_id = new RegExp("new_add_plugin_files", "g"); + var old_id = new RegExp("new_email_er_files", "g"); $(this).prev().attr('value', parseInt(new_id) + 1); $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_file', f, :email_er_files) %>").replace(old_id, new_id)); }); From 19801eb10fb1d5f6c5862499fc66b3dbe55c04bc Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 17 Sep 2013 18:00:30 +0800 Subject: [PATCH 17/21] Fix parser_front_end.rb for page content --- lib/parsers/parser_front_end.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 46b5066df..60a2a680b 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -32,13 +32,7 @@ module ParserFrontEnd ret = '' part = PagePart.find(front['part_id']) if front['part_id'] ret << eval("\"#{front['path']}\"") rescue '' - args.each do |index,arg| - if index=="tag_id" || index=="category_id" - ret << (ret.include?("?") ? "&#{index}[]=#{arg}": "?#{index}[]=#{arg}" ) - else - ret << (ret.include?("?") ? "&#{index}=#{arg}": "?#{index}=#{arg}" ) - end - end if args + ret << (ret.include?("?") ? "&#{args.to_param}" : "?#{args.to_param}") if args fragment = Nokogiri::HTML::DocumentFragment.new(body, "
") end front.swap(fragment) From 5e1d6663a1c83a4c4371563c706209ad91159f57 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Mon, 30 Sep 2013 14:09:00 +0800 Subject: [PATCH 18/21] NTUE Logo --- app/assets/images/ncculogo.ico | Bin 1150 -> 1150 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/app/assets/images/ncculogo.ico b/app/assets/images/ncculogo.ico index 0550cd4b0bd2755757af230c69053cce5f62fb11..39fdc244bbf0bb44d8b370e4e6ec300b834dd884 100644 GIT binary patch literal 1150 zcmb`G(QDFC6vvMk&6u>cnL%z&*r+zzbhzpCw^S0FjYQZQ$;w~LWg3%AR#L;zHn+Bi z3YAtw87zW=2zqR_h*Ri4*F6aC{=UmRYmq@}^Z7mfo zxP?f`cKevPOT#27e%Xe_{)YY~p+bOz9!|p4e+Gg=4wJDDdPN;#{!yfp)6i_+g#(TgFgL1T-n$>Q3*m zyvsxr=x$I$uTrDa=wfU=bk4JwxpWy%7al@q6VbJepmRsjRV{^ncLO|jN2!wpxA94`xu}Xf6il9Eg zSbNB0Fjl^cM)*B+?dc#_UH7ftNfe<9Jve~scc_DUFYw!q{hrn2>g$cv3&@w<+#WF# zKV3dX{0iOM4)omNGx@!>#|gB57d~L$<*G>n-{IFpqu!(X7LkQhmyZ*>QI6=EFxRtd zz3!tBddJVuIfs48#(FNT*ZIbA?(!O9vNd77!Sx>z^{t(lHKF#@a(Dy!!X6T)?U=;Vzb&v4{ zeqSFesjWdh$t*GV)>^+u8uM+Kg}(PI>|+M4NQLjUg%`8_&t}!>X0?ZAbvI_8{+bOY Y%tr9b8F@0>puWQV!GhT}{R!6n2TpHZDgXcg From 2ec3d776009a22a39fce2097b01a57c8f9d9f329 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Sat, 14 Sep 2013 18:18:59 +0800 Subject: [PATCH 19/21] widget code rewritten for gallery master branch --- .../app/assets/images/gallery/nodata.jpg | Bin 0 -> 12657 bytes .../panel/gallery/widget/albums_controller.rb | 31 +++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100755 vendor/built_in_modules/gallery/app/assets/images/gallery/nodata.jpg diff --git a/vendor/built_in_modules/gallery/app/assets/images/gallery/nodata.jpg b/vendor/built_in_modules/gallery/app/assets/images/gallery/nodata.jpg new file mode 100755 index 0000000000000000000000000000000000000000..d3c857b6b60e374db099ebc86b9e48307644be79 GIT binary patch literal 12657 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,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6 @class = "c" + @settings["horizontal"].to_s @total = @settings["vertical"] * @settings["horizontal"] @rnd = Random.new @images = [] - for i in 0..@total-1 - image = @album_images[@rnd.rand(0...@album_images.count)] - values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} - @images << values + + if @album_images.count > @total + @randoms = [] + until @randoms.count == @total do + r = @rnd.rand(0...@album_images.count) + if !@randoms.include?r + @randoms << r + image = @album_images[r] + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + end + elsif @album_images.count == @total + @album_images.each do |image| + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + else + @album_images.each do |image| + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + until @images.count == @total do + values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} + @images << values + end end end From 4b7703f4af688a775c4cba2a54d29cd3af76dec0 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 13 Sep 2013 12:36:41 +0800 Subject: [PATCH 20/21] ad_banner banner load fixed for test site Conflicts: app/views/front/show_banner.html.erb --- app/views/front/show_banner.html.erb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/views/front/show_banner.html.erb b/app/views/front/show_banner.html.erb index 491dbe729..c35dd3647 100644 --- a/app/views/front/show_banner.html.erb +++ b/app/views/front/show_banner.html.erb @@ -1,5 +1,16 @@ - + +
+ +
+ <% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %> + <% if ad_image.display? %> + <%= ad_image.title || ' title='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= ad_image_link(ad_image) %>' style=' <%= 'cursor:pointer;' if !ad_image_link(ad_image).blank? %>'/> + <% end %> + <% end %> +
+
- -
- -
- <% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %> - <% if ad_image.display? %> - <%= ad_image.title || ' title='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= ad_image_link(ad_image) %>' style=' <%= 'cursor:pointer;' if !ad_image_link(ad_image).blank? %>'/> - <% end %> - <% end %> -
-
\ No newline at end of file From e56e91cc930feb4edee53312f793217656f4fc24 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Thu, 26 Sep 2013 15:56:43 +0800 Subject: [PATCH 21/21] Fix path of jquery.cycle.all.latest.js --- app/views/front/show_banner.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/front/show_banner.html.erb b/app/views/front/show_banner.html.erb index c35dd3647..f06e505b6 100644 --- a/app/views/front/show_banner.html.erb +++ b/app/views/front/show_banner.html.erb @@ -1,4 +1,4 @@ - +<%= javascript_include_tag "lib/jquery.cycle.all.latest.js"%>