summaryrefslogtreecommitdiffstats
path: root/modules-available/sysconfig/inc/sysconfig.inc.php
blob: 09860c7d39c154827d2eb1329883d6dc855b6500 (plain) (blame)
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
<?php

class SysConfig
{

	public static function getAll(): array
	{
		$res = Database::simpleQuery("SELECT c.configid, c.title, c.filepath, c.status, Group_Concat(cl.locationid) AS locs FROM configtgz c"
			. " LEFT JOIN configtgz_location cl USING (configid) GROUP BY c.configid");
		$ret = array();
		foreach ($res as $row) {
			$ret[] = $row;
		}
		return $ret;
	}

	public static function archiveContentsFromTask($status, &$userGroupWarn = null) : array
	{
		// Sort files for better display
		$dirs = array();
		foreach ($status['data']['entries'] as $file) {
			if ($file['isdir']) continue;
			$dirs[dirname($file['name'])][] = $file;
			if ($file['userId'] > 0 || $file['groupId'] > 0) {
				$userGroupWarn = true;
			}
		}
		ksort($dirs);
		$list = array();
		foreach ($dirs as $dir => $files) {
			$list[] = array(
				'name' => $dir,
				'isdir' => true
			);
			sort($files);
			foreach ($files as $file) {
				$file['size'] = Util::readableFileSize($file['size']);
				$list[] = $file;
			}
		}
		return $list;
	}

}