diff -urN subscribe_47/subscribe.info subscribe_5x/subscribe.info --- subscribe_47/subscribe.info 1969-12-31 19:00:00.000000000 -0500 +++ subscribe_5x/subscribe.info 2007-05-16 13:18:49.453771824 -0400 @@ -0,0 +1,3 @@ +name = Subscribe +description = Allow site receive content from Drupal sites running the publish module. +version = 5.x-1.x-dev \ No newline at end of file diff -urN subscribe_47/subscribe.module subscribe_5x/subscribe.module --- subscribe_47/subscribe.module 2007-05-09 09:47:24.000000000 -0400 +++ subscribe_5x/subscribe.module 2007-05-16 13:18:49.454771672 -0400 @@ -15,9 +15,7 @@ */ function subscribe_help($section) { switch ($section) { - case 'admin/modules#description': - return t('Allow site receive content from Drupal sites running the publish module.'); - case strstr($section, 'admin/subscribe/pull'): + case strstr($section, 'admin/build/subscribe/pull'): return t('

Manually request updated content from the channel. Note that there may be a long pause after you initiate content tranfer.

'); } } @@ -30,28 +28,61 @@ $access = user_access('manage content subscriptions'); if ($may_cache) { - $items[] = array('path' => 'admin/subscribe', 'title' => t('subscribe'), + $items[] = array( + 'path' => 'admin/build/subscribe', + 'title' => t('Subscribe'), 'callback' => 'subscribe_overview', - 'access' => $access); - $items[] = array('path' => 'admin/subscribe/overview', 'title' => t('list'), + 'description' => t('Configure how this site receives content from Drupal sites running the publish module.'), + 'access' => $access, + ); + $items[] = array( + 'path' => 'admin/build/subscribe/overview', + 'title' => t('List'), 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10); - $items[] = array('path' => 'admin/subscribe/sub/wizard', 'title' => t('subscribe to channel'), - 'callback' => 'subscribe_url_form', + 'weight' => -10, + ); + } else { + $items[] = array( + 'path' => 'admin/build/subscribe/pull', + 'title' => t('Update content'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array( + 'subscribe_pull_form', + arg(4), + ), 'access' => $access, - 'type' => MENU_LOCAL_TASK); - $items[] = array('path' => 'admin/subscribe/sub/vocabmap', 'title' => t('Channel options'), - 'callback' => 'subscribe_vocabmap_form', + 'type' => MENU_CALLBACK, + ); + $items[] = array( + 'path' => 'admin/build/subscribe/sub/wizard', + 'title' => t('Subscribe to channel'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array( + 'subscribe_url_form', + ), 'access' => $access, - 'type' => MENU_CALLBACK); - $items[] = array('path' => 'admin/subscribe/delete', 'title' => t('Delete subscription'), - 'callback' => 'subscribe_delete_form', + 'type' => MENU_LOCAL_TASK, + ); + $items[] = array( + 'path' => 'admin/build/subscribe/sub/vocabmap', + 'title' => t('Channel options'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array( + 'subscribe_vocabmap_form', + ), 'access' => $access, - 'type' => MENU_CALLBACK); - $items[] = array('path' => 'admin/subscribe/pull', 'title' => t('update content'), - 'callback' => 'subscribe_pull_form', + 'type' => MENU_CALLBACK, + ); + $items[] = array( + 'path' => 'admin/build/subscribe/delete', + 'title' => t('Delete subscription'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array( + 'subscribe_delete_form', + ), 'access' => $access, - 'type' => MENU_CALLBACK); + 'type' => MENU_CALLBACK, + ); } return $items; @@ -93,7 +124,10 @@ case 'view': if (isset($node->remote_nid)) { - $node = theme_external_node($node, 0, 1); + $node->content['my_additional_field'] = array( + '#value' => theme('external_node', $node, 0, 1), + '#weight' => 100, + ); } break; @@ -123,15 +157,12 @@ $node->title = t('%node-title (from %remote-url)', array('%node-title' => $node->title, '%remote-url' => $node->remote_site_url)); $remote_url = $node->remote_site_url. '/'; - $item[] = t('Visit this page', array('%remote-url' => $remote_url. "node/$node->remote_nid")); - $item[] = t('Authored by: %remote-author', array('%remote-author' => $node->remote_author, '%remote-author-url' => $remote_url. "user/$node->remote_uid")); - - $referring_info = theme('item_list', $item); + $item[] = l(t('Visit this page'), $remote_url . "node/$node->remote_nid"); + $item[] = t('Authored by: !remote-author', array('!remote-author' => l($node->remote_author, $remote_url. "user/$node->remote_uid"))); - $node->body .= $referring_info; - $node->teaser .= $referring_info; + $referring_info = '
' . theme('item_list', $item) . "
\n"; - return $node; + return $referring_info; } /******************************************************************** @@ -153,58 +184,33 @@ $sub->url, $sub->last_update ? format_date($sub->last_update) : t('never'), '
' . - // l(t('edit'), "admin/subscribe/sub/$sub->sid/edit") . '' . - l(t('pull'), "admin/subscribe/pull/$sub->sid") . '' . - l(t('delete'), "admin/subscribe/delete/$sub->sid") . '
' + // l(t('edit'), "admin/build/subscribe/sub/$sub->sid/edit") . '' . + l(t('pull'), "admin/build/subscribe/pull/$sub->sid") . '' . + l(t('delete'), "admin/build/subscribe/delete/$sub->sid") . '' ); } - $output .= ($row) ? theme('table', $header, $row) : '

' . t('You currently have no subscriptions.') . '

' . t('Would you like to') . ' ' . l(t('subscribe to a channel'),'admin/subscribe/sub/wizard') . '?

'; + $output .= ($row) ? theme('table', $header, $row) : '

' . t('You currently have no subscriptions.') . '

' . t('Would you like to') . ' ' . l(t('subscribe to a channel'),'admin/build/subscribe/sub/wizard') . '?

'; return $output; } -function subscribe_delete_form() { - $sid = arg(3); +function subscribe_delete_form($sid) { $sub = subscribe_subscription_load($sid); if (!$sid || !$sub->sid) { drupal_set_message(t('Invalid channel ID.', 'error')); - drupal_goto('admin/subscribe'); + drupal_goto('admin/build/subscribe'); } $form['sid'] = array('#type' => 'value', '#value' => $sid); - $output = confirm_form('subscribe_delete_form', $form, - t('Are you sure you want to delete %title?', array('%title' => theme('placeholder', $sub->name))), - 'admin/subscribe', t('This action cannot be undone.'), - t('Delete'), t('Cancel') ); - return $output; + return confirm_form($form, + t('Are you sure you want to delete %title?', array('%title' => $sub->name)), + 'admin/build/subscribe', t('This action cannot be undone.'), + t('Delete'), t('Cancel'), + 'subscribe_delete_form' ); } function subscribe_delete_form_submit($form, $form_values) { - if ($form_values['confirm']) { - subscribe_subscription_delete($form_values['sid']); - } - return 'admin/subscribe'; -} - -function subscribe_delete($edit) { - $sub = subscribe_subscription_load($edit['sid']); - if ($edit['confirm']) { - global $user; - db_query('DELETE FROM {subscribe_subscriptions} WHERE sid = %d', $sub->sid); - watchdog('subscribe', t('%u: deleted %n', array('%u' => $user->name, '%n' => $sub->name))); - $result = subscribe_xmlc_cancel_subscription($sub); - } - else { - $extra = form_hidden('sid', $sub->sid); - $output = theme('confirm', - t('Are you sure you want to delete %title?', array('%title' => ''. $sub->name .'')), - $_GET['destination'] ? $_GET['destination'] : 'admin/subscribe', - t('This action cannot be undone. Nodes imported from this channel will not be deleted.'), - t('Delete'), - t('Cancel'), - $extra); - } - - return $output; + subscribe_subscription_delete($form_values['sid']); + return 'admin/build/subscribe'; } function subscribe_url_form() { @@ -249,7 +255,7 @@ '#value' => t('Continue') ); unset($_SESSION['edit']); - return drupal_get_form('subscribe_url_form', $form); + return $form; } /** @@ -273,6 +279,7 @@ $username = check_plain($form_values['username']); $pass = check_plain($form_values['pass']); $result = subscribe_xmlc_may_subscribe($url, $channel_id, $username, $pass); + if ($result[0]) { // if user may subscribe $form_values = array(); $form_values['name'] = $result[1]; @@ -288,7 +295,7 @@ if (!$form_values['node_types']) { drupal_set_message(t('The channel is not currently publishing any node types. This is probably a misconfiguration on the publishing site.'), 'error'); - drupal_goto('admin/subscribe/sub/wizard'); + drupal_goto('admin/build/subscribe/sub/wizard'); } $nodetypes = node_get_types(); @@ -301,26 +308,26 @@ if ($missing) { if (count($missing) == 1) { $type = $missing[0]; - drupal_set_message(t('The remote site is publishing nodes of type %type but you do not support nodes of this type on your site. Please enable the appropriate module.', array('%type' => theme('placeholder', $type))), 'error'); + drupal_set_message(t('The remote site is publishing nodes of type %type but you do not support nodes of this type on your site. Please enable the appropriate module.', array('%type' => $type)), 'error'); } else { $phrase = ''; foreach ($missing as $type) { $phrase .= ', ' . $type; } - drupal_set_message(t('The remote site is publishing nodes of the following types: %types; but you do not support nodes of these types on your site. Please enable the appropriate modules.', array('%types' => theme('placeholder', ltrim($phrase, ',')), 'error'))); + drupal_set_message(t('The remote site is publishing nodes of the following types: %types; but you do not support nodes of these types on your site. Please enable the appropriate modules.', array('%types' => ltrim($phrase, ','), 'error'))); } - drupal_goto('admin/subscribe/sub/wizard'); + drupal_goto('admin/build/subscribe/sub/wizard'); } } else { $msg = t('Unable to subscribe.'); drupal_set_message($msg, 'error'); $_SESSION['edit'] = $form_values; - drupal_goto('admin/subscribe/sub/wizard'); + drupal_goto('admin/build/subscribe/sub/wizard'); } $_SESSION['edit'] = $form_values; - return ('admin/subscribe/sub/vocabmap'); + return ('admin/build/subscribe/sub/vocabmap'); } @@ -331,7 +338,7 @@ function subscribe_vocabmap_form() { if (!isset($_SESSION['edit'])) { drupal_set_message(t('Unable to retrieve session data.'), 'error'); - drupal_goto('/subscribe/sub/wizard'); + drupal_goto('admin/build/subscribe/sub/wizard'); } $edit = $_SESSION['edit']; $remote_vocabularies = array(); @@ -383,7 +390,10 @@ '#type' => 'radios', '#title' => t('Method'), '#default_value' => isset($edit['pushpull']) ? $edit['pushpull'] : 0, - '#options' => array(t('Push: Receive content from channel automatically when the channel decides to send it.'), t('Pull: Receive content from channel only when you manually request it (your server must allow HTTP out).')), + '#options' => array( + 'push' => t('Push: Receive content from channel automatically when the channel decides to send it.'), + 'pull' => t('Pull: Receive content from channel only when you manually request it (your server must allow HTTP out).'), + ), '#description' => t('Choose how you would like this site to receive content.') ); $form['submit'] = array( @@ -391,7 +401,7 @@ '#value' => t('Subscribe to channel') ); - return drupal_get_form('subscribe_vocabmap_form', $form); + return $form; } function theme_subscribe_vocabmap_form($form) { @@ -401,32 +411,32 @@ $rows[] = array( array('data' => $form['vocabmap'][$key]['#vname']), array('data' => '→'), - array('data' => form_render($form['vocabmap'][$key])) + array('data' => drupal_render($form['vocabmap'][$key])) ); } if ($rows) { $output = theme('fieldset', array('#title' => t('Vocabulary Mapping'), '#children' => theme_table($header, $rows))); } - $output .= form_render($form); + $output .= drupal_render($form); return $output; } function subscribe_vocabmap_form_validate($form, $form_values) { if (!isset($_SESSION['edit'])) { drupal_set_message(t('Unable to retrieve session data.'), 'error'); - drupal_goto('/subscribe/sub/wizard'); + drupal_goto('admin/build/subscribe/sub/wizard'); } $edit = $_SESSION['edit']; if (!subscribe_subscription_validate($edit['url'], $edit['channel_id'])) { drupal_set_message(t('You are already subscribed to this channel.'), 'error'); - drupal_goto('admin/subscribe'); + drupal_goto('admin/build/subscribe'); } } function subscribe_vocabmap_form_submit($form, $edit) { if (!isset($_SESSION['edit'])) { drupal_set_message(t('Unable to retrieve session data.'), 'error'); - drupal_goto('/subscribe/sub/wizard'); + drupal_goto('admin//build/subscribe/sub/wizard'); } $edit = array_merge($_SESSION['edit'], $edit); unset($_SESSION['edit']); @@ -450,12 +460,12 @@ $edit['method'] = $edit['pushpull']; $edit['sid'] = subscribe_subscription_save($edit); subscribe_vocabmap_save($vocab_map, $edit['sid']); - drupal_set_message(t('Subscription to channel %name established.', array('%name' => theme('placeholder', $edit['name'])))); - drupal_goto('admin/subscribe'); + drupal_set_message(t('Subscription to channel %name established.', array('%name' => $edit['name']))); + drupal_goto('admin/build/subscribe'); } else { drupal_set_message(t('Could not subscribe.'), 'error'); - drupal_goto('admin/subscribe'); + drupal_goto('admin/build/subscribe'); } } @@ -559,7 +569,7 @@ } // Insert the subscription record into the database: db_query('INSERT INTO {subscribe_subscriptions} ('. implode(", ", $k) .') VALUES('. implode(', ', $s) .')', $v); - watchdog('subscribe', t('%u subscribed to channel %c', array('%u' => $user->name, '%c' => $edit['name']))); + watchdog('subscribe', t('!u subscribed to channel !c', array('!u' => $user->name, '!c' => $edit['name']))); } return $edit['sid']; @@ -570,7 +580,7 @@ $sub = subscribe_subscription_load($sid); db_query('DELETE FROM {subscribe_subscriptions} WHERE sid = %d', $sid); db_query('DELETE FROM {subscribe_vocab_map WHERE sid = %d', $sid); - watchdog('subscribe', t('%u: deleted subscription %n', array('%u' => $user->name, '%n' => $sub->name))); + watchdog('subscribe', t('!u: deleted subscription !n', array('!u' => $user->name, '!n' => $sub->name))); $result = subscribe_xmlc_cancel_subscription($sub); } @@ -581,13 +591,11 @@ * @param $sid * the local subscription ID */ -function subscribe_pull_form() { - - $sid = arg(3); +function subscribe_pull_form($sid) { $sub = subscribe_subscription_load($sid); if (!$sid || !$sub->sid) { drupal_set_message(t('Invalid channel ID.', 'error')); - drupal_goto('admin/subscribe'); + drupal_goto('admin/build/subscribe'); } $form['sid'] = array( '#type' => 'value', @@ -595,13 +603,13 @@ ); $form['update'] = array( '#type' => 'fieldset', - '#title' => t('Request content from channel %channel', array('%channel' => theme('placeholder', $sub->name))) + '#title' => t('Request content from channel %channel', array('%channel' => $sub->name)) ); $form['update']['submit'] = array('#type' => 'submit', '#value' => t('Update Content') ); - return drupal_get_form('subscribe_pull_form', $form); + return $form; } function subscribe_pull_form_submit($form, $form_values) { @@ -609,7 +617,7 @@ $sub = subscribe_subscription_load($form_values['sid']); subscribe_pull($sub); } - return 'admin/subscribe'; + return 'admin/build/subscribe'; } /** @@ -640,12 +648,12 @@ if ($result['count']) { $site_metadata = array('site_url' => $result['site_url'], 'site_name' => $result['site_name'], 'sid' => $subscription->sid); list($n_counter, $u_counter, $t_counter) = subscribe_import($result['nodes'], $site_metadata); - drupal_set_message(t("New content from %name. Nodes imported: %ncount; nodes updated: %ucount; terms imported: %tcount.", array('%ncount' => $n_counter, '%ucount' => $u_counter, '%tcount' => $t_counter, '%name' => $subscription->name))); + drupal_set_message(t("New content from !name. Nodes imported: !ncount; nodes updated: !ucount; terms imported: !tcount.", array('!ncount' => $n_counter, '!ucount' => $u_counter, '!tcount' => $t_counter, '!name' => $subscription->name))); db_query("UPDATE {subscribe_subscriptions} SET last_update = %d WHERE sid = %d", time(), $subscription->sid); - drupal_goto('admin/subscribe'); + drupal_goto('admin/build/subscribe'); } else { - drupal_set_message(t('Pull attempt failed for %url.', array('%url' => theme('placeholder', check_plain($subscription->url)))), 'error'); + drupal_set_message(t('Pull attempt failed for %url.', array('%url' => check_plain($subscription->url))), 'error'); } } @@ -716,7 +724,7 @@ // import node node_save($node); $local_nid = $node->nid; - watchdog('subscribe', t('%type: added %title from site %site.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%site' => theme('placeholder', $site_name))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); + watchdog('subscribe', t('%type: added %title from site %site.', array('%type' => t($node->type), '%title' => $node->title, '%site' => $site_name)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); $n_counter = $n_counter + 1; // save map of remote/local node ID's (and uids?) @@ -891,6 +899,7 @@ function subscribe_xmls_receive($message) { $subscription = db_fetch_object(db_query("SELECT * FROM {subscribe_subscriptions} WHERE token = '%s' AND method = 'push' AND rsid = %d", $message['token'], $message['rsid'])); + if (!$subscription) { return xmlrpc_error(801, t('No such subscription')); } @@ -902,13 +911,13 @@ $host = gethostbyaddr($ip); $parts = parse_url($host); if ($parts['host'] != $subscription->domain) { - return xmlrpc_error(701, t('Publishing domain not trusted.')); + return xmlrpc_error(701, t('Publishing domain not trusted.')); //MS: Lined out so that we can test this. } } $site_metadata = array('site_url' => $message['site_url'], 'site_name' => $message['site_name'], 'sid' => $subscription->sid); list($n_counter, $u_counter, $t_counter) = subscribe_import($message['nodes'], $site_metadata); - $result = t("New content from %name. Nodes imported: %ncount; noded updated: %ucount; terms imported: %tcount.", array('%ncount' => $n_counter, '%ucount' => $u_counter, '%tcount' => $t_counter, '%name' => $subscription->name)); + $result = t("New content from %name. Nodes imported: !ncount; noded updated: !ucount; terms imported: !tcount.", array('!ncount' => $n_counter, '!ucount' => $u_counter, '!tcount' => $t_counter, '!name' => $subscription->name)); return $result; }