PHP Samples
Download sdk4php
The sdk4php sample below includes the most common methods used by users when integrating their PHP applications.
The OpenKM has more than 400 methods in the API; the samples below cover the most common methods used when integrating PHP applications with OpenKM.
If you have issues trying to use methods not covered in this sample, contact the OpenKM support service.
Professional | PHP version | Status | Download |
---|---|---|---|
Version 7.1.40 and above. |
7.x | Active | sdk4php-3.0.3.zip |
Version 7.1.27 and above. |
7.x | Deprecated | sdk4php-3.0.2.zip |
Version 7.1.25 and above. |
7.x |
Deprecated | sdk4php-3.0.1.zip |
Version 7.1.22 to 7.1.24. |
7.x |
Deprecated | sdk4php-3.0.0.zip |
Preview sample
The sample below describes how to integrate the OpenKM preview feature into your PHP application.
Professional | PHP version | Status | Download |
---|---|---|---|
Version 7.1.25 and upper. |
7.x |
Active |
Login
First, you must create the webservice object:
$this->ws = OKMWebServicesFactory::build(self::HOST);
Then you should log in using the method "login". You can access the "login" method from the webservice object "ws" as shown below:
$this->ws->login(self::USER, self::PASSWORD);
Once you are logged in with the webservices, the session is kept in the webservice object. Then you can use the other API methods.
At this point you can use all the Folder methods from the "folder" class as shown below:
$folder = $this->ws->folder->getFolderProperties("4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5");
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$folder = $this->ws->folder->getFolderProperties("4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5");
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$$test->test();
?>
Document samples
createDocument
Description:
Method | Return values | Description |
---|---|---|
createDocument($uuid, $name, $content) |
Document |
Creates a new document and returns as a result an object Document with the properties of the created document. |
Parameters: $name string type is the name of the document. $content string type; it is recommended to use file_get_contents ? Reads entire file into a string |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$fileName = dirname(__FILE__) . '/files/test.pdf';
$document = $this->ws->document->createDocument('f93ac8df-e83b-487f-9a14-0af9e910a818', 'test.pdf', file_get_contents($fileName));
var_dump($document);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
deleteDocument
Description:
Method | Return values | Description |
---|---|---|
deleteDocument($uuid) |
void |
Deletes a document. |
Parameters: When a document is deleted, it is automatically moved to /okm:trash/userId folder. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->document->deleteDocument('5b37c508-b2be-4429-ba5e-acc96089c6a9');
echo 'deleted';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getDocumentProperties
Description:
Method | Return values | Description |
---|---|---|
getDocumentProperties($uuid) |
Document |
Returns the document properties. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$document = $this->ws->document->getDocumentProperties('7e12a9ff-95b2-4945-bf5f-1bb709d89c14');
var_dump($document);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getContent
Description:
Method | Return values | Description |
---|---|---|
getContent($uuid) |
string |
Retrieves a document's content ? binary data ? of the current document version. |
Parameters: $uuid string type is the uuid of the Document |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
$method = 1;
$this->ws->login(self::USER, self::PASSWORD);
$content = $this->ws->document->getContent('b02877cc-bc71-4be9-9bfb-2e50b1732fd3');
switch ($method) {
case 1:
$file = fopen(dirname(__FILE__) . '/files/logo_download.png', 'w+');
fwrite($file, $content);
fclose($file);
echo 'download correct';
break;
case 2:
ob_clean();
$document = $this->ws->document->getDocumentProperties('b02877cc-bc71-4be9-9bfb-2e50b1732fd3');
$name = PathUtils::getName($document->getPath());
header("Cache-Control: maxage=1");
header("Pragma: public");
header("Content-Type: " . $document->getMimeType());
header('Content-Disposition: attachment; filename="' . $name . '"');
header("Content-Length: " . strlen($content));
echo $content;
break;
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getDocumentChildren
Description:
Method | Return values | Description |
---|---|---|
getDocumentChildren($uuid) |
array |
Returns a list of all documents whose parent is fldId. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$documents = $this->ws->document->getDocumentChildren('f93ac8df-e83b-487f-9a14-0af9e910a818');
foreach ($documents as $document) {
var_dump($document);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
moveDocument
Description:
Method | Return values | Description |
---|---|---|
moveDocument($uuid, $dstId) |
void |
Moves a document into a folder or record. |
Parameters: $dstId string type is the uuid of the Folder or Record |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->document->moveDocument('b02877cc-bc71-4be9-9bfb-2e50b1732fd3', '55102c84-e4f5-4cbc-a3d1-cf1896367752');
echo 'moveDocument';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
copyDocument
Description:
Method | Return values | Description |
---|---|---|
copyDocument($uuid, $dstId, $newName) |
void |
Copies a document to a folder or record. |
Parameters: $dstId string type is the uuid of the Folder or Record $newName string type is the new name for the Document When the parameter newName value is null, the document will preserve the same name. Only the binary data and the security grants are copied to the destination; the metadata, keywords, etc. of the document are not copied. See "extendedDocumentCopy" method for this feature. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$document = $this->ws->document->copyDocument('b02877cc-bc71-4be9-9bfb-2e50b1732fd3', '55102c84-e4f5-4cbc-a3d1-cf1896367752', 'new_logo.png');
var_dump($document);
echo 'copyDocument';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
extendedDocumentCopy
Description:
Method | Return values | Description |
---|---|---|
extendedDocumentCopy($uuid, $dstId, $newName, $categories, $keywords, $propertyGroups, $notes, $security) |
void |
Copies a document with associated data into another folder or record. |
Parameters: $dstId string type is the uuid of the Folder or Record $newName string type is the new name $categories boolean type $keywords boolean type $propertyGroups boolean type $notes boolean type $security boolean type By default only the binary data and the security grants are copied; the metadata, keywords, etc. of the document are not copied. Additionally:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$document = $this->ws->document->extendedDocumentCopy('4ee59dea-4641-4336-a2c4-af384d9040ad', 'd81ac5f3-0cb3-4cd7-997b-3b1b9f4403f8', 'copy.pdf', true, true, true, true, true);
var_dump($document);
echo 'extendedDocumentCopy';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
checkout
Description:
Method | Return values | Description |
---|---|---|
checkout($uuid) |
void |
Marks the document for editing. |
Parameters: Only one user can modify a document at the same time. Before starting editing, you must perform a checkout action that locks the editing process for other users and allows only the user who executed the action to edit. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->document->checkout('eb0e6511-3415-47ca-bcde-393d97944c85');
// At this point the document is locked for other users except for the user who executed the action
echo 'correct';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
cancelCheckout
Description:
Method | Return values | Description |
---|---|---|
cancelCheckout($docId) |
void |
Cancels a document's editing. |
Parameters: $docId string type is the uuid or path of the Document This action can only be done by the user who previously executed the checkout action. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
// At this point the document is locked for other users except for the user who executed the action
$this->ws->document->cancelCheckout('eb0e6511-3415-47ca-bcde-393d97944c85');
// At this point other users are allowed to execute a checkout and modify the document
echo 'correct';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
forceCancelCheckout
Description:
Method | Return values | Description |
---|---|---|
forceCancelCheckout($uuid) |
void |
Cancels a document's editing. |
Parameters: This method allows cancelling the edit on any document. It is not necessary that this action be executed by the same user who previously performed the checkout action. This action can only be done by a superuser (user with ROLE_ADMIN). |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
// At this point the document is locked for other users except for the user who executed the action
$this->ws->document->forceCancelCheckout('eb0e6511-3415-47ca-bcde-393d97944c85');
// At this point other users are allowed to execute a checkout and modify the document
echo 'correct';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
isCheckedOut
Description:
Method | Return values | Description |
---|---|---|
isCheckedOut($uuid) |
bool |
Returns a boolean that indicates whether the document is being edited. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
var_dump($this->ws->document->isCheckedOut('eb0e6511-3415-47ca-bcde-393d97944c85'));
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
checkin
Description:
Method | Return values | Description |
---|---|---|
checkin($uuid, $content, $comment,$increment) |
Version |
Updates a document with a new version and returns an object with the new version values. |
Parameters: $content string type; it is recommended to use file_get_contents ? Reads entire file into a string $comment string type is the comment for the new version of the document $increment int type The value of the increment variable must be 1 or greater. The valid values of the increment variable depend on the VersionNumberAdapter you have enabled. Only the user who started the edition (checkout) is allowed to update the document. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->document->checkout('eb0e6511-3415-47ca-bcde-393d97944c85');
if ($this->ws->document->isCheckedOut('eb0e6511-3415-47ca-bcde-393d97944c85')) {
$fileName = dirname(__FILE__) . '/files/logo.png';
$version = $this->ws->document->checkin('eb0e6511-3415-47ca-bcde-393d97944c85', file_get_contents($fileName), "optional some comment", 1);
var_dump($version);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getVersionHistory
Folder sample
createFolder
Description:
Method | Return values | Description |
---|---|---|
createFolder($uuid, $name) |
Folder |
Creates a new folder and returns it as a Folder object. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$folder = $this->ws->folder->createFolder('f93ac8df-e83b-487f-9a14-0af9e910a818', 'test');
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getFolderProperties
Description:
Method | Return values | Description |
---|---|---|
getFolderProperties($uuid) |
Folder |
Returns the folder properties. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
// const HOST = "http://localhost:8080/openkm/";
const HOST = "http://192.168.1.11:8888/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$folder = $this->ws->folder->getFolderProperties("4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5");
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
deleteFolder
Description:
Method | Return values | Description |
---|---|---|
deleteFolder($uuid) |
void |
Deletes a folder. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
// const HOST = "http://localhost:8080/openkm/";
const HOST = "http://192.168.1.11:8888/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->folder->deleteFolder("56c4d33b-daad-4389-bfdc-ee8dd5273899");
echo 'delete folder';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
renameFolder
Description:
Method | Return values | Description |
---|---|---|
renameFolder($uuid, $newName) |
void |
Renames a folder. |
Parameters: $newName string type is the new name for the Folder |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
// Exists folder /okm:root/sdk/test
$folder = $this->ws->folder->renameFolder("0b89e4ca-0019-4837-82a4-05bc05d83353", "renamedFolder");
// Folder has renamed to /okm:root/sdk/renamedFolder
echo 'rename Folder';
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
moveFolder
Description:
Method | Return values | Description |
---|---|---|
moveFolder($uuid, $dstId) |
void |
Moves a folder into another folder or record. |
Parameters: $dstId string type is the uuid of the Folder or record |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
// Exists folder /okm:root/sdk/test
$this->ws->folder->moveFolder("0b89e4ca-0019-4837-82a4-05bc05d83353", "55102c84-e4f5-4cbc-a3d1-cf1896367752");
// Folder has moved to /okm:root/move/test
echo 'move Folder';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getFolderChildren
Description:
Method | Return values | Description |
---|---|---|
getFolderChildren($uuid) |
array |
Returns an array of all folders whose parent is fldId. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$folders = $this->ws->folder->getFolderChildren('f93ac8df-e83b-487f-9a14-0af9e910a818');
foreach ($folders as $folder) {
var_dump($folder);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
copyFolder
Description:
Method | Return values | Description |
---|---|---|
copyFolder($uuid, $dstId, $newName) |
void |
Copies a folder into other folder or record. |
Parameters: $dstId string type is the uuid of the Folder or Record $newName string type is the new name for the Folder. If the value is null, the folder will preserve the same name. Only the security grants are copied to the destination; the metadata, keywords, etc. of the folder are not copied. See "extendedFolderCopy" method for this feature. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->folder->copyFolder('4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5', '55102c84-e4f5-4cbc-a3d1-cf1896367752', "new_name");
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
extendedFolderCopy
Description:
Method | Return values | Description |
---|---|---|
extendedFolderCopy($uuid, $dstId, $categories, $keywords, $propertyGroups, $notes, $security) |
void |
Copies a folder with associated data into another folder or record. |
Parameters: $dstId string type is the uuid of the Folder or Record $categories boolean type $keywords boolean type $propertyGroups boolean type $notes boolean type $security boolean type By default only the binary data and the security grants are copied; the metadata, keywords, etc. of the folder are not copied. Additionally:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$folder = $this->ws->folder->extendedFolderCopy('4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5', '55102c84-e4f5-4cbc-a3d1-cf1896367752', 'new name extend copy', true, true, true, true, true);
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getContentInfo
Description:
Method | Return values | Description |
---|---|---|
getContentInfo($uuid) |
ContentInfo |
Returns a ContentInfo object with information about the folder. |
Parameters: The ContentInfo object retrieves information about:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
var_dump($this->ws->folder->getContentInfo('4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5'));
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
purgeFolder
Description:
Method | Return values | Description |
---|---|---|
purgeFolder($uuid) |
void |
The folder is permanently removed from the repository. |
Parameters: Usually you will purge folders in /okm:trash/userId - the personal trash user locations - but it is possible to directly purge any folder from the repository. When a folder is purged, it can only be restored from a previous repository backup. The purge action removes the folder permanently from the repository. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->folder->purgeFolder('d1faccb3-9e64-4d2d-865f-1c057e3a279b');
echo 'purge folder';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
setStyle
Description:
Method | Return values | Description |
---|---|---|
setStyle($uuid, $styleId) |
void |
Sets the folder style. |
Parameters: $styleId long type is the id of the style. More information at: Folder style. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->folder->setStyle('0b89e4ca-0019-4837-82a4-05bc05d83353', 1);
echo 'set style';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
createMissingFolders
Description:
Method | Return values | Description |
---|---|---|
createMissingFolders($fldPath) |
void |
Creates missing folders. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->folder->createMissingFolders("/okm:root/sdk/missingfld2/missingfld3");
var_dump('create missing folders');
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
createFolderFromTemplate
Description:
Method | Return values | Description |
---|---|---|
createFolderFromTemplate($uuid, $dstPath, $language, $categories, |
Folder |
Creates a new folder from the template and returns an object Folder. |
The $uuid parameter is the UUID value of the template file. The $dstPath value is the folder destination path. The $language parameter is optional. When the template uses metadata groups to fill in fields, these values are mandatory and must be set in the properties parameter. Additional:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
// const HOST = "http://localhost:8080/openkm/";
const HOST = "http://192.168.1.11:8888/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$properties = [];
$properties["okp:consulting.name"] = "update value";
$properties["okp:consulting.important"] = "false";
$folder = $this->ws->folder->createFolderFromTemplate('47c70047-2924-483c-bc42-23d0cbef6b17', '/okm:root/sdk/foldertemplate', 'es', true, true, true, true, $properties);
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
PropertyGroup samples
addPropertyGroup
Description:
Method | Return values | Description |
---|---|---|
addPropertyGroup($uuid, $grpName, $properties) |
void |
Adds an empty metadata group to a node. |
Parameters: $uuid string type is the uuid of the document, folder, mail or record. $grpName string type: the grpName should be a valid metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$properties = [];
$properties["okp:consulting.name"] = "new value";
$properties["okp:consulting.important"] = "true";
$this->ws->propertyGroup->addPropertyGroup('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting', $properties);
echo 'Add Group';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
removePropertyGroup
Description:
Method | Return values | Description |
---|---|---|
removePropertyGroup($uuid, $grpName) |
void |
Removes a metadata group of a node. |
Parameters: $uuid string type is the uuid of the document, folder, mail or record. $grpName string type: the grpName should be a valid metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->propertyGroup->removePropertyGroup('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting');
echo 'Remove Group';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getPropertyGroups
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroups($uuid) |
array |
Retrieves a list of metadata groups assigned to a node. |
Parameters: $uuid string type is the UUID of the document, folder, mail, or record. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$propertyGroups = $this->ws->propertyGroup->getPropertyGroups('7e12a9ff-95b2-4945-bf5f-1bb709d89c14');
foreach ($propertyGroups as $propertyGroup) {
var_dump($propertyGroup);
echo '<br>';
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getAllPropertyGroups
Description:
Method | Return values | Description |
---|---|---|
getAllPropertyGroups() |
array |
Retrieves a list of all metadata groups set into the application. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$propertyGroups = $this->ws->propertyGroup->getAllPropertyGroups();
foreach ($propertyGroups as $propertyGroup) {
var_dump($propertyGroup);
echo '<br>';
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getPropertyGroupForm
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupForm($grpName) |
array |
Retrieves a list of all metadata group element definitions. |
Parameters: $grpName string type; the grpName should be a valid metadata group name.
The method is usually used to display empty form elements for creating new metadata values.
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
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 testGetPropertyGroupForm() {
try {
$formElements = $this->ws->getPropertyGroupForm('okg:consulting');
foreach ($formElements as $formElement) {
var_dump($formElement);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetPropertyGroupPropertiesSimple();
?>
getPropertyGroupFormByNode
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupFormByNode($uuid, $grpName) |
array |
Retrieves a list of all metadata group element definitions by node. |
Parameters: $uuid string type is the UUID of the document, folder, mail, or record. $grpName string type; the grpName should be a valid metadata group name. The method is usually used to display empty form elements for creating new metadata values. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$formElements = $this->ws->propertyGroup->getPropertyGroupFormByNode('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting');
foreach ($formElements as $formElement) {
var_dump($formElement);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
setPropertyGroupProperties
Description:
Method | Return values | Description |
---|---|---|
setPropertyGroupProperties($uuid, $grpName, $properties) |
void |
Changes the metadata group values of a node. |
Parameters: $uuid string type is the UUID or path of the document, folder, mail, or record. $grpName string type; the grpName should be a valid metadata group name. $properties array type: an array. Before changing metadata, you should have the group added to the node (see addGroup method); otherwise an error will be raised. It is not mandatory to set all field values in the properties parameter; it is enough to include the fields whose values you wish to change. The sample below is based on this Metadata group definition:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$properties = [];
$properties["okp:consulting.name"] = "update value";
$properties["okp:consulting.important"] = "false";
$this->ws->login(self::USER, self::PASSWORD);
$this->ws->propertyGroup->setPropertyGroupProperties('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting', $properties);
echo 'updated';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
hasPropertyGroup
Description:
Method | Return values | Description |
---|---|---|
hasPropertyGroup($uuid, $grpName) |
bool |
Returns a boolean that indicate if the node has or not a metadata group. |
Parameters: $uuid string type is the uuid of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
try {
$this->ws->login(self::USER, self::PASSWORD);
echo 'Have metadata group: ' . $this->ws->propertyGroup->hasPropertyGroup('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting');
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getRegisteredPropertyGroupDefinition
Description:
Method | Return values | Description |
---|---|---|
getRegisteredPropertyGroupDefinition() |
string |
Returns the XML metadata groups definition. |
The method can only be executed by super users with ROLE_ADMIN privileges. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
var_dump($this->ws->propertyGroup->getRegisteredPropertyGroupDefinition());
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getPropertyGroupSuggestions
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupSuggestions($uuid, $grpName, $propName) |
array |
Retrieves a list of suggested metadata field values. |
Parameters: $uuid string type is the UUID of the document, folder, mail, or record. $grpName string type; the grpName should be a valid metadata group name. $propName string type; the propName parameter should be a Metadata Select field type. The propName parameter should be a Metadata Select field type. More information at Creating your own Suggestion Analyzer and Metadata Select field. The sample below is based on this Metadata group definition:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$suggestions = $this->ws->propertyGroup->getPropertyGroupSuggestions('055b5206-35d0-4351-ba92-c304bbba7ddf', 'okg:technology', 'okp:technology.priority');
foreach ($suggestions as $suggestion) {
var_dump($suggestion);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
registerPropertyGroupDefinition
Description:
Method | Return values | Description |
---|---|---|
registerPropertyGroupDefinition($content, $name) |
void |
Sets the XML metadata groups definition into the repository. |
Parameters: $content string type; it is recommended to use file_get_contents ? reads the entire file into a string. $name string type is the property group name. The method can only be executed by super users with ROLE_ADMIN privileges. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$fileName = dirname(__FILE__) . '/propertygroup/propertyGroups.xml';
$this->ws->propertyGroup->registerPropertyGroupDefinition(file_get_contents($fileName), 'sdk4php');
var_dump('Register Definition correct');
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getPropertyGroupProperties
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupProperties($uuid, $grpName) |
array |
Retrieves a list of all metadata group elements and their values for a node. |
Parameters: $uuid string type is the uuid of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. The method is usually used to display form elements with their values to be shown or changed by the user. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$properties = $this->ws->propertyGroup->getPropertyGroupProperties('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting');
foreach ($properties as $key => $value) {
echo 'key: ' . $key . ' value: ' . $value;
echo '<br>';
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getPropertyGroupPropertiesByVersion
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupPropertiesByVersion($uuid, $grpName, $versionName) |
array |
Retrieves a list of all metadata group elements and their values for a node. |
Parameters: $uuid string type is the uuid of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. $versionName string type is the version of the document, folder, mail, or record. The method is usually used to display form elements with their values to be shown or changed by the user. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
try {
$this->ws->login(self::USER, self::PASSWORD);
$properties = $this->ws->propertyGroup->getPropertyGroupPropertiesByVersion('7e12a9ff-95b2-4945-bf5f-1bb709d89c14', 'okg:consulting', '1.3');
foreach ($properties as $key => $value) {
echo 'key: ' . $key . ' value: ' . $value;
echo '<br>';
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
Search samples
find
Description:
Method | Return values | Description |
---|---|---|
find(QueryParams $queryParams, $propertiesPlugin) |
array |
Returns a list of QueryResults filtered by the values of the queryParams parameter. |
Parameters: $propertiesPlugin string type, must be the canonical class name of the class which implements the NodeProperties interface. Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time ? the marshalling and unmarshalling process ? while you might only be interested in a few object variables. If this is your case you can use NodeProperties classes to retrieve the object variables that you really need. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$queryParams = new QueryParams();
$queryParams->setDomain(QueryParams::DOCUMENT + QueryParams::FOLDER);
$queryParams->setFolder("f93ac8df-e83b-487f-9a14-0af9e910a818");
$queryParams->setFolderRecursive(true);
$queryParams->setLastModifiedFrom(20150628000000);
$queryParams->setLastModifiedTo(date('Ymdhis'));
$queryResults = $this->ws->search->find($queryParams, null);
foreach ($queryResults as $queryResult) {
var_dump($queryResult);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
findPaginated
Description:
Method | Return values | Description |
---|---|---|
findPaginated(QueryParams $queryParams, $offset, $limit, $propertiesPlugin) |
ResultSet |
Returns a list of paginated results filtered by the values of the queryParams parameter. |
Parameters: $offset int type $limit int type $propertiesPlugin string type, must be the canonical class name of the class which implements the NodeProperties interface. The parameter "limit" and "offset" allow you to retrieve just a portion of the results of a query.
For example if your query have 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11-20, you should use these values:
Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time ? the marshalling and unmarshalling process ? while you might only be interested in a few object variables. If this is your case you can use NodeProperties classes to retrieve the object variables that you really need. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$queryParams = new QueryParams();
$queryParams->setDomain(QueryParams::DOCUMENT + QueryParams::FOLDER);
$queryParams->setFolder("f93ac8df-e83b-487f-9a14-0af9e910a818");
$queryParams->setFolderRecursive(true);
$queryParams->setLastModifiedFrom(20150628000000);
$queryParams->setLastModifiedTo(date('Ymdhis'));
$resultSet = $this->ws->search->findPaginated($queryParams, 0, 10, null);
echo "Total results:" . $resultSet->getTotal();
foreach ($resultSet->getResults() as $queryResult) {
var_dump($queryResult);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
Task samples
getTaskStatuses
Description:
Method | Return values | Description |
---|---|---|
getTaskStatuses() |
TaskStatus |
Retrieves a list of all task statuses. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$taskStatuses = $this->ws->task->getTaskStatuses();
var_dump($taskStatuses);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getTaskProjects
Description:
Method | Return values | Description |
---|---|---|
getTaskProjects($filterActive) |
TaskProject |
Retrieves a list of all task projects. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$taskProjects = $this->ws->task->getTaskProjects(true);
var_dump($taskProjects);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
getTaskTypes
Description:
Method | Return values | Description |
---|---|---|
getTaskTypes($filterActive) |
TaskProject |
Retrieves a list of all task types. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$taskTypes = $this->ws->task->getTaskTypes(true);
var_dump($taskTypes);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>
createTask
Description:
Method | Return values | Description |
---|---|---|
createTask($subject, $start, $end, $description, $statusId, $projectId, $typeId, $user, $notificationUsers, $externalUsers, $relatedDocuments, $relatedFolders, $relatedRecords, $relatedMails, $repeatExpression, $repeatUntil, $formatDate, $repeatTimes, $reminderStartUnit, $reminderStartValue, $reminderEndUnit, $reminderEndValue) |
TaskProject |
Create a new task. |
The repeatExpression parameter description: The commands are executed by cron when the minute, hour, and month fields match the current time, and when at least one of the two day fields (day of month, or day of week) match the current time. The scheduler examines crontab entries once every minute. The time and date fields are: * * * * * command to execute |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class Test {
const HOST = "http://localhost:8080/openkm/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST);
}
public function test() {
echo '<pre>';
try {
$this->ws->login(self::USER, self::PASSWORD);
$subject = "task subject";
$start = date('YmdHis');
$end = date('YmdHis');
$description = "description test";
$statusId = 1; // A valid task status id
$projectId = 1; // A valid project id
$typeId = 1; // A valid type id
$user = "okmAdmin";
$notificationUsers = [];
$notificationUsers[] = "gnujavasergio";
$notificationUsers[] = "sochoa";
$externalUsers = [];
$externalUsers[] = "gnu.java.sergio@gmail.com";
$relatedDocuments = [];
$relatedDocuments[] = "d701c503-87fc-4a9e-829e-478dc375eb83";
$relatedDocuments[] = "f02053e3-2264-4040-bb84-67983a0208f7";
$relatedFolders = [];
$relatedFolders[] = "0a777b34-f518-4da7-9e58-8b1425e05add";
$relatedFolders[] = "271cc3aa-218e-4574-8065-c34c704f4a20";
$relatedMails = [];
$relatedMails[] = "3ae1bb26-acdf-4463-a0c1-06cc62f55b95";
$relatedMails[] = "c599be73-7831-4e93-be91-453baeda2b00";
$relatedRecords = [];
$relatedRecords[] = "96801b33-e92e-436b-8ed7-5d8dea904673";
$relatedRecords[] = "23b50095-aa18-4d16-ae75-74b994a2f2b4";
$repeatUntil = '20240113';
$repeatExpression = "0 0 1 * *";
$task = $this->ws->task->createTask($subject, $start, $end, $description, $statusId, $projectId, $typeId, $user,
$notificationUsers, $externalUsers, $relatedDocuments, $relatedFolders, $relatedRecords, $relatedMails,$repeatExpression, $repeatUntil,
"yyyyMMddHHmmss", 10, "m", 5, "m", 10);
var_dump($task);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$test = new Test();
$test->test();
?>