Ejemplo n.º 1
0
function check_rel_filter(&$focus, $secondary_array, $relationship_name, $rel_filter_array, $rel_module_type = "any")
{
    global $beanList;
    $relationship_name = strtolower($relationship_name);
    //list is already cached from a prior secondary trigger filter
    if (!empty($secondary_array['cached_lists'][$relationship_name])) {
        $target_array =& $rel_filter_array['base'];
        $target_list = $secondary_array['cached_lists'][$relationship_name];
    } else {
        //create new list
        $target_array =& $rel_filter_array['base'];
        $target_list = $focus->get_linked_beans($relationship_name, $beanList[$target_array['lhs_module']]);
        //Possibility exists that this is a new relationship, so capture via relationship fields
        if (empty($target_list)) {
            $target_list = search_filter_rel_info($focus, $target_array['lhs_module'], $relationship_name);
            //end if the target list is empty
        }
    }
    $all_count = count($target_list);
    $filtered_rel_list = setup_filter_records($target_list, $target_array);
    if ($rel_module_type == "all") {
        //compares before count and after count to makes sure 'all' records remained and none were filtered
        if (count($filtered_rel_list) == $all_count) {
            $secondary_array['results'] = true;
            $secondary_array['cached_lists'][$relationship_name] = $filtered_rel_list;
        } else {
            $secondary_array['results'] = false;
            $secondary_array['cached_lists'][$relationship_name] = $filtered_rel_list;
        }
        //if rel_module_type is all
    }
    if ($rel_module_type == "any") {
        if (!empty($filtered_rel_list)) {
            $secondary_array['results'] = true;
            $secondary_array['cached_lists'][$relationship_name] = $filtered_rel_list;
        } else {
            $secondary_array['results'] = false;
            $secondary_array['cached_lists'][$relationship_name] = $filtered_rel_list;
        }
        //if rel_module_type is any
    }
    return $secondary_array;
    //end function check_rel_filter
}
Ejemplo n.º 2
0
function process_rel_type($target_type, $target_filter, $target_list, $action_array, $type_override = false)
{
    if ($type_override == true) {
        $type_value = $target_type;
    } else {
        $type_value = $action_array[$target_type];
    }
    //process related list based on target_type (all, first, filter)
    if ($type_value == "first") {
        $new_list[0] = $target_list[0];
        return $new_list;
    }
    if ($type_value == "filter") {
        return setup_filter_records($target_list, $action_array[$target_filter]);
    }
    //return the whole list if the type is all
    return $target_list;
    //end process_rel_type
}