/**
  * Extend 
  * @see Form::validate()
  */
 function validate()
 {
     // Check that all required fields are filled.
     if (!parent::validate()) {
         return false;
     }
     // Verify that the credentials work.
     $dcc = new DuraCloudConnection($this->getData('duracloudUrl'), $this->getData('duracloudUsername'), $this->getData('duracloudPassword'));
     $ds = new DuraStore($dcc);
     if ($ds->getSpaces($storeId) === false) {
         // Could not get a list of spaces.
         $this->addError('duracloudUrl', __('plugins.importexport.duracloud.configuration.credentialsInvalid'));
         return false;
     }
     // Success.
     return true;
 }
Beispiel #2
0
// Check usage.
if (!isset($argv)) {
    echo "This is a command line example. You must use the PHP CLI tool to execute.\n";
    exit(-1);
}
if (count($argv) < 4 || count($argv) > 5) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password] [(storeID)]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
$storeId = array_shift($argv);
// Optional
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
$spaces = $ds->getSpaces($storeId);
if ($spaces !== false) {
    echo "The list of spaces is:\n";
    foreach ($spaces as $space) {
        echo " - {$space}\n";
    }
    echo "\n";
} else {
    echo "The list of spaces could not be fetched. Check your credentials.\n";
    exit(-3);
}