Commit 0fe7a7a5 authored by Chenu Denis's avatar Chenu Denis
Browse files

[fix] Continue improve DB access

[feature] config.xml
parent c09d9b3d
......@@ -5,7 +5,7 @@
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2020-2022 Denis Chenu <http://www.sondages.pro>
* @license AGPL v3
* @version 0.20.0
* @version 0.20.1
*
* 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
......@@ -54,10 +54,15 @@ class Settings
*/
private static $instance = null;
/**
* @var null|integre
*/
private $pluginid;
/**
* @var []
*/
private $settings;
private $settings = array();
/**
* constructor
......@@ -65,7 +70,11 @@ class Settings
*/
public function __construct()
{
// Nothing to do (surveyoid updated during process)
$oPlugin = \Plugin::model()->find(
"name = :name",
array(":name" => 'TokenUsersListAndManage')
);
$this->pluginid = $oPlugin->id;
}
/**
......@@ -92,15 +101,12 @@ class Settings
if (isset($this->settings[$surveyId][$sSetting])) {
return $this->settings[$surveyId][$sSetting];
}
$oPlugin = \Plugin::model()->find(
"name = :name",
array(":name" => 'TokenUsersListAndManage')
);
/* This survey setting */
$oSetting = \PluginSetting::model()->find(
'plugin_id = :pluginid AND ' . App()->getDb()->quoteColumnName('key') . ' = :key AND model = :model AND model_id = :surveyid',
array(
':pluginid' => $oPlugin->id,
':pluginid' => $this->pluginid,
':key' => $sSetting,
':model' => 'Survey',
':surveyid' => $surveyId,
......@@ -117,7 +123,7 @@ class Settings
$oSetting = \PluginSetting::model()->find(
'plugin_id = :pluginid AND ' . App()->getDb()->quoteColumnName('key') . ' = :key AND model IS NULL',
array(
':pluginid' => $oPlugin->id,
':pluginid' => $this->pluginid,
':key' => $sSetting,
)
);
......
......@@ -5,7 +5,7 @@
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2020-2021 Denis Chenu <http://www.sondages.pro>
* @license GPL v3
* @version 0.19.6
* @version 0.20.1
*
* 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
......@@ -426,7 +426,8 @@ class TokenUsersListAndManage extends PluginBase
}
$tokenAttributeGroupManager = \TokenUsersListAndManagePlugin\Utilities::getTokenAttributeGroupManager($settingsSurveyId);
$tokenAttributeRestricted = $this->get('tokenAttributeRestricted', 'Survey', $settingsSurveyId, null);
$tokenAttributeRestricted = \TokenUsersListAndManagePlugin\Utilities::getSetting($surveyId, 'tokenAttributeRestricted');
$useAttributeRestricted = \TokenUsersListAndManagePlugin\Utilities::getSetting($surveyId, 'useAttributeRestricted');
$allowAllAttributeRestricted = \TokenUsersListAndManagePlugin\Utilities::getSetting($surveyId, 'allowAllAttributeRestricted');
......@@ -1569,14 +1570,6 @@ class TokenUsersListAndManage extends PluginBase
*/
private function getSetting($surveyId, $param)
{
$setting = $this->get($param, 'survey', $surveyId, '');
if($setting !== "") {
return $setting;
}
$setting = $this->get($param, null, null, '');
if($setting !== "") {
return $setting;
}
return $this->settings[$param]['default'];
return \TokenUsersListAndManagePlugin\Utilities::getSetting($surveyId, $param);
}
}
......@@ -5,7 +5,7 @@
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2020-2022 Denis Chenu <http://www.sondages.pro>
* @license AGPL v3
* @version 0.19.6
* @version 0.20.1
*
* 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
......
<?xml version="1.0" encoding="UTF-8"?>
<config>
<metadata>
<name>TokenUsersListAndManage</name>
<type>plugin</type>
<creationDate>2018-02-18</creationDate>
<lastUpdate>2022-06-17</lastUpdate>
<author>Denis Chenu</author>
<authorUrl>https://www.sondages.pro/</authorUrl>
<supportUrl>https://support.sondages.pro/</supportUrl>
<version>0.20.1</version>
<license>GNU Affero General Public License v3.0</license>
<description><![CDATA[Token Users List And Manage.]]></description>
</metadata>
<compatibility>
<version>3</version>
</compatibility>
</config>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment