March 13, 2008

Making a Tool Only Appear in Sakai for Powerful Users

On Mar 13, 2008, at 5:20 AM, Juan Velasquez wrote:

Aloha,

I'm a new developer writing a new tool, this tool will be usable only by Teachers and Administrators,  not visible by students at all.

Do I use the SecurityService for this?

Thanks. Juan.

---- My Response Below ---

Juan,

This is pretty easy.  Take a look at this document:

https://source.sakaiproject.org/svn/reference/trunk/docs/architecture/sakai_workgroup_portal.doc

Here is an excerpt from that document.

<registration>
        <tool        id="sakai.rutgers.linktool"
                        title="Link Tool"
                        description="A tool to link to external applications.">
 
                <category name="course" />
                <category name="project" />
 
                <!-- Allow this to be set -->
                <configuration name="functions.require" />
        </tool>
</registration>

As we explore the use of these features, remember that the key value of functions.require is to make tools disappear when a user is missing a permission.  So this allows a site to have many tools that are all there when people are logged in and then have those buttons disappear for anonymous users or for users with or without a particular role.

In Sakai 2.3 there were very few tools that made use of this capability - for the Rutgers link tool the key was to allow a tool (and its page) to be suppressed for students if it was a link to a campus-wide grading system.  In this example the tool registration does not specify which function was required to include the tool in the buttons on the left hand side of the Sakai display.  For the link tool, often a function like site.upd was used as an indicator of highly powered users - any function will do - it does not have to be a function for the tool itself.  Another possible function might be content.new if this function were only given to instructor or maintain roles.

Here is an example of the use of this in the resources tool registration:

<registration>
	<tool
			id="sakai.resources"
			title="Resources"
			description="For posting documents, URLs to other websites, etc.">

		<configuration name="home" value="" />
		<configuration name="optional_properties" value="true" />
		<configuration name="user_sees_all_their_sites" value="true" />
		<configuration name="collections_per_page" value="50" />
		
		<configuration name="resources_mode" value="resources" type="final" />

		<category name="course" />
		<category name="project" />
		<category name="portfolio" />
		<category name="myworkspace" />

		<configuration name="functions.require" value="content.read" /> 
	</tool>
</registration>

The full file is here:

https://source.sakaiproject.org/svn/content/trunk/content-tool/tool/src/webapp/tools/sakai.resources.xml

So after all that - the quick summary is that if you want to hide a tool except for Site Owners, add a line like

		<configuration name="functions.require" value="site.upd" /> 

To your tool registration.

A nice thing is that all this functions.require sets is the default value - it can be overridden by tech support on a a case by case basis once the tool is placed in a site.  I think that the Page Order tool also changes this property on a tool placement as well - so if you enable page order, I think that even the instructor can fiddle with this setting on a case by case basis.

/Chuck Posted by csev at March 13, 2008 07:32 AM