diff --git a/conf/config.php.j2 b/conf/config.php.j2 index 5a99217..a27eca8 100644 --- a/conf/config.php.j2 +++ b/conf/config.php.j2 @@ -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 'debug'=>0, '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 */ diff --git a/conf/data.sql.j2 b/conf/data.sql.j2 index b53db1f..a736dce 100644 --- a/conf/data.sql.j2 +++ b/conf/data.sql.j2 @@ -1,4 +1,4 @@ -INSERT INTO `lime_plugins` (`id`, `name`, `active`) VALUES +INSERT INTO `lime_plugins` (`id`, `name`, `active`) VALUES (2,'AuditLog',0), (3,'oldUrlCompat',0), (4,'ExportR',0), @@ -6,15 +6,9 @@ INSERT INTO `lime_plugins` (`id`, `name`, `active`) VALUES (6,'extendedStartPage',0), (7,'ExportSTATAxml',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\"'), (2,9,NULL,NULL,'ldapport','\"\"'), (3,9,NULL,NULL,'ldapversion','\"3\"'), @@ -41,8 +35,13 @@ 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_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" %} UPDATE `lime_plugin_settings` SET value='\"0\"' WHERE `id`=21; -{% endif %} +{% endif %} diff --git a/manifest.json b/manifest.json index ba8b605..a1d859f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "LimeSurvey", "id": "limesurvey", "packaging_format": 1, - "version": "2.62.2", + "version": "2.62.2.1", "description": { "en": "LimeSurvey is used to create advanced poll.", "fr": "LimeSurvey est un outil de création et diffusion de sondage en ligne." diff --git a/patches/app-0001-7ca4932.patch b/patches/app-0001-14c81c8.patch similarity index 87% rename from patches/app-0001-7ca4932.patch rename to patches/app-0001-14c81c8.patch index 1394085..fe54360 100644 --- a/patches/app-0001-7ca4932.patch +++ b/patches/app-0001-14c81c8.patch @@ -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 -Date: Thu, 19 Jan 2017 00:02:45 +0100 -Subject: [PATCH] [feature] Allow update via PHP cli +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 files changed, 90 insertions(+) + 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..41ef107 +index 0000000..faa216f --- /dev/null +++ b/application/commands/UpdateCommand.php @@ -0,0 +1,90 @@ @@ -18,7 +19,8 @@ index 0000000..41ef107 + /* + * @author Denis Chenu + * @license GPL v3 -+ * @version 0.1 ++ * @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 @@ -44,11 +46,10 @@ index 0000000..41ef107 + Yii::import('application.helpers.update.updatedb_helper', true); + $result=db_upgrade_all($currentDbVersion);/* @todo : fix bad echoing here */ + if ($result) { -+ //printf(gT("Database has been successfully upgraded to version %s"),$dbversionnumber)."\n"; + echo "Database has been successfully upgraded to version $newDbVersion \n"; + } 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"; ++ return 1; + } + } else { + echo "no need update ".$newDbVersion ." ". $currentDbVersion ."\n"; @@ -57,6 +58,7 @@ index 0000000..41ef107 + + /** + * 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(){ @@ -81,15 +83,15 @@ index 0000000..41ef107 + foreach($aVersionConfigs as $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')) + { + $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) ++ foreach($config['config'] as $key=>$value) { + Yii::app()->setConfig($key,$value); ++ } + } + } + $oSettings=SettingGlobal::model()->findAll(); @@ -103,4 +105,3 @@ index 0000000..41ef107 + } + +} -+?> 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 ++ } ++ } ++ ++} diff --git a/scripts/_common.sh b/scripts/_common.sh index 9b09134..6f88e5d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,14 +7,14 @@ ynh_check_var () { test -n "$1" || ynh_die "$2" } -ynh_exit_properly () { +ynh_exit_properly () { exit_code=$? if [ "$exit_code" -eq 0 ]; then - exit 0 + exit 0 fi trap '' EXIT set +eu - echo -e "\e[91m \e[1m" + echo -e "\e[91m \e[1m" err "$app script has encountered an error." if type -t CLEAN_SETUP > /dev/null; then @@ -89,7 +89,7 @@ ynh_local_path_available () { fi } -# Save listed var in YunoHost app settings +# Save listed var in YunoHost app settings # usage: ynh_save_args VARNAME1 [VARNAME2 [...]] ynh_save_args () { for var in $@; @@ -113,7 +113,7 @@ ynh_mysql_generate_db () { export db_pwd=$(ynh_string_random) # Generate a random password ynh_check_var "$db_pwd" "db_pwd empty" - + ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database ynh_app_setting_set $app mysqlpwd $db_pwd # Store the password in the app's config @@ -161,9 +161,9 @@ ynh_setup_source () { fi echo "$SOURCE_SUM $SOURCE_FILE" |$SUM_PRG -c --status \ || ynh_die "Corrupt source" - + sudo mkdir -p "$DEST" - sudo chown $AS_USER: "$DEST" + sudo chown $AS_USER: "$DEST" if [ "$(echo ${SOURCE_FILE##*.})" == "gz" ]; then ynh_exec_as "$AS_USER" tar xf $SOURCE_FILE -C "$DEST" --strip-components 1 elif [ "$(echo ${SOURCE_FILE##*.})" == "bz2" ]; then @@ -171,18 +171,18 @@ ynh_setup_source () { elif [ "$(echo ${SOURCE_FILE##*.})" == "zip" ]; then mkdir -p "/tmp/$SOURCE_FILE" ynh_exec_as "$AS_USER" unzip -q $SOURCE_FILE -d "/tmp/$SOURCE_FILE" - ynh_exec_as "$AS_USER" mv "/tmp/$SOURCE_FILE"/./. "$DEST" + ynh_exec_as "$AS_USER" mv "/tmp/$SOURCE_FILE"/./. "$DEST" rmdir "$/tmp/$SOURCE_FILE" else false fi - + # 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" \ && for p in ${PKG_DIR}/patches/$SOURCE_ID-*.patch; do \ ynh_exec_as "$AS_USER" patch -p1 < $p; done) \ - || ynh_die "Unable to apply patches" + || ynh_die "Unable to apply patches" fi @@ -324,13 +324,13 @@ Homepage: {{ project_url }} Standards-Version: 3.9.2 Package: {{ dep_app }}-ynh-deps -Version: {{ version }} +Version: {{ version }} Depends: {{ dependencies }} Architecture: all Description: meta package for {{ app }} (YunoHost app) dependencies This meta-package is only responsible of installing its dependencies. EOF - + ynh_configure app-ynh-deps.control ./$dep_app-ynh-deps.control ynh_package_install_from_equivs ./$dep_app-ynh-deps.control \ || ynh_die "Unable to install dependencies" @@ -387,11 +387,11 @@ ynh_configure_php_fpm () { finalphpconf=/etc/php5/fpm/pool.d/$app.conf ynh_configure php-fpm.conf /etc/php5/fpm/pool.d/$app.conf sudo chown root: $finalphpconf - + finalphpini=/etc/php5/fpm/conf.d/20-$app.ini sudo cp ../conf/php-fpm.ini $finalphpini sudo chown root: $finalphpini - + sudo service php5-fpm reload } diff --git a/scripts/install b/scripts/install index 6eef0a2..e0c804f 100755 --- a/scripts/install +++ b/scripts/install @@ -34,29 +34,25 @@ ynh_mysql_generate_db "$user" "$app" ynh_system_user_create "$user" "$local_path" ynh_setup_source "$local_path" "$user" - -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 +ynh_configure config.php "$local_path/application/config/config.php" # Randomize Password user ls_cli=$local_path/application/commands/console.php 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 - +# 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 ynh_set_default_perm $local_path sudo chmod -R u+w $local_path/tmp 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 -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_nginx