SimpleDesk

SimpleDesk! => SimpleDesk Support => Topic started by: clarinet on February 15, 2013, 11:50:24 AM

Title: Membership in multiple departments
Post by: clarinet on February 15, 2013, 11:50:24 AM
Perhaps I am misinterpreting the Department philosophy, but I can't get it working as I would like to. I have three departments A, B, and C, and three groups GroupA, GroupB, and GroupC. Also, I have three roles: GroupA is assigned RoleA in department A, GroupB is assigned RoleB in department B, etc. (I tried to attach images/screenshots, but the server did not allow me to do so).

Now, when a user is member of two groups, GroupA and GroupB, I would expect this user should be able to submit tickets to both departments A and B. However, this user does not have an option to select or change department and his/her tickets are automatically submited to B. How can I enable this user to select proper department for the ticket? Or what is it that I miss? Thank you.
Title: Re: Membership in multiple departments
Post by: venguard223 on February 15, 2013, 12:40:08 PM
The user isn't staff in one department and a user in another?

Also, check the URL in question when they're submitting. If they're in a department (i.e. there's a dept= in the URL), it will assume that's the department they're submitting to.

There are a great many flaws in the structure of departments. It's pretty much broken but the original developer can't be bothered to fix it since his preferred solution is a complete ground up rewrite.
Title: Re: Membership in multiple departments
Post by: clarinet on February 18, 2013, 07:02:12 AM
The user has equal roles in all departments. All three roles (RoleA, RoleB, RoleC) are simple derivatives of the same role template "Helpdesk Users".

I checked the URL, but it contains nothing more than "index.php".

According to your explanation it seems that I will have to give it up ...  :-(

Edited 5pm local time:

After many tests I now see how it works. The system just does not assign the user the union of all roles based on all this user's group memberships,  but just a single role that corresponds to the first (or last, I am not sure) group this user is a member of.

So if I want a user to be assigned to two departments A and B, the only way is to:

a) create group GroupAB and make this user member of this group
b) make sure this user is not a member of GroupA, GroupB or GroupC or any other group that has defined a role in any department
c) create a role RoleAB that assigns members of GroupAB to departments A and B

It is not as elegant as one can imagine, but as I only need several combinations, I guess I can live with it. I think it should not be very hard to repair, but if the author prefers complete rewrite, I can understand it.


Title: Re: Membership in multiple departments
Post by: venguard223 on February 18, 2013, 06:28:39 PM
QuoteThe system just does not assign the user the union of all roles based on all this user's group memberships

It's supposed to be the union of all roles based on the membergroups the user is in.

QuoteI think it should not be very hard to repair, but if the author prefers complete rewrite, I can understand it.

Trust me, it is. A rewrite is by far the best solution.
Title: Re: Membership in multiple departments
Post by: clarinet on February 19, 2013, 04:56:13 AM
Quote from: venguard223 on February 18, 2013, 06:28:39 PM
QuoteThe system just does not assign the user the union of all roles based on all this user's group memberships

It's supposed to be the union of all roles based on the membergroups the user is in.

Yes, I understand, this is what I expected. However, unless I keep repeating some stupid mistake, in reality it does work like this. The user is assigned just one role based on the first membergroup the user is in.

Quote from: venguard223 on February 18, 2013, 06:28:39 PM
QuoteI think it should not be very hard to repair, but if the author prefers complete rewrite, I can understand it.

Trust me, it is. A rewrite is by far the best solution.

I trust you, of course. I can imagine the code is extremely complicated as the relationships among objects and attributes are complex. As I found a workaround for my problem, it is solved for the moment and I will look forward to the rewritten version (if there are plans to release any).

In any case thanks to all authors, despite some small details it is an excellent job.
Title: Re: Membership in multiple departments
Post by: venguard223 on February 19, 2013, 02:19:15 PM
QuoteThe user is assigned just one role based on the first membergroup the user is in.

There is certainly a bug attached to it, yes.

QuoteAs I found a workaround for my problem, it is solved for the moment and I will look forward to the rewritten version (if there are plans to release any).

The original author will never release a patched version for SMF, I can tell you that. He does not develop for SMF any longer, only for a rival forum software. Given how long this bug has been around and how no effort has apparently been made to fix it by the current devs, it seems unlikely SimpleDesk itself will ever be fixed.
Title: Re: Membership in multiple departments
Post by: clarinet on March 04, 2013, 08:42:29 AM
Well, I could not help myself ... it was not that hard. Edit file ./Sources/sd_source/Subs-SimpleDeskPermissions.php, replace line 364


$user_info['shd_permissions'][$perm] = $depts[$role];


with


if(is_array($user_info['shd_permissions'][$perm]))
$user_info['shd_permissions'][$perm] = array_merge($user_info['shd_permissions'][$perm],$depts[$role]);
else
$user_info['shd_permissions'][$perm] = $depts[$role];


I hope it's all that needs to be done. If you ever happen to see the original developer, please tell him. :-)
Title: Re: Membership in multiple departments
Post by: venguard223 on March 04, 2013, 01:30:19 PM
I AM the original developer. ;) I won't be releasing SMF releases (I long since ported the bulk of it to Wedge)

And yes, at a glance that looks pretty good, especially since the entirety of access is also dependent on those permissions.

I'll patch it (slightly differently, but doing the same thing), and submit a pull request for the team to integrate it. But I'm still waiting for them to revert a change from 2011 that I specifically told them not to make in the first place. (The comment in the line before actually indicates why it should not be done!) so let's just say I wouldn't be hopeful.


EDIT: Sent a pull request, thank you for your help on this one, it's been a bug for years but I long since lost the interest in actually tracking it down.
Title: Re: Membership in multiple departments
Post by: clarinet on March 05, 2013, 05:34:13 AM
Thank you for comments. I think will have a look at Wedge too, but now I already run SMF/SimpleDesk so it would not be easy to migrate.

EDIT: Looks like I will not have a look at Wedge at the moment - it seems it was not released yet.
Title: Re: Membership in multiple departments
Post by: venguard223 on March 05, 2013, 01:40:43 PM
That would be because it is still under heavy development, including by me... ;)

ETA: The changes in Wedge are substantial, though, and I'm not sure how reliable a port would be at this stage simply because I'm doing more than just porting it. It's heading towards rewrite territory.
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on June 27, 2013, 05:53:04 PM
Quote from: clarinet on March 04, 2013, 08:42:29 AM
Well, I could not help myself ... it was not that hard. Edit file ./Sources/sd_source/Subs-SimpleDeskPermissions.php, replace line 364


$user_info['shd_permissions'][$perm] = $depts[$role];


with


if(is_array($user_info['shd_permissions'][$perm]))
$user_info['shd_permissions'][$perm] = array_merge($user_info['shd_permissions'][$perm],$depts[$role]);
else
$user_info['shd_permissions'][$perm] = $depts[$role];


...


This line raises undefined index errors below for any external pages that is not entirely integrated with SMF.


Notice: Undefined index: access_helpdesk in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ticket_private_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_closed_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_new_ticket in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_edit_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_reply_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_edit_reply_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_attachment in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_post_attachment in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_resolve_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_unresolve_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ticket_logs_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_profile_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_profile_log_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_preferences_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_relationships in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_delete_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_delete_reply_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_staff in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ticket_private_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_closed_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ip_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_edit_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_reply_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_edit_reply_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_post_proxy in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_monitor_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_singleton_email in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_ignore_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_silent_update in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_resolve_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_unresolve_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_ticket_logs_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_alter_urgency_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_alter_privacy_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_assign_ticket_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_profile_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_view_profile_log_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_create_relationships in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_delete_relationships in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_access_recyclebin in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_delete_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_delete_reply_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_restore_ticket_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_restore_reply_any in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_ticket_to_topic in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_topic_to_ticket in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Notice: Undefined index: shd_move_dept_own in /home/etheriac/public_html/Sources/sd_source/Subs-SimpleDeskPermissions.php on line 364

Is there something I can do to fix this problem?
Title: Re: Membership in multiple departments
Post by: venguard223 on June 28, 2013, 02:37:52 AM
Define 'not entirely integrated'.
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on June 29, 2013, 05:22:54 AM
"Not entirely integrated" meant that SMF encapsulates the external page to be a part of it although it isn't really a part of it. SMF just load up an external page while the external page loads up nothing related to SMF.
Title: Re: Membership in multiple departments
Post by: venguard223 on June 29, 2013, 03:39:49 PM
That wasn't what I really wanted to know. If you'd like help on fixing this, you do sort of need to provide details of what you've done so I can try to figure out how to change it for you.
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on June 29, 2013, 05:16:49 PM
In order to encapsulate an external page (e.g. http://ethera.servehttp.com/Coppermine/), I used the following codes as a theme template page, which will be called by SMF:


<?php
// Version: 1.1 RC2; Gallery

function template_main()
{
global $context$settings$options$txt$scripturl;

echo '
<script language="JavaScript" type="text/javascript"><!--
function checkAll(onOff)
{
for (var i = 0; i < document.searchform.elements.length; i++)
{
if (document.searchform.elements[i].name.substr(0, 3) == "brd")
document.searchform.elements[i].checked = onOff;
}
}
// --></script>
<form action="'
$scripturl'?action=search2" method="post" name="searchform" id="searchform">

 <script type="text/javascript"><!--

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don\'t support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

// --></script>

<table width="100%" border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
<tr>
<td class="windowbg">'
;

// load the gallery
echo '<iframe id="myframe" src="http://ethera.servehttp.com/Coppermine/" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:novisible; width:100%; display:none"></iframe>';

echo '
</td>
</tr>
</table>
</form>'
;
}

?>



I included the following line somewhere in the external page to load up some variables.


...
include_once($_SERVER['DOCUMENT_ROOT'].'/SSI.php');
...


While this setup gives me no error as an administrator, when using as other users, the notices appear.
Title: Re: Membership in multiple departments
Post by: venguard223 on June 30, 2013, 12:46:16 AM
You should really have the SSI include right up front. That should be taking care of all the inclusion of SD permissions.

Though if it's a template_main function why are you loading SSI.php exactly? That sort of implies you're doing it through an index.php?action=page type function...

Is it the Coppermine stuff itself throwing it or is it definitely the main page load?
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on June 30, 2013, 03:53:06 AM
Well, I am not very familiar with SMF modding. I just know that I need to have a SSI include for the following line:


$context['user']['username']


Even though it is preferable to have the include right up front, it doesn't work in a template_main function style.

Furthermore, completely integrating the external pages via index.php?action=page type function requires a lot of modification that is way beyond my current capability.

I don't know how Coppermine is integrated with SMF and whether or not it has the SSI include inside, but it works flawlessly with SMF with absolutely no error. But using the same technique for a different module, which I manually made some code modifications on it, causes notices to appear.
Title: Re: Membership in multiple departments
Post by: venguard223 on July 01, 2013, 02:30:57 AM
So you have a module that you haven't explained, with some changes you haven't explained and sadly I can't help you with that because I'm not a mind reader.

I have absolutely no idea how you've managed to integrate the two because it's using a mash-up of two totally different SMF systems.

I'm sorry, I can't help you with this. Trouble is... I doubt anyone else will be able to either. :(
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on July 02, 2013, 04:50:38 AM
Well, the module I used is nothing special. It is just a standalone catalog module. I only modified it to better suit my needs since it doesn't have an user system at all. It can basically work on its own without SMF, but I want to allow only certain SMF users to be able to access it and request and borrow items from the catalog system, so throughout the module, I need to use following variable as I mentioned earlier from SMF to verify if the user can request the items and check if the user has requested and borrowed what items:


$context['user']['username']


I basically use a separate database to handle all requests and borrows of the users as well as the details of each items in the catalog. To make it seem to be a part of SMF when it is not, I encapsulate it the same way I did with Coppermine.

So don't give me too much credits of what I am capable of. I am still trying to learn the work of these complicated systems.

These notices also occur for another standalone game engine module called miniNEAB when I use the same variable $context['user']['username'] as username for the game instead of a separate unrelated username. The start game page is loaded in one of the PortaMx script blocks in the manner specified below:


<iframe src="http://ethera.servehttp.com/game/game_load.php" height="200" width="100%" frameborder="0"></iframe>


The notices appear right before the start button.

Even though both modules are handled differently, the only commonality is that I used the SSI include and I use variable $context['user']; thus, I strongly believe that the line 364 changes must be loaded whenever I used the SSI include, because the notices don't appear after but before I use the variable.
Title: Re: Membership in multiple departments
Post by: venguard223 on July 02, 2013, 07:35:37 AM
It's not about giving credit, it's the fact you have one system that manages to ignore both of the standard, accepted and proven-to-work-with-SimpleDesk to integrate something.

Consider it this way: if it works without error when inside SMF but not outside, that would tend to suggest it's not actually SD that's at fault, nor the code changes mentioned above, but with however the bridge to outside is managed.
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on July 02, 2013, 03:24:22 PM
Oh, I see. Do you have a guide that I can follow to properly handle the bridge then? All I need to access in the external module is the variable $context['user']. I need to know what kind of standard step apart from having a SSI include and the usage of that variable itself I am missing in those modules.
Title: Re: Membership in multiple departments
Post by: venguard223 on July 02, 2013, 11:05:02 PM
I haven't got a guide, sorry.

The standard setup would be to either create a new action, or to start with SSI.php before *anything* else, but your integration is something new and short of examining the code myself, there's not a lot I can do. Unfortunately I have neither the time or inclination to take on such a job right now, sorry.
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on July 03, 2013, 05:48:06 PM
It seems that you are incorrect about the notices. I created a simple PHP file with the code below and placed it in Coppermine directory:


<?php
require_once('../SSI.php');
?>



Just this code causes the notices to appear and the SSI include alone is causing the problems; thus, your earlier observation is invalid. I did a search of all the files in Coppermine directory. It doesn't even once bring up the SSI include. It must be using a different method to integrate with SMF apart from using SSI include, which explain why the notices didn't appear for Coppermine.

Thus, the code change for line 364 is raising the issue. Again, the notices seem to appear for all registered users except the administrator.
Title: Re: Membership in multiple departments
Post by: venguard223 on July 03, 2013, 08:50:39 PM
I still can't reproduce it but there is no harm in changing the suggested patch to:

if (isset($user_info['shd_permissions'][$perm]) && is_array($user_info['shd_permissions'][$perm]))
$user_info['shd_permissions'][$perm] = array_merge($user_info['shd_permissions'][$perm], $depts[$role]);
else
$user_info['shd_permissions'][$perm] = $depts[$role];


But it's been over two years since I wrote the code originally, I don't remember how most of it works any more. (Yes, I am SD's original developer.)
Title: Re: Membership in multiple departments
Post by: Ice_Drake1 on July 03, 2013, 09:38:04 PM
That did the trick. Thanks.  ;)
Title: Re: Membership in multiple departments
Post by: Flavio93Zena on December 07, 2014, 10:49:56 PM
Quote from: venguard223 on July 03, 2013, 08:50:39 PM
I still can't reproduce it but there is no harm in changing the suggested patch to:

if (isset($user_info['shd_permissions'][$perm]) && is_array($user_info['shd_permissions'][$perm]))
$user_info['shd_permissions'][$perm] = array_merge($user_info['shd_permissions'][$perm], $depts[$role]);
else
$user_info['shd_permissions'][$perm] = $depts[$role];


But it's been over two years since I wrote the code originally, I don't remember how most of it works any more. (Yes, I am SD's original developer.)
YAY :D had the same problem here, put that into the original code and I became really happy when I saw the results :D thanks even if very late, just thanks!