You are here

function uc_repeater_export in Ubercart 5

Pushes new products to other sites.

1 call to uc_repeater_export()
uc_repeater_nodeapi in uc_repeater/uc_repeater.module

File

uc_repeater/uc_repeater.module, line 139
Allows a multisite setup to share changes to the catalog.

Code

function uc_repeater_export($nids = array()) {
  if (count($nids)) {
    if (count($nids) == 1) {

      // Most awesome use of casting ever: wrap in an array if not an array.
      $nids = (array) $nids;
    }

    //drupal_set_message('<pre>'. print_r($nids, true) .'</pre>');
    $xml = uc_importer_export($nids);

    //drupal_set_message('<pre>'. htmlentities($xml) .'</pre>');
    if ($xml) {
      $responses = array();
      foreach (variable_get('uc_repeater_slaves', array()) as $site) {
        $responses[$site] = drupal_http_request('http://' . $site . '/repeater/import/' . md5($_SERVER['SERVER_NAME'] . substr(base_path(), 0, -1)) . '/' . md5($xml), array(
          'Content-Type' => 'text/xml',
        ), 'POST', $xml);

        //watchdog('uc_repeater', htmlentities($xml) ."<br />$site:<pre>". print_r($responses[$site], true) ."</pre>", WATCHDOG_NOTICE);
      }
    }
  }
}