You are here

function globallink_select_all_callback in GlobalLink Connect for Drupal 7.7

1 string reference to 'globallink_select_all_callback'
globallink_menu in ./globallink.module
Implements hook_menu().

File

./globallink_send_translations.inc, line 1063

Code

function globallink_select_all_callback() {
  module_load_include('inc', 'globallink', 'globallink');
  $payload = json_decode($_POST['payload']);
  $key = $payload->sessionKey;
  $ids = $payload->ids;
  if ($payload->checked) {
    if (isset($_SESSION[$key])) {
      foreach ($ids as $val) {
        if (!in_array($val, $_SESSION[$key])) {
          $_SESSION[$key][$val] = $val;
        }
      }
    }
    else {
      $_SESSION[$key] = array();
      foreach ($ids as $val) {
        $_SESSION[$key][$val] = $val;
      }
    }
  }
  else {
    if (isset($_SESSION[$key])) {
      foreach ($ids as $val) {
        if (in_array($val, $_SESSION[$key])) {
          unset($_SESSION[$key][$val]);
        }
      }
    }
  }
  $count = get_cart_count();
  return drupal_json_output(array(
    'count' => $count,
  ));
}