function globallink_test_pd_connectivity in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 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 62
Code
function globallink_test_pd_connectivity($pd_obj) {
$connectorConfig = new PDConfig();
$connectorConfig->url = $pd_obj->url;
$connectorConfig->username = $pd_obj->username;
$connectorConfig->password = $pd_obj->password;
$connectorConfig->userAgent = $pd_obj->userAgent;
$proj_arr = array();
$glExchange = new GLExchange($connectorConfig);
$pdProjects = $glExchange
->getProjects();
if (isset($pdProjects) && is_array($pdProjects)) {
foreach ($pdProjects as $project) {
$proj_arr[$project->shortcode] = $project;
}
}
$project_short_code = $pd_obj->projectShortCode;
if ($project_short_code != '') {
$arr = explode(',', $project_short_code);
foreach ($arr as $value) {
if (!array_key_exists($value, $proj_arr)) {
throw new Exception("Connection Failed - Invalid Project Code: " . $value);
}
else {
$success = FALSE;
$project = $proj_arr[$value];
if (isset($project->fileFormats) && is_array($project->fileFormats)) {
foreach ($project->fileFormats as $fileFormat) {
if ($pd_obj->classifier == $fileFormat) {
$success = TRUE;
break;
}
}
}
if (!$success) {
throw new Exception("Connection Failed - Invalid Classifier");
}
}
}
}
return TRUE;
}