1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<?php
namespace Files\Core;
require_once __DIR__ . "/class.accountstore.php";
require_once __DIR__ . "/Util/class.pathutil.php";
require_once __DIR__ . "/Util/class.logger.php";
use \Files\Core\Util\PathUtil;
use \Files\Core\Util\Logger;
class RecipientHandler
{
const LOG_CONTEXT = "RecipientHandler"; // Context for the Logger
public static function doGetRecipients()
{
// parse account id.
// wo only need to parse one string because it is
// only possible to download files from one backend at a time.
if (isset($_GET["ids"])) {
$tmpId = $_GET["ids"][0];
} else {
$tmpId = $_GET["id"];
}
$accountID = substr($tmpId, 3, (strpos($tmpId, '/') - 3));
// Initialize the account and backendstore
$accountStore = new \Files\Core\AccountStore();
$backendStore = \Files\Backend\BackendStore::getInstance();
$account = $accountStore->getAccount($accountID);
// initialize the backend
$initializedBackend = $backendStore->getInstanceOfBackend($account->getBackend());
$initializedBackend->init_backend($account->getBackendConfig());
try {
$initializedBackend->open();
} catch (\Files\Backend\Exception $e) {
Logger::error(self::LOG_CONTEXT, "Could not open the backend: " . $e->getMessage());
echo json_encode(array('success' => false, 'response' => $e->getCode(), 'message' => $e->getMessage()));
die();
}
$responsedata = $initializedBackend->getRecipients($_GET["query"]);
header('Content-Type: application/json');
echo json_encode($responsedata);
}
}
|