agesorter

The Contact Form 7 - Infusionsoft Add-on agesorter function.

Description

agesorter( $m ); 

Parameters (1)

0. $m
The m.

Usage

  1. if ( !function_exists( 'agesorter' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7-infusionsoft-add-on/src/xmlrpc-3.0/demo/server/server.php'; 
  3.  
  4. // The m. 
  5. $m = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = agesorter($m); 
  9.  

Defined (1)

The function is defined in the following location(s).

/src/xmlrpc-3.0/demo/server/server.php  
  1. function agesorter($m) 
  2. global $agesorter_arr, $xmlrpcerruser, $s; 
  3.  
  4. xmlrpc_debugmsg("Entering 'agesorter'"); 
  5. // get the parameter 
  6. $sno=$m->getParam(0); 
  7. //errorstring for [if|when] things go wrong 
  8. $err=""; 
  9. // create the output value 
  10. $v=new xmlrpcval(); 
  11. $agar=array(); 
  12.  
  13. if (isset($sno) && $sno->kindOf()=="array") 
  14. $max=$sno->arraysize(); 
  15. // TODO: create debug method to print can work once more 
  16. // print "<!-- found $max array elements -->\n"; 
  17. for($i=0; $i<$max; $i++) 
  18. $rec=$sno->arraymem($i); 
  19. if ($rec->kindOf()!="struct") 
  20. $err="Found non-struct in array at element $i"; 
  21. break; 
  22. // extract name and age from struct 
  23. $n=$rec->structmem("name"); 
  24. $a=$rec->structmem("age"); 
  25. // $n and $a are xmlrpcvals,  
  26. // so get the scalarval from them 
  27. $agar[$n->scalarval()]=$a->scalarval(); 
  28.  
  29. $agesorter_arr=$agar; 
  30. // hack, must make global as uksort() won't 
  31. // allow us to pass any other auxilliary information 
  32. uksort($agesorter_arr, agesorter_compare); 
  33. $outAr=array(); 
  34. while (list( $key, $val ) = each( $agesorter_arr ) ) 
  35. // recreate each struct element 
  36. $outAr[]=new xmlrpcval(array("name" => 
  37. new xmlrpcval($key),  
  38. "age" => 
  39. new xmlrpcval($val, "int")), "struct"); 
  40. // add this array to the output value 
  41. $v->addArray($outAr); 
  42. else 
  43. $err="Must be one parameter, an array of structs"; 
  44.  
  45. if ($err) 
  46. return new xmlrpcresp(0, $xmlrpcerruser, $err); 
  47. else 
  48. return new xmlrpcresp($v);