Note samples

Basics

On most methods you'll see parameter named "nodeId". The value of this parameter can be a valid document, folder, mail or record UUID or path.

Example of nodeId:

  • Using UUID -> "11f645a3-281e-4fa6-a2a1-6c1fce5c8ff6";
  • Using path -> "/okm:root/SDK4PHP/logo.png"

Methods

addNote

Description:

MethodReturn valuesDescription

addNote($nodeId, $text)

Note

Adds a note to a node and returns an object Note.

Parameters:

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

$text string type is the text

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Note;

class ExampleNote {

    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 testAddNote() {
        try {            
            $note = $this->ws->addNote("/okm:root/SDK4PHP/logo.png", "the note text");
            var_dump($note);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleNote = new ExampleNote();
$exampleNote->testAddNote();

?>

getNote

Description:

MethodReturn valuesDescription

getNote($noteId)

Note

Retrieves the note.

Parameters:

$noteId string type

The noteId is an UUID.

The object Node have a variable named path, in that case the path contains an UUID.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Note;

class ExampleNote {

    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 testGetNote() {
        try {
            $notes = $this->ws->listNotes("/okm:root/SDK4PHP/logo.png");
            if (count($notes) > 0) {
                var_dump($this->ws->getNote($notes[0]->getPath()));
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleNote = new ExampleNote();
$exampleNote->testGetNote();

?>

deleteNote

Description:

MethodReturn valuesDescription

deleteNote($noteId)

Note

Deletes a note.

Parameters:

$noteId string type

The noteId is an UUID.

The object Node has a variable named path, in that case the path contains an UUID.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Note;

class ExampleNote {

    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 testDeleteNote(){
        try {
            $notes = $this->ws->listNotes("/okm:root/SDK4PHP/logo.png");
            if (count($notes) > 0) {
                $this->ws->deleteNote($notes[0]->getPath());
                echo "deleted";
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleNote = new ExampleNote();
$exampleNote->testDeleteNote();

?>

setNote

Description:

MethodReturn valuesDescription

setNote($noteId, $text)

void

Changes the note text.

Parameters:

$noteId string type

$text string type is the text

The noteId is an UUID.

The object Node has a variable named path, in that case the path contains an UUID.

Example:

<?php

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

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Note;

class ExampleNote {

    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 testSetNote(){
        try {
            $notes = $this->ws->listNotes("/okm:root/SDK4PHP/logo.png");
            if (count($notes) > 0) {
                $this->ws->setNote($notes[0]->getPath(),"text modified");
                echo "updated";
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }
    
}

$openkm = new OpenKM(); //autoload
$exampleNote = new ExampleNote();
$exampleNote->testSetNote();

?>

listNotes

Description:

MethodReturn valuesDescription

listNotes($nodeId)

array

Retrieves a list of all notes 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;
use openkm\bean\Note;

class ExampleNote {

    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 testListNotes() {
        try {
            $notes = $this->ws->listNotes("/okm:root/SDK4PHP/logo.png");
            foreach ($notes as $note) {
                var_dump($note);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleNote = new ExampleNote();
$exampleNote->testListNotes();
?>