Highway to PSR2
[openemr.git] / interface / main / calendar / includes / pnMod.php
blobec8a6473f5b05a6d84e9543ff5c721e251e2d9c7
1 <?php
2 // $Id$
3 // ----------------------------------------------------------------------
4 // POST-NUKE Content Management System
5 // Copyright (C) 2001 by the Post-Nuke Development Team.
6 // http://www.postnuke.com/
7 // ----------------------------------------------------------------------
8 // Based on:
9 // PHP-NUKE Web Portal System - http://phpnuke.org/
10 // Thatware - http://thatware.org/
11 // ----------------------------------------------------------------------
12 // LICENSE
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License (GPL)
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
24 // To read the license please visit http://www.gnu.org/copyleft/gpl.html
25 // ----------------------------------------------------------------------
26 // Original Author of file: Jim McDonald
27 // Purpose of file: Module variable handling
28 // ----------------------------------------------------------------------
31 * pnModGetVar - get a module variable
32 * Takes two parameters:
33 * - the name of the module
34 * - the name of the variable
36 function pnModGetVar($modname, $name)
38 if ((empty($modname)) || (empty($name))) {
39 return false;
42 global $pnmodvar;
43 if (isset($pnmodvar[$modname][$name])) {
44 return $pnmodvar[$modname][$name];
47 list($dbconn) = pnDBGetConn();
48 $pntable = pnDBGetTables();
50 $modulevarstable = $pntable['module_vars'];
51 $modulevarscolumn = &$pntable['module_vars_column'];
52 $query = "SELECT $modulevarscolumn[value]
53 FROM $modulevarstable
54 WHERE $modulevarscolumn[modname] = '" . pnVarPrepForStore($modname) . "'
55 AND $modulevarscolumn[name] = '" . pnVarPrepForStore($name) . "'";
56 $result = $dbconn->Execute($query);
58 if ($dbconn->ErrorNo() != 0) {
59 return;
62 if ($result->EOF) {
63 $pnmodvar[$modname][$name] = false;
64 return;
67 list($value) = $result->fields;
68 $result->Close();
70 $pnmodvar[$modname][$name] = $value;
71 return $value;
75 * pnModSetVar - set a module variable
76 * Takes three parameters:
77 * - the name of the module
78 * - the name of the variable
79 * - the value of the variable
81 function pnModSetVar($modname, $name, $value)
83 if ((empty($modname)) || (empty($name))) {
84 return false;
87 list($dbconn) = pnDBGetConn();
88 $pntable = pnDBGetTables();
90 $curvar = pnModGetVar($modname, $name);
92 $modulevarstable = $pntable['module_vars'];
93 $modulevarscolumn = &$pntable['module_vars_column'];
94 if (!isset($curvar)) {
95 $query = "INSERT INTO $modulevarstable
96 ($modulevarscolumn[modname],
97 $modulevarscolumn[name],
98 $modulevarscolumn[value])
99 VALUES
100 ('" . pnVarPrepForStore($modname) . "',
101 '" . pnVarPrepForStore($name) . "',
102 '" . pnVarPrepForStore($value) . "');";
103 } else {
104 $query = "UPDATE $modulevarstable
105 SET $modulevarscolumn[value] = '" . pnVarPrepForStore($value) . "'
106 WHERE $modulevarscolumn[modname] = '" . pnVarPrepForStore($modname) . "'
107 AND $modulevarscolumn[name] = '" . pnVarPrepForStore($name) . "'";
110 $dbconn->Execute($query);
112 if ($dbconn->ErrorNo() != 0) {
113 return;
116 global $pnmodvar;
117 $pnmodvar[$modname][$name] = $value;
118 return true;
123 * pnModDelVar - delete a module variable
124 * Takes two parameters:
125 * - the name of the module
126 * - the name of the variable
128 function pnModDelVar($modname, $name)
130 if ((empty($modname)) || (empty($name))) {
131 return false;
134 list($dbconn) = pnDBGetConn();
135 $pntable = pnDBGetTables();
137 $modulevarstable = $pntable['module_vars'];
138 $modulevarscolumn = &$pntable['module_vars_column'];
139 $query = "DELETE FROM $modulevarstable
140 WHERE $modulevarscolumn[modname] = '" . pnVarPrepForStore($modname) . "'
141 AND $modulevarscolumn[name] = '" . pnVarPrepForStore($name) . "'";
142 $dbconn->Execute($query);
144 if ($dbconn->ErrorNo() != 0) {
145 return;
148 global $pnmodvar;
149 if (isset($pnmodvar[$modname][$name])) {
150 unset($pnmodvar[$modname][$name]);
153 return true;
157 * pnModGetIDFromName - get module ID given its name
158 * Takes one parameter:
159 * - the name of the module
161 function pnModGetIDFromName($module)
163 if (empty($module)) {
164 return false;
167 static $modid = array();
168 if (isset($modid[$module])) {
169 return $modid[$module];
172 list($dbconn) = pnDBGetConn();
173 $pntable = pnDBGetTables();
175 $modulestable = $pntable['modules'];
176 $modulescolumn = &$pntable['modules_column'];
177 $query = "SELECT $modulescolumn[id]
178 FROM $modulestable
179 WHERE $modulescolumn[name] = '" . pnVarPrepForStore($module) . "'";
180 $result = $dbconn->Execute($query);
182 if ($dbconn->ErrorNo() != 0) {
183 return;
186 if ($result->EOF) {
187 $modid[$module] = false;
188 return false;
191 list($id) = $result->fields;
192 $result->Close();
194 $modid[$module] = $id;
195 return $id;
199 * get information on module
200 * @param id
201 * @returns array
202 * @ return array of module information or false if core ( id = 0 )
204 function pnModGetInfo($modid)
206 // a $modid of 0 is associated with core ( pn_blocks.mid, ... ).
207 if ($modid == 0) {
208 return false;
211 static $modinfo = array();
212 if (isset($modinfo[$modid])) {
213 return $modinfo[$modid];
216 list($dbconn) = pnDBGetConn();
217 $pntable = pnDBGetTables();
219 $modulestable = $pntable['modules'];
220 $modulescolumn = &$pntable['modules_column'];
221 $query = "SELECT $modulescolumn[name],
222 $modulescolumn[type],
223 $modulescolumn[directory],
224 $modulescolumn[regid],
225 $modulescolumn[displayname],
226 $modulescolumn[description],
227 $modulescolumn[version]
228 FROM $modulestable
229 WHERE $modulescolumn[id] = " . pnVarPrepForStore($modid);
230 $result = $dbconn->Execute($query);
232 if ($dbconn->ErrorNo() != 0) {
233 return;
236 if ($result->EOF) {
237 $modinfo[$modid] = false;
238 return false;
241 list($resarray['name'],
242 $resarray['type'],
243 $resarray['directory'],
244 $resarray['regid'],
245 $resarray['displayname'],
246 $resarray['description'],
247 $resarray['version']) = $result->fields;
248 $result->Close();
250 $modinfo[$modid] = $resarray;
251 return $resarray;
255 * get list of user modules
256 * @returns array
257 * @return array of module information arrays
259 function pnModGetUserMods()
261 list($dbconn) = pnDBGetConn();
262 $pntable = pnDBGetTables();
264 $modulestable = $pntable['modules'];
265 $modulescolumn = &$pntable['modules_column'];
266 $query = "SELECT $modulescolumn[name],
267 $modulescolumn[type],
268 $modulescolumn[directory],
269 $modulescolumn[regid],
270 $modulescolumn[displayname],
271 $modulescolumn[description],
272 $modulescolumn[version]
273 FROM $modulestable
274 WHERE $modulescolumn[state] = " . _PNMODULE_STATE_ACTIVE . "
275 AND $modulescolumn[user_capable] = 1
276 ORDER BY $modulescolumn[name]";
277 $result = $dbconn->Execute($query);
279 if ($dbconn->ErrorNo() != 0) {
280 return;
283 if ($result->EOF) {
284 return false;
287 $resarray = array();
288 while (list($name,
289 $modtype,
290 $directory,
291 $regid,
292 $displayname,
293 $description,
294 $version) = $result->fields) {
295 $result->MoveNext();
297 $tmparray = array('name' => $name,
298 'type' => $modtype,
299 'directory' => $directory,
300 'regid' => $regid,
301 'displayname' => $displayname,
302 'description' => $description,
303 'version' => $version);
305 array_push($resarray, $tmparray);
308 $result->Close();
310 return $resarray;
314 * get list of administration modules
315 * @returns array
316 * @return array of module information arrays
318 function pnModGetAdminMods()
320 list($dbconn) = pnDBGetConn();
321 $pntable = pnDBGetTables();
323 $modulestable = $pntable['modules'];
324 $modulescolumn = &$pntable['modules_column'];
326 $query = "SELECT $modulescolumn[name],
327 $modulescolumn[type],
328 $modulescolumn[directory],
329 $modulescolumn[regid],
330 $modulescolumn[displayname],
331 $modulescolumn[description],
332 $modulescolumn[version]
333 FROM $modulestable
334 WHERE $modulescolumn[state] = " . _PNMODULE_STATE_ACTIVE . "
335 AND $modulescolumn[admin_capable] = 1
336 AND $modulescolumn[directory] != 'NS-Admin'
337 ORDER BY $modulescolumn[name]";
339 $result = $dbconn->Execute($query);
341 if ($dbconn->ErrorNo() != 0) {
342 return;
345 if ($result->EOF) {
346 return false;
349 $resarray = array();
350 while (list($name,
351 $modtype,
352 $directory,
353 $regid,
354 $displayname,
355 $description,
356 $version) = $result->fields) {
357 $result->MoveNext();
359 $tmparray = array('name' => $name,
360 'type' => $modtype,
361 'directory' => $directory,
362 'regid' => $regid,
363 'displayname' => $displayname,
364 'description' => $description,
365 'version' => $version);
367 array_push($resarray, $tmparray);
370 $result->Close();
372 return $resarray;
376 * load an API for a module
377 * @param modname - registered name of the module
378 * @param type - type of functions to load
379 * @returns bool
380 * @return true on success, false on failure
382 function pnModAPILoad($modname, $type = 'user')
384 static $loaded = array();
386 if (empty($modname)) {
387 return false;
390 list($dbconn) = pnDBGetConn();
391 $pntable = pnDBGetTables();
393 if (!empty($loaded["$modname$type"])) {
394 // Already loaded from somewhere else
395 return true;
398 $modulestable = $pntable['modules'];
399 $modulescolumn = &$pntable['modules_column'];
400 $query = "SELECT $modulescolumn[name],
401 $modulescolumn[directory],
402 $modulescolumn[state]
403 FROM $modulestable
404 WHERE $modulescolumn[name] = '" . pnVarPrepForStore($modname) . "'";
405 $result = $dbconn->Execute($query);
407 if ($dbconn->ErrorNo() != 0) {
408 return;
411 if ($result->EOF) {
412 pnSessionSetVar('errmsg', "Unknown module $modname");
413 return false;
416 list($name, $directory, $state) = $result->fields;
417 $result->Close();
419 list($osdirectory, $ostype) = pnVarPrepForOS($directory, $type);
421 $osfile = "modules/$osdirectory/pn{$ostype}api.php";
422 if (!file_exists($osfile)) {
423 // File does not exist
424 return false;
427 // Load the file
428 include $osfile;
429 $loaded["$modname$type"] = 1;
431 // Load the module language files
432 $currentlang = pnUserGetLang();
433 $defaultlang = pnConfigGetVar('language');
434 if (empty($defaultlang)) {
435 $defaultlang = 'eng';
438 list($oscurrentlang, $osdefaultlang) = pnVarPrepForOS($currentlang, $defaultlang);
439 if (file_exists("modules/$osdirectory/pnlang/$oscurrentlang/{$ostype}api.php")) {
440 include "modules/$osdirectory/pnlang/$oscurrentlang/{$ostype}api.php";
441 } elseif (file_exists("modules/$osdirectory/pnlang/$osdefaultlang/{$ostype}api.php")) {
442 include "modules/$osdirectory/pnlang/$osdefaultlang/{$ostype}api.php";
445 // Load datbase info
446 pnModDBInfoLoad($modname, $directory);
448 return true;
452 * load datbase definition for a module
453 * @param name - name of module to load database definition for
454 * @param directory - directory that module is in (if known)
455 * @returns bool
457 function pnModDBInfoLoad($modname, $directory = '')
459 static $loaded = array();
461 // Check to ensure we aren't doing this twice
462 if (isset($loaded[$modname])) {
463 return true;
466 // Get the directory if we don't already have it
467 if (empty($directory)) {
468 list($dbconn) = pnDBGetConn();
469 $pntable = pnDBGetTables();
470 $modulestable = $pntable['modules'];
471 $modulescolumn = &$pntable['modules_column'];
472 $sql = "SELECT $modulescolumn[directory]
473 FROM $modulestable
474 WHERE $modulescolumn[name] = '" . pnVarPrepForStore($modname) . "'";
475 $result = $dbconn->Execute($sql);
476 if ($dbconn->ErrorNo() != 0) {
477 return;
480 if ($result->EOF) {
481 return false;
484 $directory = $result->fields[0];
485 $result->Close();
488 // Load the database definition if required
489 $ospntablefile = 'modules/' . pnVarPrepForOS($directory) . '/pntables.php';
490 // Ignore errors for this, if it fails we'll find out and handle
491 // it when we look for the function itself
492 @include_once $ospntablefile;
493 $tablefunc = $modname . '_' . 'pntables';
494 if (function_exists($tablefunc)) {
495 global $pntable;
496 $pntable = array_merge($pntable, $tablefunc());
499 $loaded[$modname] = true;
501 return true;
505 * load a module
506 * @param name - name of module to load
507 * @param type - type of functions to load
508 * @returns string
509 * @return name of module loaded, or false on failure
511 function pnModLoad($modname, $type = 'user')
513 static $loaded = array();
515 if (empty($modname)) {
516 return false;
519 list($dbconn) = pnDBGetConn();
520 $pntable = pnDBGetTables();
522 $modulestable = $pntable['modules'];
523 $modulescolumn = &$pntable['modules_column'];
525 if (!empty($loaded["$modname$type"])) {
526 // Already loaded from somewhere else
527 return $modname;
530 $query = "SELECT $modulescolumn[directory],
531 $modulescolumn[state]
532 FROM $modulestable
533 WHERE $modulescolumn[name] = '" . pnVarPrepForStore($modname) . "'";
534 $result = $dbconn->Execute($query);
536 if ($dbconn->ErrorNo() != 0) {
537 return;
540 if ($result->EOF) {
541 return false;
544 list($directory, $state) = $result->fields;
545 $result->Close();
547 // Load the module and module language files
548 list($osdirectory, $ostype) = pnVarPrepForOS($directory, $type);
549 $osfile = "modules/$osdirectory/pn$ostype.php";
551 if (!file_exists($osfile)) {
552 // File does not exist
553 return false;
556 // Load file
557 include $osfile;
558 $loaded["$modname$type"] = 1;
560 $defaultlang = pnConfigGetVar('language');
561 if (empty($defaultlang)) {
562 $defaultlang = 'eng';
565 $currentlang = pnUserGetLang();
566 if (file_exists("modules/$osdirectory/pnlang/$currentlang/$ostype.php")) {
567 include "modules/$osdirectory/pnlang/" . pnVarPrepForOS($currentlang) . "/$ostype.php";
568 } elseif (file_exists("modules/$directory/pnlang/$defaultlang/$ostype.php")) {
569 include "modules/$osdirectory/pnlang/" . pnVarPrepForOS($defaultlang) . "/$ostype.php";
572 // Load datbase info
573 pnModDBInfoLoad($modname, $directory);
575 // Return the module name
576 return $modname;
580 * run a module API function
581 * @param modname - registered name of module
582 * @param type - type of function to run
583 * @param func - specific function to run
584 * @param args - arguments to pass to the function
585 * @returns mixed
587 function pnModAPIFunc($modname, $type = 'user', $func = 'main', $args = array())
590 if (empty($modname)) {
591 return false;
594 if (empty($type)) {
595 $func = 'user';
598 if (empty($func)) {
599 $func = 'main';
602 // Build function name and call function
603 $modapifunc = "{$modname}_{$type}api_{$func}";
604 if (function_exists($modapifunc)) {
605 return $modapifunc($args);
608 return false;
612 * run a module function
613 * @param modname - registered name of module
614 * @param type - type of function to run
615 * @param func - specific function to run
616 * @param args - argument array
617 * @returns mixed
619 function pnModFunc($modname, $type = 'user', $func = 'main', $args = array())
622 if (empty($modname)) {
623 return false;
626 if (empty($type)) {
627 $func = 'user';
630 if (empty($func)) {
631 $func = 'main';
634 // Build function name and call function
635 $modfunc = "{$modname}_{$type}_{$func}";
636 if (function_exists($modfunc)) {
637 return $modfunc($args);
640 return false;
644 * generate a module function URL
645 * @param modname - registered name of module
646 * @param type - type of function
647 * @param func - module function
648 * @param args - array of arguments to put on the URL
649 * @returns string
650 * @return absolute URL for call
652 function pnModURL($modname, $type = 'user', $func = 'main', $args = array(), $path = '')
654 if (empty($modname)) {
655 return false;
658 global $HTTP_SERVER_VARS;
660 // Hostname
661 $host = $HTTP_SERVER_VARS['HTTP_HOST'];
662 if (empty($host)) {
663 $host = getenv('HTTP_HOST');
664 if (empty($host)) {
665 return false;
669 // The arguments
670 $urlargs[] = "module=$modname";
671 if ((!empty($type)) && ($type != 'user')) {
672 $urlargs[] = "type=$type";
675 if ((!empty($func)) && ($func != 'main')) {
676 $urlargs[] = "func=$func";
679 $urlargs = join('&', $urlargs);
680 $url = "index.php?$urlargs";
683 // <rabbitt> added array check on args
684 // April 11, 2003
685 if (!is_array($args)) {
686 return false;
687 } else {
688 foreach ($args as $k => $v) {
689 if (is_array($v)) {
690 foreach ($v as $l => $w) {
691 $url .= "&$k" . "[$l]=$w";
693 } else {
694 $url .= "&$k=$v";
699 //remove characters not belonging in a path, prevent possible injection
700 //this may break windows path accesses?
701 $path = preg_replace("/[^\.\/a-zA-Z0-9]/", "", $path)
703 // The URL
704 $final_url = pnGetBaseURL() . $path . $url;
705 return $final_url;
709 * see if a module is available
710 * @returns bool
711 * @return true if the module is available, false if not
713 function pnModAvailable($modname)
715 if (empty($modname)) {
716 return false;
719 static $modstate = array();
720 if (isset($modstate[$modname])) {
721 if ($modstate[$modname] == _PNMODULE_STATE_ACTIVE) {
722 return true;
723 } else {
724 return false;
728 list($dbconn) = pnDBGetConn();
729 $pntable = pnDBGetTables();
731 $modulestable = $pntable['modules'];
732 $modulescolumn = &$pntable['modules_column'];
733 $query = "SELECT $modulescolumn[state]
734 FROM $modulestable
735 WHERE $modulescolumn[name] = '" . pnVarPrepForStore($modname) . "'";
736 $result = $dbconn->Execute($query);
738 if ($dbconn->ErrorNo() != 0) {
739 return;
742 if ($result->EOF) {
743 $modstate[$modname] = _PNMODULE_STATE_MISSING;
744 return false;
747 list($state) = $result->fields;
748 $result->Close();
750 $modstate[$modname] = $state;
751 if ($state == _PNMODULE_STATE_ACTIVE) {
752 return true;
753 } else {
754 return false;
759 * get name of current top-level module
760 * @returns string
761 * @return the name of the current top-level module, false if not in a module
763 function pnModGetName()
765 $modname = pnVarCleanFromInput('module');
766 if (empty($modname)) {
767 $name = pnVarCleanFromInput('name');
768 if (empty($name)) {
769 global $ModName;
770 if (empty($ModName)) {
771 return false;
774 $modname = preg_replace('/^NS-/', '', $ModName);
775 return $modname;
778 return $name;
779 } else {
780 $modname = preg_replace('/^NS-/', '', $modname);
781 return $modname;
786 * register a hook function
787 * @param hookobject the hook object
788 * @param hookaction the hook action
789 * @param hookarea the area of the hook (either 'GUI' or 'API')
790 * @param hookmodule name of the hook module
791 * @param hooktype name of the hook type
792 * @param hookfunc name of the hook function
794 function pnModRegisterHook(
795 $hookobject,
796 $hookaction,
797 $hookarea,
798 $hookmodule,
799 $hooktype,
800 $hookfunc
804 // Get database info
805 list($dbconn) = pnDBGetConn();
806 $pntable = pnDBGetTables();
807 $hookstable = $pntable['hooks'];
808 $hookscolumn = &$pntable['hooks_column'];
810 // Insert hook
811 $sql = "INSERT INTO $hookstable (
812 $hookscolumn[id],
813 $hookscolumn[object],
814 $hookscolumn[action],
815 $hookscolumn[tarea],
816 $hookscolumn[tmodule],
817 $hookscolumn[ttype],
818 $hookscolumn[tfunc])
819 VALUES (
820 " . pnVarPrepForStore($dbconn->GenId($hookstable)) . ",
821 '" . pnVarPrepForStore($hookobject) . "',
822 '" . pnVarPrepForStore($hookaction) . "',
823 '" . pnVarPrepForStore($hookarea) . "',
824 '" . pnVarPrepForStore($hookmodule) . "',
825 '" . pnVarPrepForStore($hooktype) . "',
826 '" . pnVarPrepForStore($hookfunc) . "')";
827 $dbconn->Execute($sql);
829 if ($dbconn->ErrorNo() != 0) {
830 return false;
833 return true;
837 * unregister a hook function
838 * @param hookobject the hook object
839 * @param hookaction the hook action
840 * @param hookarea the area of the hook (either 'GUI' or 'API')
841 * @param hookmodule name of the hook module
842 * @param hooktype name of the hook type
843 * @param hookfunc name of the hook function
845 function pnModUnregisterHook(
846 $hookobject,
847 $hookaction,
848 $hookarea,
849 $hookmodule,
850 $hooktype,
851 $hookfunc
855 // Get database info
856 list($dbconn) = pnDBGetConn();
857 $pntable = pnDBGetTables();
858 $hookstable = $pntable['hooks'];
859 $hookscolumn = &$pntable['hooks_column'];
861 // Remove hook
862 $sql = "DELETE FROM $hookstable
863 WHERE $hookscolumn[object] = '" . pnVarPrepForStore($hookobject) . "'
864 AND $hookscolumn[action] = '" . pnVarPrepForStore($hookaction) . "'
865 AND $hookscolumn[tarea] = '" . pnVarPrepForStore($hookarea) . "'
866 AND $hookscolumn[tmodule] = '" . pnVarPrepForStore($hookmodule) . "'
867 AND $hookscolumn[ttype] = '" . pnVarPrepForStore($hooktype) . "'
868 AND $hookscolumn[tfunc] = '" . pnVarPrepForStore($hookfunc) . "'";
869 $dbconn->Execute($sql);
871 if ($dbconn->ErrorNo() != 0) {
872 return false;
875 return true;
879 * carry out hook operations for module
880 * @param hookobject the object the hook is called for - either 'item' or 'category'
881 * @param hookaction the action the hook is called for - one of 'create', 'delete', 'transform', or 'display'
882 * @param hookid the id of the object the hook is called for (module-specific)
883 * @param extrainfo extra information for the hook, dependent on hookaction
884 * @returns string
885 * @return output from hooks
887 function pnModCallHooks($hookobject, $hookaction, $hookid, $extrainfo)
890 // Get database info
891 list($dbconn) = pnDBGetConn();
892 $pntable = pnDBGetTables();
893 $hookstable = $pntable['hooks'];
894 $hookscolumn = &$pntable['hooks_column'];
896 // Get applicable hooks
897 $sql = "SELECT $hookscolumn[tarea],
898 $hookscolumn[tmodule],
899 $hookscolumn[ttype],
900 $hookscolumn[tfunc]
901 FROM $hookstable
902 WHERE $hookscolumn[smodule] = '" . pnVarPrepForStore(pnModGetName()) . "'
903 AND $hookscolumn[object] = '" . pnVarPrepForStore($hookobject) . "'
904 AND $hookscolumn[action] = '" . pnVarPrepForStore($hookaction) . "'";
905 $result = $dbconn->Execute($sql);
907 if ($dbconn->ErrorNo() != 0) {
908 return null;
911 $output = '';
913 // Call each hook
914 for (; !$result->EOF; $result->MoveNext()) {
915 list($hookarea, $hookmodule, $hooktype, $hookfunc) = $result->fields;
916 if ($hookarea == 'GUI') {
917 if (pnModAvailable($hookmodule, $hooktype) &&
918 pnModLoad($hookmodule, $hooktype)) {
919 $output .= pnModFunc(
920 $hookmodule,
921 $hooktype,
922 $hookfunc,
923 array('objectid' => $hookid,
924 'extrainfo' => $extrainfo)
927 } else {
928 if (pnModAvailable($hookmodule, $hooktype) &&
929 pnModAPILoad($hookmodule, $hooktype)) {
930 $extrainfo = pnModAPIFunc(
931 $hookmodule,
932 $hooktype,
933 $hookfunc,
934 array('objectid' => $hookid,
935 'extrainfo' => $extrainfo)
941 if ($hookaction == 'display') {
942 return $output;
943 } else {
944 return $extrainfo;