Exemplo n.º 1
0
function get_modified_entries($session, $module_name, $ids, $select_fields)
{
    global $beanList, $beanFiles;
    $error = new SoapError();
    $field_list = array();
    $output_list = array();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    global $current_user;
    if (!check_modules_access($current_user, $module_name, 'read')) {
        $error->set_error('no_access');
        return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    $class_name = $beanList[$module_name];
    require_once $beanFiles[$class_name];
    $seed = new $class_name();
    //rsmith
    $in = '';
    $field_select = '';
    $table_name = $seed->table_name;
    if (isset($ids)) {
        foreach ($ids as $value) {
            if (empty($in)) {
                $in .= "('" . $GLOBALS['db']->quote($value) . "'";
            } else {
                $in .= ",'" . $GLOBALS['db']->quote($value) . "'";
            }
        }
        //end foreach
    }
    $index = 0;
    foreach ($select_fields as $field) {
        if (!isset($seed->field_defs[$field])) {
            continue;
        }
        $field_select .= $table_name . "." . $field;
        if ($index < count($select_fields) - 1) {
            $field_select .= ",";
            $index++;
        }
    }
    //end foreach
    $ids = array();
    //end rsmith
    if (!empty($in)) {
        $in .= ')';
    }
    $ret_array = $seed->create_new_list_query('', "{$table_name}.id IN {$in}", $select_fields, array(), -2, '', true, $seed, true);
    if (!is_array($params)) {
        $params = array();
    }
    if (!isset($params['custom_select'])) {
        $params['custom_select'] = '';
    }
    if (!isset($params['custom_from'])) {
        $params['custom_from'] = '';
    }
    if (!isset($params['custom_where'])) {
        $params['custom_where'] = '';
    }
    if (!isset($params['custom_order_by'])) {
        $params['custom_order_by'] = '';
    }
    $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
    $result = $seed->db->query($main_query);
    $xml = '<?xml version="1.0" encoding="utf-8"?><items>';
    while ($row = $seed->db->fetchByAssoc($result)) {
        if (version_compare(phpversion(), '5.0') < 0) {
            $temp = $seed;
        } else {
            $temp = @clone $seed;
        }
        $temp->setupCustomFields($temp->module_dir);
        $temp->loadFromRow($row);
        $temp->fill_in_additional_detail_fields();
        if (isset($temp->emailAddress)) {
            $temp->emailAddress->handleLegacyRetrieve($temp);
        }
        $val = get_return_value($temp, $table_name);
        $xml .= get_name_value_xml($val, $module_name);
    }
    $xml .= "</items>";
    $xml = base64_encode($xml);
    return array('result' => $xml, 'error' => $error->get_soap_array());
}
Exemplo n.º 2
0
function get_modified_entries($session, $module_name, $ids, $select_fields)
{
    global $beanList, $beanFiles;
    $error = new SoapError();
    $field_list = array();
    $output_list = array();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    global $current_user;
    if (!check_modules_access($current_user, $module_name, 'read')) {
        $error->set_error('no_access');
        return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    $class_name = $beanList[$module_name];
    require_once $beanFiles[$class_name];
    $seed = new $class_name();
    //rsmith
    $in = '';
    $field_select = '';
    $table_name = $seed->table_name;
    if (isset($ids)) {
        foreach ($ids as $value) {
            if (empty($in)) {
                $in .= "('" . $value . "'";
            } else {
                $in .= ",'" . $value . "'";
            }
        }
        //end foreach
    }
    $index = 0;
    foreach ($select_fields as $field) {
        $field_select .= $table_name . "." . $field;
        if ($index < count($select_fields) - 1) {
            $field_select .= ",";
            $index++;
        }
    }
    //end foreach
    $ids = array();
    //end rsmith
    if (!empty($in)) {
        $in .= ')';
    }
    $query = $seed->create_list_query($seed->process_order_by('', null), "{$table_name}.id IN {$in}", -2);
    $pattern = '/SELECT.*(' . $table_name . '\\.\\*.*?)/is';
    // ignores the case
    $replacement = 'SELECT ' . $field_select . ' ';
    $modified_select_query = preg_replace($pattern, $replacement, $query);
    $result = $seed->db->query($modified_select_query, true, "Error running count query for {$seed->object_name} List: ");
    $xml = '<?xml version="1.0" encoding="utf-8"?><items>';
    while ($row = $seed->db->fetchByAssoc($result)) {
        $val = array_get_return_value($row, $table_name);
        $xml .= get_name_value_xml($val, $module_name);
    }
    $xml .= "</items>";
    $xml = base64_encode($xml);
    return array('result' => $xml, 'error' => $error->get_soap_array());
}