summaryrefslogtreecommitdiff
path: root/src/views/pages/users/index.csv.php
blob: 0a69cee60788362597c1ff14948e982037c8e977 (plain)
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
<?php global $VARS;
$attribs = $VARS['attribs'];
$users = $VARS['users'];

function escape($value) {
	if (is_bool($value)) {
		return ($value?'true':'false');
	} else {
		$chars = "'" . '"' .  '\\' . ',';
		return addcslashes($value, $chars);
	}
}

$arr = array();
foreach ($attribs as $attrib) {
	$arr[] = escape($attrib['name']);
}
echo implode(',', $arr)."\n";

foreach ($users as $user) {
	$arr = array();
	foreach ($attribs as $attrib) {
		$props = $user[$attrib['key']];
		$arr[] = escape($props['value']);
	}
	echo implode(',', $arr)."\n";
}