I wrote a significant fix on views_savedsearches.module file to change the _views_savedsearches_filters_to_params function in which the iterative approach for the inspection of structured params had to be changed with a recursive approach.

Here is my code (function _views_savedsearches_recursively_examine_array is completely new):

/**
 * Helper function; examines recursively the array parameter and generate
 * the GET query string for tree-structured data
 *
 * @param $array_filter
 *  An array container filter value(s) pairs.
 * @param $current_array_string
 *  A string for internal funcionality.
 * @return
 *  A string, part of the GET query for array parameter.
 */
 function _views_savedsearches_recursively_examine_array($array_filter, $current_array_string)
{
  $inner_query = "";
  
  foreach ($array_filter as $filter => $value)
  {
	if (!is_array($value)) 
	{
	  $inner_query .= "&".$current_array_string.drupal_urlencode('[').$filter.drupal_urlencode(']')."=".drupal_urlencode($value);
	}
	else
	{
	  $inner_query .= _views_savedsearches_recursively_examine_array($value, $current_array_string.drupal_urlencode('[').$filter.drupal_urlencode(']'));
	}
  }
	
  return $inner_query;
}

/**
 * Helper function; constructs a params string from an array of filters (can
 * be used as a GET query, similar to the "params" method of jQuery).
 *
 * @param $filters
 *  An array container filter name - filter value(s) pairs.
 * @return
 *  A GET query.
 */
function _views_savedsearches_filters_to_params($filters) {
  $query = '';

  if (is_array($filters)) {
    foreach ($filters as $filter_name => $filter_value) {
      // Distinction between multiple-value filters and single-value filters.
      if (is_array($filter_value)) {
        //  foreach ($filter_value as $key => $value) {
        //    if (strlen($query) > 0) {
        //     $query .= '&';
        //   }
        //   if (!is_array($value)) {
        //     $query .= drupal_urlencode($filter_name) . drupal_urlencode('[]') .'='. drupal_urlencode($value);
        //   }
        //   else {
        //     // Date-style parameter, like date_filter[value][date]=2009-05-11 in the URL encoded
        //     $arr = drupal_urlencode('['. $key .']');
        //     $open = drupal_urlencode('[');
        //     $close = drupal_urlencode(']');
        //     foreach ($value as $k => $v) {
        //       if (strlen($query) > 0) {
        //         $query .= '&';
        //       }
        //       $query .= $filter_name . $arr . $open . $k . $close . '=' . $v;
        //     }
        //   }
        // }
		$query .= _views_savedsearches_recursively_examine_array($filter_value, $filter_name);
      }
      else {
        if (strlen($query) > 0) {
          $query .= '&';
        }
        $query .= drupal_urlencode($filter_name) .'='. drupal_urlencode($filter_value);
      }
    }
  }
  return $query;
}
 

Comments

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ivoo56’s picture

this is great solution!!! worked as a charm!
Thanks gianfrasoft!

gianfrasoft’s picture

:)

yogaf’s picture

Great job :)
Thanks