1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00
This commit is contained in:
Denis Chenu 2017-06-19 08:23:31 +00:00 committed by GitHub
commit 11714c50e8
7 changed files with 139 additions and 51 deletions

View file

@ -56,7 +56,12 @@ return array(
// LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard templates // LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard templates
'debug'=>0, 'debug'=>0,
'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2 'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2
'enableLdap'=>true /* yunohost part */
'auth_webserver_user_map' => array( '{{ admin }}'=>'ynh_admin'),// Primary user as ynh admin
'auth_webserver_autocreate_user'=>1,
'auth_webserver_autocreate_permissions'=>array(
'superadmin' => array('create'=>true,'read'=>true,'update'=>true,'delete'=>true),
),
) )
); );
/* End of file config.php */ /* End of file config.php */

View file

@ -6,13 +6,7 @@ INSERT INTO `lime_plugins` (`id`, `name`, `active`) VALUES
(6,'extendedStartPage',0), (6,'extendedStartPage',0),
(7,'ExportSTATAxml',0), (7,'ExportSTATAxml',0),
(8,'QuickMenu',0), (8,'QuickMenu',0),
(9,'AuthLDAP',0); (9,'AuthLDAP',1);
INSERT INTO `lime_permissions` (`id`, `entity`, `entity_id`, `uid`, `permission`, `create_p`, `read_p`, `update_p`, `delete_p`, `import_p`, `export_p`) VALUES
(1,'global',0,1,'superadmin',0,1,0,0,0,0),
(2,'global',0,2,'auth_ldap',0,1,0,0,0,0),
(3,'global',0,2,'surveys',1,0,0,0,0,0);
INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key`, `value`) VALUES INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key`, `value`) VALUES
(1,9,NULL,NULL,'server','\"ldap:\\/\\/localhost\"'), (1,9,NULL,NULL,'server','\"ldap:\\/\\/localhost\"'),
@ -41,7 +35,12 @@ INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key
INSERT INTO `lime_settings_global` VALUES ('defaultlang','{{ language }}'),('AssetsVersion','2620'); INSERT INTO `lime_settings_global` VALUES ('defaultlang','{{ language }}'),('AssetsVersion','2620');
INSERT INTO `lime_users` VALUES (1,'{{ admin }}','9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08','Administrator',0,'{{ language }}','','default','default','default',NULL,1,'2017-02-02 01:03:08',NULL); INSERT INTO `lime_users` VALUES (2,'{{ admin }}','9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08','Administrator',0,'{{ language }}','','default','default','default',NULL,1,'2017-02-02 01:03:08',NULL);
INSERT INTO `lime_permissions` (`id`, `entity`, `entity_id`, `uid`, `permission`, `create_p`, `read_p`, `update_p`, `delete_p`, `import_p`, `export_p`) VALUES
(2,'global',0,2,'superadmin',0,1,0,0,0,0),
(3,'global',0,2,'auth_ldap',0,1,0,0,0,0),
(4,'global',0,2,'auth_webserver',0,1,0,0,0,0);
{% if is_public == "1" %} {% if is_public == "1" %}
UPDATE `lime_plugin_settings` SET value='\"0\"' WHERE `id`=21; UPDATE `lime_plugin_settings` SET value='\"0\"' WHERE `id`=21;

View file

@ -2,7 +2,7 @@
"name": "LimeSurvey", "name": "LimeSurvey",
"id": "limesurvey", "id": "limesurvey",
"packaging_format": 1, "packaging_format": 1,
"version": "2.62.2", "version": "2.62.2.1",
"description": { "description": {
"en": "LimeSurvey is used to create advanced poll.", "en": "LimeSurvey is used to create advanced poll.",
"fr": "LimeSurvey est un outil de création et diffusion de sondage en ligne." "fr": "LimeSurvey est un outil de création et diffusion de sondage en ligne."

View file

@ -1,16 +1,17 @@
From 7ca49326dafe4d9896e67aebe414edcd3ce8c1af Mon Sep 17 00:00:00 2001 From 14c81c86b7692794e7b251de3628f9afe353e020 Mon Sep 17 00:00:00 2001
From: Denis Chenu <denis@sondages.pro> From: Denis Chenu <denis@sondages.pro>
Date: Thu, 19 Jan 2017 00:02:45 +0100 Date: Wed, 15 Feb 2017 01:15:35 +0100
Subject: [PATCH] [feature] Allow update via PHP cli Subject: [PATCH] [feature][yunohost] Allow update via PHP cli - Included in
LimeSurvey 3.0
--- ---
application/commands/UpdateCommand.php | 90 ++++++++++++++++++++++++++++++++++ application/commands/UpdateCommand.php | 90 ++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+) 1 file changed, 90 insertions(+)
create mode 100644 application/commands/UpdateCommand.php create mode 100644 application/commands/UpdateCommand.php
diff --git a/application/commands/UpdateCommand.php b/application/commands/UpdateCommand.php diff --git a/application/commands/UpdateCommand.php b/application/commands/UpdateCommand.php
new file mode 100644 new file mode 100644
index 0000000..41ef107 index 0000000..faa216f
--- /dev/null --- /dev/null
+++ b/application/commands/UpdateCommand.php +++ b/application/commands/UpdateCommand.php
@@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
@ -18,7 +19,8 @@ index 0000000..41ef107
+ /* + /*
+ * @author Denis Chenu <denis@sondages.pro> + * @author Denis Chenu <denis@sondages.pro>
+ * @license GPL v3 + * @license GPL v3
+ * @version 0.1 + * @version 0.1.1
+ * @deprecated in LimeSurvey 3.0/develop UpdateDbCommand do it
+ * + *
+ * Copyright (C) 2017 Denis Chenu + * Copyright (C) 2017 Denis Chenu
+ * This program is free software: you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify
@ -44,11 +46,10 @@ index 0000000..41ef107
+ Yii::import('application.helpers.update.updatedb_helper', true); + Yii::import('application.helpers.update.updatedb_helper', true);
+ $result=db_upgrade_all($currentDbVersion);/* @todo : fix bad echoing here */ + $result=db_upgrade_all($currentDbVersion);/* @todo : fix bad echoing here */
+ if ($result) { + if ($result) {
+ //printf(gT("Database has been successfully upgraded to version %s"),$dbversionnumber)."\n";
+ echo "Database has been successfully upgraded to version $newDbVersion \n"; + echo "Database has been successfully upgraded to version $newDbVersion \n";
+ } else { + } else {
+ //echo gT("Please fix this error in your database and try again")."\n";
+ echo "Please fix this error in your database and try again\n"; + echo "Please fix this error in your database and try again\n";
+ return 1;
+ } + }
+ } else { + } else {
+ echo "no need update ".$newDbVersion ." ". $currentDbVersion ."\n"; + echo "no need update ".$newDbVersion ." ". $currentDbVersion ."\n";
@ -57,6 +58,7 @@ index 0000000..41ef107
+ +
+ /** + /**
+ * Fonction to set all needed (and unneeded) config + * Fonction to set all needed (and unneeded) config
+ * @deprecated in LimeSurvey 3.0/develop version config is set by LimeSurvey Core
+ * @return void + * @return void
+ */ + */
+ private function _setConfigs(){ + private function _setConfigs(){
@ -81,17 +83,17 @@ index 0000000..41ef107
+ foreach($aVersionConfigs as $sConfig=>$versionConfig){ + foreach($aVersionConfigs as $sConfig=>$versionConfig){
+ Yii::app()->setConfig($sConfig,$versionConfig); + Yii::app()->setConfig($sConfig,$versionConfig);
+ } + }
+ /* LS 3 version */ +
+ Yii::app()->setConfig('runtimedir',$sRootDir.DIRECTORY_SEPARATOR."tmp".DIRECTORY_SEPARATOR."runtime");
+ if(file_exists(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php')) + 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'); + $config = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
+ if(is_array($config['config']) && !empty($config['config'])) + if(is_array($config['config']) && !empty($config['config']))
+ { + {
+ foreach($config['config'] as $key=>$value) + foreach($config['config'] as $key=>$value) {
+ Yii::app()->setConfig($key,$value); + Yii::app()->setConfig($key,$value);
+ } + }
+ } + }
+ }
+ $oSettings=SettingGlobal::model()->findAll(); + $oSettings=SettingGlobal::model()->findAll();
+ if (count($oSettings) > 0) + if (count($oSettings) > 0)
+ { + {
@ -103,4 +105,3 @@ index 0000000..41ef107
+ } + }
+ +
+} +}
+?>

View file

@ -0,0 +1,87 @@
From 301de6eb25dda2b9342a006baadaa068c42b115e Mon Sep 17 00:00:00 2001
From: Denis Chenu <denis@sondages.pro>
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 @@
+<?php
+/**
+ * Description
+ *
+ * @author Denis Chenu <denis@sondages.pro>
+ * @copyright 2015 Denis Chenu <http://www.sondages.pro>
+ * @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
+ }
+ }
+
+}

View file

@ -178,7 +178,7 @@ ynh_setup_source () {
fi fi
# Apply patches # Apply patches
if [ -f ${PKG_DIR}/patches/$SOURCE_ID-*.patch ]; then if [ $(find ${PKG_DIR}/patches/ -type f -name "$SOURCE_ID-*.patch" | wc -l) ]; then
(cd "$DEST" \ (cd "$DEST" \
&& for p in ${PKG_DIR}/patches/$SOURCE_ID-*.patch; do \ && for p in ${PKG_DIR}/patches/$SOURCE_ID-*.patch; do \
ynh_exec_as "$AS_USER" patch -p1 < $p; done) \ ynh_exec_as "$AS_USER" patch -p1 < $p; done) \

View file

@ -37,26 +37,22 @@ ynh_setup_source "$local_path" "$user"
ynh_configure config.php "$local_path/application/config/config.php" ynh_configure config.php "$local_path/application/config/config.php"
# Fill LimeSurvey database
sed "s/\`prefix_/\`$prefix/g" $local_path/installer/sql/create-mysql.sql > ./structure.sql
mysql -u $db_user -p$db_pwd $db_user < ./structure.sql
ynh_configure data.sql ./data.sql
mysql -u $db_user -p$db_pwd $db_user < ./data.sql
# Randomize Password user # Randomize Password user
ls_cli=$local_path/application/commands/console.php ls_cli=$local_path/application/commands/console.php
set +x set +x
ynh_exec_as "$user" php $ls_cli resetpassword "$admin" "$(ynh_string_random 24)" ynh_exec_as "$user" php $ls_cli install "ynh_admin" "$(ynh_string_random 24)" "Administrator" "$admin@$domain"
set -x set -x
# Setup^extra DB part (@todo : replace by a plugin system)
ynh_configure data.sql ./data.sql
mysql -u $db_user -p$db_pwd $db_user < ./data.sql
# Set permissions # Set permissions
ynh_set_default_perm $local_path ynh_set_default_perm $local_path
sudo chmod -R u+w $local_path/tmp sudo chmod -R u+w $local_path/tmp
sudo chmod -R u+w $local_path/upload sudo chmod -R u+w $local_path/upload
sudo chmod -R u+w $local_path/application/config/ #~ sudo chmod -R u+w $local_path/application/config/
sudo yunohost app addaccess $app -u $admin sudo yunohost app addaccess $app -u $admin
ynh_sso_access "/index.php?r=admin,/index.php?r=plugins,/scripts" ynh_sso_access "/index.php?r=admin"
ynh_configure_php_fpm ynh_configure_php_fpm
ynh_configure_nginx ynh_configure_nginx