Not logged in. · Lost password · Register
Forum: Support Ideas and suggestions RSS
New hooks
Reply
Reply · Quote jense #1
Member since Nov 2006 · 327 posts · Location: Dortmund
Group memberships: Members
Show profile · Link to this post
Subject: New hooks
Hook: cf.rebuild
Rationale: this allows for 'read-only' entries in the config file;  furthermore, dynamic configuration options are possible where the standard configuration is preserved in the config file (example: parallel use of 'indep_page=[0|1]' designs).
unb_lib/common.lib.php:
  1. @@ -1957,6 +1957,7 @@
  2.         $UNB['ConfigFile']['last_saved_with_version'] = $UNB['Version'];
  3.  
  4.         $nf = $UNB['ConfigFile'];              // new file (array)
  5. +       UnbCallHook('cf.rebuild', $nf);
  6.         $out = '';                    // new file (string)
  7.         $cf = file($conf_filename);   // current config file (array)
  8.         if (!is_array($cf)) return false;

Hook: page.logincontrol
Rationale: the current layout of the login control is static; within the hook function the layout can be entirely changed and the standard output can be suppressed if $params=[true|false], for instance.
unb_lib/common_out.lib.php:
  1. @@ -2471,6 +2472,10 @@
  2.                                 'key' => UnbUrlGetKey());
  3.         }
  4.  
  5. +       UnbCallHook('page.logincontrol', $params);
  6. +       if (!is_array($params))
  7. +               return '';
  8. +
  9.         $out = '';
  10.         if ($UNB['LoginUserID'])
  11.         {

Hook: page.showpath
Rationale: the current layout of the forum path and the thread/post heading is rather static; within the hook function everything can be put into global variables (and moved to other places if one uses a CMS) or redesigned, etc.
unb_lib/common_out.lib.php
  1. @@ -2513,6 +2518,11 @@
  2.  {
  3.         global $ABBC, $UNB, $UNB_T;
  4.  
  5. +       $data = array($id, $threadsubject, $desc, $threadid, $top, $important, (
  6. boolean) $bookmarked);
  7. +       UnbCallHook('page.showpath', $data);
  8. +       if (!is_array($data))
  9. +               return '';
  10. +
  11.         $forum = new IForum();
  12.         $path = '';
  13.         $fdesc = false;   // forum description
The 'return control' is a rather ad-hoc solution that just works (for me).  If there is a better one, I'd happily agree to changes (if they don't slash the functionality, of course ;-) ).  For instance, output of the hook call may be considered to be returned (return $params/$data;).
Alala, Alala, Gimme three wishes - CSS
Avatar
Reply · Quote Yves (Administrator) #2
User title: UNB developer & webmaster
Member since Jan 2004 · 3740 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I have included all three hooks. But for #2 and 3, the return value is checked to be a string, and if so, it is returned. Otherwise nothing happens and the function goes on. So if you want to suppress output at this place, just return and empty string, instead of a non-array.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Reply
Go to forum
This board is powered by the Unclassified NewsBoard software, 20100516-dev, © 2003-10 by Yves Goergen
Page created in 208 ms (164 ms) · 41 database queries in 100 ms
Current time: 2010-07-30, 10:50:27 (UTC +02:00)