Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501
AIEDAM - ZAPSupport-Developers - CustomExtensions

Documentation Support > Developers > CustomExtensions

It's easy to extend ZAP. Here's a brief overview of what you need to know.

Suppose we wanted to create a function that encrypted a CSV list of specified fields. (To encrypt one field you could just use the php command). We'll call this command "crypt".

As the ZAP Engine processes the various fields in $ZAParray, it comes to a section of the code entitled ZAP PLUGIN EXTENSIONS. This section basically checks to see if a function named ZAPX$field is defined. If it is, it calls that function.

To allow you to have multiple instances of a command, it takes a field like crypt_1 and crypt_2 and only checks for the value before the underscore. So if ZAPXcrypt() was defined either of the above would also call it. The $value and $field (only use if you need) are passed to the function in that order.

So to get it to work, just define the appropriate function in either a config file somewhere, or a separate recipe. It will be automatically be called by ZAP. Beautiful. Here's a basic crypt function:

function ZAPXcrypt($value) {
   if ($value == "") return;
   global $m, $ZAParray;
   $c = explode(",", $value);
   foreach($c as $cc) {
      $ZAParray[$cc] = crypt($ZAParray[$cc], "salt");
      $m .= "Field $cc encrypted. ";
      }
   return $value;
   }

You would probably, of course, want to make this a bit more sophisticated--adding conditionals to make sure each array item existed and had some value before calling crypt. Or you might want to take the salt value from some $ZAParray field. Or whatever.

Here are a few functions you might want to make use of:

PmWiki Functions
CondAuth(<pagename>, '<action>') -- used to determine if user has permission to do a certain action on given page
PageTextVar(<pagename>, <field>) -- to retrieve a data value from some page (text variables)

ZAP Functions
ZAPconfig(<field>, <default>) -- to look for a setting on the Site.Config page, if set
ZAPpageshortcuts(<page> -- useful in any function for fixing up page names
ZAPtemplate(<name>) -- to create a template (like page, email) with $$field replacements
ZAPwarning(<message>) -- used to halt processing if some condition fails

Feel free to study the commands in the ZAP toolbox as they give many useful examples. If you come up with an especially good extension, let me know and I'll consider adding it to the toolbox module. Or if you see ways to improve one of the existing extensions, let me know that too. ZAP is under constant development and your feedback is welcome.

Enjoy!