You are here

function cmis_sync_cron in CMIS API 6.2

Same name and namespace in other branches
  1. 6.4 cmis_sync/cmis_sync.module \cmis_sync_cron()
  2. 6 cmis_sync/cmis_sync.module \cmis_sync_cron()
  3. 6.3 cmis_sync/cmis_sync.module \cmis_sync_cron()
  4. 7.2 cmis_sync/cmis_sync.module \cmis_sync_cron()
  5. 7 cmis_sync/cmis_sync.module \cmis_sync_cron()

Implementation of hook_cron

@todo Synchronize individual node as well. Maybe exporting a hook, might allow other modules to implement their own sync logic. Handle SQL injection for CMIS query calls. Low priority.

1 string reference to 'cmis_sync_cron'
_cmis_sync_cmis_to_drupal_handle_updates in cmis_sync/cmis_sync.module
Creates/updates Drupal nodes with CMIS content.

File

cmis_sync/cmis_sync.module, line 139

Code

function cmis_sync_cron() {
  module_load_include('api.inc', 'cmis');
  module_load_include('inc', 'node', 'node.pages');
  try {
    $repository = cmisapi_getRepositoryInfo();
  } catch (CMISException $e) {
    cmis_error_handler('cmis_sync_cron', $e);
    return;
  }
  $sync_map = variable_get('cmis_sync_map', array());
  $sync_map_changed = FALSE;
  foreach ($sync_map as $node_type => $sync_map_type) {

    // Check if sync is enabled for this Drupal content type
    if (!array_key_exists('enabled', $sync_map_type) || !$sync_map_type['enabled']) {
      continue;
    }
    try {

      // Handle CMIS updates
      _cmis_sync_cmis_to_drupal_handle_updates($repository, $sync_map_type, $node_type);

      // Handle CMIS deletes
      if ($sync_map_type['deletes']) {
        _cmis_sync_cmis_to_drupal_handle_deletes($repository, $sync_map_type, $node_type);
      }

      // Update CMIS sync setting
      if ($sync_map_type['full_sync_next_cron']) {
        $sync_map[$node_type]['full_sync_next_cron'] = 0;
        $sync_map_changed = TRUE;
      }
    } catch (CMISException $e) {
      cmis_error_handler('cmis_sync_cron', $e);
    }
  }

  // Save CMIS sync settings
  if ($sync_map_changed) {
    variable_set('cmis_sync_map', $sync_map);
  }
}