changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / feature / xpi0.php
1 <?php
2
3 /*
4    This plugin provides the run-time part of the xpi feature, thus keeping
5    all installed plugins active, if you use it to replace the big xpi.php
6    plugin (the version with the built-in PlugInstall page).
7 */
8
9
10 define("XPI_DB", "system/xpi/registry");
11
12 $ewiki_plugins["handler"][] = "xpi_exec";
13 $ewiki_plugins["init"][] = "xpi_init_plugins";
14
15
16 #-- executes pages with the _EXEC flag set
17 function xpi_exec($id, $data, $action) {
18
19    global $ewiki_id, $ewiki_title, $ewiki_action, $ewiki_data,
20       $ewiki_config, $ewiki_t, $ewiki_plugins, $_EWIKI;
21
22    if ($data["flags"] & EWIKI_DB_F_EXEC) {
23       eval($data["content"]);
24       return($o);
25    }
26 }
27
28
29 #-- runs plugins at init time
30 function xpi_init_plugins() {
31
32    global $ewiki_id, $ewiki_title, $ewiki_action, $ewiki_data,
33       $ewiki_config, $ewiki_t, $ewiki_plugins, $_EWIKI;
34
35    #-- load xpi registry
36    $conf = ewiki_db::GET(XPI_DB);
37    if ($conf && ($conf["flags"] & EWIKI_DB_F_SYSTEM)
38    && ($conf = unserialize($conf["content"]))) {
39
40       #-- collect xpi code, execute it
41       $eval_this = "";
42       foreach ($conf as $xpi) {
43          if ($xpi["state"] && ($xpi["type"] != "page")) {
44             $d = ewiki_db::GET($xpi["id"]);
45             if ($d && ($d["flags"] & EWIKI_DB_F_EXEC)) {
46                $eval_this .= $d["content"];
47             }
48          }
49       }
50       eval($eval_this);
51    }
52 }
53
54
55 ?>