Commit a9e5caf4 authored by lphuberdeau's avatar lphuberdeau

[MOD] Move dump tracker

parent d983d900
......@@ -5189,7 +5189,6 @@ templates/tiki-editpage.tpl -text
templates/tiki-export-sheets.tpl -text
templates/tiki-export_comment_xml.tpl -text
templates/tiki-export_page_xml.tpl -text
templates/tiki-export_tracker.tpl -text
templates/tiki-export_tracker_item.tpl -text
templates/tiki-export_users.tpl -text
templates/tiki-faq_questions.tpl -text
......
......@@ -705,7 +705,7 @@ class Services_Tracker_Controller
session_write_close();
$trklib = TikiLib::lib('trk');
$trklib->write_export_header();
$trklib->write_export_header($encoding, $trackerId);
$header = array();
if ($showItemId) {
......@@ -754,6 +754,26 @@ class Services_Tracker_Controller
exit;
}
function action_dump_items($input)
{
$trackerId = $input->trackerId->int();
$definition = Tracker_Definition::get($trackerId);
if (! $definition) {
throw new Services_Exception(tr('Tracker does not exist'), 404);
}
$perms = Perms::get('tracker', $trackerId);
if (! $perms->export_tracker) {
throw new Services_Exception(tr('Not allowed to export'), 403);
}
$trklib = TikiLib::lib('trk');
$trklib->dump_tracker_csv($trackerId);
exit;
}
private function writeCsv($fields, $separator, $delimitorL, $delimitorR, $encoding, $cr = '%%%')
{
$values = array();
......
......@@ -1762,7 +1762,7 @@ class TrackerLib extends TikiLib
// write out file header
session_write_close();
$this->write_export_header();
$this->write_export_header('UTF-8', $trackerId);
// then "field names -- index" as first line
$str = '';
......@@ -1858,8 +1858,13 @@ class TrackerLib extends TikiLib
return $items;
}
function write_export_header() {
header("Content-type: text/comma-separated-values; charset:".$_REQUEST['encoding']);
function write_export_header($encoding = null, $trackerId = null) {
if (! $encoding) {
$encoding = $_REQUEST['encoding'];
}
if (! $trackerId) {
$trackerId = $_REQUEST['trackerId'];
}
if (!empty($_REQUEST['file'])) {
if (preg_match('/.csv$/', $_REQUEST['file'])) {
$file = $_REQUEST['file'];
......@@ -1867,8 +1872,9 @@ class TrackerLib extends TikiLib
$file = $_REQUEST['file'].'.csv';
}
} else {
$file = tra('tracker').'_'.$_REQUEST['trackerId'].'.csv';
$file = tra('tracker').'_'.$trackerId.'.csv';
}
header("Content-type: text/comma-separated-values; charset:".$encoding);
header("Content-Disposition: attachment; filename=$file");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
......
......@@ -218,8 +218,6 @@
{tabset}
{if $trackerId}
{include file='tiki-export_tracker.tpl'}
{tab name="{tr}Import CSV data{/tr}"}
<h3>{tr}Tracker Items Import{/tr}</h3>
<form action="tiki-import_tracker.php?trackerId={$trackerId}" method="post" enctype="multipart/form-data">
......
{* $Id$ *}
{if $tiki_p_tracker_dump eq "y" or $tiki_p_admin eq "y"}
{tab name="{tr}Dump All Tracker Items{/tr}"}
<h3>{tr}Tracker Items Dump{/tr}</h3>
<div>
<form action="{$smarty.server.PHP_SELF}" method="post">
<table class="formcolor">
<tr>
<td width="20%"><label for="tracker">{tr}Tracker{/tr}</label></td>
<td>
<select name="trackerId" onchange="this.form.submit();" id="dumpTrackerId">
{foreach from=$trackers item=tracker}
<option value="{$tracker.trackerId}" title="{$tracker.description|escape}"{if $tracker.trackerId eq $trackerId} selected="selected"{/if}>
{$tracker.name|escape}
</option>
{/foreach}
</select>
{$recordsMax}
{if $recordsMax eq 1}
{tr}item{/tr}
{else}
{tr}items{/tr}
{/if}
</td>
</tr>
</table>
</form>
<form action="tiki-export_tracker.php?trackerId={$trackerId}" method="post" id="dump_form">
<table class="formcolor">
<tr>
<td width="20%">&nbsp;</td>
<td>
<input type="submit" name="dump_tracker" id="dump_tracker" value="{tr}Dump{/tr}" />
</td>
</tr>
</table>
</form>
</div>
{/tab}
{/if}
......@@ -262,11 +262,6 @@
{/tab}
{/if}
{if $tiki_p_export_tracker eq 'y'}
{* -------------------------------------------------- tab with export (and dump if perms) --- *}
{include file='tiki-export_tracker.tpl'}
{/if}
{if $tracker_sync}
{tab name="{tr}Synchronization{/tr}"}
<p>
......
......@@ -6,6 +6,13 @@
<textarea>{$export|escape}</textarea>
</label>
</form>
<h4>{tr}Quick Export{/tr}</h4>
<form method="post" class="simple no-ajax" action="{service controller=tracker action=dump_items trackerId=$trackerId}">
<p>{tr}Produce a CSV with basic formatting.{/tr}</p>
<div class="submit">
<input type="submit" value="{tr}Export{/tr}"/>
</div>
</form>
<h4>{tr}Export Tracker Items{/tr}</h4>
<form class="simple no-ajax" action="{service controller=tracker action=export_items trackerId=$trackerId}" method="post">
<label>
......
......@@ -30,13 +30,6 @@ $access->check_permission('tiki_p_export_tracker');
$smarty->assign_by_ref('trackerId', $_REQUEST['trackerId']);
$smarty->assign_by_ref('tracker_info', $tracker_info);
if (isset($_REQUEST['dump_tracker'])) {
$access->check_permission('tiki_p_tracker_dump');
$trklib->dump_tracker_csv($_REQUEST['trackerId']);
return;
}
$filters = array();
if (!empty($_REQUEST['listfields'])) {
if (is_string($_REQUEST['listfields'])) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment