Edit the Document Library Block

Permalink
I have successfully been able to edit the Document Library Block

So the … File Folder
Path is NO Longer a… Pull down selection
The File Folder path is filled in using… UserName and UserGroup
I have setup each User to be in ONLY ONE Group

Defined by the… Logged in User - using the UserName
username1 - is in ONLY ONE Group = group1
So… What I did first was
Manually enter the path for the File Folder
/group1/username1
This works great

I was able to set it up to load - username1
What I am having trouble with is
Getting the logged in - username1
To load the 'gName' of the logged in users group - group1

~~~~~~~~~~~~~~~~~~~~~~~~~

`Users` (`uID`,
(1,
(2,

`UserGroups` (`uID`, `gID`
(1, 5, '2020-06-09 01:53:55'),
(2, 5, '2020-06-07 19:28:25');

`Groups` (`gID`, `gName`,
gID = 5
gName = group1

~~~~~~~~~~~~~~~~~~~~~~~~~
The code listed below - works - manually entering in… 5
I need for the code to auto load - 5
Also… it displays as a pull down showing = group1
As the ONLY select
I need to just echo or print = group1

<?php
$db = Loader::db();
$query = "SELECT gName FROM Groups where gID='5'";
$result = $db->Execute($query);
?>
<select name="group">
<option value=""></option>
<?php
while($row=$result->fetchRow()) {
$gID = $row['gID'];
$gName = $row['gName'];
?>

<option value="<?php echo $gName?>"><?php echo $gName?></option><?php
}
?>
</select>


Can anyone… Please HELP…???

nightlog
 
hutman replied on at Permalink Reply
hutman
Just to clarify, are you trying to get the group(s) for the currently logged in user? If so, you can do this.

<?php
$u = new \Concrete\Core\User\User();
$groups = $u->getUserGroupObjects();
if(count($groups)) {
    foreach($groups as $group) {
        $gID = $group->getGroupID();
        $gName = $group->getGroupName();
    }
}
nightlog replied on at Permalink Best Answer Reply
nightlog
Thank You… For responding…!!!
It works... Great
At the end - to test it - I added...

echo $gName;