Help with code: usernotinme list


  • Developer

    Hi,
    This question is for the developers.

    I am trying to make some changes in the AccessControl Plugin, the problem with this plugin is that only can assign users that are local (uType = 0 or uType = 1) because the users that LDAP plugin creates are uType = 990 or 991, and those ones don’t appear in the list.

    I want to know who or where the code decides not shows the uType 990 or 991 users

    accesscontrolmanagementpage.class.php

    Route::listem('user');
            $items = json_decode(
                Route::getData()
            );
            $items = $items->users;
            $getter = 'usersnotinme';
            $returnData = function(&$item) use (&$getter) {
                $this->obj->get($getter);
                if (!in_array($item->id, (array)$this->obj->get($getter))) {
                    return;
                }
                $this->data[] = array(
                    'user_id' => $item->id,
                    'user_name' => $item->name,
                    'friendly' => $item->display
                );
            };
            array_walk($items, $returnData);
    

  • Senior Developer

    Unless, of course, you’re trying to make it core usable? But the only time this would be viable would be if LDAP plugin is in use. Of course other plugins may want to make adjustments here as well. I need to think on this a little bit.


  • Senior Developer

    @Fernando-Gietz While I understand and respect that your spanish, might I ask you to use english for the description? We can add gettext to the description fields (which I think is already done). The only other part I might suggest, then, is putting the category as “Plugin: LDAP”. Just makes finding it and knowing what it’s impacting much simpler.


  • Developer

    In the hook file:

        public function setTypeFilter($arguments)
        {
    //        $arguments['types'] = array(990,991);
            $arguments['types'] = explode(',', self::getSetting('FOG_USER_FILTER'));
        }
    

  • Developer

    Hi Tom,

    I was thinking that, maybe, is better create a new globalStting when you install the plugin, in this way, you can setup it dinamically.

    insert into globalSettings (settingKey,settingDesc,settingValue,settingCategory) VALUES ('FOG_USER_FILTER','Esto es una prueba de configuración', '990,991','General Settings');
    

    The insert will be done by the plugin, this is an example.

    And the hook can read this filter info to show the users.


  • Senior Developer

    What I might recommend is polling for the information directly.

    Rather than worrying about the “show/no show” of the users for the “usersnotinme” instead filter out the information in a more direct fashion. For example:

    Route::listem('user');
    $items = json_decode(Route::getData());
    $items = $items->users;
    $displayTypes = ['0','1','990','991'];
    $returnData = function(&$item) use (&$displayTypes) {
        if (!in_array($item->type, $displayTypes)) {
            return;
        }
        $this->data[] = [
            'user_id' => $item->id,
            'user_name' => $item->name,
            'friendly' => $item->display
        ];
    };
    array_walk($items, $returnData);
    

    I understand wanting to use the supplied users, usersnotinme access points, but at the same time this should be controlled a bit more heavily I think.

    The idea for removing LDAP from the list of normal users on the users management side is because LDAP users should not be configured like regular users from that page. This is why the hook and removal exists in the first place. For example, changing a password from FOG will not change the password from LDAP, and may confuse a user who used this element to reset their password.


  • Developer

    @Sebastian-Roth thanks for the info. I will see what do now :)


  • Developer

    @Fernando-Gietz Edit /var/www/html/fog/lib/plugins/ldap/hooks/ldappluginhook.hook.php, jump to line 175 and comment the single line in the setTypeFilter function, so it looks like this:

        public function setTypeFilter($arguments)
        {
    //        $arguments['types'] = array(990, 991);
        }
    

    Be aware this might result in unexpected behavior in other parts!


 

480
Online

5.4k
Users

12.6k
Topics

118.9k
Posts