You are here

function globallink_entity_update_status in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.6 globallink_entity/globallink_entity.inc \globallink_entity_update_status()

Updates entity status.

Parameters

object $globallink: GlobalLink object.

4 calls to globallink_entity_update_status()
globallink_auto_receive in ./globallink.module
Automatically receives translated contents.
globallink_entity_get_translated_enties in globallink_entity/globallink_entity.inc
Gets number of translated entities.
globallink_entity_receive_form_submit in globallink_entity/globallink_entity_receive.inc
Handles entity form submission.
globallink_entity_update_deleted_records in globallink_entity/globallink_entity.inc
Updates status for deleted entities.

File

globallink_entity/globallink_entity.inc, line 561

Code

function globallink_entity_update_status(&$globallink) {
  switch ($globallink->status) {

    /*case 'Source Deleted':
        case 'Error':
          $row = globallink_entity_get_row_by_nid_and_locale($globallink->nid, $globallink->sourceLocale, $globallink->targetLocale);
          $node = node_load($row->nid);

          if ($node->vid != $row->vid) {
            db_update('globallink_core_entity')
            ->fields(array(
              'vid' => $node->vid,
              'title' => $node->title,
              'status' => 'Pending Translations',
              'timestamp' => REQUEST_TIME,
            ))
            ->condition('rid', $row->rid, '=')
            ->execute();
          }
          else {
            db_update('globallink_core_entity')
            ->fields(array(
              'status' => 'Pending Translations',
              'timestamp' => REQUEST_TIME,
            ))
            ->condition('rid', $row->rid, '=')
            ->execute();
          }

          break;*/
    case 'Source Deleted':
      $row = globallink_entity_get_row_by_nid_and_locale($globallink->nid, $globallink->sourceLocale, $globallink->targetLocale);
      db_update('globallink_core_entity')
        ->fields(array(
        'status' => 'Source Deleted',
        'document_ticket' => '',
        'submission_ticket' => '',
        'timestamp' => REQUEST_TIME,
      ))
        ->condition('rid', $row->rid, '=')
        ->execute();
      break;
    case 'Error':
      $row = globallink_entity_get_row_by_nid_and_locale($globallink->nid, $globallink->sourceLocale, $globallink->targetLocale);
      db_update('globallink_core_entity')
        ->fields(array(
        'status' => 'Error',
        'timestamp' => REQUEST_TIME,
      ))
        ->condition('rid', $row->rid, '=')
        ->execute();
      break;
    default:
      $row = globallink_entity_get_row_by_nid_and_locale($globallink->nid, $globallink->sourceLocale, $globallink->targetLocale);
      $node = node_load($row->nid);
      if ($node->vid != $row->vid) {
        db_update('globallink_core_entity')
          ->fields(array(
          'vid' => $node->vid,
          'title' => $node->title,
          'status' => 'Pending Translations',
          'timestamp' => REQUEST_TIME,
        ))
          ->condition('rid', $row->rid, '=')
          ->execute();
      }
      else {
        db_update('globallink_core_entity')
          ->fields(array(
          'status' => 'Pending Translations',
          'timestamp' => REQUEST_TIME,
        ))
          ->condition('rid', $row->rid, '=')
          ->execute();
      }
  }
}