UserOnline/copy_this/modules/d3/d3usersonline/setup/d3usersonline_update.php

306 lines
11 KiB
PHP
Raw Normal View History

2013-09-03 12:33:05 +02:00
<?php
/**
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
class d3usersonline_update extends d3install_updatebase
{
public $sModKey = 'd3usersonline';
public $sModName = 'Users Online';
2015-07-06 16:10:09 +02:00
public $sModVersion = '2.0.1.1';
public $sModRevision = '43';
public $sBaseConf = 'Nv6RXZkcTl5NmIybDdzQldqUWo5dURBTXB4Tld3aHN3N2pmNmZacUljL0R4WUg2a1o4QUxLeVUrdjBSZ
WFud2VjRFJDa2ZvTHVaS2tpczAyZ0NGOGxwV3ZISHB3c0xRLzQ4Ny9kcTdDSjVQZDBYZ3VUMHFNaVg1R
3ZudGMzOGhsb01Sd1dTRG4xd0xscCtORC93VXJsWngrV200YktMSk93UENWNzJuT2NaT0U0UkJaQWdqa
nVKT0RwVFFzclYrT2JnckNGZjNieVRDSzcyV2Z2QktDR3RqNWJsemd6WURVMm1tbWl5cEJNMDFvR3JiS
2F5OHIvb0VoMUw1Nm9XdWdTc2FwVWpCVWFkZEllT1lGTzdiY2I0YUdNMmV3K3kyakZQMVRuUVJyUjhKO
DQ9';
2013-09-03 12:33:05 +02:00
public $sRequirements = '';
public $sBaseValue = '';
protected $_aUpdateMethods = array(
array('check' => 'checkUsersOnlineTableExist',
'do' => 'updateUsersOnlineTableExist'),
2013-09-09 09:49:11 +02:00
array('check' => 'checkRenameFields',
'do' => 'fixRenameFields'),
array('check' => 'checkDeleteFields',
'do' => 'fixDeleteFields'),
2013-09-03 12:33:05 +02:00
array('check' => 'checkModCfgItemExist',
'do' => 'updateModCfgItemExist'),
array('check' => 'checkFields',
'do' => 'fixFields'),
array('check' => 'checkIndizes',
'do' => 'fixIndizes'),
2015-01-23 10:51:54 +01:00
array('check' => 'hasOldModuleFiles',
'do' => 'deleteOldModuleFiles'),
array('check' => 'hasUnregisteredFiles',
'do' => 'showUnregisteredFiles'),
2013-09-03 12:33:05 +02:00
array('check' => 'checkModCfgSameRevision',
'do' => 'updateModCfgSameRevision'),
);
2015-01-23 10:51:54 +01:00
public $aOldModuleFiles = array(
'd3/d3usersonline/models/d3usersonline_update.php',
);
2013-09-03 12:33:05 +02:00
public $aFields = array(
'OXID' => array(
'sTableName' => 'd3usersonline',
'sFieldName' => 'OXID',
'sType' => 'char(32)',
2015-01-23 10:22:46 +01:00
'blNull' => false,
'sDefault' => false,
2013-09-03 12:33:05 +02:00
'sComment' => '',
'sExtra' => '',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-03 12:33:05 +02:00
),
'TIMEVISIT' => array(
'sTableName' => 'd3usersonline',
'sFieldName' => 'TIMEVISIT',
'sType' => 'INT(11)',
2015-01-23 10:22:46 +01:00
'blNull' => false,
2013-09-03 12:33:05 +02:00
'sDefault' => '0',
'sComment' => '',
'sExtra' => '',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-03 12:33:05 +02:00
),
'OXCLASS' => array(
'sTableName' => 'd3usersonline',
'sFieldName' => 'OXCLASS',
'sType' => 'VARCHAR(32)',
2015-01-23 10:22:46 +01:00
'blNull' => false,
'sDefault' => false,
2013-09-03 12:33:05 +02:00
'sComment' => '',
'sExtra' => '',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-03 12:33:05 +02:00
),
);
public $aIndizes = array(
'OXID' => array(
'sTableName' => 'd3usersonline',
'sType' => 'PRIMARY',
'aFields' => array(
'OXID' => 'OXID',
),
),
'OXCLASS' => array(
'sTableName' => 'd3usersonline',
'sType' => '',
2013-09-03 12:33:05 +02:00
'sName' => 'OXCLASS',
'aFields' => array(
'OXCLASS' => 'OXCLASS',
),
),
);
2013-09-09 09:49:11 +02:00
public $aRenameFields = array(
'OXID' => array(
'sTableName' => 'd3usersonline',
'mOldFieldNames' => array('id', 'ID'), // is case sensitive
'sFieldName' => 'OXID',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-09 09:49:11 +02:00
),
'VISITOR' => array(
'sTableName' => 'd3usersonline',
'mOldFieldNames' => array('visitor'), // is case sensitive
'sFieldName' => 'VISITOR',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-09 09:49:11 +02:00
),
'TIMEVISIT' => array(
'sTableName' => 'd3usersonline',
'mOldFieldNames' => array('timevisit'), // is case sensitive
'sFieldName' => 'TIMEVISIT',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-09 09:49:11 +02:00
),
'OXCLASS' => array(
'sTableName' => 'd3usersonline',
'mOldFieldNames' => array('oxclass'), // is case sensitive
'sFieldName' => 'OXCLASS',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-09 09:49:11 +02:00
),
);
public $aDeleteFields = array(
'VISITOR' => array(
'sTableName' => 'd3usersonline',
'sFieldName' => 'VISITOR',
2015-01-23 10:22:46 +01:00
'blMultilang' => false,
2013-09-09 09:49:11 +02:00
),
);
2013-09-03 12:33:05 +02:00
protected $_aRefreshMetaModuleIds = array('d3usersonline');
/**
2015-01-23 10:22:46 +01:00
* @return bool true, if table is missing
2013-09-03 12:33:05 +02:00
*/
public function checkUsersOnlineTableExist()
{
return $this->_checkTableNotExist('d3usersonline');
}
/**
* @return bool
*/
public function updateUsersOnlineTableExist()
{
2015-01-23 10:22:46 +01:00
$blRet = true;
2013-09-03 12:33:05 +02:00
2015-01-23 10:51:54 +01:00
if ($this->checkUsersOnlineTableExist()) {
$blRet = $this->_addTable2('d3usersonline', $this->aFields, $this->aIndizes, 'users online', 'MyISAM');
2013-09-03 12:33:05 +02:00
}
return $blRet;
}
/**
* @return bool
*/
public function checkModCfgItemExist()
{
2015-01-23 10:22:46 +01:00
$blRet = false;
2015-01-23 10:51:54 +01:00
foreach ($this->getShopList() as $oShop) {
2013-09-03 12:33:05 +02:00
/** @var $oShop oxshop */
$aWhere = array(
'oxmodid' => $this->sModKey,
'oxnewrevision' => $this->sModRevision,
'oxshopid' => $oShop->getId(),
);
$blRet = $this->_checkTableItemNotExist('d3_cfg_mod', $aWhere);
2015-01-23 10:22:46 +01:00
if ($blRet) {
2013-09-03 12:33:05 +02:00
return $blRet;
}
}
return $blRet;
}
/**
* @return bool
*/
public function updateModCfgItemExist()
{
2015-01-23 10:22:46 +01:00
$blRet = false;
2013-09-03 12:33:05 +02:00
2015-01-23 10:22:46 +01:00
if ($this->checkModCfgItemExist()) {
2015-01-23 10:51:54 +01:00
foreach ($this->getShopList() as $oShop) {
2013-09-03 12:33:05 +02:00
/** @var $oShop oxshop */
$aWhere = array(
'oxmodid' => $this->sModKey,
'oxshopid' => $oShop->getId(),
'oxnewrevision' => $this->sModRevision,
);
2015-01-23 10:22:46 +01:00
if ($this->_checkTableItemNotExist('d3_cfg_mod', $aWhere)) {
2013-09-03 12:33:05 +02:00
// update don't use this property
unset($aWhere['oxnewrevision']);
$aInsertFields = array(
'OXID' => array (
'content' => "md5('" . $this->sModKey . " " . $oShop->getId() . " de')",
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => false,
2013-09-03 12:33:05 +02:00
),
'OXSHOPID' => array (
'content' => $oShop->getId(),
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXMODID' => array (
'content' => $this->sModKey,
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXNAME' => array (
'content' => $this->sModName,
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXACTIVE' => array (
'content' => "0",
2015-01-23 10:22:46 +01:00
'force_update' => false,
'use_quote' => false,
2013-09-03 12:33:05 +02:00
),
'OXBASECONFIG' => array (
'content' => $this->sBaseConf,
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXSERIAL' => array (
'content' => "",
2015-01-23 10:22:46 +01:00
'force_update' => false,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXINSTALLDATE' => array (
'content' => "NOW()",
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => false,
2013-09-03 12:33:05 +02:00
),
'OXVERSION' => array (
'content' => $this->sModVersion,
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXSHOPVERSION' => array (
'content' => oxRegistry::getConfig()->getEdition(),
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXREQUIREMENTS' => array (
'content' => $this->sRequirements,
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXVALUE' => array(
'content' => $this->sBaseValue,
2015-01-23 10:22:46 +01:00
'force_update' => false,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
),
'OXNEWREVISION' => array(
'content' => $this->sModRevision,
2015-01-23 10:22:46 +01:00
'force_update' => true,
'use_quote' => true,
2013-09-03 12:33:05 +02:00
)
);
2015-01-23 10:51:54 +01:00
$blRet = $this->_updateTableItem2('d3_cfg_mod', $aInsertFields, $aWhere);
$this->setUpdateBreak(false);
2013-09-03 12:33:05 +02:00
}
}
}
return $blRet;
}
2015-01-23 10:51:54 +01:00
/**
* @return bool
*/
public function hasUnregisteredFiles()
{
return $this->_hasUnregisteredFiles($this->sModKey, array('d3FileRegister', 'blocks'));
}
/**
* @return bool
*/
public function showUnregisteredFiles()
{
return $this->_showUnregisteredFiles($this->sModKey, array('d3FileRegister', 'blocks'));
}
2015-01-23 10:22:46 +01:00
}