seeddms-code/controllers/class.ExtensionMgr.php

98 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2018-03-21 12:40:17 +00:00
<?php
/**
* Implementation of ExtensionMgr controller
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2018 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Class which does the busines logic for managing extensions
*
* @category DMS
* @package SeedDMS
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2018 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_Controller_ExtensionMgr extends SeedDMS_Controller_Common {
public function refresh() { /* {{{ */
$dms = $this->params['dms'];
$extmgr = $this->params['extmgr'];
$extmgr->createExtensionConf();
return true;
} /* }}} */
public function download() { /* {{{ */
$dms = $this->params['dms'];
$settings = $this->params['settings'];
$extmgr = $this->params['extmgr'];
$extname = $this->params['extname'];
2020-01-03 09:21:58 +00:00
$filename = $extmgr->createArchive($extname, $extmgr->getExtensionConfiguration()[$extname]['version']);
2018-03-21 12:40:17 +00:00
if(null === $this->callHook('download')) {
if(file_exists($filename)) {
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"" . utf8_basename($filename) . "\"; filename*=UTF-8''".utf8_basename($filename));
header("Content-Type: application/zip");
header("Cache-Control: must-revalidate");
sendFile($filename);
}
}
return true;
} /* }}} */
public function upload() { /* {{{ */
$dms = $this->params['dms'];
$extmgr = $this->params['extmgr'];
$file = $this->params['file'];
if($extmgr->updateExtension($file)) {
2018-03-21 12:40:17 +00:00
$extmgr->createExtensionConf();
} else {
$this->setErrorMsg($extmgr->getErrorMsg());
2018-03-21 12:40:17 +00:00
return false;
}
2018-03-21 12:40:17 +00:00
return true;
} /* }}} */
public function getlist() { /* {{{ */
$dms = $this->params['dms'];
$extmgr = $this->params['extmgr'];
$forceupdate = $this->params['forceupdate'];
$version = $this->params['version'];
if(!$extmgr->updateExtensionList($version, $forceupdate)) {
$this->errormsg = $extmgr->getErrorMsg();
return false;
}
return true;
} /* }}} */
public function toggle() { /* {{{ */
$dms = $this->params['dms'];
$settings = $this->params['settings'];
$extmgr = $this->params['extmgr'];
$extname = $this->params['extname'];
if($settings->extensionIsDisabled($extname))
$settings->enableExtension($extname);
else
$settings->disableExtension($extname);
$settings->save();
return true;
} /* }}} */
2018-03-21 12:40:17 +00:00
}