dolibarr 24.0.0-beta
ToolNavigation Class Reference

AI tool for generating navigation URLs in Dolibarr. More...

Inheritance diagram for ToolNavigation:
Collaboration diagram for ToolNavigation:

Public Member Functions

 getDefinitions ()
 Returns an array of tool definitions, including name, description, and input schema.
 
 getCategories ()
 Return categories this tool belongs to.
 
 execute (string $name, array $args)
 Executes the requested tool function based on its name.
 
- Public Member Functions inherited from McpTool
 __construct ($db, $user, $conf)
 Constructor.
 
 isSystem ()
 Return true if this is a system/infrastructure tool that must always remain visible and executable regardless of the admin allow-list.
 

Private Member Functions

 mapStatusToFilter ($elementType, $statusFilter)
 Maps human-readable status terms to Dolibarr URL parameters for a given element type.
 
 resolvePath ($input, $view)
 Maps user-friendly names to specific Dolibarr paths.
 
 checkPermissions ($elementType, $view, $id=0)
 Check if user has permissions for the requested resource using the modern hasRight() method.
 
 checkSpecificRecordAccess ($elementType, $id)
 Check if user has access to a specific record.
 
 generateDescription ($type, $view, $id, $statusFilter='')
 Generate a human-readable description for the URL.
 

Detailed Description

AI tool for generating navigation URLs in Dolibarr.

Definition at line 28 of file navigation.class.php.

Member Function Documentation

◆ checkPermissions()

ToolNavigation::checkPermissions ( $elementType,
$view,
$id = 0 )
private

Check if user has permissions for the requested resource using the modern hasRight() method.

Parameters
string$elementTypeElement type
string$viewView type
int$idElement ID (for specific record access)
Returns
bool True if user has permission

Definition at line 386 of file navigation.class.php.

References $id, checkSpecificRecordAccess(), and user.

Referenced by execute().

◆ checkSpecificRecordAccess()

ToolNavigation::checkSpecificRecordAccess ( $elementType,
$id )
private

Check if user has access to a specific record.

Parameters
string$elementTypeElement type
int$idElement ID
Returns
bool True if user has access to the specific record

Definition at line 506 of file navigation.class.php.

References $db, $id, and user.

Referenced by checkPermissions().

◆ execute()

ToolNavigation::execute ( string $name,
array $args )

Executes the requested tool function based on its name.

Parameters
string$nameThe name of the tool to execute.
array<string,mixed>$args The arguments for the tool (key-value pairs).
Returns
mixed The result of the tool execution (usually an array) or an error array.

Reimplemented from McpTool.

Definition at line 94 of file navigation.class.php.

References $id, checkPermissions(), dol_buildpath(), generateDescription(), mapStatusToFilter(), resolvePath(), and user.

◆ generateDescription()

ToolNavigation::generateDescription ( $type,
$view,
$id,
$statusFilter = '' )
private

Generate a human-readable description for the URL.

Parameters
string$typeElement type
string$viewView type
int$idElement ID
string$statusFilterThe status filter used
Returns
string Description

Definition at line 544 of file navigation.class.php.

References $id.

Referenced by execute().

◆ getCategories()

ToolNavigation::getCategories ( )

Return categories this tool belongs to.

Used by the intent parser to filter available tools.

Returns
array<string> List of categories (e.g., ['billing', 'commercial'])

Reimplemented from McpTool.

Definition at line 82 of file navigation.class.php.

◆ getDefinitions()

ToolNavigation::getDefinitions ( )

Returns an array of tool definitions, including name, description, and input schema.

Returns
list<array<string, mixed>> Array of tool definitions.

Reimplemented from McpTool.

Definition at line 35 of file navigation.class.php.

◆ mapStatusToFilter()

ToolNavigation::mapStatusToFilter ( $elementType,
$statusFilter )
private

Maps human-readable status terms to Dolibarr URL parameters for a given element type.

This is the core logic for accurate list filtering.

Parameters
string$elementTypeThe normalized element type (e.g., 'invoice_customer')
string$statusFilterThe human-readable status (e.g., 'open', 'paid')
Returns
array<string, int|string>|null An associative array for the URL query string, or null if no match.

Definition at line 194 of file navigation.class.php.

Referenced by execute().

◆ resolvePath()

ToolNavigation::resolvePath ( $input,
$view )
private

Maps user-friendly names to specific Dolibarr paths.

Parameters
string$inputUser input object type
string$viewView type (list, card, create)
Returns
array<string, mixed>|null Path information or null if not found

Definition at line 268 of file navigation.class.php.

Referenced by execute().


The documentation for this class was generated from the following file: