Plugin Directory

Changeset 332168


Ignore:
Timestamp:
01/13/2011 05:17:51 PM (15 years ago)
Author:
dphiffer
Message:

Fixed a bug with the exclude query param

File:
1 edited

Legend:

Unmodified
Added
Removed
  • json-api/trunk/singletons/response.php

    r331917 r332168  
    66    global $json_api;
    77    $this->include_values = array();
     8    $this->exclude_values = array();
    89    if ($json_api->query->include) {
    910      $this->include_values = explode(',', $json_api->query->include);
    1011    }
     12    // Props to ikesyo for submitting a fix!
    1113    if ($json_api->query->exclude) {
    12       $exclude = explode(',', $json_api->query->exclude);
    13       $this->include_values = array_diff($this->include_values, $exclude);
     14      $this->exclude_values = explode(',', $json_api->query->exclude);
     15      $this->include_values = array_diff($this->include_values, $this->exclude_values);
    1416    }
    1517   
     
    4446 
    4547  function is_value_included($key) {
    46     if (empty($this->include_values)) {
     48    // Props to ikesyo for submitting a fix!
     49    if (empty($this->include_values) && empty($this->exclude_values)) {
    4750      return true;
    4851    } else {
    49       return in_array($key, $this->include_values);
     52      if (empty($this->exclude_values)) {
     53        return in_array($key, $this->include_values);
     54      } else {
     55        return !in_array($key, $this->exclude_values);
     56      }
    5057    }
    5158  }
Note: See TracChangeset for help on using the changeset viewer.