Index: modules/ff1/ff1.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ff1/ff1.module,v retrieving revision 1.5 diff -u -r1.5 ff1.module --- modules/ff1/ff1.module 15 Feb 2008 15:46:26 -0000 1.5 +++ modules/ff1/ff1.module 24 Mar 2009 23:21:40 -0000 @@ -1016,7 +1016,7 @@ break; } $breadcrumb[] = array('path' => 'node/'. $node->nid); - menu_set_location($breadcrumb); + menu_set_location($breadcrumb); } $node = node_prepare($node, $teaser); $content_type = drupal_substr($node->type, 3); @@ -1048,19 +1048,19 @@ } } // function ff1_user -/** - * Implementation of hook_block(). - * - * This hook both declares to Drupal what blocks are provided by the module, and - * generates the contents of the blocks themselves. - */ +/** + * Implementation of hook_block(). + * + * This hook both declares to Drupal what blocks are provided by the module, and + * generates the contents of the blocks themselves. + */ function ff1_block($op = 'list', $delta = 0) { global $user; - // The $op parameter determines what piece of information is being requested. - if ($op == 'list') { - // If $op is "list", we just need to return a list of block descriptions. This - // is used to provide a list of possible blocks to the administrator. + // The $op parameter determines what piece of information is being requested. + if ($op == 'list') { + // If $op is "list", we just need to return a list of block descriptions. This + // is used to provide a list of possible blocks to the administrator. $blocks[0] = array( 'info' => t('League table for \'Main Public League\''), 'weight' => 10, @@ -1099,16 +1099,16 @@ ); } return $blocks; - } - else if ($op == 'view') { - // If $op is "view", then we need to generate the block for display purposes. - // The $delta parameter tells us which block is being requested. + } + else if ($op == 'view') { + // If $op is "view", then we need to generate the block for display purposes. + // The $delta parameter tells us which block is being requested. if ($delta == 0) { // The subject is displayed at the top of the block. Note that it should - // be passed through t() for translation. + // be passed through t() for translation. $block['subject'] = t('Main Public League'); - // The content of the block is typically generated by calling a custom - // function. + // The content of the block is typically generated by calling a custom + // function. $block['content'] = ff1_block_contents(0); //break; } @@ -1116,14 +1116,14 @@ $block['subject'] = db_result(db_query("SELECT league_name FROM {ff1_leagues} WHERE nid = %d", $delta)); $block['content'] = ff1_block_contents($delta); //break; - } - return $block; - } + } + return $block; + } } // function ff1_block -/** - * A block content function. - */ +/** + * A block content function. + */ function ff1_block_contents($which_block) { if ($which_block == 0) { // return the league table for the Main Public League @@ -1177,12 +1177,12 @@ * Custom function to add/delete a relationship between ff1 nodes. */ function ff1_relationship($op = 'create', $nid, $child_nid, $relationship = NULL) { - // Make sure you don't trust the URL to be safe! Always check for exploits. + // Make sure you don't trust the URL to be safe! Always check for exploits. if (!is_numeric($nid) || !is_numeric($child_nid)) { - // We will just show a standard "access denied" page in this case. - drupal_access_denied(); - return; - } + // We will just show a standard "access denied" page in this case. + drupal_access_denied(); + return; + } if ($op == 'create') { db_query("INSERT INTO {ff1_relationships} (nid, child_nid, rel_type) VALUES (%d, '%d', '%s')", $nid, $child_nid, $relationship); @@ -1320,7 +1320,7 @@ /** * A function to update the database with the selected results. - */ + */ function _ff1_update_results_db($race, $last_race) { $tiebreaker = variable_get('ff1_tiebreaker', 0); // update ff1_component_scores with the drivers points @@ -1686,10 +1686,10 @@ } } // function ff1_cron -/** +/** * A function to send an email to all users who have a team * notifying them that the results have been updated. - */ + */ function ff1_send_email($race) { global $base_url; // Get common information @@ -1743,12 +1743,19 @@ // Put all the variables into the message body. $message_send = strtr($message, $variables); - //send the message - if (drupal_mail($mailkey, $recipient, $subject, $message_send, $headers )) { - $sent_count++; + if (function_exists('job_queue_add') { + // Queue the message + job_queue_add('drupal_mail', 'Fantasy F1 update email', array($mailkey, $recipient, $subject, $message_send, $headers ), '', TRUE); + $queued_count++; } else { - $unsent_count++; + //send the message + if (drupal_mail($mailkey, $recipient, $subject, $message_send, $headers )) { + $sent_count++; + } + else { + $unsent_count++; + } } } // add message to watchdog log @@ -1758,6 +1765,7 @@ else { watchdog('ff1', t('%unsent_count emails failed to be sent.', array('%unsent_count' => $unsent_count))); } + watchdog('ff1', t('%queued_count emails queued successfully.', array('%queued_count' => $queued_count))); watchdog('ff1', t('%sent_count emails sent successfully.', array('%sent_count' => $sent_count))); } // function ff1_send_email @@ -2311,11 +2319,11 @@ // Set the limit of teams to be returned per page $limit = 50; - // Make sure you don't trust the URL to be safe! Always check for exploits. + // Make sure you don't trust the URL to be safe! Always check for exploits. if (!is_numeric($nid)) { - // We will just show a standard "access denied" page in this case. - drupal_access_denied(); - return; + // We will just show a standard "access denied" page in this case. + drupal_access_denied(); + return; } elseif ($nid == 0) { drupal_set_title(t('League table for \'Main Public League\'')); @@ -2602,7 +2610,7 @@ // Set the limit of teams to be returned per page $limit = 500; - // Make sure you don't trust the URL to be safe! Always check for exploits. + // Make sure you don't trust the URL to be safe! Always check for exploits. if (!is_numeric($nid)) { // We will not show a standard "access denied" page in this case. $output .= "document.write('