cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling Space Creation Option

nh
Champ in-the-making
Champ in-the-making
Hi All,

I need to provide the access and visiblity of "Create Space" in the "Create" drop down menu only to the admin and only "Create Content" option to all the other users

Can someone please suggest how to implement this?

Thanks.
NH
2 REPLIES 2

gavinc
Champ in-the-making
Champ in-the-making
You can override the action definition for the create_space and create_space_wizard actions.

<config>
      <actions>
         <action id="create_space">
             <permissions>
                <permission allow="true">CreateChildren</permission>
            </permissions>
            <evaluator>your.ActionEvaluator</evaluator>
            <label-id>create_space</label-id>
            <image>/images/icons/create_space.gif</image>
            <action>dialog:createSpace</action>
         </action>
        
         <!– Create Advanced Space Wizard –>
         <action id="create_space_wizard">
            <permissions>
               <permission allow="true">CreateChildren</permission>
            </permissions>
            <evaluator>your.ActionEvaluator</evaluator>
            <label-id>advanced_space_wizard</label-id>
            <image>/images/icons/create_space.gif</image>
            <action>wizard:createSpace</action>
         </action>
   </actions>
</config>

If you add the above to your web-client-config-custom.xml file you will override the action definitions, notice the extra 'evaluator' element from the default definition. This should point to a custom action evaluator class you'll need to implement. Have a look at the org.alfresco.web.action.evaluator package for examples.

Basically you'll need to implement an evaluate method and return true or false depending on whether the current user is the admin user or not.

public boolean evaluate(Node node)
{
   return (Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName().equals("admin"));
}

nh
Champ in-the-making
Champ in-the-making
Gavin, Thanks for the hint.

I was succesfully able to hide the options for users other than admin.

But i have an other issue attched to it. Smiley Sad

We have made some chagnes in the ldap authentication and the removed the "admin" user. Instead we have other users defined as admins in the authority-services-context.xml and here the usernames are some unique id's. eg

<property name="adminUsers">
   <set>

<value>12345</value>
  </set>
   </property>

In our scenario we have more than one user acting as admin and  they might change time to time. Now,  i have hardcoded the users list in the evaluator class as a temporary arrangement as below

public boolean evaluate(Node node)
   {
      String userName=Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
    
                if(userName.equals(u1) || userName.equals(u2) || userName.equals(u3))
     return true;
     else
        return false;
   }

Can you pls suggest me a way in which i could have some permanent solution for this?

Thanks in Advance,
Hari