Hi Ryan,

You can do this with ModelGlue without having to resort to inspecting your
user bean in the layout template.  You inspect your user in a controller and
for each role the user is in add a result like "AdminRole" or whatever then
have that result include the necessary elements for you.

here's a sample config

<?xml version="1.0" encoding="UTF-8"?>
<modelglue>
<controllers>
<controller id="Controller"
type="modelglueapplicationtemplate.controller.Controller">
<message-listener message="getUserRolesAsResults" />
</controller>
</controllers>
 <event-types>
<!-- event type for pages, each 'Role' is added by the controller method as
a result,
which causes the event for that result to be executed including the elements
for that role -->
<event-type name="Page">
<after>
<broadcasts>
<message name="getUserRolesAsResults" />
</broadcasts>
<results>
<result name="FooRole" do="template.foo"/>
<result name="BarRole" do="template.bar"/>
</results>
</after>
</event-type>
 <!-- event type applied to role templates, just includes your main layout
file -->
<event-type name="Template">
<after>
<views>
<!-- use viewcollection.exists('foo_menu') in this template
to include elements that are required  -->
<include name="main" template="templates/main.cfm" />
</views>
</after>
</event-type>
</event-types>
 <event-handlers>
<!-- homepage -->
<event-handler name="page.index" type="Page">
<views>
<include name="body" template="pages/index.cfm" />
</views>
</event-handler>
<!-- define a template for each role that includes the elements you need for
that role -->
<event-handler name="template.foo" access="private" type="template">
<views>
<include name="left_sidebar" template="pages/test.cfm" />
<include name="foo_menu" template="pages/test.cfm" />
</views>
</event-handler>
<event-handler name="template.bar" access="private" type="Template">
<views>
<include name="right_sidebar" template="pages/test.cfm" />
<include name="bar_menu" template="pages/test.cfm" />
</views>
</event-handler>
 </event-handlers>
</modelglue>



2009/12/15 Ryan Stille <[email protected]>

> I've looked through that page a couple times but I still don't
> understand how it would help.
>
> I'm not interested in preventing certain events from being accessed by
> certain users.  What I need to do is when an event is called (by any
> user), I need to enable/disable parts of the page based on the groups/
> permissions the user has.  Most of the time the "parts of the page"
> that need to be turned off are complete view files, for example, a
> sidebar file.  So I could just go into all the sidebar files and add a
> cfif around the whole file:
>
> <cfif Session.userbean.isInRole("someRole")>
>    whole file here
> </cfif>
>
> But I thought there might be a better way to do it in the model glue
> XML?  I don't really think so but thought I would ask the group.
>
> On Dec 1, 4:47 pm, Chuck Savage <[email protected]> wrote:
> > check out event-type's here:
> http://trac.model-glue.com/wiki/HowTos/HowToUseTypedEvents#HowToUseTy...
> >
> > On Nov 30, 3:10 pm, RyanStille<[email protected]> wrote:
> >
> >
> >
> > > We have an established, already in use model-glue app.  Different
> > > areas of the site each have their own sidebar navigation.  We show
> > > these different files by using an <include> directive in each event-
> > > handler in our ModelGlue xml file. For example, here is part of the
> > > event-handler for an event in the users area:
> >
> > > ....
> > > <views>
> > >         <include name="sidebar" template="navigation_users.cfm" />
> > >         <include name="body" template="whatever.cfm"/>
> > > </views>
> > > ....
> >
> > > A new feature request is to turn off this sidebar navigation for some
> > > users (there is other navigation on the page they will use).  I could
> > > go into each of these sidebar files and add a CFIF block around the
> > > whole thing, but I was wondering if there was a better way?  I don't
> > > think there is anything I can do at the modelGlue.xml level?
> >
> > > I also thought about going into the main template and adding a CFIF
> > > around the #viewcollection.getView("sidebar")# area, is that a good
> > > way to do it?  I don't like it because MG will still be "executing"
> > > the sidebar, it will just never get displayed.  Seems kind of hacky.
> >
> > > Thanks,
> > > -Ryan
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to