Before today it was not possible to give permissions to a category ONLY to a group of users or individual user. But I've developed a hack to achieve this.
Before hacking the code, in the backend do the following:
components - docman - themes - default - empty categories - hide.
Then follow these steps:
1. At administrator/components/com_docman/classes/DOCMAN_utils.class.php add this function
Code: Select all
function categoryArray2()
{
static $array;
if(!isset($array))
{
global $_DMUSER;
$database = JFactory::getDBO();
$groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
$my = JFactory::getUser();
$myid = $my->id;
// get a list of the menu items
$query = "SELECT c.*, c.parent_id AS parent"
. "\n FROM #__docman_categories c"
. "\n WHERE section='com_docman'"
. "\n AND dmowner = '".$my->id."' OR dmowner IN(select (-g.groups_id-10) as id from #__docman_groups as g where groups_members = '".$my->id."' OR groups_members like '".$my->id.",%' OR groups_members like '%,".$my->id.",%' OR groups_members like '%,".$my->id."')"
// TODO gid stuff
. "\n AND published AND access IN ($groups)"
. "\n AND published"
. "\n ORDER BY ordering" ;
$database->setQuery($query);
$items = $database->loadObjectList();
// establish the hierarchy of the menu
$children = array();
// first pass - collect children
foreach ($items as $v) {
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
// second pass - get an indent list of the items
$array = DOCMAN_Utils::mosTreeRecurse(0, '', array(), $children);
// making sure it's an empty array if there were no results
// looks silly huh?
$array = is_array($array) ? $array : array();
}
return $array;
}
Code: Select all
function categoryList2($id, $action, $options = array())
{
global $_DOCMAN;
require_once($_DOCMAN->getPath('classes', 'utils'));
$list = DOCMAN_utils::categoryArray2();
// assemble menu items to the array
foreach ($list as $item) {
$options[] = JHTML::_('select.option', $item->id, $item->treename);
}
$parent = JHTML::_('select.genericlist', $options, 'catid', array(
'list.attr' => 'id="catid" class="inputbox" size="1" onchange="' . $action . '"',
'option.key' => 'value',
'option.value' => 'text',
'list.select' => $id,
'option.text.toHtml' => false
));
return $parent;
}
At components/com_docman/includes/documents replace line 168
Code: Select all
$lists['catid'] = dmHTML::categoryList2($doc->catid, "", $options);
Code: Select all
$lists['catid'] = dmHTML::categoryList2($catid, "", $options);
At administrator/components/com_docman/includes/categories.html.php add these lines at the beginning of line 207
Code: Select all
<tr>
<td class="key">
<label class="hasTip" title="<?php echo _DML_OWNER.'::'._DML_OWNER_TOOLTIP ?>"><?php echo _DML_OWNER;?>:<span class="star"> *</span></label>
</td>
<td>
<?php
echo $lists['viewer'];
?>
</td>
</tr>
At administrator/components/com_docman/includes/categories.php add these lines at the beginning of line 187
Code: Select all
// build the list of viewers
$lists['viewer'] = dmHTML::viewerList($row, 'dmowner');
Code: Select all
select option.label {
background-color: #EEEEEE;
border: 1px solid #DDDDDD;
color: #333333;
}