DocMan: categories and groups of users

This forum is for general questions about extensions for Joomla! 2.5.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
psantamaria
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 208
Joined: Tue Aug 26, 2008 8:14 pm
Location: Brisbane, Australia
Contact:

DocMan: categories and groups of users

Post by psantamaria » Tue Oct 18, 2011 1:49 am

I'm using DocMan 1.6.1 and Joomla 1.7.1 I need to use DocMan in a way where users cannot view, enter, search, or anything in other categories except where they have permissions.

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;
    }
2. At administrator/components/com_docman/classes/DOCMAN_html.class.php add this function

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);
And line 170

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">&nbsp;*</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');
Finally add the following styles to your main css of your template in the backend.

Code: Select all

select option.label {
    background-color: #EEEEEE;
    border: 1px solid #DDDDDD;
    color: #333333;
}

User avatar
psantamaria
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 208
Joined: Tue Aug 26, 2008 8:14 pm
Location: Brisbane, Australia
Contact:

Re: DocMan: categories and groups of users

Post by psantamaria » Tue Oct 18, 2011 1:58 am

Ups, I forgot something very important

Add a new column called dmowner in the table #__docman_categories. type int.

User avatar
silvarocha1
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Wed Mar 30, 2011 2:14 pm

Re: DocMan: categories and groups of users

Post by silvarocha1 » Mon Oct 31, 2011 6:02 pm

Good afternoon, and I'm using J1.7 V1.6.1 DOCman, with this help can only assign categories to a user. This user can only see your category and their respective files. Is it possible?

User avatar
silvarocha1
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Wed Mar 30, 2011 2:14 pm

Re: DocMan: categories and groups of users

Post by silvarocha1 » Tue Nov 01, 2011 12:57 pm

Hi Congratulations on these changes, but I noticed that when you add new document, the list of categories is empty now. Do not include allowing a new document.
Because it was not possible to test the changes made.

User avatar
psantamaria
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 208
Joined: Tue Aug 26, 2008 8:14 pm
Location: Brisbane, Australia
Contact:

Re: DocMan: categories and groups of users

Post by psantamaria » Tue Nov 01, 2011 3:12 pm

I can add documents.
You just need to add the category and the user to the same group.
When creating documents, users can only see categories which are in the same group.

User avatar
silvarocha1
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Wed Mar 30, 2011 2:14 pm

Re: DocMan: categories and groups of users

Post by silvarocha1 » Thu Nov 03, 2011 3:29 am

Once again I congratulate the work and initiative.
Solved my problem very well. Everything worked perfectly.
Thank you

User avatar
silvarocha1
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Wed Mar 30, 2011 2:14 pm

Re: DocMan: categories and groups of users

Post by silvarocha1 » Fri Nov 11, 2011 4:12 pm

Could you help me with another problem?

Customer may not access backend and make the management of user groups in DOCMAN.
Your users only have access to files by category, within their respective groups.

User A accesses only the category it belongs to group A.
Until then td well, could do this in DOCMAN.
But the problem. I need the client to create, edit, delete groups and categories of DOCMAN via frontend.

Does anyone know how? I searched and found no module that does that.
I DOCman in joomla 1.7 and V1.6.1.

thank you

mattewbrand
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Wed Oct 12, 2011 8:45 pm

Re: DocMan: categories and groups of users

Post by mattewbrand » Sun Nov 13, 2011 5:19 pm

Can someone perhaps provide me with a copy of Docman 1.6.1? It's GPL'ed free software. Nothing wrong about sharing it :/

User avatar
stingrey
Joomla! Hero
Joomla! Hero
Posts: 2756
Joined: Mon Aug 15, 2005 4:36 pm
Location: Marikina, Metro Manila, Philippines
Contact:

Re: DocMan: categories and groups of users

Post by stingrey » Fri Dec 09, 2011 10:06 am

Thanks for sharing your hack psantamaria

Can I suggest you also post this in the official joomlatools Hacks and Tips&Tricks forum
http://forum.joomlatools.eu/viewforum.php?f=48

as there maybe others who find your hack useful :)
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me :)
Partner, Business Development & Project Manager, Event Manager, Sports Coach :D

Herrie
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sun Oct 19, 2008 11:57 am

Re: DocMan: categories and groups of users

Post by Herrie » Thu Mar 29, 2012 9:31 am

Although this is an older topic, I have a question concerning this topic.

I use:
- Joomla 1.5 (release 25) [upgrade to 26 soon to come]
- DOCman v1.4.0.stable
next to those, in order to use more groups than the standard ones:
- ArtofUser
- Juga 2.2.1
- CB 1.2.1

Part of my site is dedicated to students. After login the template is changed to the one belonging to their group.
I found some code which does this trick. It simply 'filters' the usergroup of a member and based on that info it shows a template.

I wonder if this could be used in Docman as well.

Here is my code:

Code: Select all

<?php
$acl =& JFactory::getACL();
jimport('joomla.application.component.helper'); // include libraries/application/component/helper.php
$usersParams = & JComponentHelper::getParams('com_users'); // load the Params
// "generate" a new JUser Object
$user = & JFactory::getUser();

$data = array($user); // array for all user settings
$usertype = $usersParams->get($user->id);
$user =& JFactory::getUser(); $usergid = $user->get('gid'); 
//echo "Group ID = " . $usergid . ' ' ; //I know the groupID now
switch ($usergid) {
        //echo 'Groep = '. $usergid . ', Talen';
		$template= 'cur_bedlam';
		$css= 'cur';
        break;
	case 28:
        //echo 'Groep = '. $usergid . ', USERS';
		$template= 'base';
		$css= 'base';
        break;
	case 29:
        //echo 'Groep = ' .$usergid . ', Public Frontend';
		$template= 'base';
		$css = 'base';
        break;
    default: $usergid = 0;
		//echo 'Standaard Groep = '. $usergid. ', Geen groep Id';
		$template= 'base';
		$css = 'base';
		break;
}

// End test (It works!!!!)
// echo "The Template used =  $template || css = $css ";
// IE8 puts everything to the left without the empty echo, 
echo ""
?>
I'm NOT very familiar with php, nor with Joomla coding, but maybe someone else is..

nmwoods1
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Apr 11, 2012 5:28 am

Re: DocMan: categories and groups of users

Post by nmwoods1 » Thu Apr 12, 2012 3:09 am

I went through and applied this hack:

Added the column in database with name dmowner, type int
Changed all the files
In the backend, when i go create a new category or access old categories I can now choose groups from the Viewers list.

However, even though I change the viewer to a particular group, members of the other group can still see the category.

Any ideas?

EDIT: In my database, the dmowner value for my two categories are -12 and -11 , does this sound right?

User avatar
psantamaria
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 208
Joined: Tue Aug 26, 2008 8:14 pm
Location: Brisbane, Australia
Contact:

Re: DocMan: categories and groups of users

Post by psantamaria » Thu Apr 12, 2012 10:02 pm

Hi nmwoods1, which docman version do you have?

nmwoods1
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Apr 11, 2012 5:28 am

Re: DocMan: categories and groups of users

Post by nmwoods1 » Thu Apr 12, 2012 10:47 pm

1.6.4,

I ended up getting a work around going, whereby I ran the permissions on each document according to the group, and then disabled "Show empty categories", so that when certain groups logged in they wouldn't see each others folders because they wouldn't be able to see any of the documents anyway.

User avatar
psantamaria
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 208
Joined: Tue Aug 26, 2008 8:14 pm
Location: Brisbane, Australia
Contact:

Re: DocMan: categories and groups of users

Post by psantamaria » Thu Apr 12, 2012 11:30 pm

Yes, if you check my initial post the first thing I ask to do is:
Before hacking the code, in the backend do the following:
components - docman - themes - default - empty categories - hide.
Initially, I applied the hack to DOCman 1.6.1, but now I have DOCman 1.6.3, and the changes work. (I wasn't sure about 1.6.4)

The problem with this kind of hacks is that whenever you update your DOCman version, you have to apply the hack again. So I wouldn't recommend this solution, unless it is completely necessary and you're willing not to update DOCman.

af_1005
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Apr 25, 2012 12:44 am

Re: DocMan: categories and groups of users

Post by af_1005 » Wed Apr 25, 2012 12:49 am

I know this post has been quiet for awhile but...
I applied this hack. Everything works great except for one exception.

When my users go to submit a new document (step 3 of 3), the permissions tab drop-down called "Viewers" shows all groups that exist in DOCman. The system is setup so that all root Categories equal a Group in DOCman.

Is there a way to only show the Groups that a user belongs to in this dropdown? or am I missing something?


Locked

Return to “Extensions for Joomla! 2.5”