summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_distribution.info2
-rw-r--r--content_distribution.install6
-rw-r--r--content_distribution.module35
-rw-r--r--includes/content_distribution.views.inc11
-rw-r--r--modules/content_retriever/content_retriever.admin.inc69
-rw-r--r--modules/content_retriever/content_retriever.info2
-rw-r--r--modules/content_retriever/content_retriever.install6
-rw-r--r--modules/content_retriever/content_retriever.module220
-rw-r--r--modules/distributor_service/distributor_service.info2
-rw-r--r--readme.txt101
10 files changed, 339 insertions, 115 deletions
diff --git a/content_distribution.info b/content_distribution.info
index 9d9bea5..1587340 100644
--- a/content_distribution.info
+++ b/content_distribution.info
@@ -1,6 +1,8 @@
+; $Id$
name = Content Distributor
description = Allows nodes to be distributed via the Services module.
package = Content Distribution
+version = 6.x-1.x-dev
core = 6.x
dependencies[] = node
dependencies[] = date_api
diff --git a/content_distribution.install b/content_distribution.install
index a53d7c3..3e29b34 100644
--- a/content_distribution.install
+++ b/content_distribution.install
@@ -12,6 +12,12 @@ function content_distribution_install() {
//weight of module needs to be higher than that of the nodequeue module.
db_query("UPDATE {system} SET weight = 100 WHERE name = 'content_distribution'");
+ /* run this once */
+ /*$result = db_query("SELECT nid from {content_field_original_nid}");
+ while($nid = db_fetch_object($result)){
+ //write record in content_distribution table
+ drupal_write_record('content_distribution', $nid);
+ }*/
}
/**
diff --git a/content_distribution.module b/content_distribution.module
index 3bbfc0e..0fa3aba 100644
--- a/content_distribution.module
+++ b/content_distribution.module
@@ -12,15 +12,17 @@ function content_distribution_form_alter(&$form, $form_state, $form_id) {
// node add form - add published date field.
if($form['#id'] === 'node-form'){
- //print_r($form);
// check if content type is set up for distribution...
$is_distributable = variable_get('distribute_content_type_'.$form['type']['#value'], 0);
if($is_distributable !== 0){
- // get local date and timezone settings for form values.
$format = 'Y-m-d H:i';
- $local_timezone = date_default_timezone_get();
- $date = date_make_date(time(),$local_timezone, DATE_UNIX);
- $date = date_format_date($date, 'custom', $format);
+ $local_timezone = date_default_timezone_get();
+ $published_date = $form['#node']->published_date;
+ if(empty($published_date)){
+ // get local date and timezone settings for form values.
+ $date = date_make_date(time(),$local_timezone, DATE_UNIX);
+ $published_date = date_format_date($date, 'custom', $format);
+ }
$form['date'] = array(
'#type' => 'fieldset',
@@ -31,7 +33,7 @@ function content_distribution_form_alter(&$form, $form_state, $form_id) {
$form['date']['published_date'] = array(
'#type' => 'date_select',
- '#default_value' => $form['#node']->published_date,
+ '#default_value' => $published_date,
'#date_format' => $format,
'#date_timezone' => $local_timezone,
'#date_year_range' => '0:+2',
@@ -104,7 +106,7 @@ function content_distribution_node_type_form_submit($form, &$form_state) {
*/
function content_distribution_nodeapi(&$node, $op, $teaser, $page) {
$is_distributable = variable_get('distribute_content_type_'.$node->type, 0);
-
+ //print_r($node);
switch ($op) {
case 'load':
// check if nodes of this content type are distributable
@@ -153,7 +155,7 @@ function content_distribution_nodeapi(&$node, $op, $teaser, $page) {
// if result fetched we already have a row so just update the table with new published date
if (($nid = db_result($result)) != FALSE) {
- db_query("UPDATE {content_distribution} SET published_date = %d WHERE nid = %d", $published_date, $nid);
+ db_query("UPDATE {content_distribution} SET published_date = %d WHERE nid = %d", $published_date, $nid);
}
}
break;
@@ -168,15 +170,15 @@ function content_distribution_nodeapi(&$node, $op, $teaser, $page) {
//and delete it off that site.
foreach($sites as $k => $site){
$endpoint = $site['sitetext'] . '/services/xmlrpc';
- $api_key = '';
+ $api_key = '';
- //grab a session id from the system.connect method
+ //grab a session id from the system.connect method
$connect = xmlrpc($endpoint, 'system.connect');
$session_id = $connect['sessid'];
//call the service to delete the node on the remote site
$result = xmlrpc($endpoint, 'node.deleteDistributedNode', $session_id, (int)$node->nid);
-
+
if($result){
drupal_set_message(t('Deleted node on ' . $site['sitetext']. ' with node id ' . $result));
}else{
@@ -402,20 +404,13 @@ function distribution_site_js() {
/**
- * Theme the admin site form for choices.
+ * Theme the form for site choices.
*
* @ingroup themeable
*/
function theme_site_choices($form) {
- // Change the button title to reflect the behavior when using JavaScript.
- //drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-poll-more").val("'. t('Add another choice') .'"); }); }', 'inline');
-
foreach (element_children($form) as $key) {
- // No need to print the field title every time.
- //unset($form[$key]['sitetext']['#title']);
-
- drupal_render($form[$key]['sitetext']);
-
+ drupal_render($form[$key]['sitetext']);
}
$output .= drupal_render($form);
return $output;
diff --git a/includes/content_distribution.views.inc b/includes/content_distribution.views.inc
index e66be42..2da6313 100644
--- a/includes/content_distribution.views.inc
+++ b/includes/content_distribution.views.inc
@@ -272,7 +272,16 @@ function content_distribution_views_data(){
'handler' => 'views_handler_filter_date',
),
);
-
+
+ //week argument
+ $data['content_distribution']['published_week'] = array(
+ 'title' => t('Published week'),
+ 'help' => t('In the form of WW (01 - 53).'),
+ 'argument' => array(
+ 'field' => 'published_date',
+ 'handler' => 'views_handler_argument_node_created_week',
+ ),
+ );
return $data;
}
diff --git a/modules/content_retriever/content_retriever.admin.inc b/modules/content_retriever/content_retriever.admin.inc
index d4956b7..1aaaf0b 100644
--- a/modules/content_retriever/content_retriever.admin.inc
+++ b/modules/content_retriever/content_retriever.admin.inc
@@ -64,16 +64,13 @@ function content_retriever_admin_form() {
'#name' => 'reset_status',
'#submit' => array('content_retriever_admin_clear_http_status_form_submit'),
);
- $form['reset_timestamp_submit'] = array(
- '#type' => 'submit',
- '#value' => 'Reset last run time',
- '#validate' => array('content_retriever_admin_reset_last_run_form_validate'),
- '#submit' => array('content_retriever_admin_reset_last_run_form_submit'),
- );
+
return $form;
}
-
+/**
+ * content types form.
+ */
function content_retriever_admin_types_form($form_values = null) {
// retrieve array of content types for distribution from web service
@@ -83,6 +80,7 @@ function content_retriever_admin_types_form($form_values = null) {
// connect to the system service to get a session id
$connect = content_retriever_xmlrpc($endpoint, 'system.connect', $api_key);
$session_id = $connect['sessid'];
+
//retrieve content types
$fields = content_retriever_xmlrpc($endpoint, 'node.getAllTypes', $api_key, $session_id);
@@ -97,7 +95,8 @@ function content_retriever_admin_types_form($form_values = null) {
foreach($not_installed as $item){
unset($fields[$item]);
}
- variable_set('content_retriever_content_types', $fields);
+
+ //variable_set('content_retriever_content_types', $fields);
}else{
drupal_set_message(t('Could not retrieve a list of content types from the remote server'), 'error');
}
@@ -206,39 +205,6 @@ function content_retriever_admin_skip_form_submit($form, &$form_state) {
$form_state['skip_install'] = true;
}
-/**
- * form validate function for the reset last time run submit button
- * validates the user entered date.
- */
-function content_retriever_admin_reset_last_run_form_validate($form, &$form_state){
- $reset = $form_state['values']['reset_timestamp'];
- // get the current timestamp and convert user entered date to
- // timestamp to compare
- $now = time();
- $reset_timestamp = date_convert($reset,DATE_DATETIME, DATE_UNIX);
-
- // set form error if invalid date format
- if(!date_is_valid($reset, $type = DATE_DATETIME)){
- form_set_error('reset timestamp', t('Please enter a valid date format.'));
- }else if($reset_timestamp > $now){
- form_set_error('reset timestamp', t('Please enter a time in the past to reset the last run time to.'));
- }
-}
-
-/**
- * submit handler for the reset last time run form button
- * sets the last time run variable to whatever the user input
- * is in the form text field.
- */
-function content_retriever_admin_reset_last_run_form_submit($form, &$form_state){
- $time = $form_state['values']['reset_timestamp'];
- // convert date to unix timestamp
- $reset = date_convert($time,DATE_DATETIME, DATE_UNIX);
- variable_set('content_retriever_last_run', $reset);
- drupal_set_message('Content retriever last run time set to ' . $time);
-}
-
-
/**
* Submit function to install selected content type.
@@ -286,6 +252,19 @@ function content_retriever_admin_form_validate($form, &$form_state) {
if (strpos($form_state['values']['endpoint'], 'http') != 0) {
form_set_error('endpoint', t('The service endpoint must be a valid HTTP or HTTPS web address.'));
}
+ $reset = $form_state['values']['reset_timestamp'];
+ // get the current timestamp and convert user entered date to
+ // timestamp to compare
+ $now = time();
+ $reset_timestamp = date_convert($reset,DATE_DATETIME, DATE_UNIX);
+
+ // set form error if invalid date format
+ if(!date_is_valid($reset, $type = DATE_DATETIME)){
+ form_set_error('reset_timestamp', t('Please enter a valid date format.'));
+ }else if($reset_timestamp > $now){
+ form_set_error('reset_timestamp', t('Please enter a time in the past to reset the last run time to.'));
+ }
+
}
/**
* submit function for 'Settings' form.
@@ -298,6 +277,11 @@ function content_retriever_admin_form_submit($form, &$form_state){
variable_set('content_retriever_webservice_username', $form_state['values']['username']);
variable_set('content_retriever_webservice_pass', $form_state['values']['password']);
+ $time = $form_state['values']['reset_timestamp'];
+ // convert date to unix timestamp
+ $reset = date_convert($time,DATE_DATETIME, DATE_UNIX);
+ variable_set('content_retriever_last_run', $reset);
+
drupal_set_message(t('Content Retriever Settings Saved.'));
}
@@ -358,8 +342,9 @@ function content_retriever_admin_queues_form(){
// connect to the web service to get a session id
$connect = content_retriever_xmlrpc($endpoint, 'system.connect', $api_key);
$session_id = $connect['sessid'];
-
+
$queues = content_retriever_xmlrpc($endpoint, 'nodequeue.getQueues', $api_key, $session_id);
+
if ($queues) {
foreach ($queues as $queue) {
$queue_fields[$queue['qid']] = $queue['title'];
diff --git a/modules/content_retriever/content_retriever.info b/modules/content_retriever/content_retriever.info
index f774c7a..3089b09 100644
--- a/modules/content_retriever/content_retriever.info
+++ b/modules/content_retriever/content_retriever.info
@@ -1,6 +1,8 @@
+; $Id$
name = Content Retriever
description = Queries the views.getView method exposed by the Services module on an endpoint of your choice and parses and saves the resulting nodes in the local database.
package = Content Distribution
+version = 6.x-1.x-dev
core = 6.x
dependencies[] = node
dependencies[] = distributor_service
diff --git a/modules/content_retriever/content_retriever.install b/modules/content_retriever/content_retriever.install
index d6db5aa..59cb215 100644
--- a/modules/content_retriever/content_retriever.install
+++ b/modules/content_retriever/content_retriever.install
@@ -9,6 +9,12 @@ function content_retriever_install() {
// Create tables.
drupal_install_schema('content_retriever');
+ /* run this once */
+ /* $result = db_query("SELECT nid, field_original_nid from {content_field_original_nid}");
+ while($nid = db_fetch_object($result)){
+ //write record in content_distribution table
+ drupal_write_record('content_retriever', $nid->nid, $nid->field_original_nid);
+ }*/
}
/**
diff --git a/modules/content_retriever/content_retriever.module b/modules/content_retriever/content_retriever.module
index 8db3fbf..e30e9e7 100644
--- a/modules/content_retriever/content_retriever.module
+++ b/modules/content_retriever/content_retriever.module
@@ -23,17 +23,7 @@ function content_retriever_form_alter(&$form, $form_state, $form_id) {
* Implementation of hook_menu().
*/
function content_retriever_menu() {
- //visual output for debug purposes
- $last_run = variable_get('content_retriever_last_run', (time() - (24 * 60 * 60)) );
- $items['admin/content/retriever'] = array(
- 'title' => 'Content Retriever visual output',
- 'description' => t('If you need to physically see the retrieved content for debug purposes, touching this page runs the processes and outputs the resulting nodes to screen.'),
- 'page callback' => '_content_retriever_save_nodes',
- 'page arguments' => array((string) $last_run),
- 'access arguments' => array('access content'),
- 'weight' => -11,
- 'type' => MENU_NORMAL_ITEM,
- );
+
//the admin page
$items['admin/settings/retriever'] = array(
'title' => 'Content Retriever Settings',
@@ -77,6 +67,17 @@ function content_retriever_menu() {
'file' => 'content_retriever.admin.inc',
);
+ //visual output for debug purposes
+ $last_run = variable_get('content_retriever_last_run', (time() - (24 * 60 * 60)) );
+ $items['admin/settings/retriever/output'] = array(
+ 'title' => 'Content Retriever visual output',
+ 'description' => t('If you need to physically see the retrieved content for debug purposes, touching this page runs the processes and outputs the resulting nodes to screen.'),
+ 'page callback' => '_content_retriever_save_nodes',
+ 'page arguments' => array((string) $last_run),
+ 'access arguments' => array('administer content retrieval'),
+ 'weight' => 5,
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
@@ -189,19 +190,62 @@ function _content_retriever_save_nodes($last_run) {
$node->taxonomy = taxonomy_parser_import_taxonomy($term_categories, $node->type);
}
}else{
+ // module is not installed so capture the issue
+ watchdog('your_theme', 'Failed to call taxonomy_parser_import_taxonomy(). The taxonomy_parser module is not available.', WATCHDOG_WARNING);
unset($node->taxonomy);
}
+
+ //fetch imagefield / filefield files
+ if((module_exists('imagefield')) || (module_exists('filefield'))){
+ $fields = content_fields();
+ $files_array = array();
+ //check the cck field exists on the local content type
+
+ if (!empty($fields)) {
+ foreach($fields as $content_type_field){
+ if(($content_type_field['type_name'] == $node->type) && (($content_type_field['module'] == 'imagefield')) || ($content_type_field['module'] == 'filefield')){
+ if(!empty($node->$content_type_field['field_name'])){
+ $files_array[$content_type_field['field_name']] = $node->$content_type_field['field_name'];
+ }
+ }
+ }
+ }
+
+ $file_count = count($files_array);
+ if ($file_count > 0) {
+ // get a session id from system.service module
+ $connect = content_retriever_xmlrpc($endpoint, 'system.connect', $api_key);
+ $session_id = $connect['sessid'];
+
+ foreach($files_array as $field => $file_type){
+ $field_array = $node->$field;
+ foreach($file_type as $key => $incoming_file){
+ $file = content_retriever_xmlrpc($endpoint, 'file.get', $api_key, $session_id, (int)$incoming_file['fid']);
+ $file_details = _content_retriever_save_file($file, $node->nid, 'cck', $field, $node->type);
+
+ $field_array[$key]['fid'] = $file_details->fid;
+ $field_array[$key]['filepath'] = $file_details->filepath;
+ }
+ $node->$field = $field_array;
+ }
+ }
+ }
+
// save the node
node_save($node);
+
+ //format node->published_date to unix timestamp for DB entry.
+ $published_date = $node->published_date;
+ $published_date = date_convert($published_date, DATE_DATETIME, DATE_UNIX);
// check whether we are inserting a new node or updating an existing one
if(!empty($nid)){
- db_query("UPDATE {content_retriever} SET published_date = %d WHERE nid = %d", $node->published_date, $node->nid);
+ db_query("UPDATE {content_retriever} SET published_date = %d WHERE nid = %d", $published_date, $node->nid);
}else{
- db_query("INSERT INTO {content_retriever} (nid, original_nid, published_date) VALUES (%d, %d, %d)", $node->nid, $remote_nid, $node->published_date);
+ db_query("INSERT INTO {content_retriever} (nid, original_nid, published_date) VALUES (%d, %d, %d)", $node->nid, $remote_nid, $published_date);
}
-
+
//fetch ordinary upload module attached files
if (module_exists('upload')) {
$files_array = array();
@@ -212,8 +256,12 @@ function _content_retriever_save_nodes($last_run) {
$connect = content_retriever_xmlrpc($endpoint, 'system.connect', $api_key);
$session_id = $connect['sessid'];
$files = content_retriever_xmlrpc($endpoint, 'file.getNodeFiles', $api_key, $session_id, $remote_nid);
- foreach ($files as $file) {
- _content_retriever_save_file($file, $node->nid, 'file');
+ if(!empty($files)){
+ foreach ($files as $file) {
+ _content_retriever_save_file($file, $node->nid, 'file');
+ }
+ }else{
+ watchdog(t('integration'), t('Content retriever ran but could not retrieve files on node with node ID %node'), array('%node' => $node->nid), WATCHDOG_NOTICE);
}
}
}
@@ -263,6 +311,16 @@ function _content_retriever_fetch_nodes($last_run) {
$nodes = array();
$processed_nids = array();
+ //we need to be logged in as webservice user with
+ //'administer nodes' permissions to be able to
+ //retrieve unpublished nodes via views.get service call
+ $connect = content_retriever_xmlrpc($endpoint, 'system.connect', $api_key);
+ $session_id = $connect['sessid'];
+
+ //login as webservice user
+ $login = content_retriever_xmlrpc($endpoint, 'user.login', $api_key, $session_id, $username, $password);
+ $session_id = $login['sessid'];
+
foreach ($content_types as $contenttype) {
foreach ($queues as $qid => $queue) {
@@ -271,17 +329,9 @@ function _content_retriever_fetch_nodes($last_run) {
//print $viewname;
//var_dump(array($qid, $contenttype,
//var_dump($viewname, $contenttype, $qid, format_date($last_run, 'custom', 'YmdHi'));
-
- //we need to be logged in as webservice user with
- //'administer nodes' permissions to be able to
- //retrieve unpublished nodes via views.get service call
- $connect = content_retriever_xmlrpc($endpoint, 'system.connect', $api_key);
- $session_id = $connect['sessid'];
- //login as webservice user
- $login = content_retriever_xmlrpc($endpoint, 'user.login', $api_key, $session_id, $username, $password);
- $session_id = $login['sessid'];
-
+
$result = content_retriever_xmlrpc($endpoint, 'views.get', $api_key, $session_id, $viewname, array((int)$qid, $contenttype, format_date($last_run, 'custom', 'YmdHi')));
+ //print_r($result);
if($result) {
foreach ($result as $node_info) {
//load the remote node
@@ -354,16 +404,17 @@ function _content_retriever_fetch_node($nid, $session_id, $fields = array()) {
* - image
* - file
*/
-function _content_retriever_save_file($file, $nid, $type) {
+function _content_retriever_save_file($file, $nid, $type, $field = '', $node_type = '') {
$file_data = base64_decode($file['file']);
switch ($type) {
case 'file':
//set filepath to save to
- $file['filepath'] = file_directory_path().'/'.$file['filename'];
+ $file['filepath'] = file_directory_path().'/'.$file['filename'];
+
//save file
//note, safe to REPLACE because we can be certain we will not have duplicates
- //we wish to keep - cms.defaqto.com will be handling duplicate file names
+ //we wish to keep - distirbution site will be handling duplicate file names
//so we will only ever receive unique ones here
file_save_data($file_data, $file['filepath'], FILE_EXISTS_REPLACE);
@@ -387,8 +438,49 @@ function _content_retriever_save_file($file, $nid, $type) {
//write record in upload table
drupal_write_record('upload', $upload);
+ return true;
break;
+ case 'cck':
+ //set filepath to save to
+ $file['filepath'] = file_directory_path().'/'.$file['filename'];
+
+ //set content type db table, and field to search on.
+ $content_table = 'content_type_'.$node_type;
+ $fid_field = $field.'_fid';
+
+ $file_details = array();
+ //get timestamp and fid if there is a file on this node
+ $result = db_query("SELECT f.timestamp, f.fid, f.filepath FROM {files} as f
+ RIGHT JOIN {%s} as ctype
+ ON f.fid=ctype.%s
+ WHERE ctype.vid = (SELECT MAX({%s}.vid)
+ FROM {%s}) AND ctype.nid = %d", $content_table, $fid_field, $content_table, $content_table, $nid);
+
+
+ $file_details = db_fetch_object($result);
+
+ //check if it's the same file coming over
+ if($file_details->timestamp == $file['timestamp']){
+ //if it is it dont write another record in the files table.
+ return $file_details;
+ }else{
+ //save file
+ //note, safe to REPLACE because we can be certain we will not have duplicates
+ //we wish to keep - distribution site will be handling duplicate file names
+ //so we will only ever receive unique ones here
+ file_save_data($file_data, $file['filepath'], FILE_EXISTS_REPLACE);
+
+ //write record in files table
+ drupal_write_record('files', $file);
+
+ $result = db_query("SELECT fid,filepath FROM {files} WHERE filename = '%s'", $file['filename']);
+ $file_details = db_fetch_object($result);
+
+ return $file_details;
+ }
+ break;
+
//note, we do not need to save data in the database, as the image module
//handles this automatically using a hook_insert implementation
case 'image':
@@ -400,7 +492,8 @@ function _content_retriever_save_file($file, $nid, $type) {
//see comments against case 'file' for these steps
file_save_data($file_data, $file['filepath'], FILE_EXISTS_RENAME);
-
+
+ return true;
break;
}
@@ -442,22 +535,30 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
watchdog('integration', t('Drupal is unable to make HTTP requests. Please reset the HTTP request status.'), array(), WATCHDOG_CRITICAL);
} else {
+ if($api_key != ''){
+ //use api key to get a hash code for the service.
+ $timestamp = (string) strtotime("now");
+ $domain = $_SERVER['SERVER_NAME'];
+ $nonce = content_retriever_get_unique_code('10');
+ $hash_parameters = array(
+ $timestamp,
+ $domain,
+ $nonce,
+ $method,
+ );
+ $hash = hash_hmac("sha256", implode(';', $hash_parameters), $api_key);
+ }
+
switch ($method) {
- case 'system.connect':
- //check for an API key - if not supplied, presume not required
- if ($api_key == '') {
- //$param1 is view name, $param2 is array of view arguments
+ case 'system.connect':
$result = xmlrpc($endpoint, $method);
- } else {
- $result = xmlrpc($endpoint, $method, $api_key);
- }
break;
case 'user.login':
//check for an API key - if not supplied, presume not required
if ($api_key == '') {
- $result = xmlrpc($endpoint, $method, $session_id, $param1, $param2);
+ $result = xmlrpc($endpoint, $method, $session_id, (string) $param1, (string) $param2);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id, $param1, $param2);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, (string) $param1, (string) $param2);
}
break;
case 'user.logout':
@@ -465,7 +566,7 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
if ($api_key == '') {
$result = xmlrpc($endpoint, $method, $session_id);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id);
}
break;
case 'views.get':
@@ -473,9 +574,10 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
if ($api_key == '') {
//$param1 is view name, $param2 is array of view arguments
//'default' is display_id parameter hardcoded to default.
- $result = xmlrpc($endpoint, $method, $session_id, $param1, 'default', array(), $param2, 0, 0);
+ $result = xmlrpc($endpoint, $method, $session_id, (string) $param1, 'default', array(), (array) $param2, 0, 0);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id, $param1, 'default', array(), $param2);
+ //var_dump($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, $param1, $param2);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, (string) $param1, 'default', array(), (array) $param2, 0, 0);
}
break;
@@ -483,9 +585,19 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
//check for an API key - if not supplied, presume not required
if ($api_key == '') {
//$param1 is nid
- $result = xmlrpc($endpoint, $method, $session_id, $param1);
+ $result = xmlrpc($endpoint, $method, $session_id, (int) $param1);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id, $param1);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, (int) $param1);
+ }
+ break;
+
+ case 'file.get':
+ //check for an API key - if not supplied, presume not required
+ if ($api_key == '') {
+ //$param1 is fid
+ $result = xmlrpc($endpoint, $method, $session_id, (int) $param1);
+ } else {
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, (int) $param1);
}
break;
@@ -494,7 +606,7 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
if ($api_key == '') {
$result = xmlrpc($endpoint, $method, $session_id);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id);
}
break;
@@ -502,9 +614,9 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
//check for an API key - if not supplied, presume not required
if ($api_key == '') {
//$param1 is nid, $param2 is array of cck field names
- $result = xmlrpc($endpoint, $method, $session_id, $param1, $param2);
+ $result = xmlrpc($endpoint, $method, $session_id, (int) $param1, (array) $param2);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id, $param1, $param2);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, (int) $param1, (array) $param2);
}
break;
@@ -512,9 +624,9 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
//check for an API key - if not supplied, presume not required
if ($api_key == '') {
//$param1 is nid
- $result = xmlrpc($endpoint, $method, $session_id, $param1);
+ $result = xmlrpc($endpoint, $method, $session_id, (int) $param1);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id, $param1);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id, (int) $param1);
}
break;
@@ -524,7 +636,7 @@ function content_retriever_xmlrpc($endpoint, $method, $api_key, $session_id = ''
//$param1 is nid
$result = xmlrpc($endpoint, $method, $session_id);
} else {
- $result = xmlrpc($endpoint, $method, $api_key, $session_id);
+ $result = xmlrpc($endpoint, $method, $hash, $domain, $timestamp, $nonce, $session_id);
}
break;
@@ -572,7 +684,7 @@ function content_retriever_preprocess_page(&$variables) {
* is deleted.
*/
function content_retriever_nodeapi(&$node, $op, $teaser, $page) {
-
+
switch ($op) {
case 'delete':
// remove db row from content_retriever
@@ -581,5 +693,9 @@ function content_retriever_nodeapi(&$node, $op, $teaser, $page) {
}
}
-
+function content_retriever_get_unique_code($length = ''){
+ $code = md5(uniqid(rand(), true));
+ if ($length != "") return substr($code, 0, $length);
+ else return $code;
+}
diff --git a/modules/distributor_service/distributor_service.info b/modules/distributor_service/distributor_service.info
index ab70b4e..460c24b 100644
--- a/modules/distributor_service/distributor_service.info
+++ b/modules/distributor_service/distributor_service.info
@@ -1,5 +1,7 @@
+; $Id$
name = Distributor Service
description = Allows other modules to poll the content distribution module and retreive data via the Services module.
package = Content Distribution
+version = 6.x-1.x-dev
core = 6.x
dependencies[] = services \ No newline at end of file
diff --git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..70940b1
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,101 @@
+-----------------------------------------
+content_distribution configuration notes
+-----------------------------------------
+
+Typical Setup
+ - 1 central content distribution site
+ - 1-many remote content retriever sites
+
+You should choose which drupal instance is going to be your 'content serving' instance.
+This should be configured with the content_distribution module installed on it (see content distribution settings below)
+
+You may then have 1 or more remote 'content retrieving' sites which will receive content
+via web services from your 'content serving' drupal instance. All sites may sit on the same server or may be disparate
+since all the data is sent and received via XMLRPC and the various services modules it does not matter.
+
+To configure the content_distribution module you should do the following -
+
+---------------------------------------------------------
+Content distribution settings - distributor site (content serving) settings
+---------------------------------------------------------
+ - Install content_distribution module and relevant dependencies then:
+
+ - admin/settings/distribution - set up website URLs of your 'content retrieving' sites in the form http://www.site.com
+
+ - admin/build/services/settings - For best results Enable Session IDs for services, Enable Use Keys for services
+
+ - admin/build/services/keys - Set up individual API keys for each remote website that you have
+
+ - admin/user/user - set up a webservice user with a role with access to all permissions below
+
+ - admin/user/permissions - configure the following permissions to be accessed by your webservice user
+
+ - distributor service module permissions
+ - file service module permissions
+ - node service module permissions
+ - nodequeue_service module permissions
+ - services module permissions
+ - system_service module permissions
+
+ - admin/content/node-type/type - For each content type you want to distribute you should
+ tick the box to 'enable node type to be distributed' under the content distribution settings fieldset.
+
+ - Set up Nodequeues in admin/content/nodequeue
+ - nodequeues allow you to filter / target content to specific sites. Each remote site can be configured to receive (or not) content from the
+ available nodequeues set-up on the 'content serving' site. For example site1.com might be receiving content from nodequeue 1 and nodequeue 2 whereas
+ site2.com might only receive content from nodequeue 2.
+ - You will need to add at least 1 queue. A typical example is you might want to set-up a queue for each remote site you have.
+ This will allow content to be targetted to each of these sites individual. You might also want to have a queue which gets received by 'all' sites (for general content for example).
+
+-----------------------
+Good test at this stage
+-----------------------
+ - try create a piece of distributable content on a node/add page - there should be 2 additional fieldsets on the node/add form
+ - Published Date and Nodequeues for you to choose from to publish content to.
+
+--------------------
+Test view is working
+--------------------
+ - another good test at this stage is to test your content distribution view is working correctly. since this is what your remote
+ site will interrogate to bring content over.
+
+ - in admin/build/views/edit/content_distribution_queue - check view is configured correctly to display data - try previewing the view
+ it will accept arguments in the format -
+
+ - NodequeueID/ContentType/Date
+ - Date should be in the format - YYYYMMDD
+ - e.g. 1/news_item/20090101
+
+----------------------------------------------
+Content Retriever - remote site configurations
+----------------------------------------------
+ - install content_retriever module and relevant dependencies then:
+
+ - *NOTE* the same content type must be installed on the distributing / remote site otherwise you will not be able to retrieve and save the nodes.
+
+ - admin/build/services/settings - Enable use of sessid.
+
+ - admin/settings/retriever -
+
+ - service endpoint (distribution site (content serving) xmlrpc url) - usually http://sitename.com/services/xmlrpc
+ - Service API key for this site (as set up in distribution settings)
+ - service username and password (as set up in distribution settings)
+ - view to query on distribution site (by default this will be the view provided with the module
+ which has the name 'content_distribution_queue'
+ - reset time retriever last run - Useful if you want to set the time back to re-import a bunch of nodes
+
+
+ - admin/settings/retriever/types -
+ - this page should show a list of 'available' content types to retrieve from the content serving site
+ - if the remote site does not have one of the 'available' content types installed the module will:
+ - ask if you want to install any content types which have not been installed on this site
+
+ - skipping/installing then allows you to check which content types to retrieve from distribution server
+
+
+ - admin/settings/retriever/queues
+ - This page shows a list of available nodequeue on the distribution site to retrieve content from.
+ - check which queues you want your remote site to retrieve from.
+
+ - admin/settings/retriever/output - this just runs the content retriever and shows a visual output of the nodes it retrieved.
+useful for debugging purposes.