I know that this thread is kinda old but afaik this is still an issue for some. At least it was that for me, I made a site were many different users, resellers in this case need to edit their own part of the site without any insight in the other resellers sites. Including the Site Content and Files & Images.
The solution presented earlier in this thread works great for the Site content view, but I had to take it one step further in order to prevent the resellers from viewing each others uploaded files.
Based on the earlier solutions I made a little more general solution that have worked really good for me so far. Including all file browsing i file views etc. It will also solve the ul/li formatting issues.
Only need to edit getChildrenAsUL method in sapphire/core/model/Hierarchy.php
(Changes marked in red)
public function getChildrenAsUL( ... ) {
if($limitToMarked && $rootCall) {
$this->markingFinished();
}
if($this->owner->hasMethod($childrenMethod)) {
$children = $this->owner->$childrenMethod($extraArg);
} else {
user_error(sprintf("Can't find the method '%s' on class '%s' for getting tree children",
$childrenMethod, get_class($this->owner)), E_USER_ERROR);
}
if($children) {
if($attributes) {
$attributes = " $attributes";
}
$anyChildEditable = false;
foreach($children as $child)
{
if ( Object::has_extension((string)Extension::get_classname_without_arguments($child),'ResellerEditRights') ? $child->canEditCMS() : $child->canEdit() ) {
$anyChildEditable = true;
break;
}
}
$output = "";
if ( $anyChildEditable )
$output = "<ul$attributes>\n";
foreach($children as $child) {
if ( strstr($titleEval, 'Object::has_extension') === FALSE )
{
$titleEval = '( (Object::has_extension((string)Extension::get_classname_without_arguments($child),"ResellerEditRights") ? $child->canEditCMS() : $child->canEdit()) ?' .
$titleEval .
':"")';
}
if(!$limitToMarked || $child->isMarked()) {
$foundAChild = true;
$output .= eval("return $titleEval;") . "\n";
$childOutput = $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod, false);
if ( strlen($childOutput) > 0 )
$output .= $childOutput . "</li>\n";
}
}
if ( $anyChildEditable )
$output .= "</ul>\n";
}
if(isset($foundAChild) && $foundAChild) {
return $output;
}
Looks a little messy but if you look closely it's not that bad.
For some reason some classes didn't allowed me to override the canEdit() function. I solved this by first checking if the ResellerEditRights is present and then use the custom method canEditCMS() instead.
Hope it helps to solve any issues you have, or to make a better solution (maybe more stable :) not to sure about this one yet)