--- multiping.install 2008-03-31 22:53:46.000000000 +0100 +++ multiping.install 2009-08-06 08:22:12.000000000 +0100 @@ -1,64 +1,97 @@ array( - 'id' => array('type'=>'serial', 'unsigned'=>TRUE, 'not null'=>TRUE), - 'name' => array('type'=>'varchar', 'length'=>100, 'not null'=>TRUE), - 'url' => array('type'=>'varchar', 'length'=>255, 'not null'=>TRUE), - 'method' => array('type'=>'varchar', 'length'=>50), - 'lastping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0), - 'whentoping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>1), - 'submitmainrss' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0), - 'voc' => array('type'=>'text', 'length'=>4000), - 'nodetypes' => array('type'=>'text', 'length'=>4000), - 'failcount' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0), + 'id' => array( + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'name' => array( + 'type' => 'varchar', + 'length' => 100, + 'not null' => TRUE, + 'default' => '(no name)', + ), + 'url' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => 'http://localhost/', + ), + 'method' => array( + 'type' => 'varchar', + 'length' => 50, + 'default' => '', + ), + 'lastping' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'default' => 0, + ), + 'whentoping' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'default' => 1, + ), + 'submitmainrss' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'default' => 0, + ), + 'voc' => array( + 'type' => 'text', + 'length' => 4000, + ), + 'nodetypes' => array( + 'type' => 'text', + 'length' => 4000, + ), + 'failcount' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'default' => 0, + ), ), 'primary key' => array('id'), ); return $schema; } +/** + * Implementation of hook_install(). + */ function multiping_install() { drupal_install_schema('multiping'); - db_query("INSERT INTO {multiping} (id,name,url,method,lastping,whentoping,submitmainrss,voc,nodetypes,failcount) VALUES (1, 'Ping-o-matic', 'http://rpc.pingomatic.com', 'weblogUpdates.ping', 0, 9, 1, 'N;', 'N;', 0);"); -} -function multiping_uninstall() { - drupal_uninstall_schema('multiping'); -} + $pingomatic = (object) array( + 'name' => 'Ping-o-matic', + 'url' => 'http://rpc.pingomatic.com', + 'method' => 'weblogUpdates.ping', + 'lastping' => 0, + 'whentoping' => 9, + 'submitmainrss' => 1, + 'voc' => 'N;', + 'nodetypes' => 'N;', + 'failcount' => 0, + ); -/* -function multiping_update_1() { - $result = db_query('SELECT * FROM {multiping} LIMIT 1'); - if (db_num_rows($result) == 0) { - $items[] = update_sql('DROP TABLE {multiping}'); - $items[] = _multiping_create_table1(); - } else { - $row = db_fetch_array($result); - if (!isset($row['whentoping'])) { - $items[] = _system_update_utf8(array('multiping')); - $items[] = update_sql("ALTER TABLE `multiping` ADD `whentoping` INT NOT NULL DEFAULT '1' AFTER `lastping`"); - $items[] = update_sql("ALTER TABLE `multiping` ADD `submitmainrss` INT NOT NULL DEFAULT '0' AFTER `whentoping`"); - $items[] = update_sql("ALTER TABLE `multiping` ADD `voc` text AFTER `submitmainrss`"); - $items[] = update_sql("ALTER TABLE `multiping` ADD `failcount` INT default 0 AFTER `voc`"); - } - } - return $items; + drupal_write_record('multiping', $pingomatic); } -function multiping_update_2() { - $items=multiping_update_1(); - $result = db_query('SELECT * FROM {multiping} LIMIT 1'); - $row = db_fetch_array($result); - if (!isset($row['nodetypes'])) { - // Add new column - $items[] = update_sql("ALTER TABLE `multiping` ADD `nodetypes` text AFTER `voc`"); - // New semantics of field whentoping - $items[] = update_sql("UPDATE `multiping` SET whentoping=3 WHERE whentoping=2"); - } - return $items; +/** + * Implementation of hook_uninstall(). + */ +function multiping_uninstall() { + drupal_uninstall_schema('multiping'); } -*/ - -?> --- multiping.module 2008-08-04 17:07:26.000000000 +0100 +++ multiping.module 2009-08-06 08:09:20.000000000 +0100 @@ -1,18 +1,22 @@ array( 'time_between_pings' => '10', - 'pingatonce' => false, + 'pingatonce' => FALSE, ), ); // Defaults requested? @@ -26,7 +30,7 @@ function _multiping_get_settings($defaul if (is_array($value)) { $settings[$key] = isset($settings[$key]) ? array_merge($value, $settings[$key]) : $value; } - else if (!isset($settings[$key])) { + elseif (!isset($settings[$key])) { $settings[$key] = $value; } } @@ -41,7 +45,7 @@ function _multiping_get_settings($defaul */ function multiping_menu() { $items = array(); - $items['admin/settings/multiping'] = array( + $items['admin/settings/multiping'] = array( 'title' => 'Ping services', 'description' => 'Configure when to ping which sites', 'page callback' => 'multiping_admin', @@ -88,8 +92,8 @@ function multiping_menu() { } /** - * Implementation of hook_perm(). - */ + * Implementation of hook_perm(). + */ function multiping_perm() { return array('admin pings'); } @@ -98,106 +102,110 @@ function _multiping_doping($pingservice) global $base_url; // Assemble site name - $name=variable_get('site_name', ''); - $slogan=variable_get('site_slogan', ''); - if (strlen($slogan)>0) - $name="$name - $slogan"; + $name = variable_get('site_name', ''); + $slogan = variable_get('site_slogan', ''); + if (drupal_strlen($slogan) > 0) { + $name = $name .' - '. $slogan; + } // Determine rss url - if (module_exists('taxonomy') - && ($pingservice->whentoping & _multiping_when_taxonomy) - && count($pingservice->voc)>0 && $pingservice->submitmainrss==0) { + if (module_exists('taxonomy') && ($pingservice->whentoping & MULTIPING_WHEN_TAXONOMY) && count($pingservice->voc) > 0 && $pingservice->submitmainrss == 0) { // Taxonomy module exists, "ping only for nodes with taxonomy", // Some taxonomy elements are actually selected, "main rss" override is off - $voc=unserialize($pingservice->voc); - $rss_url="$base_url/taxonomy/term/".implode("+", $voc)."/0/feed"; - } + $voc = unserialize($pingservice->voc); + $rss_url = $base_url .'/taxonomy/term/'. implode('+', $voc) .'/0/feed'; + } else { - $rss_url="$base_url/rss.xml"; + $rss_url = $base_url .'/rss.xml'; } // Ping! Check service method - if ($pingservice->method && strlen($pingservice->method)>0) { - //watchdog("Multiping","XML ping: ".$pingservice->url); + if ($pingservice->method && drupal_strlen($pingservice->method) > 0) { + //watchdog('Multiping',"XML ping: ".$pingservice->url); $result = xmlrpc($pingservice->url, $pingservice->method, $name, $base_url, $rss_url); - } + } else { - $pingurl=strtr($pingservice->url, array( - "%name" => urlencode($name), - "%url" => urlencode("$base_url/"), - "%rss" => urlencode($rss_url)) - ); + $pingurl = strtr($pingservice->url, array( + '%name' => urlencode($name), + '%url' => urlencode($base_url .'/'), + '%rss' => urlencode($rss_url), + )); $result = drupal_http_request($pingurl); - //watchdog("Multiping","Non-XML ping: ".$pingurl." Result: ".$result->code." Data: '".$result->data."'"); - if ($result->code==200) { - if (strpos($result->data, "1")==0) - $result = TRUE; else - $result = FALSE; - } - else $result = FALSE; + //watchdog('Multiping',"Non-XML ping: ".$pingurl." Result: ".$result->code." Data: '".$result->data."'"); + if ($result->code == 200) { + $result = (strpos($result->data, '1') == 0); + } + else { + $result = FALSE; + } } // On success: Update timestamp - if ($result) + if ($result) { db_query("UPDATE {multiping} SET lastping=%d WHERE id=%d", time(), $pingservice->id); + } return $result; } function _multiping_checkpings() { - $settings=_multiping_get_settings(); + $settings = _multiping_get_settings(); $result = db_query('SELECT * FROM {multiping}'); while ($row = db_fetch_object($result)) { // Ping service active? - if (! ($row->whentoping & _multiping_when_active)) { + if (!($row->whentoping & MULTIPING_WHEN_ACTIVE)) { continue; } // Default query: Published nodes only - $sql_from="{node} n"; - $sql_where="n.status>0"; + $sql_from = '{node} n'; + $sql_where = 'n.status > 0'; // Taxonomy selection - if (module_exists('taxonomy') && ($row->whentoping & _multiping_when_taxonomy)) { + if (module_exists('taxonomy') && ($row->whentoping & MULTIPING_WHEN_TAXONOMY)) { // Find most recent date for nodes with given taxonomy - $voc=unserialize($row->voc); - $sql_from="$sql_from, {term_node} t"; - $sql_where="$sql_where AND t.nid=n.nid AND (t.tid=" . implode(" OR t.tid=", $voc) . ")"; + $voc = unserialize($row->voc); + $sql_from .= ', {term_node} t'; + $sql_where .= ' AND t.nid = n.nid AND (t.tid = '. implode(' OR t.tid=', $voc) .')'; } // Nodetype selection - if ($row->whentoping & _multiping_when_nodetype) { - $nodetype=unserialize($row->nodetypes); - $sql_where="$sql_where AND (n.type='".implode("' OR n.type='", $nodetype)."')"; + if ($row->whentoping & MULTIPING_WHEN_NODETYPE) { + $nodetype = unserialize($row->nodetypes); + $sql_where .= " AND (n.type = '". implode("' OR n.type = '", $nodetype) ."')"; } // Promoted to front page? - if ($row->whentoping & _multiping_when_frontpage) { - $sql_where="$sql_where AND n.promote>0"; + if ($row->whentoping & MULTIPING_WHEN_FRONTPAGE) { + $sql_where .= ' AND n.promote > 0'; } //watchdog("debug","Multiping ".$row->name.": SELECT * FROM ".$sql_from." WHERE ".$sql_where); // Get max creation and modification time - $max_created = 0; - $res_time = db_query('SELECT max(created) FROM {'.$sql_from.'} WHERE '.$sql_where); + $res_time = db_query('SELECT MAX(created) FROM '. $sql_from .' WHERE '. $sql_where); $row_time = db_fetch_array($res_time); - if ($row_time) $max_created=$row_time['max(created)']; - $max_changed = 0; - $res_time = db_query('SELECT max(changed) FROM {'.$sql_from.'} WHERE '.$sql_where); + $max_created = $row_time ? $row_time['MAX(created)'] : 0; + + $res_time = db_query('SELECT MAX(changed) FROM '. $sql_from .' WHERE '. $sql_where); $row_time = db_fetch_array($res_time); - if ($row_time) $max_changed=$row_time['max(changed)']; - if ($max_created>$max_changed) - $lastmodified = $max_created; else - $lastmodified = $max_changed; - //watchdog("Multiping","lastmodified=".$lastmodified); + $max_changed = $row_time ? $row_time['MAX(changed)'] : 0; + + $lastmodified = max($max_created, $max_changed); + + //watchdog('Multiping',"lastmodified=".$lastmodified); // Check wether to ping service - if ($lastmodified>$row->lastping) { + if ($lastmodified > $row->lastping) { // With every failure, exponentially increase retry time - $retry_time=$settings['global']['time_between_pings']*pow(1.5,$row->failcount); - if ($retry_time>24*60) // Retry at least once a day - $retry_time=24*60; - if ($row->lastping+60*$retry_time>time()) { - // Timeout not yet reached - watchdog("Multiping", "Timeout for service @name not yet reached", array('@name' => $row->name)); - } elseif (_multiping_doping($row)) { - watchdog("Multiping", 'Successfully notified %site.', array('%site' => $row->name)); - db_query("UPDATE {multiping} SET failcount='0' WHERE id=%d",$row->id); - } else { - watchdog("Multiping", 'Failed to notify %site.', array('%site' => $row->name), WATCHDOG_WARNING); - db_query("UPDATE {multiping} SET failcount='%d' WHERE id=%d", - ($row->failcount)+1,$row->id); + $retry_time = $settings['global']['time_between_pings'] * pow(1.5, $row->failcount); + + // Retry at least once a day + if ($retry_time > 24 * 60) { + $retry_time = 24 * 60; + } + + if ($row->lastping + 60 * $retry_time > time()) { + // Timeout not yet reached + watchdog('Multiping', "Timeout for service @name not yet reached", array('@name' => $row->name)); + } + elseif (_multiping_doping($row)) { + watchdog('Multiping', 'Successfully notified %site.', array('%site' => $row->name)); + db_query("UPDATE {multiping} SET failcount = 0 WHERE id = %d", $row->id); + } + else { + watchdog('Multiping', 'Failed to notify %site.', array('%site' => $row->name), WATCHDOG_WARNING); + db_query("UPDATE {multiping} SET failcount = %d WHERE id = %d", $row->failcount + 1, $row->id); } } } @@ -205,66 +213,70 @@ function _multiping_checkpings() { /** - * Implementation of hook_cron(). - * Check if sites need to be pinged. - */ + * Implementation of hook_cron(). + * Check if sites need to be pinged. + */ function multiping_cron() { - watchdog("Multiping","Cron run",array(),WATCHDOG_DEBUG); + watchdog('Multiping', 'Cron run', array(), WATCHDOG_DEBUG); _multiping_checkpings(); } /** - * Implementation of hook_nodeapi(). - * If pingatonce is set, check pings. - */ -function multiping_nodeapi(&$node, $op, $a3=NULL, $a4=NULL) { + * Implementation of hook_nodeapi(). + * If pingatonce is set, check pings. + */ +function multiping_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { //drupal_set_message("op=".$op); - //watchdog("Multiping","op=$op"); + //watchdog('Multiping',"op=$op"); switch ($op) { case 'insert': case 'update': - $settings=_multiping_get_settings(); - if ($settings['global']['pingatonce']) - _multiping_checkpings(); + $settings = _multiping_get_settings(); + if ($settings['global']['pingatonce']) { + _multiping_checkpings(); + } break; } } function multiping_edit_service($form_state, $id) { - $edit=array(); - $edit['id']=$id; - $edit['name']=''; - $edit['url']='http://'; - $edit['method']='weblogUpdates.ping'; - $edit['when_active']=1; - $edit['when_taxonomy']=0; - $edit['when_nodetype']=0; - $edit['when_frontpage']=0; - $edit['submitmainrss']=1; - $edit['voc']=''; - $edit['nodetype']=''; - if ($id>0) { - $result = db_query('SELECT * FROM {multiping} WHERE id=%d',$id); + $edit = array(); + $edit['id'] = $id; + $edit['name'] = ''; + $edit['url'] = 'http://'; + $edit['method'] = 'weblogUpdates.ping'; + $edit['when_active'] = 1; + $edit['when_taxonomy'] = 0; + $edit['when_nodetype'] = 0; + $edit['when_frontpage'] = 0; + $edit['submitmainrss'] = 1; + $edit['voc'] = ''; + $edit['nodetype'] = ''; + + if ($id > 0) { + $result = db_query('SELECT * FROM {multiping} WHERE id = %d', $id); $row = db_fetch_object($result); if ($row) { - $edit['name']=$row->name; - $edit['url']=$row->url; - $edit['method']=$row->method; - $edit['when_active']=(($row->whentoping & _multiping_when_active) > 0); - $edit['when_taxonomy']=(($row->whentoping & _multiping_when_taxonomy) > 0); - $edit['when_nodetype']=(($row->whentoping & _multiping_when_nodetype) > 0); - $edit['when_frontpage']=(($row->whentoping & _multiping_when_frontpage) > 0); - $edit['submitmainrss']=$row->submitmainrss; - $edit['voc']=unserialize($row->voc); - $edit['nodetype']=unserialize($row->nodetypes); - } else { - watchdog("Multiping","Query for id=@id returned 0 rows", array('@id' => $id), WATCHDOG_WARNING); - $id=0; + $edit['name'] = $row->name; + $edit['url'] = $row->url; + $edit['method'] = $row->method; + $edit['when_active'] = (($row->whentoping & MULTIPING_WHEN_ACTIVE) > 0); + $edit['when_taxonomy'] = (($row->whentoping & MULTIPING_WHEN_TAXONOMY) > 0); + $edit['when_nodetype'] = (($row->whentoping & MULTIPING_WHEN_NODETYPE) > 0); + $edit['when_frontpage'] = (($row->whentoping & MULTIPING_WHEN_FRONTPAGE) > 0); + $edit['submitmainrss'] = $row->submitmainrss; + $edit['voc'] = unserialize($row->voc); + $edit['nodetype'] = unserialize($row->nodetypes); + } + else { + watchdog('Multiping', 'Query for id=@id returned 0 rows', array('@id' => $id), WATCHDOG_WARNING); + $id = 0; } } - $form=array(); + + $form = array(); $form['id'] = array( '#type' => 'hidden', '#value' => $id, @@ -305,9 +317,12 @@ function multiping_edit_service($form_st '#attributes' => NULL, '#required' => FALSE, ); - $options = array('1' => t('Always ping'), '0' => t('Don\'t ping')); + $options = array( + '1' => t('Always ping'), + '0' => t('Don\'t ping'), + ); if (module_exists('taxonomy')) { - $options['2']=t('Ping only for nodes with the following taxonomy'); + $options['2'] = t('Ping only for nodes with the following taxonomy'); } $form['when_active'] = array( '#type' => 'checkbox', @@ -320,14 +335,14 @@ function multiping_edit_service($form_st '#type' => 'checkbox', '#title' => t('Ping only for selected taxonomies'), '#default_value' => $edit['when_taxonomy'], - '#description' => t('Send a ping only if the node belongs to one of the follwing categories'), + '#description' => t('Send a ping only if the node belongs to one of the following categories'), ); $form['voc'] = array( '#type' => 'select', '#title' => t('Taxonomy terms when to ping'), '#default_value' => $edit['voc'], '#options' => taxonomy_form_all(), - '#multiple' => true, + '#multiple' => TRUE, '#description' => t('Ping this service if any of the taxonomy terms selected above matches the respective node'), ); $form['submitmainrss'] = array( @@ -348,7 +363,7 @@ function multiping_edit_service($form_st '#title' => t('Node types when to ping'), '#default_value' => $edit['nodetype'], '#options' => node_get_types('names'), - '#multiple' => true, + '#multiple' => TRUE, '#description' => t('Ping this service if any of the node types selected above matches the respective node'), ); $form['when_frontpage'] = array( @@ -367,36 +382,51 @@ function multiping_edit_service($form_st function multiping_edit_service_submit($form_id, &$form_state) { $edit = $form_state['values']; // TODO: Is this ok? http://drupal.org/node/144132#process-params - if ($edit['form_id']=='multiping_edit_service') { - $edit['id'] = ($edit['id'] && is_numeric($edit['id'])) ? $edit['id'] : 0; - $edit['name'] = ($edit['name']) ? $edit['name'] : '(no name)'; - $edit['url'] = ($edit['url']) ? $edit['url'] : 'http://localhost/'; - $edit['method'] = ($edit['method']) ? $edit['method'] : ''; - $edit['submitmainrss'] = ($edit['submitmainrss']) ? $edit['submitmainrss'] : 0; // Not present if false! - if ($edit['submitmainrss']>0) $edit['submitmainrss']=1; - $whentoping=$edit['when_active']*_multiping_when_active+ - $edit['when_taxonomy']*_multiping_when_taxonomy+ - $edit['when_nodetype']*_multiping_when_nodetype+ - $edit['when_frontpage']*_multiping_when_frontpage; - if ($edit['id']==0) { - db_query("INSERT INTO {multiping} (name,url,method,whentoping,submitmainrss,voc,nodetypes) ". - "VALUES ('%s','%s','%s','%s','%s','%s','%s')",$edit['name'],$edit['url'], - $edit['method'],$whentoping,$edit['submitmainrss'], - serialize($edit['voc']),serialize($edit['nodetype'])); - } else { - db_query("UPDATE {multiping} SET name='%s',url='%s',method='%s',whentoping='%s',submitmainrss='%s',voc='%s',nodetypes='%s' ". - "WHERE id=%d",$edit['name'],$edit['url'],$edit['method'],$whentoping,$edit['submitmainrss'],serialize($edit['voc']),serialize($edit['nodetype']),$edit['id']); + if ($edit['form_id'] === 'multiping_edit_service') { + $service = (object) array( + 'voc' => serialize($edit['voc']), + 'nodetypes' => serialize($edit['nodetype']), + ); + + if ($edit['id'] && is_numeric($edit['id'])) { + $service->id = $edit['id']; + } + if (!empty($edit['name'])) { + $service->name = $edit['name']; + } + if (!empty($edit['url'])) { + $service->url = $edit['url']; + } + if (!empty($edit['method'])) { + $service->method = $edit['method']; + } + + $service->submitmainrss = $edit['submitmainrss'] ? $edit['submitmainrss'] : 0; // Not present if false! + if ($service->submitmainrss > 0) { + $service->submitmainrss = 1; + } + + $service->whentoping = $edit['when_active'] * MULTIPING_WHEN_ACTIVE + + $edit['when_taxonomy'] * MULTIPING_WHEN_TAXONOMY + + $edit['when_nodetype'] * MULTIPING_WHEN_NODETYPE + + $edit['when_frontpage'] * MULTIPING_WHEN_FRONTPAGE; + + if (!isset($service->id)) { + drupal_write_record('multiping', $service); + } + else { + drupal_write_record('multiping', $service, 'id'); } } - drupal_set_message("Changes saved."); + drupal_set_message(t('Changes saved.')); #drupal_goto("admin/settings/multiping"); - $form_state['redirect']="admin/settings/multiping"; + $form_state['redirect'] = 'admin/settings/multiping'; } function multiping_settings() { - $form=array(); - $settings=_multiping_get_settings(); + $form = array(); + $settings = _multiping_get_settings(); $form['global']['time_between_pings'] = array( '#type' => 'textfield', '#title' => t('Time between pings'), @@ -423,80 +453,88 @@ function multiping_settings() { function multiping_settings_submit($form_id, &$form_state) { $edit = $form_state['values']; // TODO: Is this ok? http://drupal.org/node/144132#process-params - if ($edit['form_id']=='multiping_settings') { - $settings=_multiping_get_settings(); - $settings['global']['time_between_pings']=$edit['time_between_pings']; - $settings['global']['pingatonce']=$edit['pingatonce']; + if ($edit['form_id'] === 'multiping_settings') { + $settings = _multiping_get_settings(); + $settings['global']['time_between_pings'] = $edit['time_between_pings']; + $settings['global']['pingatonce'] = $edit['pingatonce']; variable_set('multiping', $settings); } - drupal_set_message("Changes saved."); + drupal_set_message(t('Changes saved.')); #drupal_goto("admin/settings/multiping"); - $form_state['redirect']="admin/settings/multiping"; + $form_state['redirect'] = 'admin/settings/multiping'; } /** - * Menu callback: Admin page - */ + * Menu callback: Admin page + */ function multiping_admin() { $output = ""; // General settings $output .= drupal_get_form('multiping_settings', $form); // Table with services - $header = array(t('Name'), t('Last update'), array('data' => t('Operations'), 'colspan' => '3')); + $header = array( + t('Name'), + t('Last update'), + array('data' => t('Operations'), 'colspan' => '3'), + ); $result = db_query('SELECT * FROM {multiping} ORDER BY id'); while ($row = db_fetch_object($result)) { - if ($row->lastping==0) - $lastping=t('never'); else - $lastping=format_date($row->lastping,'small'); + if ($row->lastping == 0) { + $lastping = t('never'); + } + else { + $lastping = format_date($row->lastping, 'small'); + } $rows[] = array( $row->name, $lastping, - l(t('edit'),"admin/settings/multiping/".$row->id."/edit"), - l(t('ping'),"admin/settings/multiping/".$row->id."/ping"), - l(t('delete'),"admin/settings/multiping/".$row->id."/delete") + l(t('edit'), 'admin/settings/multiping/'. $row->id .'/edit'), + l(t('ping'), 'admin/settings/multiping/'. $row->id .'/ping'), + l(t('delete'), 'admin/settings/multiping/'. $row->id .'/delete'), ); } - $output .= theme('table',$header,$rows); + $output .= theme('table', $header, $rows); // Links - $output .= "

".l(t('Add service'),"admin/settings/multiping/new")."

"; + $output .= '

'. l(t('Add service'), 'admin/settings/multiping/new') .'

'; return $output; } function multiping_pingall() { - $output = "

".t("Running all pings...")."

"; - $header = array(t('Name'), t('Status')); + $output = '

'. t("Running all pings...") .'

'; + $header = array( + t('Name'), + t('Status'), + ); $result = db_query('SELECT * FROM {multiping} ORDER BY id'); while ($row = db_fetch_object($result)) { - $rows[] = array($row->name,_multiping_doping($row) ? t('Ok') : t('Failed')); + $rows[] = array($row->name, _multiping_doping($row) ? t('Ok') : t('Failed')); } - $output .= theme('table',$header,$rows); - $output .= "

".l(t('Return'),"admin/settings/multiping")."

"; + $output .= theme('table', $header, $rows); + $output .= '

'. l(t('Return'), 'admin/settings/multiping') .'

'; return $output; } function multiping_ping($id) { - watchdog("Multiping","ping @id", array('@id' => $id)); + watchdog('Multiping', 'ping @id', array('@id' => $id)); if (!is_numeric($id)) { drupal_not_found(); return; } - drupal_set_message("Not yet implemented","warning"); - drupal_goto("admin/settings/multiping"); + drupal_set_message(t('Not yet implemented'), 'warning'); + drupal_goto('admin/settings/multiping'); } function multiping_delete($id) { - watchdog("Multiping","delete @id", array('@id' => $id)); + watchdog('Multiping', 'delete @id', array('@id' => $id)); if (!is_numeric($id)) { drupal_not_found(); return; } - db_query("DELETE FROM {multiping} WHERE id=%d",intval($id)); - drupal_set_message("Service deleted."); - drupal_goto("admin/settings/multiping"); + db_query('DELETE FROM {multiping} WHERE id = %d', intval($id)); + drupal_set_message(t('Service deleted.')); + drupal_goto('admin/settings/multiping'); } - -?>