aBrookland wrote:
Hi,
I've been struggling to set up a system where I can have several private catgeories for different groups of users who can have front end editing access.
<snip>
So now I have a bit more control than I had this morning and I hope that what I've found out and modified will help improve noix - however my quest is not yet at an end because what I realy want is to give front end edit ability to "user1" only for "cat1" and not any other sections or categories in the site for which I need the noix content adapter front end permissions to work. I'm going to spend the rest of my afternoon seeing if I can figure it out and I'll post back any answers I get.
Cheers,
Alan.
So I've finally managed it and I now have groups of users who can only front end edit their particular category

unfortunately it did require a mod to one line of a core file
Here's what I've done if anyone wants the same functionality. First you'll need to set up everything as described in my
earlier post.
Next the dirty core hack

in
components/com_content/helpers/icon.php in
function create() I changed
Code:
$url = 'index.php?task=new&ret='.base64_encode($ret).'&id=0§ionid='.$article->sectionid;
to
Code:
$url = 'index.php?task=new&ret='.base64_encode($ret).'&id=0§ionid='.$article->sectionid .'&categoryid='.$article->id;
(btw if anyone knows how to override the icon.php file instead of hacking it please let me know as I couldn't figure it (I don't think it's possible). Also I called the var caetgoryid instead of the usual catid because otherwise it caused an error in com_content/router.php and I didn't want to hack that file as well if I could help it.
Next in
plugins/system/noixacl.php just before
Code:
//geting rules from multigroups
// $acl_sql = "SELECT aco_section,aco_value,aro_section,aro_value,axo_section,axo_value FROM #__noixacl_rules WHERE ACO_VALUE<>'BLOCK' AND aro_section = 'users' AND aro_value IN ('". implode("','",$arrMultiGroups) ."')";
$acl_sql = "SELECT aco_section,aco_value,aro_section,aro_value,axo_section,axo_value FROM #__noixacl_rules WHERE aro_section = 'users' AND aro_value IN ('". implode("','",$arrMultiGroups) ."')";
$db->setQuery( $acl_sql );
$rulles = $db->loadObjectList();
I added
Code:
if($option = 'com_content') {
$catid = 0;
$view = JRequest::getCMD('view');
$task = JRequest::getCMD('task');
switch($view) {
case 'category':
$catid = JRequest::getVar( 'id', 0 );
break;
case 'article':
switch($task) {
case 'new':
// Need core hack to components/com_content/helpers/icon.php
$catid = JRequest::getVar( 'categoryid', 0 );
break;
case 'save':
$catid = JRequest::getVar( 'catid', 0 );
break;
default:
$id = (int) JRequest::getVar( 'id', 0 );
$sql = 'SELECT catid FROM #__content WHERE id='. $id;
$db->setQuery( $sql );
$catid = $db->loadResult();
}
}
}
Which gets the current category id if applicable.
Then in the same file I modified
Code:
if( count($rulles) > 0 ){
/**
* Adding a rule to joomlaACL
*/
foreach($rulles as $r){
$acl->addACL( $r->aco_section, $r->aco_value, $r->aro_section, $user->usertype, $r->axo_section, $r->axo_value );
}
}
to
Code:
if( count($rulles) > 0 ){
/**
* Adding a rule to joomlaACL
*/
foreach($rulles as $r){
if($option == 'com_content' && $r->aco_value == 'edit' && $r->aco_section == 'com_content' && $r->axo_value == $catid) {
$acl->addACL( 'com_content', 'edit', $r->aro_section, $user->usertype, 'content', 'all' );
$acl->addACL( 'com_content', 'add', $r->aro_section, $user->usertype, 'content', 'all' );
$acl->addACL( 'com_content', 'publish', $r->aro_section, $user->usertype, 'content', 'all' );
}
$acl->addACL( $r->aco_section, $r->aco_value, $r->aro_section, $user->usertype, $r->axo_section, $r->axo_value );
}
}
Which checks if the front end edit permission has been set for the current category and if so sets the correct permissions in the core ACL to allow front end editing. Note - these permissions are for front end editing of all content but since they are set on each page load they will only affect the given category (which is one nice side effect of the permissions being set programatically and not saved in the database

)
I think that the code I've added to noixacl.php here should be refactor into the noixACL adapter plugin system so that each adapter can modify the core ACL rules as needed to enable fine grained permission setting in the same manner - also noixacl.php just insn't the right place for content specific code

Finally I made a template override for com_content/views/article/tmpl/form.php where I added
Code:
$special_group_user = in_array($this->user->usertype, array('group1', 'group2'));
so I could use the $special_group_user var to control whether to show the publishing options or not by wrapping each element div like so
Code:
<?php
if($special_group_user) {
?>
<input type="hidden" value="1" name="access" />
<?php
} else {
?>
<div class="formelement access">
<label for="access"><span><?php echo JText::_( 'Access Level' ); ?>:</span><?php echo $this->lists['access']; ?></label>
</div>
<?php
}
?>
In this example we're hiding the access level setting for the special users and setting the articles access level to registered with a hidden input field. I do the same to remove the section and category choices and set them to the correct current section and category and I also remove the front page option.
So now I have my holy grail - special users who have front end edit access limited to a specific category based on the usergroup and they also have limited publishing options on the front end article editor controllable by me (admittedly by modifying the template) so they can't create articles not within their category or change the access level from registered.