1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: global $cfg;
17: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.api.string.php');
18:
19: 20: 21: 22: 23: 24: 25:
26: class cUpgradeJob_0002 extends cUpgradeJobAbstract {
27:
28: public $maxVersion = "4.9.0-alpha1";
29:
30: 31: 32: 33: 34:
35: private function _convertModulesToFile($clientId) {
36: global $cfg;
37:
38: $db = getSetupMySQLDBConnection();
39:
40: $sql = sprintf("SELECT * FROM %s WHERE idclient='%s' ORDER BY idmod", $cfg['tab']['mod'], $clientId);
41: $db->query($sql);
42:
43: $moduleHandler = new cModuleHandler();
44:
45: while ($db->nextRecord()) {
46:
47:
48: $moduleHandler->initWithDatabaseRow($db);
49:
50:
51: if ($moduleHandler->modulePathExists() != true) {
52:
53:
54: if ($moduleHandler->createModule($db->f('input'), $db->f('output')) == true) {
55:
56: $translations = new cModuleFileTranslation($db->f('idmod'));
57: $translations->saveTranslations();
58: }
59: }
60: }
61:
62:
63: $sql = sprintf("UPDATE %s SET input = '', output = '' WHERE idclient='%s'", $cfg['tab']['mod'], $clientId);
64: $db->query($sql);
65: }
66:
67: public function _execute() {
68: global $cfg;
69: global $client, $lang, $cfgClient;
70:
71: if ($this->_setupType != 'upgrade') {
72: return;
73: }
74:
75: $sql = "SHOW COLUMNS FROM %s LIKE 'frontendpath'";
76: $sql = sprintf($sql, $cfg['tab']['clients']);
77:
78: $this->_oDb->query($sql);
79: if ($this->_oDb->numRows() != 0) {
80: $sql = "SELECT * FROM " . $cfg['tab']['clients'];
81: $this->_oDb->query($sql);
82:
83: while ($this->_oDb->nextRecord()) {
84: updateClientCache($this->_oDb->f("idclient"), $this->_oDb->f("htmlpath"), $this->_oDb->f("frontendpath"));
85: }
86:
87: $sql = sprintf("ALTER TABLE %s DROP htmlpath", $cfg['tab']['clients']);
88: $this->_oDb->query($sql);
89:
90: $sql = sprintf("ALTER TABLE %s DROP frontendpath", $cfg['tab']['clients']);
91: $this->_oDb->query($sql);
92: }
93:
94: $cfgClient = updateClientCache();
95:
96: $clientBackup = $client;
97: $langBackup = $lang;
98:
99: $db2 = getSetupMySQLDBConnection();
100:
101:
102: $this->_oDb->query("SELECT * FROM `%s`", $cfg['tab']['mod']);
103: while ($this->_oDb->nextRecord()) {
104: $newName = cString::toLowerCase(cModuleHandler::getCleanName($this->_oDb->f('name')));
105: $sql = $db2->prepare("UPDATE `%s` SET `alias` = '%s' WHERE `idmod` = %d", $cfg['tab']['mod'], $newName, $this->_oDb->f('idmod'));
106: $db2->query($sql);
107: }
108:
109:
110: $this->_oDb->query("SELECT * FROM `%s`", $cfg['tab']['lay']);
111: while ($this->_oDb->nextRecord()) {
112: $newName = cModuleHandler::getCleanName(cString::toLowerCase($this->_oDb->f('name')));
113: $sql = $db2->prepare("UPDATE `%s` SET `alias` = '%s' WHERE `idlay` = %d", $cfg['tab']['lay'], $newName, $this->_oDb->f('idlay'));
114: $db2->query($sql);
115: }
116:
117:
118: foreach ($cfgClient as $iClient => $aClient) {
119: if ((int) $iClient == 0) {
120: continue;
121: }
122:
123: $client = $iClient;
124:
125:
126: $this->_oDb->query("SHOW COLUMNS FROM `%s` LIKE 'output'", $cfg['tab']['mod']);
127: if ($this->_oDb->numRows() > 0) {
128: $this->_convertModulesToFile($client);
129: }
130:
131:
132: $this->_oDb->query("SHOW COLUMNS FROM `%s` LIKE 'code'", $cfg['tab']['lay']);
133: if ($this->_oDb->numRows() > 0) {
134: cLayoutHandler::upgrade($this->_oDb, $cfg, $client);
135: }
136: }
137:
138: $client = $clientBackup;
139: $lang = $langBackup;
140: }
141: }
142: