Home
In Development
The JACL - Customizing Permissions
The JACL - Customizing Permissions
In the Front End, a user can be Public, Registered, Author, Editor, or Publisher. There are a lot of reasons why you might have a site where only one person or one small group is granted any access to the Back End at all. In that instance, with these user permissions, you cannot create a situation where, for example, users can register, fill in forms that store data in your database, and you can log in and view that form data. Since, there's no way to restrict the Back End access to just viewing form data, and since it's not really displayed in any meaningful way back there anyhow (meaningful in a business management sense), you need some way to restrict access to a section to only a small subset of the Front End users.
As always, there is more than one way to skin this cat. First off, you need to decide whether to create a module and then restrict access to it, or whether to build an application elsewhere and run it in a wrapper. You could also use a combination of directPHP and custom content to create your app inside an article and further restrict access to that article to a select group of users. Any way you cut it, you're going to have to start in the database.
This site is solely maintained by a single web-master. All content, layout, and back end access is limited to the web-master and her team. This technique is not very well suited to a site maintained by a group of people.
I'm going to add a table called client_forms_users
--
-- Table structure for table client_forms_users--
CREATE TABLE client_forms_users (
id int(11) NOT NULL auto_increment,
joomla_id int(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I'll insert a row for each user joomla user who should be allowed access to the form data. (If I were making a module, rather than encapsulating functionality in an article, I'd want to make an administrator bit to be able to assign users to this table in the back end. Part of the reasoning behind just using an article is that there is only ever going to be one entry in this table - the site owner.)
I've already installed DirectPHP and Custom Comment extensions. I am going to create one script to check if my joomla user is allowed access to the form data page, and if so, add a menu-looking cutsom content module to his page called "Back Office". This script will be in an article, assigned to an unused menu.
- Create a new article, leave it uncategorized, and call it Back Office. This article will be the php script that displays the forms for the site owner to view. For now just type a word or two and save it, and publish it.
- Create a new menu, call it Restricted Links.
- Put the Back Office article on the Restricted Links menu.
- Enable the module for that menu that you just created.
- Click the link to the new Back Office article, and save the URL to the article somewhere. You'll need this link to create menu items later on.
- Un-publish the Restricted Links menu.
Back to that Back Office article. It's going to check if the current user should have access to the forms, and if so display a link to the forms report page (which we will create later).
<?php
global $mainframe;
$user =& JFactory::getUser();$db =& JFactory::getDBO();
$query = "select * from client_forms_user where joomla_id = " . $user->id;
$db->setQuery($query);
$result = $db->loadObject();
if ($result) { // validated user
return "<ul><li><a href=\"#">Pre-Enrollment Forms</a></li></ul>";
}
?>
We'll replace the # with an actual article link in a bit.
Now we need to make a custom content module which we will use as a menu for the restricted links. Go to Extensions->Module Manager and click the New button. Then, select Custom Content.
Set the Title: Back Office; Set the access level to Registered; Set the Article to the Back Office article you created earlier; Set the Module Class Suffix to _menu.
Now, registered users see a new menu: 
Now, we just need to create a new article, write a script inside it to pull all the Pre-Enrollment forms out of the database and display them in some meaningful way.
Trackback(0)
TrackBack URI for this entryComments (0)
Subscribe to this comment's feedWrite comment

Last Updated (Tuesday, 22 July 2008 12:11)





