Loading...
 

Data Channels

Prerequisite: Profile Developer Documentation

Data channels are "named pipes" which allow one or more profiles to be run at the command of some user or external event. They can be used to:

  • Allow external applications to feed data into tiki
  • Create forms to execute complex actions in tiki
  • Can be called from a wiki plugin.

Data channel profiles use the User Input syntax to transmit information from the request to the profile. Used locally, data channels can be a way to call a set of profiles which all refer to the same user name or some other variables.

Defining a Data Channel

Channels are defined in Admin>Profiles>Advanced tab, using a textbox. Here you will name a wiki page that contains the YAML code for the channel. The format of the textbox is comma delimited, one channel per line. See Administration Interface.

Sample configuration
svn_commit, tiki://local, SvnCommit, Subversion, Admins
create_workspace, tiki://local, WorkspaceConfiguration, ProjectLeads, Admins


The parameters, comma separated, are
  • A unique name composed of alphanumeric characters and underscores
  • A profile domain, usually tiki://local to use local pages as profiles
  • A wiki pagename where the YAML is.
  • One or more groups allowed to execute the channel

The above sample creates two channels. One that will receive commit messages from subversion and save them using the profile located in the local wiki page called SvnCommit. The channel can only be used by administrators for test purposes and users in Subversion (which likely contains a single system user with credentials stored in the SVN plugin). The second one creates a base workspace and is accessible by normal users. A custom form (using the PluginDataChannel ) will be required to use it.

Caution: Channels can use remote profiles, but it is not advisable - you can do a lot of damage if someone has changed the profile since you last looked at it. Unless the remote tiki installation is in a controlled environment, like an intranet configuration repository, remote channels are not recommended.



Editing the Data Channel

Once you have defined the data channel, go to the specified wiki pages and include one or more blocks of YAML code (using the pluginCODE). From here on, it works the same as all other profiles. See Object References for how the profiles share a variable.

Calling Data Channels


You can call a data channel either from a plugin, or via 'yourdomain.com/tiki-channel.php'. The request uses a simple HTTP request to perform the desired task. The file can execute multiple channels simultaneously and will verify that the user can execute them all before executing any of them. Basic authentication will be used for anonymous users if any of the channels require groups other than Anonymous to handle machine requests.

Root keys on GET or POST request:
  • return_uri: Optional URI to return to when processed for end users
  • channels: Mandatory array containing the channels to process. Each element of the array contains:
    • channel_name: Mandatory name of the channel to process
    • Arbitrary keys: Will be sent to the installer as user input

Sample POST request
channels[0][channel_name]=svn_commit&channels[0][version]=16345&channels[0][message]=Sample+Message&channels[1][channel_name]=svn_file_modification&channels[1][version]=16345&channels[1][file]=test.php&channels[2][channel_name]=svn_file_modification&channels[2][version]=16345&channels[1][file]=test2.php&return_uri=/success.php

Example


Suppose you want to create a wiki page but ask the user for the name of the page via a data channel.


Step 1: Define a data channel on your local install in Admin>Profiles>Advanced. Here it is called simply test. Paste the following in the data channels window.
test, tiki://local, DataChannelTest, Admins


Tip: Watch your capitalization. Data Channels are case sensitive.


Step 2: Create the profile (YAML) for the data channel in the wiki page DataChannelTest. Create the page and paste the following, (including the CODE plugin).

{CODE(caption=>YAML)}
objects:
 -
  type: wiki_page
  data:
   name: $profilerequest:page_name$My Personal Page$
   content: xxxxx
{CODE}


Step 3: Create a wiki page with the plugin to summon the data channel.

{DATACHANNEL(channel=test)}
page_name,Give a Page Name
{DATACHANNEL}



  • the result
Image



Related

http://blog.lphuberdeau.com/wordpress/2009/01/25/adding-collaboration-and-durability-to-code-reviews/

Other Examples of uses

Project_Management

Needed profiles

  • A site owner would like that all users that register can create their own image galleries, one public and one private.
  • A company would like to deploy a Time_Sheet for each employee.
    • Employees can only see their own time sheet.
    • Supervisors can see all the Time sheets of employees in their group.

Category: Documentation