[geeklog-cvs] geeklog-1.3/system lib-plugins.php,1.56,1.57 lib-story.php,1.17,1.18 lib-trackback.php,1.4,1.5

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Sat Jan 29 12:52:57 EST 2005


Update of /var/cvs/geeklog-1.3/system
In directory www:/tmp/cvs-serv10468/system

Modified Files:
	lib-plugins.php lib-story.php lib-trackback.php 
Log Message:
Changed plugin API for Trackback / Pingback functions


Index: lib-story.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-story.php,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** lib-story.php	29 Jan 2005 09:02:11 -0000	1.17
--- lib-story.php	29 Jan 2005 17:52:55 -0000	1.18
***************
*** 509,511 ****
--- 509,576 ----
  }
  
+ /**
+ *
+ */
+ function STORY_getItemInfo ($sid, $what)
+ {
+     global $_CONF, $_TABLES;
+ 
+     $properties = explode (',', $what);
+     $fields = array ();
+     foreach ($properties as $p) {
+         switch ($p) {
+             case 'description':
+                 $fields[] = 'introtext';
+                 $fields[] = 'bodytext';
+                 break;
+             case 'excerpt':
+                 $fields[] = 'introtext';
+                 break;
+             case 'title':
+                 $fields[] = 'title';
+                 break;
+             default: // including 'url'
+                 // nothing to do
+                 break;
+         }
+     }
+ 
+     if (count ($fields) > 0) {
+         $result = DB_query ("SELECT " . implode (',', $fields)
+                     . " FROM {$_TABLES['stories']} WHERE sid = '$sid'"
+                     . COM_getPermSql ('AND') . COM_getTopicSql ('AND'));
+         $A = DB_fetchArray ($result);
+     } else {
+         $A = array ();
+     }
+ 
+     $retval = array ();
+     foreach ($properties as $p) {
+         switch ($p) {
+             case 'description':
+                 $retval[] = trim ($A['introtext'] . ' ' . $A['bodytext']);
+                 break;
+             case 'excerpt':
+                 $retval[] = trim ($A['introtext']);
+                 break;
+             case 'title':
+                 $retval[] = stripslashes ($A['title']);
+                 break;
+             case 'url':
+                 $retval[] = COM_buildUrl ($_CONF['site_url']
+                                           . '/article.php?story=' . $sid);
+                 break;
+             default:
+                 $retval[] = ''; // return empty string for unknown properties
+                 break;
+         }
+     }
+ 
+     if (count ($retval) == 1) {
+         $retval = $retval[0];
+     }
+ 
+     return $retval;
+ }
+ 
  ?>

Index: lib-trackback.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-trackback.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** lib-trackback.php	28 Jan 2005 08:38:41 -0000	1.4
--- lib-trackback.php	29 Jan 2005 17:52:55 -0000	1.5
***************
*** 180,184 ****
          }
      } else {
!         $allowed = PLG_handleTrackbackComment ($type, $sid, 'delete');
      }
  
--- 180,184 ----
          }
      } else {
!         $allowed = PLG_handlePingComment ($type, $sid, 'delete');
      }
  

Index: lib-plugins.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-plugins.php,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** lib-plugins.php	28 Jan 2005 23:14:29 -0000	1.56
--- lib-plugins.php	29 Jan 2005 17:52:55 -0000	1.57
***************
*** 1271,1296 ****
  
  /**
! * Ask plugins to handle a trackback comment operation.
! *
! * Operations:
! * 'accept' - does the plugin accept a trackback comment for its entry $id,
! *            returns: true or false
! * 'delete' - does the user have permission to delete comments on entry $id,
! *            returns: true or false
! * 'info'   - plugin is asked to provide information on entry $id,
! *            returns: array (url, title, excerpt)
  *
  * @param    string  $type       plugin type
! * @param    string  $id         ID of an entry under the plugin's control
! * @param    string  $operation  operation to perform
! * @return   mixed               depends on the operation (see above)
  *
  */
! function PLG_handleTrackbackComment ($type, $id, $operation)
  {
      $args[1] = $id;
!     $args[2] = $operation;
  
!     $function = 'plugin_handletrackbackcomment_' . $type;
  
      return PLG_callFunctionForOnePlugin ($function, $args);
--- 1271,1301 ----
  
  /**
! * Ask plugin for information about one of its items
  *
  * @param    string  $type       plugin type
! * @param    string  $id         ID of an item under the plugin's control
! * @param    string  $what       comma-separated list of item properties
! * @return   mixed               string or array of strings with the information
! *
! * Item properties that can be requested:
! * 'url'         - URL of the item
! * 'title'       - title of the item
! * 'excerpt'     - short description of the item
! * 'description' - full description of the item
! *
! * 'excerpt' and 'description' may return the same value. Properties should be
! * returned in the order they are listed in $what. Properties that are not
! * available should return an empty string.
! * Return false for errors (e.g. access denied, item does not exist, etc.).
! *
! * Note: This API function has not been finalized yet ...
  *
  */
! function PLG_getItemInfo ($type, $id, $what)
  {
      $args[1] = $id;
!     $args[2] = $what;
  
!     $function = 'plugin_getiteminfo_' . $type;
  
      return PLG_callFunctionForOnePlugin ($function, $args);
***************
*** 1298,1322 ****
  
  /**
! * Ask plugin if it accepts a pingback for the item at URL $targetURI
! *
! * Pingback only sends the URL of the item it's pinging. Geeklog has determined
! * that the URL belongs to a plugin and is now asking that plugin if it will
! * accept pingbacks for it. The plugin is expected to return a unique ID for
! * the entry if it accepts the ping or an empty string to reject it.
  *
! * Note: This API function is subject to change ...
  *
  * @param    string  $type       plugin type
! * @param    string  $sourceURI  URL the ping came from (FYI only)
! * @param    string  $targetURI  URL being pinged
! * @return   string              ID of the pinged item or empty string = rejected
  *
  */
! function PLG_acceptPingback ($type, $sourceURI, $targetURI)
  {
!     $args[1] = $sourceURI;
!     $args[2] = $targetURI;
  
!     $function = 'plugin_acceptpingback_' . $type;
  
      return PLG_callFunctionForOnePlugin ($function, $args);
--- 1303,1335 ----
  
  /**
! * Geeklog is about to perform an operation on a trackback or pingback comment
! * to one of the items under the plugin's control and asks for the plugin's
! * permission to continue.
  *
! * Geeklog handles receiving and deleting trackback comments and pingbacks
! * for the plugin but since it doesn't know about the plugin's access control,
! * it has to ask the plugin to approve / reject such an operation.
  *
  * @param    string  $type       plugin type
! * @param    string  $id         an ID or URL, depending on the operation
! * @param    string  $operation  operation to perform
! *
! * $operation can be one of the following:
! * 'acceptByID'  - accept a trackback comment on item with ID $id
! *                 returns: true for accept, false for reject
! * 'acceptByURI' - accept a pingback comment on item at URL $id
! *                 returns: the item's ID for accept, false for reject
! * 'delete'      - is the current user allowed to delete item with ID $id?
! *                 returns: true for accept, false for reject
! *
! * Note: This API function has not been finalized yet ...
  *
  */
! function PLG_handlePingComment ($type, $id, $operation)
  {
!     $args[1] = $id;
!     $args[2] = $operation;
  
!     $function = 'plugin_handlepingoperation_' . $type;
  
      return PLG_callFunctionForOnePlugin ($function, $args);




More information about the geeklog-cvs mailing list