<?php

/*
This file is part of CMS Made Simple module: Tourney.
Copyright(C) 2014-2015 Tom Phane <*****@*****.**>
Refer to licence and other details at the top of file Tourney.module.php
More info at http://dev.cmsmadesimple.org/projects/tourney
*/
if (!$this->CheckAccess('adview')) {
    $this->Redirect($id, 'defaultadmin', '', array('tmt_message' => $this->PrettyMessage('lackpermission', FALSE)));
}
$funcs = new tmtXML();
$res = $funcs->ExportXML($this, $params['bracket_id']);
if ($res === TRUE) {
    exit;
} else {
    $this->Redirect($id, 'defaultadmin', '', array('tmt_message' => $this->PrettyMessage($res, FALSE)));
}
        if ($content) {
            @ob_clean();
            header('Pragma: public');
            header('Expires: 0');
            header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
            header('Cache-Control: private', FALSE);
            header('Content-Description: File Transfer');
            header('Content-Type: ' . $ft);
            header('Content-Length: ' . strlen($content));
            header('Content-Disposition: attachment; filename="' . $fn . '"');
            echo $content;
            if (!$message) {
                exit;
            }
            $this->Redirect($id, 'defaultadmin', '', array('tmt_message' => $message));
        }
    }
} elseif (isset($params['export'])) {
    $vals = array_flip($params['selitems']);
    //convert strings
    $vals = array_flip($vals);
    if ($vals) {
        $funcs = new tmtXML();
        $res = $funcs->ExportXML($this, $params['selitems']);
        if ($res === TRUE) {
            exit;
        }
        $this->Redirect($id, 'defaultadmin', '', array('tmt_message' => $this->PrettyMessage($res, FALSE)));
    }
}
$this->Redirect($id, 'defaultadmin');