function globallink_test_pd_connectivity in GlobalLink Connect for Drupal 7.5
Same name and namespace in other branches
- 7.7 gl_ws/gl_ws_common.inc \globallink_test_pd_connectivity()
- 7.6 gl_ws/gl_ws_common.inc \globallink_test_pd_connectivity()
1 call to globallink_test_pd_connectivity()
- globallink_pd_settings_validate in ./
globallink_settings.inc - Handles validation of globallink_pd_settings form.
File
- gl_ws/
gl_ws_common.inc, line 50
Code
function globallink_test_pd_connectivity($pd_obj) {
$username = $pd_obj->username;
$password = $pd_obj->password;
$url = $pd_obj->url;
$project_short_code = $pd_obj->projectShortCode;
$proj_arr = array();
if ($project_short_code != '') {
$arr = explode(',', $project_short_code);
foreach ($arr as $value) {
$proj_arr[$value] = $value;
}
}
$session_service = new SessionService2(GL_WSDL_PATH . 'SessionService2.wsdl', array(
'location' => $url . '/services/SessionService2',
));
$project_service = new ProjectService2(GL_WSDL_PATH . 'ProjectService2.wsdl', array(
'location' => $url . '/services/ProjectService2',
));
$success = FALSE;
$token = globallink_login($session_service, $username, $password);
foreach ($proj_arr as $proj_code) {
try {
$project = globallink_find_project_by_short_code($project_service, $proj_code, $token);
} catch (SoapFault $se) {
watchdog('GlobalLink', 'SOAP Exception - %function - Code[%faultcode], Message[%faultstring]', array(
'%function' => __FUNCTION__,
'%faultcode' => $se->faultcode,
'%faultstring' => $se->faultstring,
), WATCHDOG_ERROR);
return 'Connection Failed - Invalid Project Code: ' . $proj_code;
} catch (Exception $e) {
watchdog('GlobalLink', 'Exception - %function - File[%file], Line[%line], Code[%code], Message[%message]', array(
'%function' => __FUNCTION__,
'%file' => $e
->getFile(),
'%line' => $e
->getLine(),
'%code' => $e
->getCode(),
'%message' => $e
->getMessage(),
), WATCHDOG_ERROR);
return 'Connection Failed - Invalid Project Code: ' . $proj_code;
}
if (isset($project->ticket)) {
if (isset($project->fileFormatProfiles) && is_array($project->fileFormatProfiles)) {
foreach ($project->fileFormatProfiles as $file_format) {
if ($pd_obj->classifier == $file_format->profileName) {
$success = TRUE;
break;
}
}
}
elseif (isset($project->fileFormatProfiles)) {
if ($pd_obj->classifier == $project->fileFormatProfiles->profileName) {
$success = TRUE;
}
}
}
if (!$success) {
return 'Connection Failed - Invalid Classifier.';
}
else {
$success = FALSE;
}
}
return TRUE;
}