[geeklog-cvs] geeklog-1.3/system lib-plugins.php,1.15,1.16

dhaun at geeklog.net dhaun at geeklog.net
Sun Feb 23 15:45:11 EST 2003


Update of /usr/cvs/geeklog/geeklog-1.3/system
In directory internal.geeklog.net:/tmp/cvs-serv9590/system

Modified Files:
	lib-plugins.php 
Log Message:
Introduced new plugin API functions that let plugins extend the user profile with their own fields and blocks.


Index: lib-plugins.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/system/lib-plugins.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** lib-plugins.php	23 Feb 2003 14:57:12 -0000	1.15
--- lib-plugins.php	23 Feb 2003 20:45:09 -0000	1.16
***************
*** 546,550 ****
  function PLG_getModerationValues($type) 
  {
! 	return PLG_callFunctionForOnePlugin('plugin_moderationvalues_' . $type);
  }
  
--- 546,550 ----
  function PLG_getModerationValues($type) 
  {
!     return PLG_callFunctionForOnePlugin('plugin_moderationvalues_' . $type);
  }
  
***************
*** 554,563 ****
  *
  * @param        string      $type       Plugin to show submission form for
! * @return       string      HTML for submti form for plugin
  *
  */
  function PLG_showSubmitForm($type) 
  {
! 	return PLG_callFunctionForOnePlugin('plugin_submit_' . $type);
  }
  
--- 554,563 ----
  *
  * @param        string      $type       Plugin to show submission form for
! * @return       string      HTML for submit form for plugin
  *
  */
  function PLG_showSubmitForm($type) 
  {
!     return PLG_callFunctionForOnePlugin('plugin_submit_' . $type);
  }
  
***************
*** 627,630 ****
--- 627,749 ----
              $function ($uid);
          }
+     }
+ }
+ 
+ /**
+ * Geeklog is about to display the edit form for the user's profile. Plugins
+ * now get a chance to add their own variables and input fields to the form.
+ *
+ * @param   int   $uid        user id of the user profile to be edited
+ * @param   ref   $template   reference of the Template for the profile edit form
+ *
+ */
+ function PLG_profileVariablesEdit ($uid, &$template)
+ {
+     global $_TABLES;
+ 
+     $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
+     $nrows = DB_numRows($result);
+     for ($i = 1; $i <= $nrows; $i++) {
+         $A = DB_fetchArray($result);
+         $function = 'plugin_profilevariablesedit_' . $A['pi_name'];
+         if (function_exists($function)) {
+             $function ($uid, $template);
+         }
+     }
+ }
+ 
+ /**
+ * Geeklog is about to display the edit form for the user's profile. Plugins
+ * now get a chance to add their own blocks below the standard form.
+ *
+ * @param    int      $uid   user id of the user profile to be edited
+ * @return   string          HTML for additional block(s)
+ *
+ */
+ function PLG_profileBlocksEdit ($uid)
+ {
+     global $_TABLES;
+ 
+     $retval = '';
+ 
+     $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
+     $nrows = DB_numRows($result);
+     for ($i = 1; $i <= $nrows; $i++) {
+         $A = DB_fetchArray($result);
+         $function = 'plugin_profileblocksedit_' . $A['pi_name'];   
+         if (function_exists($function)) {
+             $retval .= $function ($uid);
+         }
+     }
+ 
+     return $retval;
+ }
+ 
+ /**
+ * Geeklog is about to display the user's profile. Plugins now get a chance to
+ * add their own variables to the profile.
+ *
+ * @param   int   $uid        user id of the user profile to be edited
+ * @param   ref   $template   reference of the Template for the profile edit form
+ *
+ */
+ function PLG_profileVariablesDisplay ($uid, &$template)
+ {
+     global $_TABLES;
+ 
+     $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
+     $nrows = DB_numRows($result);
+     for ($i = 1; $i <= $nrows; $i++) {
+         $A = DB_fetchArray($result);
+         $function = 'plugin_profilevariablesdisplay_' . $A['pi_name'];
+         if (function_exists($function)) {
+             $function ($uid, $template);
+         }
+     }
+ }
+ 
+ /**
+ * Geeklog is about to display the user's profile. Plugins now get a chance to
+ * add their own blocks below the standard profile form.
+ *
+ * @param    int      $uid        user id of the user profile to be edited
+ * @return   string               HTML for additional block(s)
+ *
+ */
+ function PLG_profileBlocksDisplay ($uid)
+ {
+     global $_TABLES;
+ 
+     $retval = '';
+ 
+     $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
+     $nrows = DB_numRows($result);
+     for ($i = 1; $i <= $nrows; $i++) {
+         $A = DB_fetchArray($result);
+         $function = 'plugin_profileblocksdisplay_' . $A['pi_name'];
+         if (function_exists($function)) {
+             $retval .= $function ($uid);
+         }
+     }
+ 
+     return $retval;
+ }
+ 
+ /**
+ * The user wants to save changes to his/her profile. Any plugin that added it's
+ * own variables or blocks to the profile input form will now have to extract
+ * it's data and save it.
+ * Plugins will have to refer to the global $HTTP_POST_VARS array to get the
+ * actual data.
+ *
+ * @param   string   $plugin   name of a specific plugin or empty (all plugins)
+ *
+ */
+ function PLG_profileExtrasSave ($plugin = '')
+ {
+     if (empty ($plugin)) {
+         PLG_callFunctionForAllPlugins ('plugin_profileextrassave_');
+     } else {
+         PLG_callFunctionForOnePlugin ('plugin_profileextrassave_' . $plugin);
      }
  }





More information about the geeklog-cvs mailing list