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');
Tiki libs
Copy to clipboard
db/config/tiki.xml
Call the function
Copy to clipboard
$structLib->move_to_structure($page_ref_id, $structure_id);
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 [http://en.wikipedia.org/wiki/Cross-site_request_forgery|CSRF].
{CODE()}$access->check_authenticity()
//function to prevent CSRF by including a ticket in the popup form{CODE}
{CODE(caption="Include ticket in smarty tpl" wrap="1" colors="smarty")}<input type="hidden" name="ticket" value="{$ticket}">{CODE}
!!Preference checking
Check if a preference (feature) is enabled.
{CODE()}//check preference
Services_Exception_Disabled::check('feature_wiki_structure');{CODE}
If you want to check several preferences, call each separately
{CODE()}//check preferences
Services_Exception_Disabled::check('feature_wiki');
Services_Exception_Disabled::check('feature_wiki_structure');
Services_Exception_Disabled::check('feature_wiki_export');{CODE}
!!Permission checking
Check for necessary permissions (tiki_p_XXXX)
{CODE()}//check permission
$permission = Perms::get();
if (! $permission->tiki_p_edit_menu_options) {
throw new Services_Exception_Denied(tr('Permission denied'));
}{CODE}
!!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
{CODE()}$structLib = TikiLib::lib('struct');{CODE}
{REMARKSBOX(type="tip" title="Tiki libs" close="n")}
{CODE()}db/config/tiki.xml{CODE}
{REMARKSBOX}
!!!Call the function
{CODE()}$structLib->move_to_structure($page_ref_id, $structure_id);{CODE}