From d574e836c9788af9492c55c32469c0972ffe17b8 Mon Sep 17 00:00:00 2001 From: Shnoulle Date: Mon, 20 Feb 2017 16:21:45 +0100 Subject: [PATCH] [dev][fix] Add the patchs :whistle: --- patches/app-0001-14c81c8.patch | 107 +++++++++++++++++++++++++++++++++ patches/app-0002-301de6e.patch | 87 +++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 patches/app-0001-14c81c8.patch create mode 100644 patches/app-0002-301de6e.patch diff --git a/patches/app-0001-14c81c8.patch b/patches/app-0001-14c81c8.patch new file mode 100644 index 0000000..fe54360 --- /dev/null +++ b/patches/app-0001-14c81c8.patch @@ -0,0 +1,107 @@ +From 14c81c86b7692794e7b251de3628f9afe353e020 Mon Sep 17 00:00:00 2001 +From: Denis Chenu +Date: Wed, 15 Feb 2017 01:15:35 +0100 +Subject: [PATCH] [feature][yunohost] Allow update via PHP cli - Included in + LimeSurvey 3.0 + +--- + application/commands/UpdateCommand.php | 90 ++++++++++++++++++++++++++++++++++ + 1 file changed, 90 insertions(+) + create mode 100644 application/commands/UpdateCommand.php + +diff --git a/application/commands/UpdateCommand.php b/application/commands/UpdateCommand.php +new file mode 100644 +index 0000000..faa216f +--- /dev/null ++++ b/application/commands/UpdateCommand.php +@@ -0,0 +1,90 @@ ++ ++ * @license GPL v3 ++ * @version 0.1.1 ++ * @deprecated in LimeSurvey 3.0/develop UpdateDbCommand do it ++ * ++ * Copyright (C) 2017 Denis Chenu ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU Affero General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ */ ++class UpdateCommand extends CConsoleCommand ++{ ++ public function run(){ ++ $this->_setConfigs(); ++ $newDbVersion = (float)Yii::app()->getConfig('dbversionnumber'); ++ $currentDbVersion = (float)Yii::app()->getConfig('DBVersion'); ++ if($newDbVersion > $currentDbVersion){ ++ echo "Update ".Yii::app()->db->connectionString.", prefix :".Yii::app()->db->tablePrefix." from {$currentDbVersion} to {$newDbVersion}\n"; ++ Yii::import('application.helpers.common_helper', true); ++ Yii::import('application.helpers.update.updatedb_helper', true); ++ $result=db_upgrade_all($currentDbVersion);/* @todo : fix bad echoing here */ ++ if ($result) { ++ echo "Database has been successfully upgraded to version $newDbVersion \n"; ++ } else { ++ echo "Please fix this error in your database and try again\n"; ++ return 1; ++ } ++ } else { ++ echo "no need update ".$newDbVersion ." ". $currentDbVersion ."\n"; ++ } ++ } ++ ++ /** ++ * Fonction to set all needed (and unneeded) config ++ * @deprecated in LimeSurvey 3.0/develop version config is set by LimeSurvey Core ++ * @return void ++ */ ++ private function _setConfigs(){ ++ /* default config */ ++ $aDefaultConfigs = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config-defaults.php'); ++ foreach($aDefaultConfigs as $sConfig=>$defaultConfig){ ++ Yii::app()->setConfig($sConfig,$defaultConfig); ++ } ++ /* Fix for badly set rootdir */ ++ $sRootDir=realpath(Yii::app()->basePath. DIRECTORY_SEPARATOR . "..") ; ++ Yii::app()->setConfig('rootdir',$sRootDir); ++ Yii::app()->setConfig('publicdir',$sRootDir); ++ Yii::app()->setConfig('homedir',$sRootDir); ++ Yii::app()->setConfig('tempdir',$sRootDir.DIRECTORY_SEPARATOR."tmp"); ++ Yii::app()->setConfig('imagedir',$sRootDir.DIRECTORY_SEPARATOR."images"); ++ Yii::app()->setConfig('uploaddir',$sRootDir.DIRECTORY_SEPARATOR."upload"); ++ Yii::app()->setConfig('standardtemplaterootdir',$sRootDir.DIRECTORY_SEPARATOR."templates"); ++ Yii::app()->setConfig('usertemplaterootdir',$sRootDir.DIRECTORY_SEPARATOR."upload".DIRECTORY_SEPARATOR."templates"); ++ Yii::app()->setConfig('styledir',$sRootDir.DIRECTORY_SEPARATOR."styledir"); ++ /* version */ ++ $aVersionConfigs = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'version.php'); ++ foreach($aVersionConfigs as $sConfig=>$versionConfig){ ++ Yii::app()->setConfig($sConfig,$versionConfig); ++ } ++ ++ if(file_exists(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php')) ++ { ++ $config = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'); ++ if(is_array($config['config']) && !empty($config['config'])) ++ { ++ foreach($config['config'] as $key=>$value) { ++ Yii::app()->setConfig($key,$value); ++ } ++ } ++ } ++ $oSettings=SettingGlobal::model()->findAll(); ++ if (count($oSettings) > 0) ++ { ++ foreach ($oSettings as $oSetting) ++ { ++ Yii::app()->setConfig($oSetting->getAttribute('stg_name'), $oSetting->getAttribute('stg_value')); ++ } ++ } ++ } ++ ++} diff --git a/patches/app-0002-301de6e.patch b/patches/app-0002-301de6e.patch new file mode 100644 index 0000000..a147c73 --- /dev/null +++ b/patches/app-0002-301de6e.patch @@ -0,0 +1,87 @@ +From 301de6eb25dda2b9342a006baadaa068c42b115e Mon Sep 17 00:00:00 2001 +From: Denis Chenu +Date: Wed, 15 Feb 2017 01:59:12 +0100 +Subject: [PATCH] [feature][yunohost] Activate a plugin by command - Needed for + update + +--- + application/commands/ActivatePluginCommand.php | 70 ++++++++++++++++++++++++++ + 1 file changed, 70 insertions(+) + create mode 100644 application/commands/ActivatePluginCommand.php + +diff --git a/application/commands/ActivatePluginCommand.php b/application/commands/ActivatePluginCommand.php +new file mode 100644 +index 0000000..512e9a4 +--- /dev/null ++++ b/application/commands/ActivatePluginCommand.php +@@ -0,0 +1,70 @@ ++ ++ * @copyright 2015 Denis Chenu ++ * @license GPL v3 ++ * @version 0.0.1 ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ */ ++class ActivatePluginCommand extends CConsoleCommand ++{ ++ ++ /** ++ * @var string $defaultAction ++ * @see http://www.yiiframework.com/doc/api/1.1/CConsoleCommand#defaultAction-detail ++ */ ++ public $defaultAction='activate'; ++ /** ++ * Activate a plugin by name ++ * @param string $name The plugin Class name ++ * @return void ++ */ ++ public function actionActivate($classname) ++ { ++ $oPluginManager = \Yii::app()->pluginManager; ++ $aDiscoveredPlugins = $oPluginManager->scanPlugins(); ++ if(!array_key_exists($classname,$aDiscoveredPlugins)) { ++ echo "Plugin {$classname} are not in your plugin directory\n"; ++ return 1; ++ } ++ ++ $oPlugin=Plugin::model()->find("name=:name",array(":name"=>$classname)); ++ /* If plugin is not installed : just install it */ ++ if(!$oPlugin) { ++ $oPlugin = new Plugin(); ++ $oPlugin->name = $classname; ++ $oPlugin->active = 0; ++ $oPlugin->save(); ++ } ++ /* Activate the plugin with the event beforeActivate */ ++ if ($oPlugin->active == 0) ++ { ++ /* Load the plugin and dispatch beforeActivate event */ ++ App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id); ++ $result = App()->getPluginManager()->dispatchEvent(new PluginEvent('beforeActivate',$this), $oPlugin->name); ++ if ($result->get('success', true)) { ++ $oPlugin->active = 1; ++ if(!$oPlugin->save()){ ++ return 1; /* This must not happen */ ++ } ++ } else { ++ echo $result->get('message', 'Failed to activate the plugin.')."\n"; ++ return 1; ++ } ++ } else { ++ // No error if try to activate an already activated plugin ++ } ++ } ++ ++}