Commit 41276214 authored by Chenu Denis's avatar Chenu Denis
Browse files

[fix] 5.X compatibility

parent 5dacb680
......@@ -4,10 +4,10 @@
<name>cpVille</name>
<type>plugin</type>
<creationDate>2015-10-13</creationDate>
<lastUpdate>2021-02-23</lastUpdate>
<lastUpdate>2021-09-09</lastUpdate>
<author>Denis Chenu</author>
<authorUrl>https://www.sondages.pro</authorUrl>
<version>3.2.7</version>
<version>3.3.0</version>
<license>GNU Affero General Public License</license>
<description><![CDATA[Allow user to enter part of postal code or town and get the insee code in survey.]]></description>
</metadata>
......@@ -16,6 +16,7 @@
<version>2.72</version>
<version>3</version>
<version>4</version>
<version>5</version>
</compatibility>
<updaters disabled="disabled">
......
......@@ -137,13 +137,18 @@ class cpVille extends PluginBase {
throw new CHttpException(403);
}
if($getValues){
if(floatval($this->get('tableVersion',null,null,0)) < self::csvFileVersion){
$sTableName=self::tableName('insee_cp');
App()->getDb()->createCommand()->dropTable($sTableName);
Yii::app()->setFlashMessage(gT("Table for plugin was deleted to be updated"));
$this->_insertInseeCp();
$oPlugin = Plugin::model()->findByPk($this->getId());
if($oPlugin && $oPlugin->active) {
if(floatval($this->get('tableVersion',null,null,0)) < self::csvFileVersion){
$sTableName = self::tableName('insee_cp');
if(in_array($sTableName, Yii::app()->db->schema->getTableNames())) {
App()->getDb()->createCommand()->dropTable($sTableName);
Yii::app()->setFlashMessage(gT("Table for plugin was deleted to be updated"));
$this->_insertInseeCp();
}
}
$this->_checkAndUpdateTable();
}
$this->_checkAndUpdateTable();
}
$this->settings['versionInfo']['content'] = sprintf($this->settings['versionInfo']['content'],$this->get('tableVersion',null,null,0),$this->get('dbVersion',null,null,0));
return parent::getPluginSettings($getValues);
......@@ -160,6 +165,7 @@ class cpVille extends PluginBase {
private function _checkAndUpdateTable() {
$pluginId = $this->getId();
if($this->get('dbVersion',null,null,0) < 2) {
try {
$oTransaction = Yii::app()->getDb()->beginTransaction();
......
Markdown is supported
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