XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
myUpdater.class.php
1<?php
12
13if (!defined('XOOPS_ROOT_PATH')) {
14 exit();
15}
16
17require_once XOOPS_ROOT_PATH.'/modules/legacy/admin/class/ModuleUpdater.class.php';
18
19class Message_myUpdater extends Legacy_ModulePhasedUpgrader
20{
21 public function Message_myUpdater()
22 {
23 self::__construct();
24 }
25
26 public function __construct()
27 {
28 parent::__construct();
29 $this->_mMilestone = [
30 '041' => 'update041',
31 '060' => 'update060',
32 '070' => 'update070'
33 ];
34 }
35
36 public function updatemain()
37 {
38 Legacy_ModuleInstallUtils::clearAllOfModuleTemplatesForUpdate($this->_mTargetXoopsModule, $this->mLog);
39 Legacy_ModuleInstallUtils::installAllOfModuleTemplates($this->_mTargetXoopsModule, $this->mLog);
40
41 $this->saveXoopsModule($this->_mTargetXoopsModule);
42 $this->mLog->add('Version'.($this->_mTargetVersion / 100).' for update.');
43 $this->_mCurrentVersion = $this->_mTargetVersion;
44 }
45
46 public function update070()
47 {
48 $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
49 $root = XCube_Root::getSingleton();
50 $db = $root->mController->getDB();
51
52 $sql = 'ALTER TABLE `' . $db->prefix('message_inbox') . '` ';
53 $sql.= "ADD `uname` varchar(100) NOT NULL default ''";
54 if (!$db->query($sql)) {
55 $this->mLog->addReport($db->error());
56 }
57
58 $this->updatemain();
59 return true;
60 }
61
62 public function update060()
63 {
64 $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
65 $root = XCube_Root::getSingleton();
66 $db = $root->mController->getDB();
67
68 $sql = 'ALTER TABLE `' . $db->prefix('message_users') . '` ';
69 $sql.= "ADD `viewmsm` int( 1 ) UNSIGNED NOT NULL DEFAULT '0', ";
70 $sql.= "ADD `pagenum` int( 2 ) UNSIGNED NOT NULL DEFAULT '0', ";
71 $sql.= "ADD `blacklist` VARCHAR( 191 ) NOT NULL DEFAULT ''";
72 if (!$db->query($sql)) {
73 $this->mLog->addReport($db->error());
74 }
75
76 $this->updatemain();
77 return true;
78 }
79
80 public function update041()
81 {
82 $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
83
84 //Add Table
85 $sqlfileInfo = $this->_mTargetXoopsModule->getInfo('sqlfile');
86 $dirname = $this->_mTargetXoopsModule->getVar('dirname');
87 $sqlfile = $sqlfileInfo[XOOPS_DB_TYPE];
88 $sqlfilepath = XOOPS_MODULE_PATH.'/'.$dirname.'/'.$sqlfile;
89 require_once XOOPS_MODULE_PATH.'/legacy/admin/class/Legacy_SQLScanner.class.php';
90 $scanner = new Legacy_SQLScanner();
91 $scanner->setDB_PREFIX(XOOPS_DB_PREFIX);
92 $scanner->setDirname($this->_mTargetXoopsModule->get('dirname'));
93 if (!$scanner->loadFile($sqlfilepath)) {
94 $this->mLog->addError(XCube_Utils::formatString(_AD_LEGACY_ERROR_SQL_FILE_NOT_FOUND, $sqlfile));
95 return false;
96 }
97
98 $scanner->parse();
99 $sqls = $scanner->getSQL();
100 $root = XCube_Root::getSingleton();
101 $db = $root->mController->getDB();
102
103 foreach ($sqls as $sql) {
104 if (false !== strpos($sql, '_message_users')) {
105 if (!$db->query($sql)) {
106 $this->mLog->addError($db->error());
107 return false;
108 }
109 }
110 }
111 $this->mLog->addReport(_AD_LEGACY_MESSAGE_DATABASE_SETUP_FINISHED);
112 //add table
113
114 $this->updatemain();
115 return true;
116 }
117}
static installAllOfModuleTemplates(&$module, &$log)
static formatString()
[Static] Formats string with special care for international.