[Sites plugin] Sites shown when adding or editing a host



  • Hi!
    I have installed Fog 1.5.8 with the Sites plugin.
    When an unprivileged user tries to add or edit a host, the site selection box shows all sites, not just the sites of which the user is a part.
    It would be great if only the sites to which the user belongs are displayed.

    I have implemented it by adding the following code to line 262 of the file /var/www/html/fog/lib/plugins/site/hooks/addsitehost.hook.php

    $UserIsRestricted = self::getSubObjectIDs(
        'SiteUserRestriction',
        array('userID' => self::$FOGUser->get('id')),
        'isRestricted'
    )[0];
    if ($UserIsRestricted == 1) {
        $SitesFiltered = array_diff(
            self::getSubObjectIDs(
                'Site',
                '',
                'id'
            ),
            self::getSubObjectIDs(
                'SiteUserAssociation',
                array('userID' => self::$FOGUser->get('id')),
                'siteID'
            )
        );
    } else {
        $SitesFiltered = '';
    }
    

    And modifying lines 284 of the file /var/www/html/fog/lib/plugins/site/hooks/addsitehost.hook.php by:

    $sID,
    '',
    'name',
    $SitesFiltered
    

    Thanks!



  • Hi,
    I’m a new user of FOG and I start to use also this plugin ( I modifying the code like itexido suggested and works fine).

    But I have the following problem or maybe a bad configuration.
    When restricted user creates a host and associated it with a site and when he tried to list the hosts that host is not listed. I need to log in with the administrator profile to re-add the host to the site and after that the host is listed with restricted user
    Thanks


  • Senior Developer

    @iteixido Thanks for your request and as well thanks to @Fernando-Gietz for adding this so quickly. I just merged this into dev-branch.


  • Developer

    Thanks @iteixido ! We will fix the bug as soon as possible


Log in to reply
 

296
Online

7.1k
Users

14.3k
Topics

135.1k
Posts