Loading...
 
Skip to main content

History: Ex-post functions

Source of version: 18 (current)

Copy to clipboard
{REMARKSBOX(type="tips" title="Information" close="n")}
This page documents useful functions that can be used in a service controller action __after__ the execution of modifications (insert/update/delete)
{REMARKSBOX}

!!Events
Trigger events to be displayed in notification streams
{REMARKSBOX(type="tips" title="Learn more" close="n")}
Learn more more about ((Events|events)) and ((Activities|activities))
{REMARKSBOX}
{CODE()}TikiLib::events()->trigger('tiki.category.update', [
			'type' => 'category',
			'object' => $id,
			'user' => $user,
		]);{CODE}
!!Logs
Trigger log entries to be created

!!Forward
Forward to another service controller action
{CODE()}
			return array(
				'FORWARD' => array(
					'controller' => 'tracker',
					'action' => 'update_item_status',
					'status' => 'DONE',
					'redirect' => $input->redirect->text(),
				)
			);
{CODE}
!!Redirect
Trigger a redirect to another screen, optionally with a message that will appear on the target screen in a remarksbox
{REMARKSBOX(type="tips" title="Related libs and services" close="n")}
{CODE()}lib/tikiaccesslib.php{CODE}
{CODE()}lib/core/Services/Broker.php{CODE}
{REMARKSBOX}
!!!Redirect to a URL
{CODE()}$accessLib = TikiLib::lib('access');
$accessLib->redirect('tiki-admin.php?page=wiki');{CODE}
!!!Redirect with a message to a URL variable
{CODE()}$accessLib = TikiLib::lib('access');
$accessLib->redirect($return_url, tr('Your comment was posted.'));{CODE}

!!Index update/rebuild
Tigger incremental update or complete rebuild of the unified search index.

{CODE(caption="Sample code" wrap="1" colors="php")}TikiLib::lib('unifiedsearch')->processUpdateQueue();
TikiLib::events()->trigger('tiki.process.redirect'); // wait for indexing to complete before loading of next request to ensure updated info shown{CODE}

!!Feedback
Trigger instant feedback for the user about the success of the action

{CODE()}
In the tpl file add this to the <form> element: class="confirm-action"

In the controller add this return array:
return array(
 'modal' => '1',
 'FORWARD' => array(
  'controller' => 'utilities',
  'action' => 'modal_alert',
  'ajaxtype' => 'feedback',
  'ajaxheading' => tra('Success'),
  'ajaxmsg' => tra('Changes saved'),
  'ajaxdismissible' => 'n',
  'ajaxtimer' => '3',
 )
);
{CODE}
Show PHP error messages