/** * Callback for creating the plugin header. * * @param unknown $args */ function ibm_sbtk_header($args = array()) { $settings = new SBTSettings(); $store = SBTCredentialStore::getInstance(); $endpoints = $settings->getEndpoints(); if ($endpoints == null || empty($endpoints)) { return; } foreach ($endpoints as $endpoint) { if (($settings->getAuthenticationMethod($endpoint['name']) == 'oauth1' || $settings->getAuthenticationMethod($endpoint['name']) == 'oauth2') && $store->getOAuthAccessToken($endpoint['name']) == null && (!isset($_COOKIE['IBMSBTKOAuthLogin']) || $_COOKIE['IBMSBTKOAuthLogin'] != 'yes')) { $deploy_url = $settings->getSDKDeployURL($endpoint['name']); $authentication_method = $settings->getAuthenticationMethod($endpoint['name']); $js_library = $settings->getJSLibrary($endpoint['name']); $url = $settings->getURL($endpoint['name']); $name = $settings->getName($endpoint['name']); $api_version = $settings->getAPIVersion($endpoint['name']); $type = $settings->getServerType($endpoint['name']); $allow_client_access = $settings->allowClientAccess($endpoint['name']); $endpoints = $settings->getEndpoints(); // Load the header view require BASE_PATH . '/views/includes/header.php'; return; } } $plugin = new SBTPlugin($endpoints[0]['name']); $plugin->createHeader(); }
/** * Tests create, update and delete operations. */ public function testCRUD() { $this->tearDown(); $this->setUp(); $settings = new SBTSettings(); global $USER; global $CFG; $USER->id = $this->uid; // Create $_POST = $this->_prepareCreatePOST(); require $CFG->dirroot . '/blocks/ibmsbt/endpoint_settings.php'; // Check that endpoint really has been created $settings = new SBTSettings(); // Update $newValue = $this->_prepareUpdatePOST(); require $CFG->dirroot . '/blocks/ibmsbt/endpoint_settings.php'; $settings = new SBTSettings(); $this->assertEquals($settings->getAPIVersion($this->config['name']), $newValue); // Get $this->_prepareGet(); require $CFG->dirroot . '/blocks/ibmsbt/endpoint_settings.php'; // Delete $this->_prepareDeletePOST(); require $CFG->dirroot . '/blocks/ibmsbt/endpoint_settings.php'; $settings = new SBTSettings(); $this->assertEquals($settings->getAPIVersion($this->config['name']), null); }
/** * Creates the header for the SBTK plugin. */ public function createHeader() { $this->loadModel('SBTSettings'); $settings = new SBTSettings(); $viewData['deploy_url'] = $settings->getSDKDeployURL($this->endpointName); $viewData['authentication_method'] = $settings->getAuthenticationMethod($this->endpointName); $viewData['js_library'] = $settings->getJSLibrary($this->endpointName); $viewData['url'] = $settings->getURL($this->endpointName); $viewData['name'] = $settings->getName($this->endpointName); $viewData['api_version'] = $settings->getAPIVersion($this->endpointName); $viewData['type'] = $settings->getServerType($this->endpointName); $viewData['allow_client_access'] = $settings->allowClientAccess($this->endpointName); $viewData['endpoints'] = $settings->getEndpoints(); // Load the header view return $this->loadView('includes/header', $viewData); }