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