| Conditions | 49 |
| Paths | 0 |
| Total Lines | 304 |
| Code Lines | 151 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 36 | function xoops_module_update_newbb_v100(XoopsObject $module) |
||
| 37 | { |
||
| 38 | $result = $GLOBALS['xoopsDB']->queryF( |
||
| 39 | 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_archive') . "( |
||
| 40 | `topic_id` tinyint(8) NOT NULL default '0', |
||
| 41 | `post_id` tinyint(8) NOT NULL default '0', |
||
| 42 | `post_text` text NOT NULL |
||
| 43 | ) ENGINE=MyISAM" |
||
| 44 | ); |
||
| 45 | if (!$result) { |
||
| 46 | $module->setErrors('Could not create bb_archive'); |
||
| 47 | } |
||
| 48 | |||
| 49 | $result = $GLOBALS['xoopsDB']->queryF( |
||
| 50 | 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_attachments') . "( |
||
| 51 | `attach_id` int(8) unsigned NOT NULL auto_increment, |
||
| 52 | `post_id` int(10) default NULL, |
||
| 53 | `name_saved` varchar(255) default NULL, |
||
| 54 | `name_disp` varchar(255) default NULL, |
||
| 55 | `mimetype` varchar(255) default NULL, |
||
| 56 | `online` int(1) NOT NULL default '1', |
||
| 57 | `attach_time` int(10) NOT NULL default '0', |
||
| 58 | `download` int(10) NOT NULL default '0', |
||
| 59 | PRIMARY KEY (`attach_id`), |
||
| 60 | KEY `post_id` (`post_id`) |
||
| 61 | ) ENGINE=MyISAM" |
||
| 62 | ); |
||
| 63 | if (!$result) { |
||
| 64 | $module->setErrors('Could not create bb_attachments'); |
||
| 65 | } |
||
| 66 | |||
| 67 | $result = $GLOBALS['xoopsDB']->queryF( |
||
| 68 | 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_digest') . "( |
||
| 69 | `digest_id` int(8) unsigned NOT NULL auto_increment, |
||
| 70 | `digest_time` int(10) NOT NULL default '0', |
||
| 71 | `digest_content` text, |
||
| 72 | PRIMARY KEY (`digest_id`), |
||
| 73 | KEY `digest_time` (`digest_time`) |
||
| 74 | ) ENGINE=MyISAM" |
||
| 75 | ); |
||
| 76 | if (!$result) { |
||
| 77 | $module->setErrors('Could not create bb_digest'); |
||
| 78 | } |
||
| 79 | |||
| 80 | $result = $GLOBALS['xoopsDB']->queryF( |
||
| 81 | 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_online') . "( |
||
| 82 | `online_forum` int(10) NOT NULL default '0', |
||
| 83 | `online_topic` int(10) NOT NULL default '0', |
||
| 84 | `online_uid` int(10) default NULL, |
||
| 85 | `online_uname` varchar(255) default NULL, |
||
| 86 | `online_ip` varchar(32) default NULL, |
||
| 87 | `online_updated` int(14) default NULL |
||
| 88 | ) ENGINE=MyISAM" |
||
| 89 | ); |
||
| 90 | if (!$result) { |
||
| 91 | $module->setErrors('Could not create bb_online'); |
||
| 92 | } |
||
| 93 | |||
| 94 | $result = $GLOBALS['xoopsDB']->queryF( |
||
| 95 | 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_report') . "( |
||
| 96 | `report_id` int(8) unsigned NOT NULL auto_increment, |
||
| 97 | `post_id` int(10) default NULL, |
||
| 98 | `reporter_uid` int(10) default NULL, |
||
| 99 | `reporter_ip` int(11) NOT NULL default '0', |
||
| 100 | `report_time` int(10) NOT NULL default '0', |
||
| 101 | `report_text` varchar(255) default NULL, |
||
| 102 | `report_result` tinyint(1) NOT NULL default '0', |
||
| 103 | `report_memo` varchar(255) default NULL, |
||
| 104 | PRIMARY KEY (`report_id`), |
||
| 105 | KEY `post_id` (`post_id`) |
||
| 106 | ) ENGINE=MyISAM" |
||
| 107 | ); |
||
| 108 | if (!$result) { |
||
| 109 | $module->setErrors('Could not create bb_report'); |
||
| 110 | } |
||
| 111 | |||
| 112 | $result = $GLOBALS['xoopsDB']->queryF( |
||
| 113 | 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_votedata') . "( |
||
| 114 | `ratingid` int(11) unsigned NOT NULL auto_increment, |
||
| 115 | `topic_id` int(11) unsigned NOT NULL default '0', |
||
| 116 | `ratinguser` int(11) NOT NULL default '0', |
||
| 117 | `rating` tinyint(3) unsigned NOT NULL default '0', |
||
| 118 | `ratinghostname` varchar(60) NOT NULL default '', |
||
| 119 | `ratingtimestamp` int(10) NOT NULL default '0', |
||
| 120 | PRIMARY KEY (ratingid), |
||
| 121 | KEY ratinguser (ratinguser), |
||
| 122 | KEY ratinghostname (ratinghostname), |
||
| 123 | KEY topic_id (topic_id) |
||
| 124 | ) ENGINE=MyISAM" |
||
| 125 | ); |
||
| 126 | if (!$result) { |
||
| 127 | $module->setErrors('Could not create bb_votedata'); |
||
| 128 | } |
||
| 129 | |||
| 130 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_categories') . ' ADD `cat_image` VARCHAR(50) DEFAULT NULL AFTER `cat_id`'); |
||
| 131 | if (!$result) { |
||
| 132 | $module->setErrors('Could not add field in bb_categories'); |
||
| 133 | } |
||
| 134 | |||
| 135 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_categories') . ' ADD `cat_description` TEXT NOT NULL AFTER `cat_title`'); |
||
| 136 | if (!$result) { |
||
| 137 | $module->setErrors('Could not add field in bb_categories'); |
||
| 138 | } |
||
| 139 | |||
| 140 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_categories') . " CHANGE `cat_order` `cat_order` SMALLINT(3) UNSIGNED NOT NULL DEFAULT '0'"); |
||
| 141 | if (!$result) { |
||
| 142 | $module->setErrors('Could not change field in bb_categories'); |
||
| 143 | } |
||
| 144 | |||
| 145 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_categories') . ' ADD `cat_url` VARCHAR(50) DEFAULT NULL AFTER `cat_state`'); |
||
| 146 | if (!$result) { |
||
| 147 | $module->setErrors('Could not add field in bb_categories'); |
||
| 148 | } |
||
| 149 | |||
| 150 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . ' DROP `forum_access`'); |
||
| 151 | if (!$result) { |
||
| 152 | $module->setErrors('Could not drop field in bb_forums'); |
||
| 153 | } |
||
| 154 | |||
| 155 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . ' DROP `posts_per_page`'); |
||
| 156 | if (!$result) { |
||
| 157 | $module->setErrors('Could not drop field in bb_forums'); |
||
| 158 | } |
||
| 159 | |||
| 160 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . ' DROP `topics_per_page`'); |
||
| 161 | if (!$result) { |
||
| 162 | $module->setErrors('Could not drop field in bb_forums'); |
||
| 163 | } |
||
| 164 | |||
| 165 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " ADD `parent_forum` INT(10) NOT NULL DEFAULT '0' AFTER `forum_desc`"); |
||
| 166 | if (!$result) { |
||
| 167 | $module->setErrors('Could not add field in bb_forums'); |
||
| 168 | } |
||
| 169 | |||
| 170 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . ' CHANGE `forum_moderator` `forum_moderator` TEXT NOT NULL'); |
||
| 171 | if (!$result) { |
||
| 172 | $module->setErrors('Could not change field in bb_forums'); |
||
| 173 | } |
||
| 174 | |||
| 175 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " CHANGE `forum_type` `forum_type` INT(1) NOT NULL DEFAULT '0'"); |
||
| 176 | if (!$result) { |
||
| 177 | $module->setErrors('Could not change field in bb_forums'); |
||
| 178 | } |
||
| 179 | |||
| 180 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " CHANGE `allow_html` `allow_html` INT(1) NOT NULL DEFAULT '1'"); |
||
| 181 | if (!$result) { |
||
| 182 | $module->setErrors('Could not change field in bb_forums'); |
||
| 183 | } |
||
| 184 | |||
| 185 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " CHANGE `allow_sig` `allow_sig` INT(1) NOT NULL DEFAULT '1'"); |
||
| 186 | if (!$result) { |
||
| 187 | $module->setErrors('Could not change field in bb_forums'); |
||
| 188 | } |
||
| 189 | |||
| 190 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " ADD `allow_subject_prefix` INT(1) NOT NULL DEFAULT '0' AFTER `allow_sig`"); |
||
| 191 | if (!$result) { |
||
| 192 | $module->setErrors('Could not add field in bb_forums'); |
||
| 193 | } |
||
| 194 | |||
| 195 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " ADD `forum_order` INT(8) NOT NULL DEFAULT '0' AFTER `hot_threshold`"); |
||
| 196 | if (!$result) { |
||
| 197 | $module->setErrors('Could not add field in bb_forums'); |
||
| 198 | } |
||
| 199 | |||
| 200 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " ADD `allow_attachments` INT(1) NOT NULL DEFAULT '1' AFTER `forum_order`"); |
||
| 201 | if (!$result) { |
||
| 202 | $module->setErrors('Could not add field in bb_forums'); |
||
| 203 | } |
||
| 204 | |||
| 205 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " ADD `attach_maxkb` INT(10) NOT NULL DEFAULT '1000' AFTER `allow_attachments`"); |
||
| 206 | if (!$result) { |
||
| 207 | $module->setErrors('Could not add field in bb_forums'); |
||
| 208 | } |
||
| 209 | |||
| 210 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . ' ADD `attach_ext` TEXT NOT NULL AFTER `attach_maxkb`'); |
||
| 211 | if (!$result) { |
||
| 212 | $module->setErrors('Could not add field in bb_forums'); |
||
| 213 | } |
||
| 214 | |||
| 215 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . " ADD `allow_polls` INT(1) NOT NULL DEFAULT '0' AFTER `attach_ext`"); |
||
| 216 | if (!$result) { |
||
| 217 | $module->setErrors('Could not add field in bb_forums'); |
||
| 218 | } |
||
| 219 | |||
| 220 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' ADD `poster_name` varchar(255) DEFAULT NULL AFTER `uid`'); |
||
| 221 | if (!$result) { |
||
| 222 | $module->setErrors('Could not add field in bb_posts'); |
||
| 223 | } |
||
| 224 | |||
| 225 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " CHANGE `poster_ip` `poster_ip` INT(11) NOT NULL DEFAULT '0'"); |
||
| 226 | if (!$result) { |
||
| 227 | $module->setErrors('Could not change field in bb_posts'); |
||
| 228 | } |
||
| 229 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' DROP `nosmiley`'); |
||
| 230 | if (!$result) { |
||
| 231 | $module->setErrors('Could not drop nosmiley in bb_posts'); |
||
| 232 | } |
||
| 233 | |||
| 234 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " CHANGE `nohtml` `dohtml` TINYINT(1) NOT NULL DEFAULT '0'"); |
||
| 235 | if (!$result) { |
||
| 236 | $module->setErrors('Could not change field in bb_posts'); |
||
| 237 | } |
||
| 238 | |||
| 239 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `dosmiley` TINYINT(1) NOT NULL DEFAULT '1' AFTER `dohtml`"); |
||
| 240 | if (!$result) { |
||
| 241 | $module->setErrors('Could not change field in bb_posts'); |
||
| 242 | } |
||
| 243 | |||
| 244 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `doxcode` TINYINT(1) NOT NULL DEFAULT '1' AFTER `dosmiley`"); |
||
| 245 | if (!$result) { |
||
| 246 | $module->setErrors('Could not add field in bb_posts'); |
||
| 247 | } |
||
| 248 | |||
| 249 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `dobr` TINYINT(1) NOT NULL DEFAULT '1' AFTER `doxcode`"); |
||
| 250 | if (!$result) { |
||
| 251 | $module->setErrors('OK exist just to be sure bb_posts'); |
||
| 252 | } |
||
| 253 | |||
| 254 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `doimage` TINYINT(1) NOT NULL DEFAULT '1' AFTER `dobr`"); |
||
| 255 | if (!$result) { |
||
| 256 | $module->setErrors('OK exist just to be sure bb_posts'); |
||
| 257 | } |
||
| 258 | |||
| 259 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `approved` int(1) NOT NULL default '1' AFTER `attachsig`"); |
||
| 260 | if (!$result) { |
||
| 261 | $module->setErrors('Could not add field in bb_posts'); |
||
| 262 | } |
||
| 263 | |||
| 264 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `post_karma` int(10) NOT NULL default '0' AFTER `approved`"); |
||
| 265 | if (!$result) { |
||
| 266 | $module->setErrors('Could not add field in bb_posts'); |
||
| 267 | } |
||
| 268 | |||
| 269 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' ADD `attachment` text AFTER `post_karma`'); |
||
| 270 | if (!$result) { |
||
| 271 | $module->setErrors('Could not add field in bb_posts'); |
||
| 272 | } |
||
| 273 | |||
| 274 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . " ADD `require_reply` int(1) NOT NULL default '0' AFTER `attachment`"); |
||
| 275 | if (!$result) { |
||
| 276 | $module->setErrors('Could not add field in bb_posts'); |
||
| 277 | } |
||
| 278 | |||
| 279 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts_text') . ' ADD `post_edit` TEXT NOT NULL AFTER `post_text`'); |
||
| 280 | if (!$result) { |
||
| 281 | $module->setErrors('Could not add field in bb_posts_text'); |
||
| 282 | } |
||
| 283 | |||
| 284 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `topic_subject` INT(3) NOT NULL default '0' AFTER `topic_status`"); |
||
| 285 | if (!$result) { |
||
| 286 | $module->setErrors('Could not add field in bb_topics'); |
||
| 287 | } |
||
| 288 | |||
| 289 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `topic_digest` TINYINT(1) NOT NULL default '0' AFTER `topic_sticky`"); |
||
| 290 | if (!$result) { |
||
| 291 | $module->setErrors('Could not add field in bb_topics'); |
||
| 292 | } |
||
| 293 | |||
| 294 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `digest_time` int(10) NOT NULL default '0' AFTER `topic_digest`"); |
||
| 295 | if (!$result) { |
||
| 296 | $module->setErrors('Could not add field in bb_topics'); |
||
| 297 | } |
||
| 298 | |||
| 299 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `approved` int(1) NOT NULL default '1' AFTER `digest_time`"); |
||
| 300 | if (!$result) { |
||
| 301 | $module->setErrors('Could not add field in bb_topics'); |
||
| 302 | } |
||
| 303 | |||
| 304 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . ' ADD `poster_name` varchar(255) DEFAULT NULL AFTER `approved`'); |
||
| 305 | if (!$result) { |
||
| 306 | $module->setErrors('Could not add field in bb_topics'); |
||
| 307 | } |
||
| 308 | |||
| 309 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `rating` double(6,4) NOT NULL default '0.0000' AFTER `poster_name`"); |
||
| 310 | if (!$result) { |
||
| 311 | $module->setErrors('Could not add field in bb_topics'); |
||
| 312 | } |
||
| 313 | |||
| 314 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `votes` int(11) unsigned NOT NULL default '0' AFTER `rating`"); |
||
| 315 | if (!$result) { |
||
| 316 | $module->setErrors('Could not add field in bb_topics'); |
||
| 317 | } |
||
| 318 | |||
| 319 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `topic_haspoll` tinyint(1) NOT NULL default '0' AFTER `votes`"); |
||
| 320 | if (!$result) { |
||
| 321 | $module->setErrors('Could not add field in bb_topics'); |
||
| 322 | } |
||
| 323 | |||
| 324 | $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . " ADD `poll_id` mediumint(8) unsigned NOT NULL default '0' AFTER `topic_haspoll`"); |
||
| 325 | if (!$result) { |
||
| 326 | $module->setErrors('Could not add field in bb_topics'); |
||
| 327 | } |
||
| 328 | |||
| 329 | $result = $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forum_access')); |
||
| 330 | if (!$result) { |
||
| 331 | $module->setErrors('Could not drop bb_forum_access'); |
||
| 332 | } |
||
| 333 | |||
| 334 | $result = $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_forum_mods')); |
||
| 335 | if (!$result) { |
||
| 336 | $module->setErrors('Could not drop bb_forum_mods'); |
||
| 337 | } |
||
| 338 | |||
| 339 | return true; |
||
| 340 | } |
||
| 341 |