Record samples

On most methods you'll see parameter named "recId". The value of this parameter can be a valid record UUID or path.

Example of recId:

  • Using UUID -> "8e03c11a-fd67-4ba0-8924-180ce538e586";
  • Using path -> "/okm:root/SDK4PHP/PKI-100200"

Methods

createRecord

Description:

MethodReturn valuesDescription

createRecord(Record $record)

Record

Creates a new record and return as a result an object Record.

Parameters:
$document Record type is an Object Record

The variable path into the parameter record, must be initializated. It indicates the folder path into OpenKM.

Record record = new Record();
record.setPath("/okm:root/PKI-100200");

Optionally a title variable can be set, the other variables of the Record  ( record ) will not take any effect on record creation.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testCreateRecord() {
        try {
            $record = new Record();
            $record->setPath("/okm:root/SDK4PHP/PKI-100200");
            $record->setTitle("some title");
            $this->ws->createRecord($record);
            var_dump($record);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testCreateRecord();
?>

getRecordProperties

Description:

MethodReturn valuesDescription

getRecordProperties($recId)

Record

Returns the record properties.

Parameters:
$recId
string type is the uuid or path of the Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testGetRecordProperties() {
        try {
            $record = $this->ws->getRecordProperties("/okm:root/SDK4PHP/PKI-100200");            
            var_dump($record);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testGetRecordProperties();
?>

deleteRecord

Description:

MethodReturn valuesDescription

deleteRecord($recId)

void

Deletes a record.

Parameters:
$recId
string type is the uuid or path of the Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testDeleteRecord() {
        try {
            $this->ws->deleteRecord("/okm:root/SDK4PHP/PKI-100200");            
            echo 'Deleted';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
    
}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testDeleteRecord();
?>

purgeRecord

Description:

MethodReturn valuesDescription

purgeRecord($recId)

void

Records is definitely removed from repository.

Parameters:
$recId
string type is the uuid or path of the Record

Usually you will purge records into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any record from the whole repository.

When a record is purged only will be able to be restored from a previously repository backup. The purge action remove the record definitely from the repository.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testPurgeRecord() {
        try {
            $this->ws->purgeRecord("/okm:trash/okmAdmin/PKI-100200");
            echo 'Purge';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testPurgeRecord();
?>

renameRecord

Description:

MethodReturn valuesDescription

renameRecord($recId, $newName)

Record

Changes the name of a Record and returns the Record

Parameters:
$recId
string type is the uuid or path of the Record

$newName string type is the new name for the Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testRenameRecord() {
        try {
            $record = $this->ws->renameRecord("/okm:root/SDK4PHP/PKI-100200", 'new_name');
            var_dump($record);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testRenameRecord();
?>

moveRecord

Description:

MethodReturn valuesDescription

moveRecord($recId, $dstId)

void

Moves a record into a folder or record.

Parameters:
$recId
string type is the uuid or path of the Record

$dstId string type is the uuid or path of the Folder or Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testMoveRecord() {
        try {
            $this->ws->moveRecord("/okm:root/SDK4PHP/PKI-100200","/okm:root/SDK4PHP/tmp");
            echo 'Move';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testMoveRecord();
?>

copyRecord

Description:

MethodReturn valuesDescription

copyRecord($recId, $dstId, $newName)

void

Copies a record into a folder or record.

Parameters:
$recId
string type is the uuid or path of the Record

$dstId string type is the uuid or path of the Folder or Record

$newName string type is the new name for the Record. Value is null, record will preservate the same name.

Only the security grants are copied to destination, the metadata, keywords, etc. of the record are not copied.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testcopyRecord() {
        try {
            $this->ws->copyRecord("/okm:root/SDK4PHP/PKI-100200","/okm:root/SDK4PHP/tmp",'new_name');
            echo 'Copy';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testcopyRecord();
?>

isValidRecord

Description:

MethodReturn valuesDescription

isValidRecord($recId)

bool

Returns a boolean that indicates if the node is a record or not.

Parameters:
$recId
string type is the uuid or path of the Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testIsValidRecord() {
        try {
            echo "Is a record:" . $this->ws->isValidRecord("/okm:root/SDK4PHP/PKI-100200");
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testIsValidRecord();
?>

getRecordChildren

Description:

MethodReturn valuesDescription

getRecordChildren($fldId)

array

Returns a list of all records which their parent is fldId

Parameters:
$fldId
string type is the uuid or path of the Folder or a record node.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testGetRecordChildren() {
        try {
            $records = $this->ws->getRecordChildren('/okm:root/SDK4PHP');
            foreach ($records as $record) {
                var_dump($record);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testGetRecordChildren();
?>

lockRecord

Description:

MethodReturn valuesDescription

lockRecord($recId)

LockInfo

Locks a record and returns an object with the Lock information

Parameters:
$recId
string type is the uuid or path of the Record

Only the user who locked the record is allowed to unlock.

A locked record can not be modified by other users.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testLockRecord() {
        try {
            $lockinfo = $this->ws->lockRecord('/okm:root/SDK4PHP/PKI-100200');            
            var_dump($lockinfo);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testLockRecord();
?>

unlockRecord

Description:

MethodReturn valuesDescription

unlockRecord($recId)

void

Unlocks a locked record.

Parameters:
$recId
string type is the uuid or path of the Record

Only the user who locked the document is allowed to unlock.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testUnlockRecord() {
        try {
            $this->ws->unlockRecord("/okm:root/SDK4PHP/PKI-100200");
            echo 'unlock';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testUnlockRecord();
?>

forceUnlockRecord

Description:

MethodReturn valuesDescription

forceUnlockRecord($recId)

void

Unlocks a locked record.

Parameters:
$recId
string type is the uuid or path of the Record

This method allows to unlock any locked record.

It is not mandatory to execute this action by the same user who previously executed the checkout lock action.

This action can only be done by a super user ( user with ROLE_ADMIN ).

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testForceUnlockRecord() {
        try {
            $this->ws->forceUnlockRecord("/okm:root/SDK4PHP/PKI-100200");
            echo 'forceUnlock';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testForceUnlockRecord();
?>

setRecordTitle

Description:

MethodReturn valuesDescription

setRecordTitle($recId, $title)

void

Sets record title.

Parameters:
$recId
string type is the uuid or path of the Record

$title string type is the title of the Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testSetRecordTitle() {
        try {
            $this->ws->setRecordTitle("/okm:root/SDK4PHP/PKI-100200",'some title');
            echo 'setTitle';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testSetRecordTitle();
?>

getRecordPath

Description:

MethodReturn valuesDescription

getRecordPath($uuid)

string

Converts record UUID to record path.

Parameters:
$uuid
string type is the uuid of the Record

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Record;

class ExampleRecord {

    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 testGetRecordPath() {
        try {
            var_dump($this->ws->getRecordPath("8e03c11a-fd67-4ba0-8924-180ce538e586"));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleRecord = new ExampleRecord();
$exampleRecord->testGetRecordPath();
?>