Loading...
 
Skip to main content

Ex-ante functions

This page documents useful functions available to be called before executing data modifications (insert/update/delete) using a service controller.

Authenticity (ticket) checking

Check if the user has authenticity to prevent CSRF.

Copy to clipboard
$access->check_authenticity() //function to prevent CSRF by including a ticket in the popup form

Include ticket in smarty tpl
Copy to clipboard
<input type="hidden" name="ticket" value="{$ticket}">

Preference checking

Check if a preference (feature) is enabled.

Copy to clipboard
//check preference Services_Exception_Disabled::check('feature_wiki_structure');


If you want to check several preferences, call each separately

Copy to clipboard
//check preferences Services_Exception_Disabled::check('feature_wiki'); Services_Exception_Disabled::check('feature_wiki_structure'); Services_Exception_Disabled::check('feature_wiki_export');

Permission checking

Check for necessary permissions (tiki_p_XXXX)

Copy to clipboard
//check permission $permission = Perms::get(); if (! $permission->tiki_p_edit_menu_options) { throw new Services_Exception_Denied(tr('Permission denied')); }

Checking mandatory input

Check if a mandatory input data is available and fire error it is if not provided

Call a function from a library

You will probably need to use some functions from libraries.

Initialize the library

Copy to clipboard
$structLib = TikiLib::lib('struct');

Call the function

Copy to clipboard
$structLib->move_to_structure($page_ref_id, $structure_id);
Show PHP error messages