Added function to install extensions from commandline

This commit is contained in:
Andreas Österreicher
2019-03-20 16:30:44 +01:00
parent 120a775dbb
commit fe4017c786
3 changed files with 26 additions and 8 deletions
@@ -81,10 +81,15 @@ class Manager extends Auth_Controller
}
/**
*
* Installiert eine Extension.
* Es wird davon ausgegangen, dass die Extension ueber einen Fileupload hochgeladen wird.
* alternativ kann hier auch der Name und Filename uebergeben werden um die installation ueber
* die Commandline ohne Upload durchzufuehren.
* @param $extensioName string Name der Extension
* @param $filename Url Encoded Pfad zum tgz File der Extension
*/
public function uploadExtension()
public function uploadExtension($extensionName = null, $filename = null)
{
$this->extensionslib->installExtension();
$this->extensionslib->installExtension($extensionName, urldecode($filename));
}
}
+16 -4
View File
@@ -59,17 +59,29 @@ class ExtensionsLib
/**
* Main method to install an extension
* If no filename / Extensionname is provided the extension should be uploaded via webupload
*
* @param $extensionName string Name of Extension (optional)
* @param $filename Path to tgz Extension File (optional)
*/
public function installExtension()
public function installExtension($extensionName = null, $filename = null)
{
$extensionDB = null; // contains data from DB about an extension
$extensionJson = null; // contains the extension.json data
$this->_printInfo('WARNING!!! Please do not change page or stop this procedure before it is finished');
$this->_loadUploadLibrary(); // loads CI upload library
$uploadData = $this->_uploadExtension(); // perform the upload of the file and returns info about it
if (!is_null($extensionName) && !is_null($filename))
{
$uploadData = new stdClass();
$uploadData->fullPath = $filename;
$uploadData->extensionName = $extensionName;
}
else
{
$this->_loadUploadLibrary(); // loads CI upload library
$uploadData = $this->_uploadExtension(); // perform the upload of the file and returns info about it
}
if ($uploadData != null) // if no error occurred
{
+2 -1
View File
@@ -123,11 +123,12 @@ class PermissionLib
public function isEntitled($requiredPermissions, $calledMethod)
{
$checkPermissions = false;
$requestMethod = $_SERVER['REQUEST_METHOD'];
// If it's called from command line than it's trusted
if (is_cli()) return true;
$requestMethod = $_SERVER['REQUEST_METHOD'];
// Checks if the parameter $requiredPermissions is set, is an array and contains at least one element
if (isset($requiredPermissions) && !isEmptyArray($requiredPermissions))
{