20 public $_mMilestone = [
25 public function _processScript()
27 parent::_processScript();
29 if ($cVersion < 204) {
30 $this->auto_update_session_blob();
34 public function auto_update_session_blob()
36 $root = XCube_Root::getSingleton();
37 $db = $root->mController->getDB();
38 $table = $db->prefix(
'session');
40 $sql =
'SHOW COLUMNS FROM `'. $table .
'` WHERE Field = \'sess_data\'';
41 if ($res = $db->query($sql)) {
42 $row = $db->fetchArray($res);
44 if (
'blob' !== strtolower($row[
'Type'])) {
45 $sql =
'ALTER TABLE `'. $table .
'` CHANGE `sess_data` `sess_data` BLOB NOT NULL';
47 if ($db->query($sql)) {
48 $this->mLog->addReport(
'Table `'.$table.
'` field `sess_data` changed type to BLOB.');
50 $this->mLog->addError(
'Type change error of table `'.$table.
'` field `sess_data` to BLOB.');
56 public function update200()
58 $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
62 if (!$this->_mForceMode && $this->mLog->hasError()) {
63 $this->_processReport();
69 if (!$this->_mForceMode && $this->mLog->hasError()) {
70 $this->_processReport();
75 if (!$this->_mForceMode && $this->mLog->hasError()) {
76 $this->_processReport();
81 if (!$this->_mForceMode && $this->mLog->hasError()) {
82 $this->_processReport();
87 if (!$this->_mForceMode && $this->mLog->hasError()) {
88 $this->_processReport();
92 $this->_processScript();
93 if (!$this->_mForceMode && $this->mLog->hasError()) {
94 $this->_processReport();
98 $this->_processReport();
103 public function update106()
105 $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
108 $this->_setUniqueToGroupUserLink();
110 if (!$this->_mForceMode && $this->mLog->hasError()) {
111 $this->_processReport();
117 if (!$this->_mForceMode && $this->mLog->hasError()) {
118 $this->_processReport();
123 if (!$this->_mForceMode && $this->mLog->hasError()) {
124 $this->_processReport();
129 if (!$this->_mForceMode && $this->mLog->hasError()) {
130 $this->_processReport();
135 if (!$this->_mForceMode && $this->mLog->hasError()) {
136 $this->_processReport();
140 $this->_processScript();
141 if (!$this->_mForceMode && $this->mLog->hasError()) {
142 $this->_processReport();
146 $this->_processReport();
157 $root =& XCube_Root::getSingleton();
158 $db =& $root->mController->getDB();
159 $table = $db->prefix(
'config');
161 $sql =
'ALTER TABLE `'. $table .
'` MODIFY `conf_title` varchar(191) NOT NULL default "", MODIFY `conf_desc` varchar(191) NOT NULL default ""';
163 if ($db->query($sql)) {
170 public function _setUniqueToGroupUserLink()
172 $root =& XCube_Root::getSingleton();
173 $db =& $root->mController->getDB();
174 $table = $db->prefix(
'groups_users_link');
177 $sql =
'SELECT `uid`,`groupid`,COUNT(*) AS c FROM `' . $table .
'` GROUP BY `uid`,`groupid` HAVING `c` > 1';
178 if ($res = $db->query($sql)) {
179 while ($row = $db->fetchArray($res)) {
180 $sql = sprintf(
'DELETE FROM `%s` WHERE `uid` = %d AND `groupid` = %d ORDER BY `linkid` DESC', $table, $row[
'uid'], $row[
'groupid']);
181 if (!$db->query($sql, $row[
'c'] - 1)) {
189 $sql =
'ALTER TABLE `' . $table .
'` DROP INDEX `groupid_uid`';
191 $sql =
'ALTER TABLE `' . $table .
'` ADD UNIQUE `uid_groupid` (`uid`,`groupid`)';
192 if ($db->query($sql)) {
205 $root =& XCube_Root::getSingleton();
206 $db =& $root->mController->getDB();
208 $permTable = $db->prefix(
'group_permission');
209 $groupTable = $db->prefix(
'groups');
211 'SELECT DISTINCT `gperm_groupid` FROM `%s` LEFT JOIN `%s` ON `%s`.`gperm_groupid`=`%s`.`groupid`' .
' WHERE `gperm_modid`=1 AND `groupid` IS NULL',
212 $permTable, $groupTable, $permTable, $groupTable);
213 $result = $db->query($sql);
219 while ($myrow = $db->fetchArray($result)) {
220 $gids[] = $myrow[
'gperm_groupid'];
223 $db->freeRecordSet($result);
226 if (0 != count($gids)) {
227 $sql = sprintf(
'DELETE FROM `%s` WHERE `gperm_groupid` IN (%s) AND `gperm_modid`=1',
228 $permTable, implode(
',', $gids));
229 $result = $db->query($sql);