Auth samples

Basics

The class openkm\bean\Permission contains permission values ( READ, WRITE, etc. ). You should use it in combination with methods that are changing or getting security grants.

To set READ and WRITE access you should do:

$permission = Permission::READ + Permission::WRITE;

To check if you have permission access you should do:

// permission is a valid integer value
if (($permission | Permission::WRITE) = Permission::WRITE) {
  // Has WRITE grants.
}

On almost methods you'll see parameter named "nodeId". The value of this parameter can be some valid node UUID ( folder, document, mail, record ) or node path.

Example of nodeId:

  • Using UUID -> "96c44de6-1d0d-45fb-b380-4984f46bbeb3";
  • Using path -> "/okm:root/SDK4PHP/sample.pdf"

Methods

getGrantedRoles

Description:

MethodReturn valuesDescription

getGrantedRoles($nodeId)

array

Return the granted roles of a node.

Parameters:

$nodeId string type is the uuid or path of the document, folder, mail or record.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetGrantedRoles() {
        try {
            $grantedRoles = $this->ws->getGrantedRoles('/okm:root/SDK4PHP');
            foreach ($grantedRoles as $role) {
                var_dump($role);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetGrantedRoles();
?>

getGrantedUsers

Description:

MethodReturn valuesDescription

getGrantedUsers($nodeId)

array

Returns the granted users of a node.

Parameters:

$nodeId string type is the uuid or path of the document, folder, mail or record.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetGrantedUsers() {
        try {
            $grantedUsers = $this->ws->getGrantedUsers('/okm:root/SDK4PHP');
            foreach ($grantedUsers as $user) {
                var_dump($user);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetGrantedUsers();
?>

getRoles

Description:

MethodReturn valuesDescription

getRoles()

array

Returns the list of all the roles.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetRoles() {
        try {
            $roles = $this->ws->getRoles();
            foreach ($roles as $role) {
                var_dump($role);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetRoles();
?>

getUsers

Description:

MethodReturn valuesDescription

getUsers()

array

Returns the list of all the users.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetUsers() {
        try {
            $users = $this->ws->getUsers();
            foreach ($users as $user) {
                var_dump($user);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetUsers();
?>

grantRole

Description:

MethodReturn valuesDescription

grantRole($nodeId, $role, $permissions, $recursive)

void

Adds a role grant on a node.

Parameters:

$nodeId string type is the uuid or path of the document, folder, mail or record.

$role string type

$permissions int type

$recursive bool type

The parameter recursive only has sense when the nodeId is a folder or record node.

When parameter recursive is true, the change will be applied to the node and descendants.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGrantRole() {
        try {
            // Add ROLE_USER write grants at the node but not descendants
            $this->ws->grantRole("/okm:root/SDK4PHP", "ROLE_USER", openkm\bean\Permission::ALL_GRANTS, false);

            // Add all ROLE_ADMIN grants to the node and descendants
            $this->ws->grantRole("/okm:root/SDK4PHP", "ROLE_ADMIN", openkm\bean\Permission::ALL_GRANTS, true);
            
            echo 'grant Role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGrantRole();
?>

grantUser

Description:

MethodReturn valuesDescription

grantUser($nodeId, $user, $permissions, $recursive)

void

Adds a user grant on a node.

Parameters:

$nodeId string type is the uuid or path of the document, folder, mail or record.

$user string type

$permissions int type

$recursive bool type

The parameter recursive only makes sense when the nodeId is a folder or record node.

When parameter recursive is true, the change will be applied to the node and descendants.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGrantUser() {
        try {
            // Add sochoa write grants at the node but not descendants
            $this->ws->grantUser("/okm:root/SDK4PHP", "sochoa", \openkm\bean\Permission::ALL_GRANTS, false);

            // Add all okmAdmin grants at the node and descendants
            $this->ws->grantUser("/okm:root/SDK4PHP", "okmAdmin", \openkm\bean\Permission::ALL_GRANTS, true);

            echo 'grant User';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGrantUser();
?>

revokeRole

Description:

MethodReturn valuesDescription

revokeRole($nodeId, $role, $permissions, $recursive)

void

Removes a role grant on a node.

Parameters:

$nodeId string type is the uuid or path of the document, folder, mail or record.

$role string type

$permissions int type

$recursive bool type

The parameter recursive only makes  sense when the nodeId is a folder or record node.

When parameter recursive is true, the change will be applied to the node and descendants.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testRevokeRole() {
        try {
            // Remove ROLE_USER write grants at the node but not descendants
            $this->ws->revokeRole("/okm:root/SDK4PHP", "ROLE_USER", \openkm\bean\Permission::ALL_GRANTS, false);

            // Remove all ROLE_ADMIN grants to the node and descendants
            $this->ws->revokeRole("/okm:root/SDK4PHP", "ROLE_ADMIN", \openkm\bean\Permission::ALL_GRANTS, true);

            echo 'revoke Role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testRevokeRole();
?>

revokeUser

Description:

MethodReturn valuesDescription

revokeUser($nodeId, $user, $permissions, $recursive)

void

Removes a user grant on a node.

Parameters:

$nodeId string type is the uuid or path of the document, folder, mail or record.

$user string type

$permissions int type

$recursive bool type

The parameter recursive only makes sense when the nodeId is a folder or record node.

When parameter recursive is true, the change will be applied to the node and descendants.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testRevokeUser() {
        try {
            // Remove sochoa write grants at the node but not descendants
            $this->ws->revokeUser("/okm:root/SDK4PHP", "sochoa", \openkm\bean\Permission::ALL_GRANTS, false);

            // Remove all okmAdmin grants at the node and descendants
            $this->ws->revokeUser("/okm:root/SDK4PHP", "okmAdmin", \openkm\bean\Permission::ALL_GRANTS, true);
            echo 'revoke User';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testRevokeUser();
?>

getRolesByUser

Description:

MethodReturn valuesDescription

getRolesByUser($user)

array

Returns the list of all the roles assigned to a user.

Parameters:

$user string type is the user

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetRolesByUser() {
        try {
            $roles = $this->ws->getRolesByUser('okmAdmin');
            foreach ($roles as $role) {
                var_dump($role);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetRolesByUser();
?>

getUsersByRole

Description:

MethodReturn valuesDescription

getUsersByRole($role)

array

Returns the list of all the users who have assigned a role.

Parameters:

$role string type is the role

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetUsersByRole() {
        try {
            $users = $this->ws->getUsersByRole('ROLE_ADMIN');
            foreach ($users as $user) {
                var_dump($user);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetUsersByRole();
?>

getMail

Description:

MethodReturn valuesDescription

getMail($user)

string

Returns the mail of a valid user.

Parameters:

$user string type is the user

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetMail() {
        try {
            var_dump($this->ws->getMail('okmAdmin'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetMail();
?>

getName

Description:

MethodReturn valuesDescription

getName($user)

string

Returns the name of a valid user.

Parameters:

$user string type is the user

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetName() {
        try {
            var_dump($this->ws->getName('okmAdmin'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetName();
?>

createUser

Description:

MethodReturn valuesDescription

createUser($user, $password, $email, $name, $active)

void

Create a new user.

Parameters:

$user string type

$password string type

$email string type

$name string type

$active bool type

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateUser() {
        try {
            $this->ws->createUser('gnu.java.sergio', "sochoa", "sochoa@openkm.com", "Sergio Antonio Ochoa Martinez", true);
            echo 'create user';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testCreateUser();
?>

deleteUser

Description:

MethodReturn valuesDescription

deleteUser($user)

void

Delete a user.

Parameters:

$user string type

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testDeleteUser() {
        try {
            $this->ws->deleteUser('gnu.java.sergio');
            echo 'delete user';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testDeleteUser();
?>

updateUser

Description:

MethodReturn valuesDescription

updateUser($user, $password, $email, $name, $active)

void

Update a user.

Parameters:

$user string type

$password string type

$email string type

$name string type

$active bool type

Example:

<?php

include '../src/openkm/OpenKM.php';

ini_set('display_errors', true);
error_reporting(E_ALL);

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testUpdateUser() {
        try {
            $this->ws->updateUser("gnu.java.sergio", "sochoa", "sochoa@openkm.com", "Sergio Ochoa", true);
            echo 'update user';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testUpdateUser();
?>

createRole

Description:

MethodReturn valuesDescription

createRole($role, $active)

void

Create a new role.

Parameters:

$role string type

$active bool type

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateRole() {
        try {
            $this->ws->createRole('ROLE_MANAGER', true);
            echo 'create role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }   

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testCreateRole(); 
?>

deleteRole

Description:

MethodReturn valuesDescription

deleteRole($role)

void

Delete a role.

Parameters:

$role string type

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testDeleteRole() {
        try {
            $this->ws->deleteRole('ROLE_MANAGER');
            echo 'delete role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testDeleteRole();
?>

updateRole

Description:

MethodReturn valuesDescription

updateRole($role, $active)

void

Update a role.

Parameters:

$role string type

$active bool type

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testUpdateRole() {
        try {
            $this->ws->updateRole('ROLE_MANAGER',true);
            echo 'update role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testUpdateRole();
?>
 

assignRole

Description:

MethodReturn valuesDescription

assignRole($user, $role)

void

Assign role to a user.

Parameters:

$user string type

$role string type

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testAssignRole() {
        try {
            $this->ws->assignRole('gnu.java.sergio','ROLE_MANAGER');
            echo 'assign role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }    

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testAssignRole();
?>

removeRole

Description:

MethodReturn valuesDescription

removeRole($user, $role)

void

Remove a role from a user.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testRemoveRole() {
        try {
            $this->ws->removeRole('gnu.java.sergio', 'ROLE_MANAGER');
            echo 'remove role';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testRemoveRole();
?>

changeSecurity

Description:

MethodReturn valuesDescription

changeSecurity(ChangeSecurity $changeSecurity)

void

Change the security of a node.

Example:

<?php

include '../src/openkm/OpenKM.php';

ini_set('display_errors', true);
error_reporting(E_ALL);

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testChangeSecurity() {
        try {
            $changeSecurity = new \openkm\bean\ChangeSecurity();
            $changeSecurity->setNodeId("768748c5-04ab-4921-b0d4-7545d239ce5a");
            $changeSecurity->setRecursive(true);
            
            $grantedRoles = array();
            $grantedRole = new \openkm\bean\GrantedRole();
            $grantedRole->setRole('ROLE_MANAGER');
            $grantedRole->setPermissions(\openkm\bean\Permission::READ + \openkm\bean\Permission::WRITE);                        
            $grantedRoles[] = $grantedRole;
            
            $changeSecurity->setGrantedRoles($grantedRoles);
            
            $grantedUsers = array();
            $grantedUser = new \openkm\bean\GrantedUser();
            $grantedUser->setUser('gnu.java.sergio');
            $grantedUser->setPermissions(\openkm\bean\Permission::READ + \openkm\bean\Permission::WRITE);
            $grantedUsers[] = $grantedUser;
            $changeSecurity->setGrantedUsers($grantedUsers);
            
            $revokedRoles = array();
            $revokedRole = new \openkm\bean\RevokedRole();
            $revokedRole->setRole('ROLE_USER');
            $revokedRole->setPermissions(\openkm\bean\Permission::DELETE);
            $changeSecurity->setRevokedRoles($revokedRoles);
                        
            $this->ws->changeSecurity($changeSecurity);
            echo 'change security';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testChangeSecurity();
?>

getProfiles

Description:

MethodReturn valuesDescription

getProfiles($filterByActive)

array

Returns the list of all profiles.

Parameters:

$filterByActive bool type is the parameter filterByActive when enabled the method will return only the active profiles, otherwise will return all avalaible profiles.

Each user has assigned one profile that enables more or less OpenKM UI features.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetProfiles() {
        try {
            $profiles = $this->ws->getProfiles(true);
            foreach ($profiles as $profile) {
                var_dump($profile);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetProfiles();
?>

getUserProfile

Description:

MethodReturn valuesDescription

getUserProfile($userId)

ProfileSimple

Return the profile assigned to a user.

Parameters:

$user string type is the user

Each user has assigned one profile that enables more or less OpenKM UI features.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetUserProfile() {
        try {
            var_dump($this->ws->getUserProfile('okmAdmin'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testGetUserProfile();
?>

setUserProfile

Description:

MethodReturn valuesDescription

setUserProfile($userId, $profileId)

void

Changes the assigned profile to a user.

Parameters:

$userId string type is the id user

$profileId int type is the id profile

Each user has assigned one profile that enables more or less OpenKM UI features.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleAuth {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testSetUserProfile() {
        try {
            $profileId = 1;            
            $this->ws->setUserProfile('sochoa', $profileId);
            echo 'set user profile';        
        } catch (Exception $e) {
            var_dump($e);
        }
    }
    
}

$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testSetUserProfile();
?>