2ac4df084fa97871ee823f5d76f0eb102d53850b
[atutor.git] / mods / wiki / plugins / lib / save_storevars.php
1 <?php
2
3 /*
4    This plugin automatically stores global variables into a
5    pages {meta} field, if they is saved after editing.
6
7    In the following configuration array you can define which variable
8    is to be stored with which name into the {meta} field.
9 */
10
11 #-- which vars to store:
12 $ewiki_config["save_storevars"] = array(
13 #   "global_var" => "meta_field_name",
14 #   "icon" => "icon",
15 #   "counter" => "X-Hit-Counter",
16 );
17
18
19 #-- glue
20 $ewiki_plugins["edit_save"][] = "ewiki_edit_save_storevars";
21
22
23 #-- implementation
24 function ewiki_edit_save_storevars(&$save, &$old_data) {
25
26    global $ewiki_config;
27
28    foreach ($ewiki_config["save_storevars"] as $globalname => $metaname) {
29       if ($value = &$GLOBALS[$globalname]) {
30          $save["meta"][$metaname] = $value;
31       }
32    }
33 }
34
35 ?>