summaryrefslogblamecommitdiffstats
path: root/modules-available/sysconfig/inc/configmodule/branding.inc.php
blob: 7013e3ae9534e0267241504ed833088968c6f353 (plain) (tree)
1
2
3
4
5
6
7
8
9

     
                             
                                           


                                                                                                             

                                     



                                                
 
                                 
                          

                                
                                 
 
                                                                         
         
                                               
                                                                                                                                                                   
                 
                                                             



                                                   
                   
         
 
                                               



                                     
                                                 



                                                                               
                                                          
         
                                                                                     

                                        
                            

         
                                                   



                             
                                             



                            
 
<?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?
	600
);

class ConfigModule_Branding extends ConfigModule
{

	const MODID = 'Branding';
	const VERSION = 1;

	/** @var false|string */
	private $tmpFile = false;

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

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

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

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

	public function getData(?string $key): bool
	{
		return false;
	}

	public function allowDownload(): bool
	{
		return true;
	}

}