Created
March 17, 2016 19:12
-
-
Save lianglee/cef412a6e7048a97b805 to your computer and use it in GitHub Desktop.
Get user groups that he is member of (not his own groups)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$id = 2; | |
$groups = new OssnGroup; | |
$joined = ossn_get_relationships(array( | |
'to' => $id, | |
'type' => 'group:join:approve' | |
)); | |
$myown = $groups->searchObject(array( | |
'type' => 'user', | |
'subtype' => 'ossngroup', | |
'owner_guid' => $id | |
)); | |
if($myown) { | |
foreach($myown as $mitem) { | |
$mowngroups[] = $mitem->guid; | |
} | |
} | |
if($joined) { | |
foreach($joined as $item) { | |
if(!in_array($item->relation_from, $mowngroups)) { | |
$ids[] = $item->relation_from; | |
} | |
} | |
$joinedids = implode(',', $ids); | |
$groups_memberof = $groups->searchObject(array( | |
'type' => 'user', | |
'subtype' => 'ossngroup', | |
'wheres' => "o.guid IN ('$joinedids')" | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment