Managing Planet feeds


Functions

 planet__build_user_feeds_table ()
 Fetches all feeds and build an html table for admnistration.
 planet__add_feed ($data)
 Adds a new feed to planet_feeds table.
 planet__update_feed ($data)
 Updates an existing feed in planet_feeds table.
 planet__build_admin_feeds_table ()
 builds an HTML table of feeds for administrator interaction.
 planet_multiple_delete_confirm_submit (&$form_state, $edit)
 TODO.

Function Documentation

planet__add_feed ( data  ) 

Adds a new feed to planet_feeds table.

Parameters:
$data associative array with keys 'uid' (optional), 'title', 'link', 'image' (optional)
Returns:
success status
00380                                  {
00381   $data['checked'] = 0;
00382   $data['frozen']  = 0;
00383   // @DIFFINFO Removed debugging block. Internal function is supposed to receive clean arguments. Checking will be left to planet_feed class
00384 
00385   $rslt = drupal_write_record('planet_feeds', $data);
00386   if ($rslt==SAVED_NEW) {
00387     $title = planet_refresh(intval($data['fid']));
00388     drupal_set_message('Added new feed: ' . $title);    
00389     return TRUE;
00390   }
00391   trigger_error('Failed to add new feed');
00392   return FALSE;
00393 }

Here is the call graph for this function:

Here is the caller graph for this function:

planet__build_admin_feeds_table (  ) 

builds an HTML table of feeds for administrator interaction.

Returns:
00490                                            {
00491   // @DIFFINFO renamed planet__build_feeds_table() {
00492   global $user;
00493   $feeds = db_query('SELECT  fid, title, checked, frozen FROM {planet_feeds} '
00494                     . ' WHERE uid = %d;', $user->uid);
00495   $rows = array();
00496   $headers = array('Feed', 'Items', 'Edit', 'Last checked', 'Refresh', 'Freeze');
00497   $now = time();
00498   $items_statement = 'SELECT count(*) FROM {planet_items} WHERE fid=%d';
00499   // TODO: change this to prepared statement when supported by drupal DB Abstraction Layer.
00500   while ($feed = db_fetch_object($feeds)) {
00501     $_checked = $now - $feed->checked;
00502     $checked = intval($_checked / 60) .' minutes';
00503     if ($_checked % 60 > 0) {
00504       $checked .= ', '. $feed->_checked % 60 .' seconds';
00505     }
00506     $checked .= ' ago';
00507     $items = db_query($items_statement, $feed->fid);
00508     if (!$items) trigger_error('ERROR while counting feed items.');
00509     $cnt = db_result($items);
00510     $fid = strval($feed->fid);
00511     array_push($rows, array(
00512                             $feed->title,
00513                             $cnt,
00514                             l('edit', 'admin/settings/planet/'. $fid),
00515                             $checked,
00516                             l('refresh', 'admin/settings/planet/refresh/'. $fid),
00517                             l($feed->frozen ? 'unfreeze' : 'freeze', 'admin/settings/planet/'. ($feed->frozen ? 'unfreeze/' : 'freeze/') . $fid)          
00518                             )
00519                );
00520   }
00521   return theme('table', $headers, $rows);      
00522 }

Here is the call graph for this function:

Here is the caller graph for this function:

planet__build_user_feeds_table (  ) 

Fetches all feeds and build an html table for admnistration.

See also:
planet__build_admin_feeds_table()
00297                                           {
00298   // @DIFFINFO renamed planet__build_feeds_table1
00299   global $user;
00300       $feeds = db_query('SELECT  fid, title, checked FROM {planet_feeds} '
00301                         . ' WHERE uid = %d;', $user->uid);
00302       $rows = array();
00303       $headers = array('Feed', 'Items', 'Edit', 'Last checked');
00304       $now = time();
00305       $items_statement = 'SELECT count(*) FROM {planet_items}'
00306         . ' WHERE fid=%d';
00307       // TODO: change this to prepared statement when supported by drupal DB abstraction layer.
00308       while ($feed = db_fetch_object($feeds)) {
00309         $_checked = $now - $feed->checked;
00310         $checked = intval($_checked / 60) .' minutes';
00311         if ($_checked % 60 > 0) {
00312           $checked .= ', '. $feed->_checked % 60 .' seconds';
00313         }
00314         $checked .= ' ago';
00315         $items = db_query($items_statement, $feed->fid);
00316         if (!$items) trigger_error('ERROR while counting feed items.');
00317         $cnt = db_result($items);
00318         array_push($rows, array(
00319           $feed->title,
00320           $cnt,
00321           l('edit', 'user/'. $user->uid .'/planet/'. intval($feed->fid)),
00322           $checked,
00323           )
00324         );
00325       }
00326       return theme('table', $headers, $rows);      
00327 }

Here is the call graph for this function:

Here is the caller graph for this function:

planet__update_feed ( data  ) 

Updates an existing feed in planet_feeds table.

Parameters:
$data associative array with keys 'fid' (mandatory, primary key), other fields as needed: 'uid', 'title', 'link', 'image', 'checked', 'frozen'
Returns:
success status
00407                                     {
00408   $rslt = drupal_write_record('planet_feeds', $data, 'fid');
00409 
00410   if ($rslt==SAVED_UPDATED) { 
00411     drupal_set_message('Edited "'. $data['title'] .'" feed.');
00412     return TRUE;
00413   }
00414   if ($rslt==SAVED_NEW) // @DEBUGGING
00415     trigger_error('Feed {$data->fid} didn\'t exist. Record added.', E_ERROR);
00416   else 
00417     trigger_error('Failed to edit feed');
00418   return FALSE;
00419 }      

Here is the call graph for this function:

Here is the caller graph for this function:

planet_multiple_delete_confirm_submit ( &$  form_state,
edit 
)

TODO.

Parameters:
&$form_state 
$edit 
Returns:
DB @CRUD: node[D]

DB @CRUD: planet_items[D]

DB @CRUD: planet_feeds[D]

00571                                                                     {
00572   $fid = $edit['fid'];
00573   if ($edit['confirm']) {
00574     foreach ($edit['nodes'] as $nid => $value) {
00575       node_delete($nid);
00576     }
00577     // @DIFFINFO inverted drop order to respect foreign keys
00578     db_query('DELETE FROM {planet_items} WHERE fid = %d', $fid);
00579     db_query('DELETE FROM {planet_feeds} WHERE fid = %d', $fid);
00580     drupal_set_message(t('The feed and items have been deleted.'));
00581   }
00582   drupal_goto($edit['redirect']);
00583 }

Here is the call graph for this function:


Generated on Tue Mar 24 20:27:25 2009 for ubuntu-drupal by  doxygen 1.5.8