[commits] [Wiki] changed: CustomizingPreferences

Jan Schneider jan at horde.org
Thu Nov 23 16:57:22 UTC 2017


jan  Thu, 23 Nov 2017 16:57:22 +0000

Modified page: https://wiki.horde.org/CustomizingPreferences
New Revision:  11
Change log:  Add reference to H3 version; fix formatting

@@ -1,13 +1,14 @@
  [[toc]]
-+ User Contributed Preferences in Horde5
+
++ User Contributed Preferences

  Perhaps the greatest feature of Horde and all of it's modules is the  
flexibility to adapt to a myriad of different uses and I would expect  
that eventually, a more integrated system of managing 'defaults' will  
become part of the code but at this moment in time, the only way to  
effect settings system wide is to edit the various prefs.php file  
inside each module.
-
+
  In general: Add any local changes to a prefs.local.php or a  
prefs.d/<name>,php file. Never change prefs.php because this file is  
overwritten on upgrade and contains vital system information about the  
preferences that must match the other parts of the system. For instance,

  {{kronolith/config/prefs.php}} contains:
-<code type="php">
+<code type="php">
  // Address book(s) to use when expanding addresses ``
  // Refer to turba/config/sources.php for possible source values
  //
  // You can provide default values this way:
@@ -20,15 +21,17 @@
  To change the default value add the following PHP code to either  
{{kronolith/config/prefs.local.php}} or  
{{kronolith/config/prefs.d/**name**.php}} {{name}} can be any name you  
like, I prefer the local hostname:
  <code type="php">
  <?PHP
  $_prefs['search_sources']['value'] = '["favourites"]';
-</code>
-
+</code>
+
  ++ Hooks
-
+
  You can provide default values by hooks, which are little PHP functions.

-Since Horde4 hooks are organized in classes, e.g.  
{{config/hooks.php}} uses {{class Horde_Hooks}}, whereas   
{{kronolith/config/hooks.php}} uses {{class Kronolith_Hooks}}. See  
{{config/hooks.php}} for a description of hooks.
+See CustomizingPreferencesH3 for more ideas for preference hooks.  
Those use the old, no longer supported format from Horde 3, but still  
may provide some starting points for further customizations. If you  
port one of those Hooks to a recent Horde version, please add them here.
+
+Since Horde 4 hooks are organized in classes, e.g.  
{{config/hooks.php}} uses {{class Horde_Hooks}}, whereas   
{{kronolith/config/hooks.php}} uses {{class Kronolith_Hooks}}. See  
{{config/hooks.php}} for a description of hooks.

  For instance to automatically prepare Kronolith's {{search_sources}}  
with all address books the user has access to:

  Enable the hook in the local prefs.php {{kronolith/config/prefs.local.php}}:
@@ -42,22 +45,22 @@
  class Kronolith_Hooks
  {
      public function prefs_init($pref, $value, $username, $scope_ob)
      {
-            if (is_null($username)) {	// not logged in
-                return $value;
-            }
+        if (is_null($username)) {	// not logged in
+            return $value;
+        }

          switch ($pref) {
-         case 'search_sources':	// enable all sources by default
-        	if($value == '') {
-			$sources = $GLOBALS['registry']->call('contacts/sources');
-			$value = json_encode(array_keys($sources));
-			$scope_ob->set($pref, $value);
-			$scope_ob->setDirty($pref, true);
-        	}
-		return $value;
- 	}
+        case 'search_sources':	// enable all sources by default
+            if ($value == '') {
+                $sources = $GLOBALS['registry']->call('contacts/sources');
+                $value = json_encode(array_keys($sources));
+                $scope_ob->set($pref, $value);
+                $scope_ob->setDirty($pref, true);
+            }
+            return $value;
+        }
      }
  }
  </code>




More information about the commits mailing list