summaryrefslogtreecommitdiffstats
path: root/modules-available/sysconfig/inc/configmodule/branding.inc.php
blob: fd11dade633d1793d9557767148d79f1a722f116 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

ConfigModule::registerModule(
	ConfigModule_Branding::MODID, // ID
	Dictionary::translateFileModule('sysconfig', 'config-module', 'branding_title'), // Title
	Dictionary::translateFileModule('sysconfig', 'config-module', 'branding_description'), // Description
	Dictionary::translateFileModule('sysconfig', 'config-module', 'group_branding'), // Group
	true // Only one per config?
);

class ConfigModule_Branding extends ConfigModule
{

	const MODID = 'Branding';
	const VERSION = 1;
	
	private $tmpFile = false;

	protected function generateInternal($tgz, $parent)
	{
		if (!$this->validateConfig()) {
			return $this->archive() !== false && file_exists($this->archive()); // No new temp file given, old archive still exists, pretend it worked...
		}
		$task = Taskmanager::submit('MoveFile', array(
			'source' => $this->tmpFile,
			'destination' => $tgz,
			'parentTask' => $parent,
			'failOnParentFail' => false
		));
		return $task;
	}

	protected function moduleVersion()
	{
		return self::VERSION;
	}

	protected function validateConfig()
	{
		return $this->tmpFile !== false && file_exists($this->tmpFile);
	}

	public function setData($key, $value)
	{
		if ($key !== 'tmpFile' || !is_string($value) || !file_exists($value))
			return false;
		$this->tmpFile = $value;
		return true;
	}

	public function getData($key)
	{
		return false;
	}

	public function allowDownload()
	{
		return true;
	}

}