GData Module structure

Events happening in the community are now at Drupal community events on www.drupal.org.
brainless's picture

I have again started re-working on the module since last Saturday (before that I was stuck due to exams). Looking at all options that I am aware of and using my knowledge to the limit (well almost) I have come up with the following structure:

  • The module is almost a ditto of the Atom module when it comes to simple syndication. I have almost copy-pasted the Atom module's code in this place.
  • The remaining aspects are insert, update, delete and search. We handle these in the following ways.
  • GData module creates a hook 'gdata' which any other module uses to enable insert, update, delete.
  • GData module registers the menu gfeed. Since through gdata any module may request to update / insert data, it is natural that there is a common URL for all gdata related stuff.
  • Some example URL paths can be:
    • For insert : URL is like /gfeed/add/blog/12 (Add a new entry to blog number 12).
    • For update : URL is like /gfeed/update/blog/12/2 (Change the 2nd entry of blog number 12).
    • For delete : URL is like /gfeed/delete/blog/12/2 (Delete the 2nd entry of blog number 12).
    • For search : URL is like /gfeed/search/blog/12 (Search the entries of blog number 12).
  • Through the 'gdata' hook, other modules can reqister their URL paths under gfeed. When GData module receives an incoming request, it passes this data to a registered callback function of the module handling the incoming request type (say blog module). Thus the blog module (for example) can now decide what to do with the incoming request.
  • For all insert, update and delete requests, GData will make sure the user is authenticated, according to the authentication mechanism given in GData Protocol detail by Google. Syndication and Search will not be authenticated as such.

Please provide all suggestions. I think there is more discussion needed on this part.

Comments

GData modules gdata hook implementation example

brainless's picture

An example of a module implementing the gdata hook:

<?php
function gdata_gdata($op) {
  switch (
$op) {
    case
"read":
      break;
    case
"write":
      break;
    case
"update":
      break;
    case
"delete":
      break;
    case
"search":
      break;
/<
em>
</
em> Return an array cantaining three elements 'implements', 'path', 'help':
*  
'implements' :: this is an array of the terms :
*    
'read', 'write', 'update', 'delete', 'search', in any order. Each
*     term signifies that, your module implements the feature. The
*     absence of any term means that feature is not implemented.
<
em>
</
em>   'path' :: this is the path under /gfeed/ that you want to handle.
*     Do
NOT register this path with the normal node_menu( ) hook.
*    
Also the administrator may change the path. All that is handled by
*     gdata module. If this is null then the name of module is used.
<
em>
</
em>   'help' :: this is a string which explains what your module does (incase
*      the administrator has forgotten it or is confused :) )
*/
    case
'info':
     
$array = array(
       
'implements' => array('read','write'),
       
'path' => 'gdata_test',
       
'help' => t('This is just a testing of GData hook'),
      );
      break;
  }
  return
$array;
}
?>

Ass things get updated I will add new versions.
Oh and they are available at : http://cvs.drupal.org/viewcvs/drupal/contributions/modules/gdata/

brainless,
Sumit Datta,
brainlessphp.blogspot.com
Web Developer

2007 - April

integrationcreations's picture

Hi,

Is this module still active - how far did it get.

Which gdata apis specifically - calendar/apps for your domain/picasa or the whole gdata set as it appears to be?

Were any subset of the api fully implemented.

Cheers

I don't know if anything

coreb's picture

I don't know if anything practical was implemented with it, but someone's going to try to work with Google Apps this summer. http://groups.drupal.org/node/3609

brainless's picture

The gdata module implements the _settings hook to give the administrator to chose what is done through gdata and what modules get permitted to read/write/update/delete/search through gdata.

This function isnt complete...

<?php
function gdata_settings() {
  if (!
user_access('administer gdata')) {
    die(
drupal_access_denied());
  }
 
//$result = db_query('SELECT * FROM {gdata}');
 
$options = array('read','write','update','delete','search');
 
$modules_array = module_implements('gdata');
  foreach (
$modules_array as $module) {
   
$module_details = module_invoke($module, 'gdata', 'info');
   
$form[$module] = array(
     
'#type' => 'fieldset',
     
'#collapsible' => TRUE,
     
'#collapsed' => TRUE,
     
'#title' => t('Module ').$module,
     
'#description' => $module_details['help'],
    );
   
$form[$module]['implements'] = array(
     
'#type' => 'checkboxes',
     
'#title' => t('What the module implements'),
     
'#options' => $module_details['implements'],
     
'#description' => t('You can set if this module should enable syndicatation, write, update, delete, etc.'),
    );
   
$form[$module]['path'] = array(
     
'#type' => 'textfield',
     
'#title' => t('The path for this module under /gfeed/'),
     
'#default-value' => $module_details['path'],
     
'#description' => t('If you set this is as "blog" for example then external user will be able to access blog module through GData at yoursite.com/gfeed/blog'),
    );
  }

  return
$form;
}
?>

brainless,
Sumit Datta,
brainlessphp.blogspot.com
Web Developer

SoC 2006: GData

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: