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
login
Description:
Method | Return values | Description |
---|---|---|
login() |
void |
Simulate first login process |
When user login into the application the first time, is called internally a method what creates user specific folders, like /okm:trash/userId etc. From API point of view, this method should be only executed first time user accessing from API, for creating specific user folder structure. Otherwise you can get errors, for example PathNotExistsException /okm:trash/userId when deleting objects, because the folders has not been created. |
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 testLogin() {
try {
$this->ws->login();
echo 'login';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleAuth = new ExampleAuth();
$exampleAuth->testLogin();
?>
getGrantedRoles
Description:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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 profileEach 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();
?>