Sha256: d00d4070ef143dc98efe055b201b06261df0259c0fa695f4967603abe908ade3

Contents?: true

Size: 1.57 KB

Versions: 23

Compression:

Stored size: 1.57 KB

Contents

class Caboose::PagePlugin < Caboose::CaboosePlugin

  def self.admin_nav(nav, user, page)    
    return nav if user.nil? || !user.is_allowed('pages', 'view')
    
    item = {
      'id' => 'pages', 
      'text' => 'Pages',
      'children' => []
      #'show_children_default' => true
    }
      
    is_admin = user.is_allowed('all', 'all')
    actions = Caboose::Page.permissible_actions(user.id, page.id)
    if (actions.include?('edit') || is_admin)
    	item['children'] << { 'href' => "/pages/#{page.id}/sitemap"       , 'text' => 'Site Map This Page'  }
    	item['children'] << { 'href' => "/pages/#{page.id}/edit"          , 'text' => 'Edit Page Content'   }
    	item['children'] << { 'href' => "/pages/#{page.id}/edit-settings" , 'text' => 'Edit Page Settings'  }

    	#uru = session['use_redirect_urls'].nil? ? true : session['use_redirect_urls']
    	#item['children'] << { 'id' => 'use_redirect_urls', 'href' => '#', 'text' => '' + (uru ? 'Disable' : 'Enable') + ' Redirect Urls' }
    end
    if (user.is_allowed('pages', 'add') || is_admin)
      item['children'] << { 'href' => "/pages/new?parent_id=#{page.id}"  , 'text' => 'New Page' }
    end    
    nav << item
    return nav
  end
  
  def self.admin_js
    return "
      $('#use_redirect_urls').click(function() {
        uru = $('#use_redirect_urls');
        val = (uru.html() == 'Enable' ? 1 : 0);        
        $.ajax({
          url: '/admin/settings/toggle-redirect-urls',
          data: 'val='+val,
          succes: function(resp) { uri.html(val == 1 ? 'Disable' : 'Enable'); }
        });
      });"
  end
  
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
caboose-cms-0.2.5 app/models/caboose/page_plugin.rb
caboose-cms-0.2.4 app/models/caboose/page_plugin.rb
caboose-cms-0.2.2 app/models/caboose/page_plugin.rb
caboose-cms-0.2.1 app/models/caboose/page_plugin.rb
caboose-cms-0.1.102 app/models/caboose/page_plugin.rb
caboose-cms-0.1.101 app/models/caboose/page_plugin.rb
caboose-cms-0.1.98 app/models/caboose/page_plugin.rb
caboose-cms-0.1.97 app/models/caboose/page_plugin.rb
caboose-cms-0.1.96 app/models/caboose/page_plugin.rb
caboose-cms-0.1.93 app/models/caboose/page_plugin.rb
caboose-cms-0.1.92 app/models/caboose/page_plugin.rb
caboose-cms-0.1.91 app/models/caboose/page_plugin.rb
caboose-cms-0.1.78 app/models/caboose/page_plugin.rb
caboose-cms-0.1.35 app/models/caboose/page_plugin.rb
caboose-cms-0.1.34 app/models/caboose/page_plugin.rb
caboose-cms-0.1.7 app/models/caboose/page_plugin.rb
caboose-cms-0.1.6 app/models/caboose/page_plugin.rb
caboose-cms-0.1.5 app/models/caboose/page_plugin.rb
caboose-cms-0.1.4 app/models/caboose/page_plugin.rb
caboose-cms-0.1.3 app/models/caboose/page_plugin.rb