public static function grant($userId = null, $role = null, $action = null, $objectType = '*', $objectId = 0)
    {
        global $PPHP;
        $db = $PPHP['db'];
        $success = false;

        if ($objectId === '') {
            $objectId = 0;
        };
        if ($userId !== null  &&  $role !== null) {
            $success = $db->insert(
                'users_roles',
                array(
                    'userId' => $userId,
                    'role'   => $role
                )
            );
        } elseif ($userId !== null  &&  $action !== null) {
            $success = $db->insert(
                'acl_users',
                array(
                    'userId'     => $userId,
                    'action'     => $action,
                    'objectType' => $objectType,
                    'objectId'   => $objectId
                )
            );
        } elseif ($role !== null  &&  $action !== null) {
            $success = $db->insert(
                'acl_roles',
                array(
                    'role'       => $role,
                    'action'     => $action,
                    'objectType' => $objectType,
                    'objectId'   => $objectId
                )
            );
        };

        if (($userId !== null
            && (isset($_SESSION['user']) && $_SESSION['user']['id'] == $userId))
            || ($userId === null && $role !== null && self::hasRole($role))
        ) {
            self::reload();
        };

        return $success;
    }