diff --git a/Gemfile b/Gemfile index d6f88b3ef..e4e69edef 100644 --- a/Gemfile +++ b/Gemfile @@ -3,14 +3,15 @@ gem 'rails','>=3.1.0' gem 'yajl-ruby', :require => 'yajl' gem 'bson_ext' -gem 'carrierwave', '0.5.4' +gem 'carrierwave' +gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' gem 'ckeditor' gem 'devise' gem 'mini_magick' gem 'rubyzip' gem 'sinatra' gem 'execjs' -gem 'mongoid', :git => 'git://github.com/mongoid/mongoid.git', :ref => '7a915395db50e2bc6071a503a11530e644879e49' +gem 'mongoid' gem 'rake','0.8.7' gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index d7c74ccf4..9f4fce7e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,3 @@ -GIT - remote: git://github.com/mongoid/mongoid.git - revision: 7a915395db50e2bc6071a503a11530e644879e49 - ref: 7a915395db50e2bc6071a503a11530e644879e49 - specs: - mongoid (2.4.0) - activemodel (~> 3.1) - mongo (~> 1.3) - tzinfo (~> 0.3.22) - GEM remote: http://rubygems.org/ specs: @@ -47,8 +37,11 @@ GEM bson_ext (1.5.2) bson (= 1.5.2) builder (3.0.0) - carrierwave (0.5.4) + carrierwave (0.5.8) activesupport (~> 3.0) + carrierwave-mongoid (0.1.3) + carrierwave (>= 0.5.6) + mongoid (~> 2.1) chronic (0.6.6) ckeditor (3.6.3) mime-types (~> 1.16) @@ -96,6 +89,10 @@ GEM subexec (~> 0.1.0) mongo (1.5.2) bson (= 1.5.2) + mongoid (2.4.0) + activemodel (~> 3.1) + mongo (~> 1.3) + tzinfo (~> 0.3.22) multi_json (1.0.4) orm_adapter (0.0.5) polyglot (0.3.3) @@ -192,7 +189,8 @@ PLATFORMS DEPENDENCIES bson_ext - carrierwave (= 0.5.4) + carrierwave + carrierwave-mongoid ckeditor coffee-rails database_cleaner @@ -203,7 +201,7 @@ DEPENDENCIES factory_girl_rails jquery-rails mini_magick - mongoid! + mongoid radius rails (>= 3.1.0) rake (= 0.8.7) diff --git a/app/assets/images/PIE.htc b/app/assets/images/PIE.htc new file mode 100644 index 000000000..00b63838a --- /dev/null +++ b/app/assets/images/PIE.htc @@ -0,0 +1,96 @@ + + + + + + + + + diff --git a/app/assets/images/bar_orbit.png b/app/assets/images/bar_orbit.png index feaca6b83..eb0c95ee0 100644 Binary files a/app/assets/images/bar_orbit.png and b/app/assets/images/bar_orbit.png differ diff --git a/app/assets/images/service_btn.png b/app/assets/images/service_btn.png index 8a386406f..bfe156e40 100644 Binary files a/app/assets/images/service_btn.png and b/app/assets/images/service_btn.png differ diff --git a/app/assets/javascripts/rc.js b/app/assets/javascripts/rc.js new file mode 100644 index 000000000..37472e938 --- /dev/null +++ b/app/assets/javascripts/rc.js @@ -0,0 +1,120 @@ +$(document).ready(function(){ + dropmenu(); + tab(); + tooltip(); + accordion(); +}); + +function dropmenu(){ + if( !$('.rc_dm').length ){ + return; + } + $('.rc_dm').each(function(){ + $(this) + .find('.dm_ctrl') + .click(function(){ + var target = $(this).attr('rel'); + var w = $(this).outerWidth(); + var h = $(this).outerHeight(); + var p = $(this).position(); + + $('.dm_list').not('#'+target).hide(); + $('#'+target) + .css({ + width: w, + zIndex: 999, + left: p.left, + top: p.top + h + }) + .toggle(); + + return false; + }); + }); + $(document).click(function(){ + $('.dm_list').hide(); + }); +} + +function tab(){ + if( !$('.rc_tab').length ){ + return; + } + $('.rc_tab').each(function(){ + $(this).find('.tab_ctrl:first').addClass('recent'); + $(this).find('.tab_content:not(:first)').hide(); + $(this).find('.tab_ctrl').click(function(){ + var target = $(this).attr('href'); + $(this) + .parents('.rc_tab') + .find('.tab_content').hide() + .end() + .find('.tab_ctrl').removeClass('recent'); + $(this).addClass('recent'); + $(target).show(); + return false; + }); + }); +} + +function tooltip(){ + if( !$('.rc_tip').length ){ + return; + } + $('.rc_tip').each(function(){ + $(this).css({position: 'relative'}); + var t = $(this).data('tip'); + + $(this) + .mouseover(function(){ + var th = $(this).find('.td').outerHeight(); + var p = $(this).offset(); + + $(this).append(''+t+''); + $(this).find('.td').show().css('display','inline-block'); + $(document).mousemove(function(e){ + $(this).find('.td').css({ + left: e.pageX - p.left + 16, + top: e.pageY - p.top - th - 20 + }); + }); + }) + .mouseout(function(){ + $(this).find('.td').hide().detach(); + }); + }); +} + +function accordion(){ + if( !$('.rc_accor').length ){ + return; + } + $('.rc_accor').each(function(){ + $(this).find('.ac_ctrl:first').addClass('recent'); + $(this).find('.ac_content:not(:first)').hide(); + if($(this).hasClass('av')){ + $(this).find('.ac_ctrl').click(function(){ + var index = $(this).parents('.av').find('.ac_ctrl').index(this); + $(this).siblings('.ac_ctrl').removeClass('recent'); + $(this).addClass('recent'); + $(this).parents('.rc_accor').find('.ac_content:not(:eq('+index+'))').stop().slideUp(); + $(this).parents('.rc_accor').find('.ac_content:eq('+index+')').stop().slideToggle(); + return false; + }); + } else if($(this).hasClass('ah')){ + var w = $(this).find('.ac_content').css('width'); + $(this).find('.ac_content:not(:eq(0))').css({width:0}); + $(this).find('.ac_ctrl').click(function(){ + var index = $(this).parents('.ah').find('.ac_ctrl').index(this); + $(this).siblings('.ac_ctrl').removeClass('recent'); + $(this).addClass('recent'); + $(this).parents('.rc_accor').find('.ac_content:not(:eq('+index+'))').stop().animate({width:0}); + $(this).parents('.rc_accor').find('.ac_content:eq('+index+')').stop().show().animate({width:w}); + return false; + }); + } + + + + }); +} diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js index 93b52140b..737b08b71 100644 --- a/app/assets/javascripts/rss.js +++ b/app/assets/javascripts/rss.js @@ -393,9 +393,9 @@ modalWindow : function(settings,callbackFn){ }else{tempwidth="auto";} $rss("body").append('
'); - $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199}); + $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.5,'z-index':199}); $rss("body").append('
'); - $rss("#rgWindow").css({"position": "fixed", "z-index": "999", "background": "#fff", "border": "solid 3px #ccc", "padding": "20px", "overflow": "hidden", "border-radius": "12px", "-webkit-border-radius": "12px", "-moz-border-radius": "12px", "-ms-border-radius": "12px", "box-shadow": "0 0 20px rgba(0,0,0,0.9)","-webkit-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-moz-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-ms-box-shadow": "0 0 20px rgba(0,0,0,0.9)"}); + $rss("#rgWindow").css({"position": "fixed", "z-index": "999", "background": "#fff", "border": "solid 1px #ccc", "padding": "10px", "border-radius": "5px", "-webkit-border-radius": "5px", "-moz-border-radius": "5px", "-ms-border-radius": "5px", "box-shadow": "0 0 20px rgba(0,0,0,0.7)","-webkit-box-shadow": "0 0 20px rgba(0,0,0,0.7)","-moz-box-shadow": "0 0 20px rgba(0,0,0,0.7)","-ms-box-shadow": "0 0 20px rgba(0,0,0,0.7)"}); var rgWTop = (rgmaskHeight-20)/2; var rgWLeft = (rgmaskWidth-20)/2; $rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"}); @@ -429,12 +429,12 @@ modalWindow : function(settings,callbackFn){ tempwidth=maxwidth; rgWLeft=(rgmaskWidth-tempwidth)/2; } - tempwidth+=25; + tempwidth=parseInt(tempwidth)+25; $rss("#rgWindow").empty().show(); var closebtn = ""; if(closeBtn) - closebtn='X'; - $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"
"+dhtml+"
"); + closebtn='X'; + $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"
"+dhtml+"
"); $rss("#close_modal").mouseover(function(){$rss(this).css("color","#999");}).mouseout(function(){$rss(this).css("color","#666");}) $rss("#close_modal").click(function(){ $rss("#rgWindow").empty(); @@ -508,7 +508,7 @@ modalWindowUpdate : function(settings,callbackFn){ tempwidth=maxwidth; rgWLeft=(rgmaskWidth-tempwidth)/2; } - tempwidth+=25; + tempwidth=parseInt(tempwidth)+25; $rss("#rgContent").empty(); $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgContent").css("height",tempheight+"px").html(dhtml)}); $rss("#rgwindow_temp_div").remove(); diff --git a/app/assets/javascripts/site_editor.js b/app/assets/javascripts/site_editor.js index 98405564c..ef4acc855 100644 --- a/app/assets/javascripts/site_editor.js +++ b/app/assets/javascripts/site_editor.js @@ -7,4 +7,5 @@ //= require jquery //= require jquery_ujs //= require page_edit -//= require side_bar_history \ No newline at end of file +//= require side_bar_history +//= require rc \ No newline at end of file diff --git a/app/assets/stylesheets/admin_back_end.css.erb b/app/assets/stylesheets/admin_back_end.css.erb index 405281b49..5aecff454 100644 --- a/app/assets/stylesheets/admin_back_end.css.erb +++ b/app/assets/stylesheets/admin_back_end.css.erb @@ -14,39 +14,69 @@ body{ } #back_banner_link{ - background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; - height: 50px; - left: 0; - position: fixed; - top: 0; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #787e82), color-stop(0.05, #61676c), color-stop(1, #292c2d) ); + background:-moz-linear-gradient( center top -90deg, #787e82 0%, #61676c 5%, #292c2d 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#61676c', endColorstr='#292c2d'); + -moz-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + -webkit-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + border-top: 1px solid #474a4c; + border-bottom: 1px solid #1d2020; + height: 41px; width: 100%; - z-index: 5; + behavior: url(<%= asset_path "PIE.htc" %>); } .hmenu{ - height: 40px; - position: absolute; - right: 0; - top: 1px; - width: 250px; + float: right; + height: 41px; } #back_orbit{ - background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; - cursor:pointer; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #70787d), color-stop(1, #3b4043) ); + background:-moz-linear-gradient( center top -90deg, #70787d 0%, #3b4043 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#70787d', endColorstr='#3b4043'); + -webkit-border-radius: 0px 0px 5px 5px; + -moz-border-radius: 0px 0px 5px 5px; + border-radius: 0px 0px 5px 5px; + -moz-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + -webkit-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + cursor: pointer; + float: left; height: 43px; - left: 10px; - position: relative; + margin-left: 10px; width: 41px; + behavior: url(<%= asset_path "PIE.htc" %>); +} +#back_orbit span{ + text-indent: -9999px; + background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; + display: block; + height: 43px; + width: 100%; } #back_orbit:hover{ - background-position:0 -43px; - box-shadow: 0 3px 3px #000000; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #fefefe), color-stop(1, #e4e4e4) ); + background:-moz-linear-gradient( center top -90deg, #fefefe 0%, #e4e4e4 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fefefe', endColorstr='#e4e4e4'); + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} +#back_orbit:hover span{ + background-position: 0 -44px; } #back_orbit:hover #orblist{ display:block; } #orblist{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 0 3px 3px 3px; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #e4e4e4), color-stop(1, #FFFFFF) ); + background:-moz-linear-gradient( center top -90deg, #e4e4e4 0%, #FFFFFF 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e4e4e4', endColorstr='#FFFFFF'); + -webkit-border-radius: 0px 3px 3px 3px; + -moz-border-radius: 0px 3px 3px 3px; + border-radius: 0px 3px 3px 3px; + -webkit-box-shadow: 0 3px 3px #000000; + -moz-box-shadow: 0 3px 3px #000000; box-shadow: 0 3px 3px #000000; display: none; margin: 0; @@ -70,30 +100,37 @@ body{ background:#eee; color:#333; } - +#log_out{ + -moz-box-shadow:inset 1px 0px 0px 0px #73777b; + -webkit-box-shadow:inset 1px 0px 0px 0px #73777b; + box-shadow:inset 1px 0px 0px 0px #73777b; + border-right:1px solid #41474c; + border-left:1px solid #41474c; + float:right; + width:41px; + height:41px; +} +#log_out:hover{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #01afde), color-stop(1, #007ec6) ); + background:-moz-linear-gradient( center top -90deg, #01afde 0%, #007ec6 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#01afde', endColorstr='#007ec6'); +} #log_out a{ background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; - border: medium none !important; - display: block !important; - height: 40px !important; - line-height: normal !important; - padding: 0 !important; - position: absolute; - right: 0px; - text-indent: -10000px; - top: 0px; - width: 43px !important; + display: block; + height: 41px; + text-indent: -9999px; + width: 41px; } #log_out a:hover{ background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; } .lang{ - color: #FFFFFF; - font-size: 15px; - line-height: 40px; - position: absolute; - right: 55px; - top: 0; + color: #FFFFFF; + float: right; + font-size: 15px; + line-height: 40px; + margin-right: 10px; } .lang a{ color:#fff; @@ -589,4 +626,40 @@ hr.student_block { position: absolute; top: -15%; width: 130%; +} +#rgContent .main2{ + padding:0; +} +#rgContent h1{ + border-bottom: 1px dashed #CCCCCC; + color: #333333; + font-size: 19px; + font-weight: bold; + margin: 0 0 20px; + padding: 0 0 10px; + text-align: center; +} +#rgContent label { + color: #888888; + display: block; + font-size: 12px; + margin: 25px 0 5px; + width: 100%; +} +#rgContent input { + color: #888888; + width: 98%; +} +#rgContent .button_bar { + float: none; + text-align: center; + width:100%; + margin:30px 0 0; +} +#rgContent .button_bar a { + float: none; + display:block; +} +#close_modal{ + display:none !important; } \ No newline at end of file diff --git a/app/assets/stylesheets/reset.css b/app/assets/stylesheets/reset.css index 44f2ae777..612cab191 100644 --- a/app/assets/stylesheets/reset.css +++ b/app/assets/stylesheets/reset.css @@ -42,3 +42,7 @@ input:focus, select:focus, textarea:focus { height:0; visibility:hidden; } +.fixed { + position: fixed; + z-index: 100; +} \ No newline at end of file diff --git a/app/assets/stylesheets/site_items.css.erb b/app/assets/stylesheets/site_items.css.erb index 151dabdee..38b0a1855 100644 --- a/app/assets/stylesheets/site_items.css.erb +++ b/app/assets/stylesheets/site_items.css.erb @@ -1,445 +1,482 @@ -html, body{ - height: 100%; - margin: 0; - padding: 0; -} -html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat fixed 0 0 transparent; - background-size: cover; -} - -body{ - color: #000000; - font-family: Helvetica, '微軟正黑體'; -} -#back_banner_link{ - background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; - height: 50px; - left: 0; - position: fixed; - top: 0; - width: 100%; - z-index: 5; -} -.hmenu{ - height: 40px; - position: absolute; - right: 0; - top: 1px; - width: 250px; -} -#back_orbit{ - background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; - cursor:pointer; - height: 43px; - left: 10px; - position: relative; - width: 41px; -} -#back_orbit:hover{ - background-position:0 -43px; - box-shadow: 0 3px 3px #000000; -} -#back_orbit:hover #orblist{ - display:block; -} -#orblist{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 0 3px 3px 3px; - box-shadow: 0 3px 3px #000000; - display: none; - margin: 0; - padding: 10px; - position: absolute; - top: 43px; - width: 130px; -} -#orblist li{ - border-bottom:1px solid #aaa; - list-style:none; -} -.orblink{ - color: #333333; - display: block; - font: 12px/100% arial,sans-serif; - padding: 5px; - text-decoration: none; -} -.orblink:hover{ - background:#eee; - color:#333; -} - -#log_out a{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; - border: medium none !important; - display: block !important; - height: 40px !important; - line-height: normal !important; - padding: 0 !important; - position: absolute; - right: 0px; - text-indent: -10000px; - top: 0px; - width: 43px !important; -} -#log_out a:hover{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; -} -.lang{ - color: #FFFFFF; - font-size: 15px; - line-height: 40px; - position: absolute; - right: 55px; - top: 0; -} -.lang a{ - color:#fff; - text-decoration:none; -} -.lang a:hover{ - text-decoration:underline; -} -#back_content{ - height: 100%; -} -#back_footer{ - background-color: #101010; - bottom: 0; - color: #FFFFFF; - font-size: 11px; - padding: 10px; - position: fixed; - width: 100%; - left: 0; - box-shadow: 0 -3px 4px #000; -} -.items_setup{ - padding:42px 0 0 0; -} -#back_sidebar .items_setup .list li{ - padding: 6px 0 7px 5px; -} -#back_sidebar .items_setup .list li a{ - display: inline; - font-size: 0.9em; - padding: 0; -} -#back_sidebar .items_setup .list li a span{ - background:none; - padding:0; - text-shadow:none; -} -.main { - background: none repeat scroll 0 0 #FFFFFF; - height: 100%; - margin-left: 220px; - padding: 0 40px; - position: relative; -} -.main_list { - padding-top: 70px; -} -.main_list ul { - clear:both; -} -#porfile { - padding-top: 100px; -} -/*add_buttom*/ -.button_bar { - float: right; - -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); - background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); - background-color:#4f4f4f; - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; - display:inline-block; - padding:0; - margin:10px 0 60px; -} -.button_bar a { - text-decoration:none; - text-shadow:0px -1px 0px #000000; - font-size:12px; - color:#EDEDED; - border-right:1px solid #555; - -moz-box-shadow:1px 0px 0px black; - -webkit-box-shadow:1px 0px 0px black; - box-shadow:1px 0px 0px black; - padding: 6px 10px 4px; - display: inline-block; - float: left; -} -.button_bar a:active { - padding: 7px 10px 3px !important; - text-shadow:0px 1px 0px #000000; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); - background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); -} -.button_bar a:last-child { - border-right:none; - -moz-box-shadow:none; - -webkit-box-shadow:none; - box-shadow:none; - -moz-border-radius:0px 5px 5px 0px; - -webkit-border-radius:0px 5px 5px 0px; - border-radius:0px 5px 5px 0px; -} -.button_bar a:first-child { - -moz-border-radius:5px 0px 0px 5px; - -webkit-border-radius:5px 0px 0px 5px; - border-radius:5px 0px 0px 5px; -} -.button_bar a.new { - padding: 5px 10px; - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; -} -.button_bar a:hover { - color:#FFFFFF; -} -.up { - margin:10px 0; -} -#person { - left: 245px; - position: fixed; - text-align: center; - top: 75px; - width: 140px; - background-color:#FFF; - padding:15px; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ - -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ - box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ -} -#file { - display:none; -} -#person img { -} -.user_mail { - border: medium none; - border:1px solid #DDDDDD; - color: #666666; - font-size: 12px; - width: 140px; -} -#person label { - display: block; - margin: 15px 0 0; -} -#person label input { -} -#person label #user_admin { - float:right; - margin: 0; -} -#person label span { - text-align:left; - font-size:11px; - color:#888; - display:block; -} -#person select { - border: 1px solid #DDDDDD; - padding: 0; - width: 140px; -} -#porfile .users{ - margin-left: 180px; -} -.roles_block { - background: url(<%= asset_path "75.png" %>) repeat left top; - min-width:710px; - margin-bottom:50px; - position:relative; - padding-bottom: 20px; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ - -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ - box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ -} -.roles_block h2 { - color: #FFFFFF; - font-weight: normal; - margin: 0; - padding: 0; - position: absolute; - text-shadow: 0 3px 2px #000000; - top: -30px; -} -.main hr { - height:8px; - border:none; - margin:0; - border-radius: 5px 5px 0px 0px; - -moz-border-radius: 5px 5px 0px 0px; - -webkit-border-radius: 5px 5px 0px 0px; - border-bottom:1px solid #000; -} -.main2{ - padding:70px 0 0; -} -#basic_block hr { - background-color: #666666; -} -#teacher_block hr { - background-color: #0071A9; -} -#student_block hr { - background-color: #AF0045; -} -.info_input { - padding:10px 20px; -} -.info_input table { - color:#fff; - width:100%; - font-size:14px; -} -.info_input table td { - padding:5px 10px 5px 0; - width: 10%; -} -.info_input .list_head { - background:url(<%= asset_path "line.png" %>) left bottom repeat-x; -} -.info_input .list_head td { -} -.info_input .list_item { - color:#AEAEAE; -} -.info_input .add { - display:block; - padding-left:22px; - font-size:12px; - line-height:21px; - height:19px; - background:url(<%= asset_path "icon.png" %>) no-repeat -59px 0; - margin-top: 10px; - color: #DDDDDD; -} - -.main table { - width:100%; -} -.main td { - padding-left:20px; - color:#fff; - font-size:14px; - line-height:40px; -} -.main tr.have td{ - background: url(<%= asset_path "75.png" %>) repeat left top; -} -.main tr.have td:first-child{ - border-radius: 5px 0 0 5px; - -moz-border-radius: 5px 0 0 5px; - -webkit-border-radius: 5px 0 0 5px; -} -.main tr.have td:last-child{ - border-radius: 0 5px 5px 0; - -moz-border-radius: 0 5px 5px 0; - -webkit-border-radius: 0 5px 5px 0; -} -.main thead td { - line-height:40px; - font-size:16px; - text-shadow: 0px 1px 1px #3e2914; -} -.main thead td.action { - width:140px; -} -.main tbody td.roles { - background-image: url(<%= asset_path "roles_type.jpg" %>); - background-repeat: repeat-x; -} -.main tbody td.teacher { - background-position: 0 -54px; -} -.main tbody td.student { - background-position: 0 -5px; -} -.main tbody td.action a { - background-image: url(<%= asset_path "icon.png" %>); - display: inline-block; - height: 19px; - margin-right: 10px; - top: 8px; - text-indent: -9999px; - width: 19px; - position: relative; -} -.main tbody td.action a.show { - background-position: left top; -} -.main tbody td.action a.show:hover { - background-position: left -19px; -} -.main tbody td.action a.edit { - background-position: -19px top; -} -.main tbody td.action a.edit:hover { - background-position: -19px -19px; -} -.main tbody td.action a.delete { - background-position: -38px top; -} -.main tbody td.action a.delete:hover { - background-position: -38px -19px; -} -.main tbody td.action a.switch { - background: url(<%= asset_path "switch.png" %>) no-repeat left 3px; - width: 40px; -} -.main tbody tr.disable td.action a.switch { - background-position:left bottom; -} -.main tbody td.action a.delete:hover { - background-position: -38px -19px; -} -.main tbody tr.have { -} -.main tbody tr.disable { - opacity: 0.7; -} -.main tbody tr { - background:none; - height:15px; -} -h1{ - margin:0 0 20px; -} -p{ - margin:0 0 10px; -} - -#back_sidebar .items_setup .list li{ - background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; - border:none; - padding: 0 0 0 5px; -} -#back_sidebar .items_setup .list li a{ - line-height:31px; -} -#back_sidebar .items_setup .list li:hover{ - background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; - border:none; -} -#back_sidebar .items_setup ul .list { +html, body{ + height: 100%; + margin: 0; + padding: 0; +} +html{ + background: url(<%= asset_path "body.jpg" %>) no-repeat fixed 0 0 transparent; + background-size: cover; +} + +body{ + color: #000000; + font-family: Helvetica, '微軟正黑體'; +} +#back_banner_link{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #787e82), color-stop(0.05, #61676c), color-stop(1, #292c2d) ); + background:-moz-linear-gradient( center top -90deg, #787e82 0%, #61676c 5%, #292c2d 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#61676c', endColorstr='#292c2d'); + -moz-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + -webkit-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + border-top: 1px solid #474a4c; + border-bottom: 1px solid #1d2020; + height: 41px; + width: 100%; + behavior: url(<%= asset_path "PIE.htc" %>); +} +.hmenu{ + float: right; + height: 41px; +} +#back_orbit{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #70787d), color-stop(1, #3b4043) ); + background:-moz-linear-gradient( center top -90deg, #70787d 0%, #3b4043 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#70787d', endColorstr='#3b4043'); + -webkit-border-radius: 0px 0px 5px 5px; + -moz-border-radius: 0px 0px 5px 5px; + border-radius: 0px 0px 5px 5px; + -moz-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + -webkit-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + cursor: pointer; + float: left; + height: 43px; + margin-left: 10px; + width: 41px; + behavior: url(<%= asset_path "PIE.htc" %>); +} +#back_orbit span{ + text-indent: -9999px; + background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; + display: block; + height: 43px; + width: 100%; +} +#back_orbit:hover{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #fefefe), color-stop(1, #e4e4e4) ); + background:-moz-linear-gradient( center top -90deg, #fefefe 0%, #e4e4e4 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fefefe', endColorstr='#e4e4e4'); + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} +#back_orbit:hover span{ + background-position: 0 -44px; +} +#back_orbit:hover #orblist{ + display:block; +} +#orblist{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #e4e4e4), color-stop(1, #FFFFFF) ); + background:-moz-linear-gradient( center top -90deg, #e4e4e4 0%, #FFFFFF 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e4e4e4', endColorstr='#FFFFFF'); + -webkit-border-radius: 0px 3px 3px 3px; + -moz-border-radius: 0px 3px 3px 3px; + border-radius: 0px 3px 3px 3px; + -webkit-box-shadow: 0 3px 3px #000000; + -moz-box-shadow: 0 3px 3px #000000; + box-shadow: 0 3px 3px #000000; + display: none; + margin: 0; + padding: 10px; + position: absolute; + top: 43px; + width: 130px; +} +#orblist li{ + border-bottom:1px solid #aaa; + list-style:none; +} +.orblink{ + color: #333333; + display: block; + font: 12px/100% arial,sans-serif; + padding: 5px; + text-decoration: none; +} +.orblink:hover{ + background:#eee; + color:#333; +} +#log_out{ + -moz-box-shadow:inset 1px 0px 0px 0px #73777b; + -webkit-box-shadow:inset 1px 0px 0px 0px #73777b; + box-shadow:inset 1px 0px 0px 0px #73777b; + border-right:1px solid #41474c; + border-left:1px solid #41474c; + float:right; + width:41px; + height:41px; +} +#log_out:hover{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #01afde), color-stop(1, #007ec6) ); + background:-moz-linear-gradient( center top -90deg, #01afde 0%, #007ec6 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#01afde', endColorstr='#007ec6'); +} +#log_out a{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; + display: block; + height: 41px; + text-indent: -9999px; + width: 41px; +} +#log_out a:hover{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; +} +.lang{ + color: #FFFFFF; + float: right; + font-size: 15px; + line-height: 40px; + margin-right: 10px; +} +.lang a{ + color:#fff; + text-decoration:none; +} +.lang a:hover{ + text-decoration:underline; +} +#back_content{ + height: 100%; +} +#back_footer{ + background-color: #101010; + bottom: 0; + color: #FFFFFF; + font-size: 11px; + padding: 10px; + position: fixed; + width: 100%; + left: 0; + box-shadow: 0 -3px 4px #000; +} +.items_setup{ + padding:42px 0 0 0; +} +#back_sidebar .items_setup .list li{ + padding: 6px 0 7px 5px; +} +#back_sidebar .items_setup .list li a{ + display: inline; + font-size: 0.9em; + padding: 0; +} +#back_sidebar .items_setup .list li a span{ + background:none; + padding:0; + text-shadow:none; +} +.main { + background: none repeat scroll 0 0 #FFFFFF; + height: 100%; + margin-left: 220px; + padding: 0 40px; + position: relative; +} +.main_list { + padding-top: 70px; +} +.main_list ul { + clear:both; +} +#porfile { + padding-top: 100px; +} +/*add_buttom*/ +.button_bar { + float: right; + -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); + background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); + background-color:#4f4f4f; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + display:inline-block; + padding:0; + margin:10px 0 60px; +} +.button_bar a { + text-decoration:none; + text-shadow:0px -1px 0px #000000; + font-size:12px; + color:#EDEDED; + border-right:1px solid #555; + -moz-box-shadow:1px 0px 0px black; + -webkit-box-shadow:1px 0px 0px black; + box-shadow:1px 0px 0px black; + padding: 6px 10px 4px; + display: inline-block; + float: left; +} +.button_bar a:active { + padding: 7px 10px 3px !important; + text-shadow:0px 1px 0px #000000; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); + background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); +} +.button_bar a:last-child { + border-right:none; + -moz-box-shadow:none; + -webkit-box-shadow:none; + box-shadow:none; + -moz-border-radius:0px 5px 5px 0px; + -webkit-border-radius:0px 5px 5px 0px; + border-radius:0px 5px 5px 0px; +} +.button_bar a:first-child { + -moz-border-radius:5px 0px 0px 5px; + -webkit-border-radius:5px 0px 0px 5px; + border-radius:5px 0px 0px 5px; +} +.button_bar a.new { + padding: 5px 10px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; +} +.button_bar a:hover { + color:#FFFFFF; +} +.up { + margin:10px 0; +} +#person { + left: 245px; + position: fixed; + text-align: center; + top: 75px; + width: 140px; + background-color:#FFF; + padding:15px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ + -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ + box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ +} +#file { + display:none; +} +#person img { +} +.user_mail { + border: medium none; + border:1px solid #DDDDDD; + color: #666666; + font-size: 12px; + width: 140px; +} +#person label { + display: block; + margin: 15px 0 0; +} +#person label input { +} +#person label #user_admin { + float:right; + margin: 0; +} +#person label span { + text-align:left; + font-size:11px; + color:#888; + display:block; +} +#person select { + border: 1px solid #DDDDDD; + padding: 0; + width: 140px; +} +#porfile .users{ + margin-left: 180px; +} +.roles_block { + background: url(<%= asset_path "75.png" %>) repeat left top; + min-width:710px; + margin-bottom:50px; + position:relative; + padding-bottom: 20px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ + -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ + box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ +} +.roles_block h2 { + color: #FFFFFF; + font-weight: normal; + margin: 0; + padding: 0; + position: absolute; + text-shadow: 0 3px 2px #000000; + top: -30px; +} +.main hr { + height:8px; + border:none; + margin:0; + border-radius: 5px 5px 0px 0px; + -moz-border-radius: 5px 5px 0px 0px; + -webkit-border-radius: 5px 5px 0px 0px; + border-bottom:1px solid #000; +} +.main2{ + padding:70px 0 0; +} +#basic_block hr { + background-color: #666666; +} +#teacher_block hr { + background-color: #0071A9; +} +#student_block hr { + background-color: #AF0045; +} +.info_input { + padding:10px 20px; +} +.info_input table { + color:#fff; + width:100%; + font-size:14px; +} +.info_input table td { + padding:5px 10px 5px 0; + width: 10%; +} +.info_input .list_head { + background:url(<%= asset_path "line.png" %>) left bottom repeat-x; +} +.info_input .list_head td { +} +.info_input .list_item { + color:#AEAEAE; +} +.info_input .add { + display:block; + padding-left:22px; + font-size:12px; + line-height:21px; + height:19px; + background:url(<%= asset_path "icon.png" %>) no-repeat -59px 0; + margin-top: 10px; + color: #DDDDDD; +} + +.main table { + width:100%; +} +.main td { + padding-left:20px; + color:#fff; + font-size:14px; + line-height:40px; +} +.main tr.have td{ + background: url(<%= asset_path "75.png" %>) repeat left top; +} +.main tr.have td:first-child{ + border-radius: 5px 0 0 5px; + -moz-border-radius: 5px 0 0 5px; + -webkit-border-radius: 5px 0 0 5px; +} +.main tr.have td:last-child{ + border-radius: 0 5px 5px 0; + -moz-border-radius: 0 5px 5px 0; + -webkit-border-radius: 0 5px 5px 0; +} +.main thead td { + line-height:40px; + font-size:16px; + text-shadow: 0px 1px 1px #3e2914; +} +.main thead td.action { + width:140px; +} +.main tbody td.roles { + background-image: url(<%= asset_path "roles_type.jpg" %>); + background-repeat: repeat-x; +} +.main tbody td.teacher { + background-position: 0 -54px; +} +.main tbody td.student { + background-position: 0 -5px; +} +.main tbody td.action a { + background-image: url(<%= asset_path "icon.png" %>); + display: inline-block; + height: 19px; + margin-right: 10px; + top: 8px; + text-indent: -9999px; + width: 19px; + position: relative; +} +.main tbody td.action a.show { + background-position: left top; +} +.main tbody td.action a.show:hover { + background-position: left -19px; +} +.main tbody td.action a.edit { + background-position: -19px top; +} +.main tbody td.action a.edit:hover { + background-position: -19px -19px; +} +.main tbody td.action a.delete { + background-position: -38px top; +} +.main tbody td.action a.delete:hover { + background-position: -38px -19px; +} +.main tbody td.action a.switch { + background: url(<%= asset_path "switch.png" %>) no-repeat left 3px; + width: 40px; +} +.main tbody tr.disable td.action a.switch { + background-position:left bottom; +} +.main tbody td.action a.delete:hover { + background-position: -38px -19px; +} +.main tbody tr.have { +} +.main tbody tr.disable { + opacity: 0.7; +} +.main tbody tr { + background:none; + height:15px; +} +h1{ + margin:0 0 20px; +} +p{ + margin:0 0 10px; +} + +#back_sidebar .items_setup .list li{ + background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; + border:none; + padding: 0 0 0 5px; +} +#back_sidebar .items_setup .list li a{ + line-height:31px; +} +#back_sidebar .items_setup .list li:hover{ + background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; + border:none; +} +#back_sidebar .items_setup ul .list { } \ No newline at end of file diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index e925b8578..cb3340fd9 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -1,7 +1,7 @@ class Admin::AppAuthsController < ApplicationController layout "admin" before_filter :authenticate_user! - before_filter :is_admin? +# before_filter :is_admin? ,:only => :index def index # @roles = Role.all.entries @@ -12,7 +12,60 @@ class Admin::AppAuthsController < ApplicationController # obj_auth = obj.send "auth" # [:app_obj => app,:auth_field => obj_auth] # end - @module_apps = ModuleApp.all + if current_user.admin? + @module_apps = ModuleApp.all + else + @module_apps = current_user.managing_apps.collect{|t| t.managing_app} + end end + def create + app_auth = AppAuth.find_or_create_by(module_app_id: params[:module_app_id]) + params[:new].each do |item| + field = item[0] + field_value = item[1] + if field_value!='' + case field + when 'role' + app_auth.send("add_#{field}",(Role.find field_value)) rescue nil + when 'sub_role' + app_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil + when 'privilege_user' + app_auth.add_user_to_privilege_list (User.find field_value) rescue nil + when 'blocked_user' + app_auth.add_user_to_black_list (User.find field_value) rescue nil + end + end + end + app = ModuleApp.find params[:module_app_id] rescue nil + redirect_to edit_admin_module_app_path(app) + end + + def remove + app_auth = AppAuth.find( params[:id] ) + type = params[:type] + field_value = params[:target_id] + if field_value!='' + case type + when 'role' + app_auth.remove_role(Role.find field_value) rescue nil + when 'sub_role' + app_auth.remove_sub_role(SubRole.find field_value) rescue nil + when 'privilege_user' + app_auth.remove_user_from_privilege_list (User.find field_value) rescue nil + when 'blocked_user' + app_auth.remove_user_from_black_list (User.find field_value) rescue nil + end + end + + app = ModuleApp.find params[:module_app_id] rescue nil + redirect_to edit_admin_module_app_path(app) + end + + def edit + @module_app = ModuleApp.find(params[:id]) + end + + + end \ No newline at end of file diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 5930d1bfb..68fbb2436 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -46,7 +46,7 @@ class Admin::DesignsController < ApplicationController filename = params[:filename] files = @design.themes + @design.javascripts + @design.images file_to_removed = files.find{ |obj| - obj.file_filename == filename + obj.file_identifier == filename } type = file_to_removed._type new_file = "" @@ -103,7 +103,7 @@ class Admin::DesignsController < ApplicationController temp_file.write (zip_file.read entry ).force_encoding('UTF-8') default_css = design.build_default_css default_css.file = temp_file - default_css.file_filename = filename + default_css.file_identifier = filename default_css.to_save = true when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css filename = File.basename(entry.to_s) @@ -111,7 +111,7 @@ class Admin::DesignsController < ApplicationController temp_file.write (zip_file.read entry ).force_encoding('UTF-8') reset_css = design.build_reset_css reset_css.file = temp_file - reset_css.file_filename = filename + reset_css.file_identifier = filename reset_css.to_save = true when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html filename = File.basename(entry.to_s) @@ -135,7 +135,7 @@ class Admin::DesignsController < ApplicationController temp_file.write (zip_file.read entry).force_encoding('UTF-8') build_and_store = eval("design.#{type}").build build_and_store.file = temp_file - build_and_store.file_filename = filename + build_and_store.file_identifier = filename build_and_store.to_save = true end end diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 142830f19..56c2523fe 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -1,4 +1,7 @@ class Admin::ModuleAppsController < ApplicationController + before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ] + before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ] + layout "admin" def index @@ -15,9 +18,9 @@ class Admin::ModuleAppsController < ApplicationController def edit @module_app = ModuleApp.find(params[:id]) - end + def update @module_app = ModuleApp.find(params[:id]) unless params['module_app']['enable_frontend'].nil? @@ -30,4 +33,82 @@ class Admin::ModuleAppsController < ApplicationController format.js { render 'admin/attributes/toggle_enable' } end end + + + def assign_sub_manager + unless @assign_to_user.nil? || @assign_to_user.admin? + if @module_app.assign_sub_manager(@assign_to_user,current_user) + flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_ok') + else + flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_fail') + end + else + flash[:notice] = t('admin.app_auth.assigning_manager.failed_no_user') + end + flash[:notice] = t('admin.app_auth.can_not_add_this_user') + redirect_to :action => "edit" + end + + + def assign_manager + unless @assign_to_user.nil? || @assign_to_user.admin? + if @module_app.assign_manager(@assign_to_user,current_user) + flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_ok') + else + flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_fail') + end + else + flash[:notice] = t('admin.app_auth.assigning_sub_manager.failed_no_user') + end + flash[:notice] = t('admin.app_auth.can_not_add_this_user') + redirect_to :action => "edit" + end + + + def remove_manager + @app_manager = AppManager.find(params[:app_manager_id]) + if @module_app.remove_manager(@app_manager.user) + flash[:notice] = t('admin.app_auth.delete_manager.success') + else + flash[:notice] = t('admin.app_auth.delete_manager.fail') + end + redirect_to :action => "edit" + end + + + def remove_sub_manager + @app_sub_manager = AppManager.find(params[:app_sub_manager_id]) + if @module_app.remove_sub_manager(@app_sub_manager.user) + flash[:notice] = t('admin.app_auth.delete_sub_manager.success') + else + flash[:notice] = t('admin.app_auth.delete_sub_manager.fail') + end + redirect_to :action => "edit" + end + + + private + def user_has_manager_privilege? + @module_app = ModuleApp.find(params[:id]) + @assign_to_user = User.find params[:manager][:id] rescue nil + if current_user.admin? #only admin can assign app's manager + return + end + #user is not permited to do that + flash[:notice] = t('admin.app_auth.operation_not_permitted') + redirect_to :action => "edit" # [TODO] maybe need to redirect to some other page + end + + + def user_has_sub_manager_privilege? + @module_app = ModuleApp.find(params[:id]) + @assign_to_user = User.find params[:sub_manager][:id] rescue nil + if current_user.admin? || @module_app.managing_users.include?(current_user) #admin or app's manager can assign app's subanager + return + end + #user is not permited to do that + flash[:notice] = t('admin.app_auth.operation_not_permitted') + redirect_to :action => "edit" # [TODO] maybe need to redirect to some other page + end + end \ No newline at end of file diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index 40a042f44..00980cec0 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -172,7 +172,7 @@ class Admin::PurchasesController < ApplicationController def build_file(orig_zip, zip_name, dir, object, type = nil) - title = object.file_filename + title = object.file_identifier temp = File.new(dir + '/' + title, 'w+') temp.write orig_zip.read(zip_name + '/' + (type ? (type + '/') : '') + title) object.file = temp diff --git a/app/controllers/obit_frontend_component_controller.rb b/app/controllers/obit_frontend_component_controller.rb index d5bfaac68..06bb06a52 100644 --- a/app/controllers/obit_frontend_component_controller.rb +++ b/app/controllers/obit_frontend_component_controller.rb @@ -1,4 +1,10 @@ class ObitFrontendComponentController< ApplicationController + before_filter :setup_vars before_filter {|c| c.front_end_available(@app_title)} layout 'production' + + def setup_vars + @app_title = request.fullpath.split('/')[2] + end + end \ No newline at end of file diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 693243c22..33c927acd 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -19,7 +19,7 @@ class PagesController < ApplicationController end def show - begin + #begin item = Item.first(:conditions => {:full_name => params[:page_name]}) case item._type when 'Page' @@ -28,9 +28,9 @@ class PagesController < ApplicationController when 'Link' redirect_to "http://#{item[:url]}" end - rescue - render :file => "#{Rails.root}/public/404.html", :status => :not_found - end + #rescue + # render :file => "#{Rails.root}/public/404.html", :status => :not_found + #end end end diff --git a/app/helpers/admin/module_app_helper.rb b/app/helpers/admin/module_app_helper.rb new file mode 100644 index 000000000..0a636e9cd --- /dev/null +++ b/app/helpers/admin/module_app_helper.rb @@ -0,0 +1,19 @@ +module Admin::ModuleAppHelper + + def if_permit_to_delete(item) + case item.downcase + when :manager + current_user.admin? + when :sub_manager + @module_app.managing_users.include?(current_user) || current_user.admin? + end + end + + def if_permit_to_assign(item) + if_permit_to_delete(item) + end + + def get_auth_by(manager_obj) + "-AuthBy: " +( manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name) + end +end diff --git a/app/models/app_manager.rb b/app/models/app_manager.rb new file mode 100644 index 000000000..46cbbb913 --- /dev/null +++ b/app/models/app_manager.rb @@ -0,0 +1,12 @@ +class AppManager + include Mongoid::Document + include Mongoid::Timestamps + + belongs_to :user + + belongs_to :managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" + belongs_to :sub_managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :sub_manager,:foreign_key => "sub_user_id" + + belongs_to :rule_creator,:class_name => 'User' + +end \ No newline at end of file diff --git a/app/models/design/design.rb b/app/models/design/design.rb index e77f7f0ff..eb1f5e64f 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -31,7 +31,7 @@ class Design def files_with_duplicate? [self.javascripts, self.images,self.themes].each do |objects_hash| - ary = objects_hash.collect{ |k| k.file_filename} + ary = objects_hash.collect{ |k| k.file_identifier} ary.compact! # debugger return true if(ary.count!=ary.uniq.count) @@ -42,7 +42,7 @@ class Design def files_with_noname? [self.javascripts, self.images,self.themes].each do |objects_hash| objects_hash.each{ |k| - return true if(k.file_filename.nil? && !k.to_save?) + return true if(k.file_identifier.nil? && !k.to_save?) } end false @@ -121,7 +121,7 @@ class Design def process_object(object) if object.to_save - if object.file_filename.nil? + if object.file_identifier.nil? new_object = self.send(object._type.downcase.pluralize).build(object.attributes) new_object.file = object.file object.destroy diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb index f26f15584..13fb154d3 100644 --- a/app/models/design/stylesheet.rb +++ b/app/models/design/stylesheet.rb @@ -11,14 +11,14 @@ class Stylesheet < DesignFile content.scan(/(?<=url)(.*?)(?=\))/){ css_name = $1.gsub(' ','').gsub('(','') name = File.basename(css_name).gsub(/[\\\"]/, '') - file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil + file_name = images.detect{ |i| i.file_identifier.eql?(name) }.file_url rescue nil names << [css_name, file_name] } names.each do |name| content.gsub!(name[0], name[1]) if name[1] end Dir.mktmpdir('f_path') { |dir| - orig_file_name = self.file_filename + orig_file_name = self.file_identifier temp_file = File.new(dir + '/' + orig_file_name, 'w+') temp_file.write orig_content.force_encoding("UTF-8") diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index e69741818..dd4a6b01f 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -7,7 +7,7 @@ class Theme < Stylesheet protected def set_name - self.name = File.basename(self.file_filename,".css") + self.name = File.basename(self.file_identifier,".css") end end diff --git a/app/models/module_app.rb b/app/models/module_app.rb index d398f7ef5..f4a636183 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -14,9 +14,52 @@ class ModuleApp field :app_pages ,type: Array field :widgets ,type: Array + has_many :managers,as: :managing_app ,:class_name => "AppManager" #,:dependent => :destroy,:foreign_key => "managing_app_id",:inverse_of => :managing_app + has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager"#, :dependent => :destroy,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app + has_one :app_auth,dependent: :delete + def managing_users + self.managers.collect{ |t| t.user } + end + def sub_managing_users + self.sub_managers.collect{ |t| t.user } + end + + def assign_manager(user,assigner) + manager = AppManager.first(conditions: {managing_app_id: self.id,user_id: user.id}) rescue nil + if manager.nil? + manager = self.managers.create(:user => user,:rule_creator => assigner) + end + manager + end + + def assign_sub_manager(user,assigner) + submanager = AppManager.first(conditions: {sub_managing_app_id: self.id,user_id: user.id}) rescue nil + if submanager.nil? && !self.managing_users.include?(user) + submanager = self.sub_managers.create(:user => user,:rule_creator => assigner) + end + submanager + end + + def remove_manager(user) + manager = AppManager.first(conditions: {managing_app_id: self.id,user_id: user.id}) rescue nil + if manager + manager.destroy + else + false + end + end + + def remove_sub_manager(user) + submanager = AppManager.first(conditions: {sub_managing_app_id: self.id,user_id: user.id}) rescue nil + if submanager + submanager.destroy + else + false + end + end field :app_pages ,type: Array diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index af8a11064..846504218 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -7,7 +7,7 @@ class Attribute field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - has_many :attribute_fields, :autosave => true, :dependent => :destroy + embeds_many :attribute_fields, :cascade_callbacks => true has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :attribute_fields, :allow_destroy => true diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 42bbf9109..2d909b3e4 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -10,7 +10,7 @@ class AttributeField field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - belongs_to :attribute + embedded_in :attribute has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :attribute_values diff --git a/app/models/user/role.rb b/app/models/user/role.rb index 86f7266fc..788d281d2 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -7,7 +7,7 @@ class Role field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - has_many :sub_roles, :autosave => true, :dependent => :destroy + embeds_many :sub_roles, :cascade_callbacks => true has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :users accepts_nested_attributes_for :i18n_variable, :allow_destroy => true diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb index cdefb5f50..47f3e2dee 100644 --- a/app/models/user/sub_role.rb +++ b/app/models/user/sub_role.rb @@ -1,6 +1,6 @@ class SubRole < Attribute - belongs_to :role + embedded_in :role has_and_belongs_to_many :users # Get an sub_role from key diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 60199ce7f..13d282bb4 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -14,6 +14,9 @@ class User has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth" has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth" + + has_many :managing_apps,:class_name => "AppManager" + belongs_to :role has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true diff --git a/app/views/admin/assets/_asset.html.erb b/app/views/admin/assets/_asset.html.erb index b29bc51df..ea71dc6c0 100644 --- a/app/views/admin/assets/_asset.html.erb +++ b/app/views/admin/assets/_asset.html.erb @@ -5,7 +5,7 @@ <%= asset.description %> <%= asset.data.file.content_type %> - <%= asset.data_filename %> + <%= asset.data_identifier %> <%= number_to_human_size(asset.data.file.file_length) %> <%= link_to t(:edit), edit_admin_asset_path(asset), :remote => true, :class => 'edit' %> @@ -13,5 +13,5 @@ - + \ No newline at end of file diff --git a/app/views/admin/assets/_edit.html.erb b/app/views/admin/assets/_edit.html.erb index cc0a5c52b..33f8131cb 100644 --- a/app/views/admin/assets/_edit.html.erb +++ b/app/views/admin/assets/_edit.html.erb @@ -1,12 +1,16 @@

<%= t('editing_asset') %>

- <%= form_for @asset, :url => admin_asset_path(@asset), :html => {:id => 'ajaxForm', :multipart => true } do |f| %> + <%= form_for @asset, :url => admin_asset_path(@asset), :html => {:id => (is_html ? nil : 'ajaxForm'), :multipart => true } do |f| %> <%= f.error_messages %> <%= render :partial => "form", :locals => { :f => f } %>
- <%= link_back if is_html %> - <%= t(:update) %> + <% if is_html %> + <%= link_back %> + <%= f.submit t(:edit) %> + <% else %> + <%= t(:edit) %> + <% end %>
<% end %>
\ No newline at end of file diff --git a/app/views/admin/assets/_form.html.erb b/app/views/admin/assets/_form.html.erb index 3ee7c6447..72199ceb4 100644 --- a/app/views/admin/assets/_form.html.erb +++ b/app/views/admin/assets/_form.html.erb @@ -9,6 +9,6 @@

-<%= f.label :data, t('admin.data') %> +<%= f.label :data, t('admin.data'), :class => 'file' %> <%= f.file_field :data %>

\ No newline at end of file diff --git a/app/views/admin/assets/_new.html.erb b/app/views/admin/assets/_new.html.erb index 2f997a116..49e638c8c 100644 --- a/app/views/admin/assets/_new.html.erb +++ b/app/views/admin/assets/_new.html.erb @@ -1,12 +1,16 @@

<%= t('admin.new_asset') %>

- <%= form_for :asset, :url => admin_assets_path, :html => {:id => 'ajaxForm', :multipart => true }, :remote => true do |f| %> + <%= form_for :asset, :url => admin_assets_path, :html => {:id => (is_html ? nil : 'ajaxForm'), :multipart => true } do |f| %> <%= f.error_messages %> <%= render :partial => "form", :locals => { :f => f } %>
- <%= link_back if is_html %> - <%= t(:create) %> + <% if is_html %> + <%= link_back %> + <%= f.submit t(:create) %> + <% else %> + <%= t(:create) %> + <% end %>
<% end %>
diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index c29450696..9e4945525 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -1,8 +1,8 @@ <%= f.label "field_name", t('admin.' + field_name) %>