コード例 #1
0
}
$display_xml = false;
if (isset($arguments['x'])) {
    $display_xml = true;
}
$options = array();
if (isset($arguments['t'])) {
    $options['tracker_id'] = (int) $arguments['t'];
}
$options['force'] = isset($arguments['f']);
$project = ProjectManager::instance()->getProject($project_id);
if ($project && !$project->isError() && !$project->isDeleted()) {
    try {
        $rng_validator = new XML_RNGValidator();
        $users_collection = new UserXMLExportedCollection($rng_validator, new XML_SimpleXMLCDATAFactory());
        $xml_exporter = new ProjectXMLExporter(EventManager::instance(), new UGroupManager(), $rng_validator, new UserXMLExporter(UserManager::instance(), $users_collection), new ProjectXMLExporterLogger());
        $archive = new ZipArchive();
        if ($archive->open($output, ZipArchive::CREATE) !== true) {
            echo '*** ERROR: Cannot create archive: ' . $archive_path;
            exit(1);
        }
        $xml_security = new XML_Security();
        $xml_security->enableExternalLoadOfEntities();
        $user = UserManager::instance()->forceLogin($username);
        $xml_content = $xml_exporter->export($project, $options, $user, $archive);
        $users_xml_content = $users_collection->toXML();
        if ($display_xml) {
            echo $xml_content;
            echo PHP_EOL;
            echo $users_xml_content;
        }
コード例 #2
0
    $project_id = (int) $arguments['p'];
}
if (!isset($arguments['u'])) {
    usage();
} else {
    $username = $arguments['u'];
}
$options = array();
if (isset($arguments['t'])) {
    $options['tracker_id'] = (int) $arguments['t'];
}
$options['force'] = isset($arguments['f']);
$project = ProjectManager::instance()->getProject($project_id);
if ($project && !$project->isError() && !$project->isDeleted()) {
    try {
        $xml_exporter = new ProjectXMLExporter(EventManager::instance(), new UGroupManager(), new XML_RNGValidator(), new UserXMLExporter(UserManager::instance()), new ProjectXMLExporterLogger());
        $user = UserManager::instance()->forceLogin($username);
        echo $xml_exporter->export($project, $options, $user);
        exit(0);
    } catch (XML_ParseException $exception) {
        fwrite(STDERR, "*** PARSE ERROR: " . $exception->getIndentedXml() . PHP_EOL);
        foreach ($exception->getErrors() as $parse_error) {
            fwrite(STDERR, "*** PARSE ERROR: " . $parse_error . PHP_EOL);
        }
        fwrite(STDERR, "RNG path: " . $exception->getRngPath() . PHP_EOL);
        exit(1);
    } catch (Exception $exception) {
        fwrite(STDERR, "*** ERROR: " . $exception->getMessage() . PHP_EOL);
        exit(1);
    }
} else {
コード例 #3
0
} else {
    $output = $arguments['o'];
}
$display_xml = false;
if (isset($arguments['x'])) {
    $display_xml = true;
}
$options = array();
if (isset($arguments['t'])) {
    $options['tracker_id'] = (int) $arguments['t'];
}
$options['force'] = isset($arguments['f']);
$project = ProjectManager::instance()->getProject($project_id);
if ($project && !$project->isError() && !$project->isDeleted()) {
    try {
        $xml_exporter = new ProjectXMLExporter(EventManager::instance(), new UGroupManager(), new XML_RNGValidator(), new UserXMLExporter(UserManager::instance()), new ProjectXMLExporterLogger());
        $archive = new ZipArchive();
        if ($archive->open($output, ZipArchive::CREATE) !== true) {
            echo '*** ERROR: Cannot create archive: ' . $archive_path;
            exit(1);
        }
        $xml_security = new XML_Security();
        $xml_security->enableExternalLoadOfEntities();
        $user = UserManager::instance()->forceLogin($username);
        $xml_content = $xml_exporter->export($project, $options, $user);
        if ($display_xml) {
            echo $xml_content;
        }
        $archive->addFromString('project.xml', $xml_content);
        $xml_security->disableExternalLoadOfEntities();
        $archive->close();