| @@ 27-43 (lines=17) @@ | ||
| 24 | if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { |
|
| 25 | $errors = 0; |
|
| 26 | // 1) Create, if it does not exists, the stories_files table |
|
| 27 | if (!NewsUtility::existTable($xoopsDB->prefix('news_stories_files'))) { |
|
| 28 | $sql = 'CREATE TABLE ' . $xoopsDB->prefix('news_stories_files') . " ( |
|
| 29 | fileid INT(8) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
| 30 | filerealname VARCHAR(255) NOT NULL DEFAULT '', |
|
| 31 | storyid INT(8) UNSIGNED NOT NULL DEFAULT '0', |
|
| 32 | date INT(10) NOT NULL DEFAULT '0', |
|
| 33 | mimetype VARCHAR(64) NOT NULL DEFAULT '', |
|
| 34 | downloadname VARCHAR(255) NOT NULL DEFAULT '', |
|
| 35 | counter INT(8) UNSIGNED NOT NULL DEFAULT '0', |
|
| 36 | PRIMARY KEY (fileid), |
|
| 37 | KEY storyid (storyid) |
|
| 38 | ) ENGINE=MyISAM;"; |
|
| 39 | if (!$xoopsDB->queryF($sql)) { |
|
| 40 | echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED1; |
|
| 41 | ++$errors; |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| 45 | // 2) Change the topic title's length, in the topics table |
|
| 46 | $sql = sprintf('ALTER TABLE ' . $xoopsDB->prefix('news_topics') . ' CHANGE topic_title topic_title VARCHAR( 255 ) NOT NULL;'); |
|
| @@ 71-88 (lines=18) @@ | ||
| 68 | } |
|
| 69 | ||
| 70 | // 3) If it does not exists, create the table stories_votedata |
|
| 71 | if (!NewsUtility::existTable($xoopsDB->prefix('news_stories_votedata'))) { |
|
| 72 | $sql = 'CREATE TABLE ' . $xoopsDB->prefix('news_stories_votedata') . " ( |
|
| 73 | ratingid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
| 74 | storyid INT(8) UNSIGNED NOT NULL DEFAULT '0', |
|
| 75 | ratinguser INT(11) NOT NULL DEFAULT '0', |
|
| 76 | rating TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', |
|
| 77 | ratinghostname VARCHAR(60) NOT NULL DEFAULT '', |
|
| 78 | ratingtimestamp INT(10) NOT NULL DEFAULT '0', |
|
| 79 | PRIMARY KEY (ratingid), |
|
| 80 | KEY ratinguser (ratinguser), |
|
| 81 | KEY ratinghostname (ratinghostname), |
|
| 82 | KEY storyid (storyid) |
|
| 83 | ) ENGINE=MyISAM;"; |
|
| 84 | if (!$xoopsDB->queryF($sql)) { |
|
| 85 | echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED3; |
|
| 86 | ++$errors; |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| 90 | // 4) Create the four new fields for the votes in the story table |
|
| 91 | if (!NewsUtility::existField('rating', $xoopsDB->prefix('news_stories'))) { |
|
| @@ 33-53 (lines=21) @@ | ||
| 30 | echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED2; |
|
| 31 | ++$errors; |
|
| 32 | } |
|
| 33 | } else { |
|
| 34 | ||
| 35 | // 1) Create, if it does not exists, the stories_files table |
|
| 36 | if (!NewsUtility::existTable($xoopsDB->prefix('news_stories_files'))) { |
|
| 37 | $sql = 'CREATE TABLE ' . $xoopsDB->prefix('news_stories_files') . " ( |
|
| 38 | fileid INT(8) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
| 39 | filerealname VARCHAR(255) NOT NULL DEFAULT '', |
|
| 40 | storyid INT(8) UNSIGNED NOT NULL DEFAULT '0', |
|
| 41 | date INT(10) NOT NULL DEFAULT '0', |
|
| 42 | mimetype VARCHAR(64) NOT NULL DEFAULT '', |
|
| 43 | downloadname VARCHAR(255) NOT NULL DEFAULT '', |
|
| 44 | counter INT(8) UNSIGNED NOT NULL DEFAULT '0', |
|
| 45 | PRIMARY KEY (fileid), |
|
| 46 | KEY storyid (storyid) |
|
| 47 | ) ENGINE=MyISAM;"; |
|
| 48 | if (!$xoopsDB->queryF($sql)) { |
|
| 49 | echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED1; |
|
| 50 | ++$errors; |
|
| 51 | } |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||
| 55 | if (NewsUtility::existTable($xoopsDB->prefix('stories'))) { |
|
| 56 | $sql = sprintf('ALTER TABLE ' . $xoopsDB->prefix('stories') . ' RENAME ' . $xoopsDB->prefix('news_stories')); |
|
| @@ 108-125 (lines=18) @@ | ||
| 105 | } |
|
| 106 | ||
| 107 | // 3) If it does not exists, create the table stories_votedata |
|
| 108 | if (!NewsUtility::existTable($xoopsDB->prefix('news_stories_votedata'))) { |
|
| 109 | $sql = 'CREATE TABLE ' . $xoopsDB->prefix('news_stories_votedata') . " ( |
|
| 110 | ratingid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
| 111 | storyid INT(8) UNSIGNED NOT NULL DEFAULT '0', |
|
| 112 | ratinguser INT(11) NOT NULL DEFAULT '0', |
|
| 113 | rating TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', |
|
| 114 | ratinghostname VARCHAR(60) NOT NULL DEFAULT '', |
|
| 115 | ratingtimestamp INT(10) NOT NULL DEFAULT '0', |
|
| 116 | PRIMARY KEY (ratingid), |
|
| 117 | KEY ratinguser (ratinguser), |
|
| 118 | KEY ratinghostname (ratinghostname), |
|
| 119 | KEY storyid (storyid) |
|
| 120 | ) ENGINE=MyISAM;"; |
|
| 121 | if (!$xoopsDB->queryF($sql)) { |
|
| 122 | echo '<br>' . _AM_NEWS_UPGRADEFAILED . ' ' . _AM_NEWS_UPGRADEFAILED3; |
|
| 123 | ++$errors; |
|
| 124 | } |
|
| 125 | } |
|
| 126 | ||
| 127 | // 4) Create the four new fields for the votes in the story table |
|
| 128 | if (!NewsUtility::existField('rating', $xoopsDB->prefix('news_stories'))) { |
|