public static function getServerByUri($uri, $userId = -1) { $servers = BIMsie::getServers(false, $userId); $foundServer = false; foreach ($servers as $server) { $oldServer = $server; if (BIMBCFManagement::removeProtocol($server['uri']) == BIMBCFManagement::removeProtocol($uri)) { $foundServer = $server; if ($foundServer['remember'] == 0) { if (isset($_POST['username']) && isset($_POST['password'])) { $foundServer['username'] = $_POST['username']; $foundServer['password'] = $_POST['password']; } if (isset($_POST['remember']) && $_POST['remember'] != '') { $foundServer['remember'] = 1; } } if ($foundServer['remember'] == 0 || !isset($foundServer['token']) || $foundServer['tokenValid'] < time()) { $token = BIMsie::publicRequest($foundServer['uri'], 'Bimsie1AuthInterface', 'login', array('username' => isset($foundServer['username']) ? $foundServer['username'] : '', 'password' => isset($foundServer['password']) ? $foundServer['password'] : '')); if (isset($token) && isset($token->response) && isset($token->response->result) && BIMsie::getErrorMessage($token) === false) { $token = $token->response->result; $foundServer['token'] = $token; $foundServer['tokenValid'] = time() + BIMsie::$tokenTimeout; if ($foundServer['remember'] == 1) { update_user_meta($userId == -1 ? get_current_user_id() : $userId, 'bimsie-servers', $foundServer, $oldServer); } } } break; } } return $foundServer; }
} } else { if (isset($response['error'])) { $response['error'] .= '<br />' . $error; } else { $response['error'] = $error; } } } } $response['projects'] = $projectsLackingRevision; } elseif ($_POST['method'] == 'getRevisions') { // set this project for this issue and retrieve a list of revisions for this project from the BIMsie server $poid = isset($_POST['poid']) ? intval($_POST['poid']) : -1; $BIMsieResponse = BIMsie::request($uri, $token, 'Bimsie1ServiceInterface', 'getAllRevisionsOfProject', array('poid' => $poid)); $error = BIMsie::getErrorMessage($BIMsieResponse); if ($error === false && isset($BIMsieResponse->response) && isset($BIMsieResponse->response->result)) { $response['revisions'] = $BIMsieResponse->response->result; foreach ($response['revisions'] as $key => $revision) { if (isset($revision->date) && is_numeric($revision->date)) { $response['revisions'][$key]->dateString = date('d-m-Y H:i', $revision->date * 0.001); } else { $response['revisions'][$key]->dateString = __('unknown', 'bim-bcf-management'); } } } else { $response['error'] = $error; } } } else { // We have no BIMsie server information so cannot perform request