diff --git a/Gemfile b/Gemfile index 5c9b15e7..0012fa39 100644 --- a/Gemfile +++ b/Gemfile @@ -11,11 +11,13 @@ gem 'devise', '1.5.3' gem 'exception_notification' # Send error trace gem 'execjs' gem 'jquery-rails' +gem 'jquery-ui-rails' gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'mini_magick' gem 'mongoid' +gem 'mongoid-tree', :require => 'mongoid/tree' gem "mongo_session_store-rails3" gem 'mysql2' gem 'nokogiri' diff --git a/Gemfile.lock b/Gemfile.lock index 2db01455..4e085437 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,6 +96,9 @@ GEM jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) + jquery-ui-rails (0.4.0) + jquery-rails + railties (>= 3.1.0) json (1.6.5) libv8 (3.3.10.4) linecache19 (0.5.12) @@ -116,6 +119,8 @@ GEM activemodel (~> 3.1) mongo (~> 1.3) tzinfo (~> 0.3.22) + mongoid-tree (0.7.0) + mongoid (~> 2.0) multi_json (1.1.0) mysql2 (0.3.11) net-ldap (0.3.1) @@ -273,10 +278,12 @@ DEPENDENCIES execjs factory_girl_rails jquery-rails + jquery-ui-rails kaminari! mini_magick mongo_session_store-rails3 mongoid + mongoid-tree mysql2 net-ldap (~> 0.3.1) nokogiri diff --git a/app/assets/images/editicon.png b/app/assets/images/editicon.png new file mode 100644 index 00000000..cef3e600 Binary files /dev/null and b/app/assets/images/editicon.png differ diff --git a/app/assets/images/icons_pack.png b/app/assets/images/icons_pack.png index 39669303..16ac9872 100644 Binary files a/app/assets/images/icons_pack.png and b/app/assets/images/icons_pack.png differ diff --git a/app/assets/images/icons_pack_white.png b/app/assets/images/icons_pack_white.png index 70fe3d85..e7360702 100644 Binary files a/app/assets/images/icons_pack_white.png and b/app/assets/images/icons_pack_white.png differ diff --git a/app/assets/javascripts/lib/jquery.ui.nestedSortable.js b/app/assets/javascripts/lib/jquery.ui.nestedSortable.js new file mode 100755 index 00000000..aad83af5 --- /dev/null +++ b/app/assets/javascripts/lib/jquery.ui.nestedSortable.js @@ -0,0 +1,391 @@ +/* + * jQuery UI Nested Sortable + * v 1.3.4 / 28 apr 2011 + * http://mjsarfatti.com/sandbox/nestedSortable + * + * Depends: + * jquery.ui.sortable.js 1.8+ + * + * License CC BY-SA 3.0 + * Copyright 2010-2011, Manuele J Sarfatti + */ + +(function($) { + + $.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, { + + options: { + tabSize: 20, + disableNesting: 'ui-nestedSortable-no-nesting', + errorClass: 'ui-nestedSortable-error', + listType: 'ol', + maxLevels: 0, + revertOnError: 1 + }, + + _create: function() { + this.element.data('sortable', this.element.data('nestedSortable')); + return $.ui.sortable.prototype._create.apply(this, arguments); + }, + + destroy: function() { + this.element + .removeData("nestedSortable") + .unbind(".nestedSortable"); + return $.ui.sortable.prototype.destroy.apply(this, arguments); + }, + + _mouseDrag: function(event) { + + //Compute the helpers position + this.position = this._generatePosition(event); + this.positionAbs = this._convertPositionTo("absolute"); + + if (!this.lastPositionAbs) { + this.lastPositionAbs = this.positionAbs; + } + + //Do scrolling + if(this.options.scroll) { + var o = this.options, scrolled = false; + if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') { + + if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) + this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; + else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) + this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; + + if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) + this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; + else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) + this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; + + } else { + + if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) + scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); + else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) + scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); + + if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) + scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); + else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) + scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); + + } + + if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) + $.ui.ddmanager.prepareOffsets(this, event); + } + + //Regenerate the absolute position used for position checks + this.positionAbs = this._convertPositionTo("absolute"); + + //Set the helper position + if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; + if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; + + //Rearrange + for (var i = this.items.length - 1; i >= 0; i--) { + + //Cache variables and intersection, continue if no intersection + var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); + if (!intersection) continue; + + if(itemElement != this.currentItem[0] //cannot intersect with itself + && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before + && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked + && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true) + //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container + ) { + + $(itemElement).mouseenter(); + + this.direction = intersection == 1 ? "down" : "up"; + + if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) { + $(itemElement).mouseleave(); + this._rearrange(event, item); + } else { + break; + } + + // Clear emtpy ul's/ol's + this._clearEmpty(itemElement); + + this._trigger("change", event, this._uiHash()); + break; + } + } + + var parentItem = (this.placeholder[0].parentNode.parentNode + && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) + ? $(this.placeholder[0].parentNode.parentNode) + : null, + level = this._getLevel(this.placeholder), + childLevels = this._getChildLevels(this.helper), + previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null; + + if (previousItem != null) { + while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) { + if (previousItem[0].previousSibling) { + previousItem = $(previousItem[0].previousSibling); + } else { + previousItem = null; + break; + } + } + } + + newList = document.createElement(o.listType); + + this.beyondMaxLevels = 0; + + // If the item is moved to the left, send it to its parent level + if (parentItem != null && this.positionAbs.left < parentItem.offset().left) { + parentItem.after(this.placeholder[0]); + this._clearEmpty(parentItem[0]); + this._trigger("change", event, this._uiHash()); + } + // If the item is below another one and is moved to the right, make it a children of it + else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) { + this._isAllowed(previousItem, level+childLevels+1); + if (!previousItem.children(o.listType).length) { + previousItem[0].appendChild(newList); + } + previousItem.children(o.listType)[0].appendChild(this.placeholder[0]); + this._trigger("change", event, this._uiHash()); + } + else { + this._isAllowed(parentItem, level+childLevels); + } + + //Post events to containers + this._contactContainers(event); + + //Interconnect with droppables + if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); + + //Call callbacks + this._trigger('sort', event, this._uiHash()); + + this.lastPositionAbs = this.positionAbs; + return false; + + }, + + _mouseStop: function(event, noPropagation) { + + // If the item is in a position not allowed, send it back + if (this.beyondMaxLevels) { + + this.placeholder.removeClass(this.options.errorClass); + + if (this.options.revertOnError) { + if (this.domPosition.prev) { + $(this.domPosition.prev).after(this.placeholder); + } else { + $(this.domPosition.parent).prepend(this.placeholder); + } + this._trigger("revert", event, this._uiHash()); + } else { + var parent = this.placeholder.parent().closest(this.options.items); + + for (var i = this.beyondMaxLevels - 1; i > 0; i--) { + parent = parent.parent().closest(this.options.items); + } + + parent.after(this.placeholder); + this._trigger("change", event, this._uiHash()); + } + + } + + // Clean last empty ul/ol + for (var i = this.items.length - 1; i >= 0; i--) { + var item = this.items[i].item[0]; + this._clearEmpty(item); + } + + $.ui.sortable.prototype._mouseStop.apply(this, arguments); + + }, + + serialize: function(o) { + + var items = this._getItemsAsjQuery(o && o.connected), + str = []; o = o || {}; + + $(items).each(function() { + var res = ($(o.item || this).attr(o.attribute || 'id') || '') + .match(o.expression || (/(.+)[-=_](.+)/)), + pid = ($(o.item || this).parent(o.listType) + .parent('li') + .attr(o.attribute || 'id') || '') + .match(o.expression || (/(.+)[-=_](.+)/)); + + if (res) { + str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']') + + '=' + + (pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root')); + } + }); + + if(!str.length && o.key) { + str.push(o.key + '='); + } + + return str.join('&'); + + }, + + toHierarchy: function(o) { + + o = o || {}; + var sDepth = o.startDepthCount || 0, + ret = []; + + $(this.element).children('li').each(function () { + var level = _recursiveItems($(this)); + ret.push(level); + }); + + return ret; + + function _recursiveItems(li) { + var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); + if (id) { + var item = {"id" : id[2]}; + if ($(li).children(o.listType).children('li').length > 0) { + item.children = []; + $(li).children(o.listType).children('li').each(function() { + var level = _recursiveItems($(this)); + item.children.push(level); + }); + } + return item; + } + } + }, + + toArray: function(o) { + + o = o || {}; + var sDepth = o.startDepthCount || 0, + ret = [], + left = 2; + + ret.push({ + "item_id": 'root', + "parent_id": 'none', + "depth": sDepth, + "left": '1', + "right": ($('li', this.element).length + 1) * 2 + }); + + $(this.element).children('li').each(function () { + left = _recursiveArray(this, sDepth + 1, left); + }); + + ret = ret.sort(function(a,b){ return (a.left - b.left); }); + + return ret; + + function _recursiveArray(item, depth, left) { + + var right = left + 1, + id, + pid; + + if ($(item).children(o.listType).children('li').length > 0) { + depth ++; + $(item).children(o.listType).children('li').each(function () { + right = _recursiveArray($(this), depth, right); + }); + depth --; + } + + id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/)); + + if (depth === sDepth + 1) { + pid = 'root'; + } else { + var parentItem = ($(item).parent(o.listType) + .parent('li') + .attr(o.attribute || 'id')) + .match(o.expression || (/(.+)[-=_](.+)/)); + pid = parentItem[2]; + } + + if (id) { + ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right}); + } + + left = right + 1; + return left; + } + + }, + + _clearEmpty: function(item) { + + var emptyList = $(item).children(this.options.listType); + if (emptyList.length && !emptyList.children().length) { + emptyList.remove(); + } + + }, + + _getLevel: function(item) { + + var level = 1; + + if (this.options.listType) { + var list = item.closest(this.options.listType); + while (!list.is('.ui-sortable')) { + level++; + list = list.parent().closest(this.options.listType); + } + } + + return level; + }, + + _getChildLevels: function(parent, depth) { + var self = this, + o = this.options, + result = 0; + depth = depth || 0; + + $(parent).children(o.listType).children(o.items).each(function (index, child) { + result = Math.max(self._getChildLevels(child, depth + 1), result); + }); + + return depth ? result + 1 : result; + }, + + _isAllowed: function(parentItem, levels) { + var o = this.options; + // Are we trying to nest under a no-nest or are we nesting too deep? + if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) { + if (o.maxLevels < levels && o.maxLevels != 0) { + this.placeholder.addClass(o.errorClass); + this.beyondMaxLevels = levels - o.maxLevels; + } else { + this.placeholder.removeClass(o.errorClass); + this.beyondMaxLevels = 0; + } + } else { + this.placeholder.addClass(o.errorClass); + if (o.maxLevels < levels && o.maxLevels != 0) { + this.beyondMaxLevels = levels - o.maxLevels; + } else { + this.beyondMaxLevels = 1; + } + } + } + + })); + + $.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options); +})(jQuery); \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/assets/javascripts/module_widget.js b/app/assets/javascripts/module.js.erb similarity index 95% rename from vendor/built_in_modules/news/app/assets/javascripts/module_widget.js rename to app/assets/javascripts/module.js.erb index aea46d72..fc19b8e6 100644 --- a/vendor/built_in_modules/news/app/assets/javascripts/module_widget.js +++ b/app/assets/javascripts/module.js.erb @@ -6,4 +6,3 @@ // //= require jquery //= require jquery_ujs -//= require news_link \ No newline at end of file diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js.erb similarity index 63% rename from app/assets/javascripts/page_edit.js rename to app/assets/javascripts/page_edit.js.erb index a889f5b2..7c0f6923 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js.erb @@ -32,3 +32,24 @@ $('.part_kind').live('click', function() { $('.part_kind_partial').hide(); $('#part_' + $(this).attr('value')).show(); }); + +$(document).ready(function(){ + $('ol.sortable').nestedSortable({ + disableNesting: 'no-nest', + forcePlaceholderSize: true, + handle: 'i', + helper: 'clone', + items: 'li', + maxLevels: 3, + opacity: .5, + placeholder: 'placeholder', + revert: 250, + tabSize: 25, + tolerance: 'pointer', + toleranceElement: '> div', + + stop: function(event, ui) { + $.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } ); + } + }); +}); \ No newline at end of file diff --git a/app/assets/javascripts/site_editor.js b/app/assets/javascripts/site_editor.js index 2076f04d..5d77e701 100644 --- a/app/assets/javascripts/site_editor.js +++ b/app/assets/javascripts/site_editor.js @@ -5,6 +5,9 @@ // the compiled file. // //= require jquery +//= require jquery.ui.draggable +//= require jquery.ui.droppable +//= require jquery.ui.sortable //= require jquery_ujs //= require bootstrap //= require jquery.isotope.min @@ -14,4 +17,5 @@ //= require side_bar_history //= require page_edit //= require tinymce-jquery -//= require tinymce_orbit \ No newline at end of file +//= require tinymce_orbit +//= require lib/jquery.ui.nestedSortable.js \ No newline at end of file diff --git a/app/assets/javascripts/tinymce_orbit.js b/app/assets/javascripts/tinymce_orbit.js index 60492914..71264fde 100644 --- a/app/assets/javascripts/tinymce_orbit.js +++ b/app/assets/javascripts/tinymce_orbit.js @@ -1,4 +1,4 @@ -$(function() { +function load_tinymce() { $('.tinymce_textarea').tinymce({ theme: 'advanced', plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", @@ -22,4 +22,8 @@ $(function() { external_image_list_url : "js/image_list.js", media_external_list_url : "js/media_list.js" }); +} + +$(document).ready(function() { + load_tinymce(); }); \ No newline at end of file diff --git a/app/assets/stylesheets/sidebar.css.erb b/app/assets/stylesheets/sidebar.css.erb index 4231d0bf..1e4b4010 100644 --- a/app/assets/stylesheets/sidebar.css.erb +++ b/app/assets/stylesheets/sidebar.css.erb @@ -6,13 +6,14 @@ .nav-list li { position: relative; } -.nav-list ul { - margin-left: 10px; +.nav-list ol { + margin-left: 20px; } -.nav-list ul li { +.nav-list ol li { padding: 5px 0; + list-style: none; } -.nav-list ul li a { +.nav-list ol li a { font-size: 13px; padding: 3px 0px; display: block; @@ -148,4 +149,28 @@ } #main-sidebar .quick-edit a:hover { background-color: #DDDDDD; +} +ol.nav>li>.icons-moves { + display: none; +} +.sortable i { + position: absolute; + left: -20px; + top: 6px; + margin-right: 0; + opacity: 0.3; + filter: alpha(opacity=30); +} +.sortable i:hover { + cursor:move; + opacity: 0.7; + filter: alpha(opacity=70); +} +.placeholder { + background-color: rgba(0,136,204,.6); + border-radius: 3px; +} +.ui-nestedSortable-error { + background: rgba(255,206,206,.6); + color: #8a1f11; } \ No newline at end of file diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index 9bba5765..ba1c3066 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -110,10 +110,8 @@ padding:6px; } #orbit-bar .nav > li.search { - background-image: none; overflow: hidden; width: 28px; - margin-bottom: 0; position: relative; } #orbit-bar .nav > li > a.orbit-bar-home { @@ -685,6 +683,33 @@ #banner [id^="slideshow-"] { z-index: 2 !important; } + +#back_main .editable { + position: relative; +} +#back_main .editable:after { + content: ''; + clear: both; + display: block; + visibility: hidden; + height: 0; +} + +#back_main .edit_link a { + position: absolute; + z-index: 10; + width: 100%; + height: 100%; + top: 0; + left: 0; + text-indent: -9999px; + background: url(<%= asset_path 'editicon.png' %>) no-repeat center center rgba(255,255,255,.8); + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); +} + + [class^="icons-"] { display: inline-block; width: 16px; @@ -1243,12 +1268,63 @@ .icons-plus { background-position: -288px -576px; } +/*20*/ .icons-power { background-position: -0px -608px; } -/*20*/ -.icons- { - background-position: -0px -608px; +.icons-output { + background-position: -32px -608px; +} +.icons-col-resize { + background-position: -64px -608px; +} +.icons-move { + background-position: -96px -608px; +} +.icons-size-out { + background-position: -128px -608px; +} +.icons-size-in { + background-position: -160px -608px; +} +.icons-slash { + background-position: -192px -608px; +} +.icons-level { + background-position: -224px -608px; +} +.icons-share { + background-position: -256px -608px; +} +.icons-share2 { + background-position: -288px -608px; +} +.icons-re { + background-position: -320px -608px; +} +.icons-insert { + background-position: -352px -608px; +} +.icons-insert2 { + background-position: -384px -608px; +} +.icons-download { + background-position: -416px -608px; +} +.icons-tag-rignt { + background-position: -448px -608px; +} +.icons-tag-top { + background-position: -480px -608px; +} +.icons-tag-bottom { + background-position: -512px -608px; +} +.icons-tag-left { + background-position: -544px -608px; +} +.icons-moves { + background-position: -576px -608px; } /*21*/ .icons- { diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb index 33bc0fd2..1ea40640 100644 --- a/app/controllers/admin/items_controller.rb +++ b/app/controllers/admin/items_controller.rb @@ -15,6 +15,12 @@ class Admin::ItemsController < ApplicationController @item = get_homepage end end + + def update_position + item = Item.find(params[:id]) + item.shift_to(params[:parent_id], params[:position]) + render :nothing => true + end protected diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index f124dec2..0c90f854 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -12,13 +12,16 @@ class Admin::ModuleAppsController < ApplicationController def reload_frontend_pages @categories =[] @module_app = ModuleApp.find(params[:id]) - unless (@module_app.category.nil? rescue true) - @module_app.category.each do |category| - @categories << eval(category).all.entries - end - @categories.flatten! - else - @categories = nil + case @module_app.key + when 'announcement' + @categories = BulletinCategory.all + @tags = AnnouncementTag.all + when 'news' + @categories = NewsBulletinCategory.all + @tags = NewsTag.all + when 'web_resource' + @categories = WebLinkCategory.all + @tags = WebResourceTag.all end respond_to do |format| format.js {} diff --git a/app/controllers/admin/new_interface_module_apps_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb similarity index 93% rename from app/controllers/admin/new_interface_module_apps_controller.rb rename to app/controllers/admin/module_apps_new_interface_controller.rb index 6603334c..52292588 100644 --- a/app/controllers/admin/new_interface_module_apps_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -1,4 +1,4 @@ -class Admin::NewInterfaceModuleAppsController < ApplicationController +class Admin::ModuleAppsNewInterfaceController < ApplicationController before_filter :authenticate_user! before_filter :is_admin? include AdminHelper @@ -6,7 +6,7 @@ class Admin::NewInterfaceModuleAppsController < ApplicationController layout "new_admin" def setting - @sys_users = User.all + @sys_users = User.all(conditions: {admin: false}) @module_app = ModuleApp.find(params[:module_app_id]) @options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] } # if params.has_key? :category diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb new file mode 100644 index 00000000..427ec722 --- /dev/null +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -0,0 +1,71 @@ +class Admin::ObjectAuthsNewInterfaceController < ApplicationController + include OrbitCoreLib::PermissionUnility + layout "new_admin" + before_filter :force_order + + layout "new_admin" + + + def setting + @sys_users = User.all(conditions: {admin: false}) + @ob_auth = ObjectAuth.find params[:object_auth_id] + @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } + @users_array = @ob_auth.privilege_users rescue [] + + respond_to do |format| + format.html + format.js + end + end + + def update_setting + ob_auth = update_setting_by_params + if ob_auth.save! + flash[:notice] = t("admin.object_auth.update_done") + else + flash[:notice] = t("admin.object_auth.update_failed") + end + end + + def user_list + @ob_auth = ObjectAuth.find params[:ob_auth][:id] + end + + protected + def update_setting_by_params + oa = ObjectAuth.find params[:ob_auth][:id] + user_sat = User.find params[:users].keys + users_to_new = user_sat - oa.auth_users + users_to_remove = oa.auth_users - user_sat + + users_to_new.each do |new_user| + oa.add_user_to_privilege_list(new_user) + end + + users_to_remove.each do |remove_user| + oa.remove_user_from_privilege_list(remove_user) + end + oa + end + + # def get_categorys(id = nil) + # @bulletin_categorys = [] + # if(is_manager? || is_admin?) + # @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + # elsif is_sub_manager? + # @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + # end + # end + + def force_order + authenticate_user! + check_if_user_can_do_object_auth + end + + def check_if_user_can_do_object_auth + unless check_permission(:manager) + render :nothing => true, :status => 403 + end + end + +end \ No newline at end of file diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 65754319..44bda4aa 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -20,14 +20,14 @@ class Admin::PagesController < ApplicationController def new @item = Page.new @item.parent = Item.find(params[:parent_id]) rescue nil - @apps = ModuleApp.all + @apps = ModuleApp.excludes(app_pages: nil).entries @designs = Design.all.entries @design = Design.first end def edit @item = Page.find(params[:id]) - @apps = ModuleApp.all + @apps = ModuleApp.excludes(app_pages: nil).entries @designs = Design.all.entries @design = @item.design ? @item.design : @designs.first @app_frontend_urls = @item.module_app.app_pages if @item.module_app @@ -35,10 +35,13 @@ class Admin::PagesController < ApplicationController case @item.module_app.key when 'announcement' @categories = BulletinCategory.all + @tags = AnnouncementTag.all when 'news' @categories = NewsBulletinCategory.all + @tags = NewsTag.all when 'web_resource' @categories = WebLinkCategory.all + @tags = WebResourceTag.all end else @categories = nil diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fb82774e..0a645397 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,9 +45,9 @@ class ApplicationController < ActionController::Base end # Render the page - def render_page(id = nil) + def render_page if @item - render :text => process_page(@item, id), :layout => 'page_layout' + render :text => parse_page_noko(@item), :layout => 'page_layout' else render :text => '404 Not Found' end diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index a03a1f6c..bdddfb43 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -23,7 +23,7 @@ class OrbitBackendController< ApplicationController def check_user_can_use unless check_permission #redirect_to polymorphic_path(['panel',@app_title,'back_end','public']) - render :text => '403 Forbidden' + redirect_to root_url end end diff --git a/app/controllers/orbit_frontend_component_controller.rb b/app/controllers/orbit_frontend_component_controller.rb index 185dbce6..09621e5f 100644 --- a/app/controllers/orbit_frontend_component_controller.rb +++ b/app/controllers/orbit_frontend_component_controller.rb @@ -1,7 +1,7 @@ class OrbitFrontendComponentController< ApplicationController before_filter :setup_vars before_filter {|c| c.front_end_available(@app_title)} - layout :false + layout "module_widget" def setup_vars @app_title = request.fullpath.split('/')[2] diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c4e00aa2..45299450 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -15,11 +15,11 @@ class PagesController < ApplicationController def show #begin - @item = Item.first(:conditions => {:full_name => params[:page_name]}) + @item = Item.first(:conditions => {:path => params[:page_name]}) if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) case @item._type when 'Page' - render_page(params) + render_page when 'Link' redirect_to "http://#{@item[:url]}" end @@ -32,17 +32,19 @@ class PagesController < ApplicationController end def index_from_link - if params[:page] - redirect_to "/#{@item.full_name}?page=#{params[:page]}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}" - else - redirect_to "/#{@item.full_name}?category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}" - end + url = "/#{@item.path}" + options = '' + options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank? + options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank? + options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank? + redirect_to url + options end def show_from_link - # debugger - # a=1 - redirect_to "/#{@item.full_name}?id=#{params[:id]}&preview=#{params[:preview]}" + url = "/#{@item.path}?id=#{params[:id]}" + options = '' + options << "&preview=#{params[:preview]}" unless params[:preview].blank? + redirect_to url + options end def load_orbit_bar diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index 8af4db34..b5ab255e 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -8,9 +8,10 @@ module Admin::ItemHelper dest = admin_page_path(node) when 'Link' dest = admin_link_path(node) + no_nested = 'no-nest' end - ret << "