2010-12-02 23:34:41 +00:00
< html >
< head >
2012-10-17 14:21:55 -04:00
< title > SugarCRM test webservices </ title >
2010-12-02 23:34:41 +00:00
</ head >
< style type = " text/css " >
ul . krumo - node {
margin : 0 px ;
padding : 0 px ;
background - color : white ;
2012-10-17 14:21:55 -04:00
}
2010-12-02 23:34:41 +00:00
ul . krumo - node ul {
margin - left : 20 px ;
2012-10-17 14:21:55 -04:00
}
2010-12-02 23:34:41 +00:00
* html ul . krumo - node ul {
margin - left : 24 px ;
2012-10-17 14:21:55 -04:00
}
2010-12-02 23:34:41 +00:00
div . krumo - root {
border : solid 1 px black ;
margin : 1 em 0 em ;
2012-10-17 14:21:55 -04:00
text - align : left ;
}
2010-12-02 23:34:41 +00:00
ul . krumo - first {
font : normal 11 px tahoma , verdana ;
border : solid 1 px white ;
2012-10-17 14:21:55 -04:00
}
2010-12-02 23:34:41 +00:00
li . krumo - child {
2012-10-17 14:21:55 -04:00
display : block ;
2010-12-02 23:34:41 +00:00
list - style : none ;
padding : 0 px ;
margin : 0 px ;
2012-10-17 14:21:55 -04:00
overflow : hidden ;
}
2010-12-02 23:34:41 +00:00
2012-10-17 14:21:55 -04:00
div . krumo - element {
cursor : default ;
display : block ;
clear : both ;
white - space : nowrap ;
2010-12-02 23:34:41 +00:00
background - color : white ;
background - image : url ( / Krumo / skins / schablon . com / empty . gif );
background - repeat : no - repeat ;
background - position : 6 px 5 px ;
padding : 2 px 0 px 3 px 20 px ;
2012-10-17 14:21:55 -04:00
}
2010-12-02 23:34:41 +00:00
* html div . krumo - element {
padding - bottom : 3 px ;
line - height : 13 px ;
2012-10-17 14:21:55 -04:00
}
2010-12-02 23:34:41 +00:00
a . krumo - name {
2012-10-17 14:21:55 -04:00
color : navy ;
2010-12-02 23:34:41 +00:00
font : bold 13 px courier new ;
2012-10-17 14:21:55 -04:00
line - height : 12 px ;
}
2010-12-02 23:34:41 +00:00
</ style >
2011-01-06 11:11:53 +00:00
< ? php
2012-10-17 14:21:55 -04:00
2017-02-15 16:26:02 +00:00
2015-03-18 16:06:25 -04:00
$filter = new InputFilter ();
$_POST = $filter -> xssFilterHard ( $_POST );
$_SESSION = $filter -> xssFilterHard ( $_SESSION );
2012-10-17 14:21:55 -04:00
if ( isset ( $_POST [ " epr " ] )) {
$_SESSION [ 'END_POINT' ] = $_POST [ " epr " ];
}
$endpoint = isset ( $_SESSION [ 'END_POINT' ] ) ? $_SESSION [ 'END_POINT' ] : 'http://sugar.opensource.colosa.net/soap.php' ;
2015-03-18 16:06:25 -04:00
$endpoint = $filter -> xssFilterHard ( $endpoint );
2012-10-17 14:21:55 -04:00
$sessionId = isset ( $_SESSION [ 'SESSION_ID' ] ) ? $_SESSION [ 'SESSION_ID' ] : '' ;
2015-03-18 16:06:25 -04:00
$sessionId = $filter -> xssFilterHard ( $sessionId );
2010-12-02 23:34:41 +00:00
?>
< form method = " post " action = " " >
2012-10-17 14:21:55 -04:00
< div class = " krumo-root " >
< ul class = " krumo-node krumo-first " >
< div class = " krumo-element " >
End Point < input type = " text " size = " 80 " maxlength = " 160 " name = " epr "
value = " <?php echo $endpoint ?> " > < input type = " submit "
value = " change endpoint " name = " action " >
</ div >
</ ul >
</ div >
</ form >
2010-12-02 23:34:41 +00:00
< form method = " post " action = " " >
2012-10-17 14:21:55 -04:00
< div class = " krumo-root " >
< a class = " krumo-name " > login </ a >
< ul class = " krumo-node krumo-first " >
< div >
User Id < input type = " text " size = " 16 " maxlength = " 20 " name = " user "
value = " admin " > Password < input type = " text " size = " 16 " maxlength = " 20 "
name = " pass " value = " sample " > < input type = " submit " value = " login "
name = " action " >
</ div >
</ ul >
</ div >
</ form >
2010-12-02 23:34:41 +00:00
< form method = " post " action = " " >
2012-10-17 14:21:55 -04:00
< div class = " krumo-root " >
< a class = " krumo-name " > createUser </ a >
< ul class = " krumo-node krumo-first " >
< div class = " krumo-element " >
Session Id < input type = " text " size = " 36 " maxlength = " 32 "
name = " sessionid " value = " <?php print $sessionId ?> " >
</ div >
< div class = " krumo-element " >
User Id < input type = " text " size = " 16 " maxlength = " 20 " name = " userid "
value = " " > < img src = " /Krumo/skins/schablon.com/empty.gif " > First
Name < input type = " text " size = " 16 " maxlength = " 20 " name = " firstname "
value = " " > < img src = " /Krumo/skins/schablon.com/empty.gif " > Last Name
< input type = " text " size = " 16 " maxlength = " 20 " name = " lastname " value = " " >
< img src = " /Krumo/skins/schablon.com/empty.gif " > Email < input
type = " text " size = " 16 " maxlength = " 20 " name = " email " value = " " > < img
src = " /Krumo/skins/schablon.com/empty.gif " > Role < input type = " text "
size = " 16 " maxlength = " 20 " name = " role " value = " " > < img
src = " /Krumo/skins/schablon.com/empty.gif " > < input type = " submit "
value = " createUser " name = " action " >
</ div >
</ ul >
</ div >
</ form >
2010-12-02 23:34:41 +00:00
< form method = " post " action = " " >
2012-10-17 14:21:55 -04:00
< div class = " krumo-root " >
< a class = " krumo-name " > assignUserToGroup </ a >
< ul class = " krumo-node krumo-first " >
< div class = " krumo-element " >
Session Id < input type = " text " size = " 36 " maxlength = " 32 "
name = " sessionid " value = " <?php print $sessionId ?> " >
</ div >
< div class = " krumo-element " >
User Id < input type = " text " size = " 16 " maxlength = " 20 " name = " userid "
value = " " > < img src = " /Krumo/skins/schablon.com/empty.gif " > Group Id
< input type = " text " size = " 16 " maxlength = " 20 " name = " groupid " value = " " >
< input type = " submit " value = " assignUserToGroup " name = " action " >
</ div >
</ ul >
</ div >
</ form >
2010-12-02 23:34:41 +00:00
< form method = " post " action = " " >
2012-10-17 14:21:55 -04:00
< div class = " krumo-root " >
< a class = " krumo-name " > newCase </ a >
< ul class = " krumo-node krumo-first " >
< div class = " krumo-element " >
Session Id < input type = " text " size = " 36 " maxlength = " 32 "
name = " sessionid " value = " <?php print $sessionId ?> " >
</ div >
< div class = " krumo-element " >
Process Id < input type = " text " size = " 16 " maxlength = " 20 "
name = " processid " value = " " > < img
src = " /Krumo/skins/schablon.com/empty.gif " > Variables < input
type = " text " size = " 16 " maxlength = " 20 " name = " variables " value = " " > < input
type = " submit " value = " newCase " name = " action " >
</ div >
</ ul >
</ div >
</ form >
2011-01-06 11:11:53 +00:00
< ? php
2010-12-02 23:34:41 +00:00
2012-10-17 14:21:55 -04:00
if ( ! isset ( $_POST [ " action " ] ) or $_POST [ " action " ] == 'change endpoint' ) {
die ();
}
$action = $_POST [ " action " ];
//krumo ($_POST);
2010-12-02 23:34:41 +00:00
2012-10-17 14:21:55 -04:00
ini_set ( " soap.wsdl_cache_enabled " , " 0 " ); // disabling WSDL cache
2010-12-02 23:34:41 +00:00
2012-10-17 14:21:55 -04:00
switch ( $action ) {
case 'login' :
$user = $_POST [ " user " ];
2015-03-26 11:22:37 -04:00
$pass = G :: encryptOld ( $_POST [ " pass " ] );
2012-10-17 14:21:55 -04:00
$wsdl = $endpoint ;
//$client = new SoapClient( $endpoint );
$client = new SoapClient ( null , array ( 'location' => $endpoint , 'uri' => 'http://www.sugarcrm.com/sugarcrm' , 'soap_version' => SOAP_1_1 , //SOAP_1_2 - 1.2 not supported by sugar nusoap
'trace' => 1 , 'exceptions' => 0 , 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5
) );
2010-12-02 23:34:41 +00:00
2012-10-17 14:21:55 -04:00
$params = array ( 'user_name' => $user , 'password' => $pass , 'version' => '1'
);
$result = $client -> __SoapCall ( 'login' , array ( 'user_auth' => $params , 'application_name' => 'ProcessMaker'
) );
if ( $result -> error -> number == 0 ) {
$_SESSION [ 'SESSION_ID' ] = $result -> id ;
$session = $result -> id ;
2010-12-02 23:34:41 +00:00
2012-10-17 14:21:55 -04:00
$res = $client -> __getFunctions ();
krumo ( $res );
$params = array ( 'session' => $result -> id
);
$res = $client -> __SoapCall ( 'is_user_admin' , array ( $session
) );
if ( $res == 1 )
print " is Administrator user " ;
$first_name = 'juan' ;
$last_name = 'perez' ;
$phone = '7235131' ;
$fax = '2454545' ;
$companyname = 'ABC company' ;
$prod_desc = 'descripcion del prod 1 ' ;
$user_guid = '' ;
$set_entry_params = array ( 'session' => $session , 'module_name' => 'Leads' ,
'name_value_list' => array ( array ( 'name' => 'last_name' , 'value' => $last_name
), array ( 'name' => 'status' , 'value' => 'New'
), array ( 'name' => 'phone_work' , 'value' => $phone
), array ( 'name' => 'phone_fax' , 'value' => $fax
), array ( 'name' => 'account_name' , 'value' => $companyname
), array ( 'name' => 'lead_source' , 'value' => 'Web Site'
), array ( 'name' => 'description' , 'value' => $prod_desc
), array ( 'name' => 'email1' , 'value' => 'juan@colosa.com'
), array ( 'name' => 'assigned_user_id' , 'value' => $user_guid
)
)
);
$res = $client -> __SoapCall ( 'set_entry' , $set_entry_params );
krumo ( $res );
//$query = "contacts.email1 != '' ";
//$orderby = 'email1 desc ';
$query = '' ;
$orderby = '' ;
$fields = array ( 'id' , 'first_name' , 'last_name' , 'account_name' , 'account_id' , 'email1' , 'phone_work'
);
$params = array ( $session , 'Leads' , $query , $orderby , 0 , $fields , 100 , false
);
$res = $client -> __SoapCall ( 'get_entry_list' , $params );
krumo ( $res );
}
break ;
case 'processList' :
$wsdl = PATH_METHODS . " services " . PATH_SEP . " pmos.wsdl " ;
$endpoint = $wsdl ;
$client = new SoapClient ( $endpoint );
$params = array ( 'sessionId' => $sessionId
);
$result = $client -> __SoapCall ( 'processesList' , array ( $params
) );
krumo ( $result );
die ();
break ;
default :
krumo ( $_POST );
die ();
}
2010-12-02 23:34:41 +00:00
?>
< div class = " krumo-root " >
< ul class = " krumo-node krumo-first " >
< li class = " krumo-child " >
2012-10-17 14:21:55 -04:00
< div class = " krumo-element " >
status_code ( < em class = " krumo-type " > Integer </ em > ) < strong
class = " krumo-integer " >< ? php echo $result -> error -> number ?> </strong>
</ div >
< div class = " krumo-element " >
message ( < em class = " krumo-type " > string </ em > ) < strong
class = " krumo-integer " >< ? php echo $result -> error -> name ?> </strong>
</ div >
< div class = " krumo-element " >
timestamp ( < em class = " krumo-type " > string </ em > ) < strong
class = " krumo-integer " >< ? php echo $result -> error -> description ?> </strong>
</ div >
</ li >
2010-12-02 23:34:41 +00:00
</ ul >
</ div >