till please look at this

Discussion in 'Developers' Forum' started by afandino, Jun 23, 2009.

  1. afandino

    afandino ISPConfig Developer ISPConfig Developer

    till,

    I have written a couple of functions one works, the other won't,
    one function has been placed in ispconfig_web.lib.php. the other in the reseller_web.lib.php
    class file. I have been having a hard time trying to trap errors that occur on the soap server side trying to debug the functions. any ideas on how to set up my environment.

    lets get to the code
    /*
    Function web_plans
    params
    return Array with all web plans from invoicing
    */

    function web_plans($session,$params) {
    global $go_api, $go_info;


    if($session["user"]["web_query"] != 1) {
    $this->errorMessage .= "method not allowed for user\r\n";
    return false;

    }

    $wplans = $go_api->db->queryAllRecords("SELECT isp_fakt_artikel.artikelbezeichnung AS web_plan, isp_fakt_artikel.artikelpreis FROM isp_fakt_artikel WHERE isp_fakt_artikel.artikeltyp = 'Web' ORDER BY isp_fakt_artikel.artikelbezeichnung");


    if(!empty($wplans)) {
    foreach($wplans as $plan) {

    $out[$plan["web_plan"]] = $plan;

    }
    return $out;


    } else {
    $this->errorMessage .= "no records found\r\n";
    return false;

    }

    }

    The way it is right now this will not return the array or an error to the soap server. Can you see anything? bellow is some test code i used to call the function through the soap connector.


    <?php
    include_once('soap.lib.php');
    include('err_lib.php');
    // Insert here your ispconfig server
    $server_url = "https://xxxxx.xxxxx:81";

    // creating object for soap_client
    $soap_client = new soap_client($server_url.'/remote/index.php');
    //echo ($server_url.'/remote/index.php');
    //echo "<br>";


    // Username and Password of the remoting user (not identical
    // with the user to log into the web interface!)

    $parameters = array('user' => 'xxxxxxx',
    'pass' => 'xxxxxx');

    // Login into ispconfig Server
    $session_id = $soap_client->call('login',$parameters);
    //echo "<br> Calling soap client" ;

    // Error Check
    if($err = $soap_client->getError()) die("Error: ".$err);



    $df2 = 1 ;

    //if($_POST['p_df'] == 1) {
    //$df2 =1 ;
    //}


    if($df2==1) {


    //get web plans list as an array
    // and fill in the select menu

    $paramsL = array ( 'sid' => $session_id,
    'module' => 'web',
    'function' => 'web_plans',
    'params' => array( 'reseller_title' => "AJFNET.COM", // Reseller1, admin, all
    'kunde_id' => '1' // kunde_title or kuunde_id (kunde_title/kunde_id overrides reseller_title)
    ));

    $Planlist = $soap_client->call('service',$paramsL);

    // Error Check

    if($err = $soap_client->getError()) die("Error: ".$err);
    print_r($Planlist) ;


    print_r('<form name="formPlan" method="post" action="auto.php">
    <select name="planSelect">');
    echo "\n";


    foreach($Planlist as $plan => $plan["web_plan"] ) {
    #
    echo "<option>$plan</option>\n";
    }
    //$df2 = 0 ;
    print_r('</select>
    <input type="submit" name="Submit" value="Submit">
    <input type="hidden" name="p_df" value= "');
    echo $df2;
    print_r('">
    </form>');


    }
    print_r($Planlist) ;
    $soap_client->call('logout',array('sid' => $session_id));
    ?>
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    And the other remoting functions are working?
     
  3. afandino

    afandino ISPConfig Developer ISPConfig Developer

    yes the other functions are working
     
  4. afandino

    afandino ISPConfig Developer ISPConfig Developer

    I guess i'll post the solution myself. It appears that the query returned an array but the way i walked through the array was wrong. The function was returning a multidimensional array which the loop could not handle, array(array(array))).
    So getting back on track now...

    Tony Fandino
     

Share This Page