PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/simple-forum/install/sf-upgrade.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 3019 lines | 2392 code | 417 blank | 210 comment | 107 complexity | 99d82506a6870d7ad8bd853de4a9f79e MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. Simple:Press
  4. Upgrade Path Routines
  5. $LastChangedDate: 2011-06-05 09:16:54 -0700 (Sun, 05 Jun 2011) $
  6. $Rev: 6253 $
  7. */
  8. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
  9. die('Access Denied');
  10. }
  11. global $wpdb, $current_user;
  12. $InstallID = get_option('sfInstallID'); # use wp option table
  13. wp_set_current_user($InstallID);
  14. # use WP check here since SPF stuff may not be set up
  15. if(!current_user_can('activate_plugins'))
  16. {
  17. echo (__('Access Denied - Only Users who can Activate Plugins may perform this upgrade', 'sforum'));
  18. die();
  19. }
  20. sf_setup_sitewide_constants();
  21. sf_setup_global_constants();
  22. require_once (dirname(__FILE__).'/sf-upgrade-support.php');
  23. require_once (dirname(__FILE__).'/../admin/library/sfa-support.php');
  24. if(!isset($_GET['start'])) die();
  25. $checkval = $_GET['start'];
  26. $build = intval($checkval);
  27. # Start of Upgrade Routines =============
  28. $section = 200;
  29. if($build < $section)
  30. {
  31. # 1.2 =====================================================================================
  32. add_option('sfsortdesc', false);
  33. # 1.3 =====================================================================================
  34. add_option('sfavatars', true);
  35. add_option('sfshownewadmin', true);
  36. add_option('sfshownewuser', true);
  37. add_option('sfshownewcount', 6);
  38. add_option('sfdates', get_option('date_format'));
  39. add_option('sftimes', get_option('time_format'));
  40. add_option('sfzone', 0);
  41. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_desc varchar(150) default NULL)";
  42. sf_upgrade_database(SFFORUMS, 'forum_desc', $create_ddl);
  43. # 1.4 =====================================================================================
  44. add_option('sfshowavatars', true);
  45. add_option('sfuserabove', false);
  46. add_option('sfrte', true);
  47. add_option('sfskin', 'default');
  48. add_option('sficon', 'default');
  49. # 1.6 =====================================================================================
  50. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_status int(4) NOT NULL default '0')";
  51. sf_upgrade_database(SFFORUMS, 'forum_status', $create_ddl);
  52. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (post_pinned smallint(1) NOT NULL default '0')";
  53. sf_upgrade_database(SFPOSTS, 'post_pinned', $create_ddl);
  54. $postusers = $wpdb->get_results("SELECT user_id, COUNT(post_id) AS numposts FROM ".SFPOSTS." WHERE user_id IS NOT NULL GROUP BY user_id");
  55. if($postusers)
  56. {
  57. foreach($postusers as $postuser)
  58. {
  59. update_user_option($postuser->user_id, 'sfposts', $postuser->numposts);
  60. }
  61. }
  62. add_option('sfstopedit', true);
  63. add_option('sfmodmembers', false);
  64. add_option('sfmodusers', '');
  65. add_option('sftopicsort', false);
  66. sf_check_data_integrity();
  67. # 1.7 =====================================================================================
  68. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_subs longtext)";
  69. sf_upgrade_database(SFTOPICS, 'topic_subs', $create_ddl);
  70. sf_rebuild_subscriptions();
  71. add_option('sfavatarsize', 50);
  72. delete_option('sffilters');
  73. delete_option('sfrte');
  74. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_desc varchar(150) default NULL)";
  75. sf_upgrade_database(SFGROUPS, 'group_desc', $create_ddl);
  76. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_view varchar(20) default 'public')";
  77. sf_upgrade_database(SFGROUPS, 'group_view', $create_ddl);
  78. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_view varchar(20) default 'public')";
  79. sf_upgrade_database(SFFORUMS, 'forum_view', $create_ddl);
  80. # 1.8 =====================================================================================
  81. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_sort varchar(4) default NULL)";
  82. sf_upgrade_database(SFTOPICS, 'topic_sort', $create_ddl);
  83. add_option('sfspam', true);
  84. add_option('sfpermalink', get_permalink(get_option('sfpage')));
  85. add_option('sfextprofile', true);
  86. add_option('sfusersig', true);
  87. add_option('sfhome', SFHOMEURL);
  88. # 1.9 =====================================================================================
  89. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_opened bigint(20) NOT NULL default '0')";
  90. sf_upgrade_database(SFTOPICS, 'topic_opened', $create_ddl);
  91. $icons='Login;1@Register;1@Logout;1@Profile;1@Add a New Topic;1@Forum Locked;1@Reply to Post;1@Topic Locked;1@Quote and Reply;1@Edit Your Post;1@Return to Search Results;1@Subscribe;1@Forum RSS;1@Topic RSS;1';
  92. update_option('sfshowicon', $icons);
  93. add_option('sfrss', true);
  94. add_option('sfrsscount', 15);
  95. add_option('sfrsswords', 0);
  96. add_option('sfpagedposts', 20);
  97. add_option('sfgravatar', false);
  98. add_option('sfmodonce', false);
  99. add_option('sftitle', true);
  100. add_option('sflang', 'en');
  101. $fcols['topics']=true;
  102. $fcols['posts']=true;
  103. add_option('sfforumcols', $fcols);
  104. $tcols['first']=true;
  105. $tcols['last']=true;
  106. $tcols['posts']=true;
  107. $tcols['views']=true;
  108. add_option('sftopiccols', $tcols);
  109. $sql = "
  110. CREATE TABLE IF NOT EXISTS ".SFTRACK." (
  111. id bigint(20) NOT NULL auto_increment,
  112. trackuserid bigint(20) default 0,
  113. trackname varchar(25) NOT NULL,
  114. trackdate datetime NOT NULL,
  115. PRIMARY KEY (id)
  116. ) ENGINE=MyISAM ".sf_charset().";";
  117. $wpdb->query($sql);
  118. update_option('sfbuild', $section);
  119. echo $section;
  120. die();
  121. }
  122. $section = 220;
  123. if($build < $section)
  124. {
  125. # 2.0 =====================================================================================
  126. $create_ddl = "ALTER TABLE ".SFWAITING. " ADD (post_id bigint(20) NOT NULL default '0')";
  127. sf_upgrade_database(SFWAITING, 'post_id', $create_ddl);
  128. $sql = "ALTER TABLE ".SFTRACK." MODIFY trackname VARCHAR(50) NOT NULL;";
  129. $wpdb->query($sql);
  130. sf_clean_topic_subs();
  131. $icons=sf_opcheck(get_option('sfshowicon'));
  132. if(strpos($icons, '@New Posts;') === false)
  133. {
  134. $icons.= '@All RSS;1@Search;1@New Posts;1';
  135. update_option('sfshowicon', $icons);
  136. }
  137. $sql = "
  138. CREATE TABLE IF NOT EXISTS ".SFSETTINGS." (
  139. setting_id bigint(20) NOT NULL auto_increment,
  140. setting_name varchar(20) NOT NULL,
  141. setting_value longtext,
  142. PRIMARY KEY (setting_id)
  143. ) ENGINE=MyISAM ".sf_charset().";";
  144. $wpdb->query($sql);
  145. $sql = "
  146. CREATE TABLE IF NOT EXISTS ".SFNOTICE." (
  147. id varchar(30) NOT NULL,
  148. item varchar(15),
  149. message longtext,
  150. PRIMARY KEY (id)
  151. ) ENGINE=MyISAM ".sf_charset().";";
  152. $wpdb->query($sql);
  153. delete_option('sfsearch');
  154. delete_option('sfaction');
  155. delete_option('sfppage');
  156. delete_option('sftpage');
  157. delete_option('sfmessage');
  158. add_option('sfstats', true);
  159. add_option('sfshownewabove', false);
  160. add_option('sfshowlogin', true);
  161. $avatar = sf_relocate_avatars();
  162. if($avatar != 0)
  163. {
  164. add_option('sfinstallav', $avatar);
  165. }
  166. update_option('sfbuild', $section);
  167. echo $section;
  168. die();
  169. }
  170. $section = 228;
  171. if($build < $section)
  172. {
  173. # 2.1 =====================================================================================
  174. sf_correct_sflast();
  175. $wpdb->query("DELETE FROM ".SFSETTINGS." WHERE setting_name <> 'maxonline';");
  176. $wpdb->query("ALTER TABLE ".SFSETTINGS." MODIFY setting_name VARCHAR(50) NOT NULL;");
  177. $create_ddl = "ALTER TABLE ".SFSETTINGS." ADD (setting_date datetime NOT NULL);";
  178. sf_upgrade_database(SFSETTINGS, 'setting_date', $create_ddl);
  179. $create_ddl = "ALTER TABLE ".SFNOTICE." ADD (ndate datetime NOT NULL);";
  180. sf_upgrade_database(SFNOTICE, 'ndate', $create_ddl);
  181. $create_ddl = "ALTER TABLE ".SFWAITING." ADD (user_id bigint(20) default 0);";
  182. sf_upgrade_database(SFWAITING, 'user_id', $create_ddl);
  183. $wpdb->query("ALTER TABLE ".SFFORUMS." ADD INDEX groupf_idx (group_id);");
  184. $wpdb->query("ALTER TABLE ".SFPOSTS." ADD INDEX topicp_idx (topic_id);");
  185. $wpdb->query("ALTER TABLE ".SFPOSTS." ADD INDEX forump_idx (forum_id);");
  186. $wpdb->query("ALTER TABLE ".SFTOPICS." ADD INDEX forumt_idx (forum_id);");
  187. add_option('sfregmath', true);
  188. add_option('sfsearchbar', true);
  189. add_option('sfadminspam', true);
  190. add_option('sfshowhome', true);
  191. add_option('sflockdown', false);
  192. add_option('sfshowmodposts', true);
  193. # Links
  194. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (blog_post_id bigint(20) NOT NULL default '0')";
  195. sf_upgrade_database(SFTOPICS, 'blog_post_id', $create_ddl);
  196. add_option('sflinkuse', false);
  197. add_option('sflinkexcerpt', false);
  198. add_option('sflinkwords', 100);
  199. add_option('sflinkblogtext', '%ICON% Join the forum discussion on this post');
  200. add_option('sflinkforumtext', '%ICON% Read original blog post');
  201. add_option('sflinkabove', false);
  202. # Announce Tag
  203. add_option('sfuseannounce', false);
  204. add_option('sfannouncecount', 8);
  205. add_option('sfannouncehead', 'Most Recent Forum Posts');
  206. add_option('sfannounceauto', false);
  207. add_option('sfannouncetime', 60);
  208. add_option('sfannouncetext', '%TOPICNAME% posted by %POSTER% in %FORUMNAME% on %DATETIME%');
  209. add_option('sfannouncelist', false);
  210. # Rankings
  211. $ranks=array('New Member' => 2, 'Member' => 1000);
  212. add_option('sfrankings', $ranks);
  213. $icons=sf_opcheck(get_option('sfshowicon'));
  214. if(strpos($icons, '@Group RSS;') === false)
  215. {
  216. $icons.= '@Group RSS;1';
  217. update_option('sfshowicon', $icons);
  218. }
  219. # New since build 225
  220. $cols=sf_opcheck(get_option('sfforumcols'));
  221. $cols['last'] = false;
  222. update_option('sfforumcols', $cols);
  223. update_option('sfbuild', $section);
  224. echo $section;
  225. die();
  226. }
  227. $section = 250;
  228. if($build < $section)
  229. {
  230. # 3.0 =====================================================================================
  231. # Pre-create last visit dates for all existing users who don't have one
  232. sf_precreate_sflast();
  233. $sql = "
  234. CREATE TABLE IF NOT EXISTS ".SFMESSAGES." (
  235. message_id bigint(20) NOT NULL auto_increment,
  236. sent_date datetime NOT NULL,
  237. from_id bigint(20) default NULL,
  238. to_id bigint(20) default NULL,
  239. title text,
  240. message text,
  241. message_status smallint(1) NOT NULL default '0',
  242. inbox smallint(1) NOT NULL default '1',
  243. sentbox smallint(1) NOT NULL default '1',
  244. is_reply smallint(1) NOT NULL default '0',
  245. PRIMARY KEY (message_id)
  246. ) ENGINE=MyISAM ".sf_charset().";";
  247. $wpdb->query($sql);
  248. # Slugs
  249. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_slug varchar(85) NOT NULL)";
  250. sf_upgrade_database(SFFORUMS, 'forum_slug', $create_ddl);
  251. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_slug varchar(110) NOT NULL)";
  252. sf_upgrade_database(SFTOPICS, 'topic_slug', $create_ddl);
  253. sf_create_slugs();
  254. add_option('sfimgenlarge', false);
  255. add_option('sfthumbsize', 100);
  256. add_option('sfmodasadmin', false);
  257. add_option('sfmemberspam', true);
  258. add_option('sfuppath', '');
  259. # email option array
  260. $adminname = sf_opcheck(get_user_meta($current_user->ID, 'first_name', true));
  261. $sfmail = array();
  262. $sfmail['sfmailsender'] = get_bloginfo('name');
  263. $sfmail['sfmailfrom'] = str_replace(' ', '', $adminname);
  264. $sfmail['sfmaildomain'] = preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
  265. add_option('sfmail', $sfmail);
  266. # new user email array
  267. $sfmail = array();
  268. $sfmail['sfnewusersubject'] = 'Welcome to %BLOGNAME%';
  269. $sfmail['sfnewusertext'] = 'Welcome %USERNAME% to %BLOGNAME% %NEWLINE%Please find below your login details: %NEWLINE%Username: %USERNAME% %NEWLINE%Password: %PASSWORD% %NEWLINE%%LOGINURL%';
  270. add_option('sfnewusermail', $sfmail);
  271. $icons=sf_opcheck(get_option('sfshowicon'));
  272. if(strpos($icons, '@Send PM;') === false)
  273. {
  274. $icons.= '@Send PM;1@Return to forum;1@Compose PM;1@Go To Inbox;1@Go To Sentbox;1@Report Post;1';
  275. update_option('sfshowicon', $icons);
  276. }
  277. update_option('sfbuild', $section);
  278. echo $section;
  279. die();
  280. }
  281. $section = 255;
  282. if($build < $section)
  283. {
  284. # Change usermeta values that previously used table prefix
  285. $oldkeys[0] = $wpdb->prefix.'sfavatar';
  286. $oldkeys[1] = $wpdb->prefix.'sfposts';
  287. $oldkeys[2] = $wpdb->prefix.'sflast';
  288. $oldkeys[3] = $wpdb->prefix.'sfsubscribe';
  289. $oldkeys[4] = $wpdb->prefix.'sfadmin';
  290. $newkeys[0] = 'sfavatar';
  291. $newkeys[1] = 'sfposts';
  292. $newkeys[2] = 'sflast';
  293. $newkeys[3] = 'sfsubscribe';
  294. $newkeys[4] = 'sfadmin';
  295. for($x=0; $x<count($oldkeys); $x++)
  296. {
  297. $sql = "UPDATE ".SFUSERMETA." SET meta_key = '".$newkeys[$x]."' WHERE meta_key = '".$oldkeys[$x]."'";
  298. $wpdb->query($sql);
  299. }
  300. # Create User Groups table
  301. $sql = "
  302. CREATE TABLE IF NOT EXISTS ".SFUSERGROUPS." (
  303. usergroup_id mediumint(8) unsigned NOT NULL auto_increment,
  304. usergroup_name varchar(50) NOT NULL default '',
  305. usergroup_desc varchar(150) NOT NULL default '',
  306. usergroup_locked tinyint(4) unsigned NOT NULL default '0',
  307. usergroup_is_moderator tinyint(4) unsigned NOT NULL default '0',
  308. PRIMARY KEY (usergroup_id)
  309. ) ENGINE=MyISAM ".sf_charset().";";
  310. $wpdb->query($sql);
  311. # Create the Permissions table
  312. $sql = "
  313. CREATE TABLE IF NOT EXISTS ".SFPERMISSIONS." (
  314. permission_id mediumint(8) unsigned NOT NULL auto_increment,
  315. forum_id mediumint(8) unsigned NOT NULL default '0',
  316. usergroup_id mediumint(8) unsigned NOT NULL default '0',
  317. permission_role mediumint(8) unsigned NOT NULL default '0',
  318. PRIMARY KEY (permission_id)
  319. ) ENGINE=MyISAM ".sf_charset().";";
  320. $wpdb->query($sql);
  321. # Create the Roles table
  322. $sql = "
  323. CREATE TABLE IF NOT EXISTS ".SFROLES." (
  324. role_id mediumint(8) unsigned NOT NULL auto_increment,
  325. role_name varchar(50) NOT NULL default '',
  326. role_desc varchar(150) NOT NULL default '',
  327. role_actions longtext NOT NULL,
  328. PRIMARY KEY (role_id)
  329. ) ENGINE=MyISAM ".sf_charset().";";
  330. $wpdb->query($sql);
  331. # setup an array of info for the data upgrades
  332. $keys = array();
  333. # Create default role data
  334. $actions = array();
  335. $actions['Can view forum'] = 0;
  336. $actions['Can start new topics'] = 0;
  337. $actions['Can reply to topics'] = 0;
  338. $actions['Can create linked topics'] = 0;
  339. $actions['Can break linked topics'] = 0;
  340. $actions['Can edit topic titles'] = 0;
  341. $actions['Can pin topics'] = 0;
  342. $actions['Can move topics'] = 0;
  343. $actions['Can move posts'] = 0;
  344. $actions['Can lock topics'] = 0;
  345. $actions['Can delete topics'] = 0;
  346. $actions['Can edit own posts forever'] = 0;
  347. $actions['Can edit own posts until reply'] = 0;
  348. $actions['Can edit any posts'] = 0;
  349. $actions['Can delete any posts'] = 0;
  350. $actions['Can pin posts'] = 0;
  351. $actions['Can view users email addresses'] = 0;
  352. $actions['Can view members profiles'] = 0;
  353. $actions['Can report posts'] = 0;
  354. $actions['Can sort most recent posts'] = 0;
  355. $actions['Can bypass spam control'] = 0;
  356. $actions['Can bypass post moderation'] = 0;
  357. $actions['Can bypass post moderation once'] = 0;
  358. $actions['Can upload images'] = 0;
  359. $actions['Can upload media'] = 0;
  360. $actions['Can upload files'] = 0;
  361. $actions['Can use signatures'] = 0;
  362. $actions['Can use images in signatures'] = 0;
  363. $actions['Can upload avatars'] = 0;
  364. $actions['Can use private messaging'] = 0;
  365. $actions['Can subscribe'] = 0;
  366. $actions['Can moderate pending posts'] = 0;
  367. $role_name = 'No Access';
  368. $role_desc = 'Permission with no access to any Forum features.';
  369. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  370. $actions = array();
  371. $actions['Can view forum'] = 1;
  372. $actions['Can start new topics'] = 0;
  373. $actions['Can reply to topics'] = 0;
  374. $actions['Can create linked topics'] = 0;
  375. $actions['Can break linked topics'] = 0;
  376. $actions['Can edit topic titles'] = 0;
  377. $actions['Can pin topics'] = 0;
  378. $actions['Can move topics'] = 0;
  379. $actions['Can move posts'] = 0;
  380. $actions['Can lock topics'] = 0;
  381. $actions['Can delete topics'] = 0;
  382. $actions['Can edit own posts forever'] = 0;
  383. $actions['Can edit own posts until reply'] = 0;
  384. $actions['Can edit any posts'] = 0;
  385. $actions['Can delete any posts'] = 0;
  386. $actions['Can pin posts'] = 0;
  387. $actions['Can view users email addresses'] = 0;
  388. $actions['Can view members profiles'] = 0;
  389. $actions['Can report posts'] = 0;
  390. $actions['Can sort most recent posts'] = 0;
  391. $actions['Can bypass spam control'] = 0;
  392. $actions['Can bypass post moderation'] = 0;
  393. $actions['Can bypass post moderation once'] = 0;
  394. $actions['Can upload images'] = 0;
  395. $actions['Can upload media'] = 0;
  396. $actions['Can upload files'] = 0;
  397. $actions['Can use signatures'] = 0;
  398. $actions['Can use images in signatures'] = 0;
  399. $actions['Can upload avatars'] = 0;
  400. $actions['Can use private messaging'] = 0;
  401. $actions['Can subscribe'] = 0;
  402. $actions['Can moderate pending posts'] = 0;
  403. $role_name = 'Read Only Access';
  404. $role_desc = 'Permission with access to only view the Forum.';
  405. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  406. $actions = array();
  407. $actions['Can view forum'] = 1;
  408. $actions['Can start new topics'] = 1;
  409. $actions['Can reply to topics'] = 1;
  410. $actions['Can create linked topics'] = 0;
  411. $actions['Can break linked topics'] = 0;
  412. $actions['Can edit topic titles'] = 0;
  413. $actions['Can pin topics'] = 0;
  414. $actions['Can move topics'] = 0;
  415. $actions['Can move posts'] = 0;
  416. $actions['Can lock topics'] = 0;
  417. $actions['Can delete topics'] = 0;
  418. $actions['Can edit own posts forever'] = 0;
  419. $actions['Can edit own posts until reply'] = 1;
  420. $actions['Can edit any posts'] = 0;
  421. $actions['Can delete any posts'] = 0;
  422. $actions['Can pin posts'] = 0;
  423. $actions['Can view users email addresses'] = 0;
  424. $actions['Can view members profiles'] = 1;
  425. $actions['Can report posts'] = 1;
  426. $actions['Can sort most recent posts'] = 0;
  427. $actions['Can bypass spam control'] = 0;
  428. $actions['Can bypass post moderation'] = 0;
  429. $actions['Can bypass post moderation once'] = 0;
  430. $actions['Can upload images'] = 0;
  431. $actions['Can upload media'] = 0;
  432. $actions['Can upload files'] = 0;
  433. $actions['Can use signatures'] = 0;
  434. $actions['Can use images in signatures'] = 0;
  435. $actions['Can upload avatars'] = 1;
  436. $actions['Can use private messaging'] = 0;
  437. $actions['Can subscribe'] = 1;
  438. $actions['Can moderate pending posts'] = 0;
  439. $role_name = 'Limited Access';
  440. $role_desc = 'Permission with access to reply and start topics but with limited features.';
  441. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  442. if(sf_opcheck(get_option('sfallowguests'))) $roleid = $wpdb->insert_id;
  443. # Create default 'Guest' user group data
  444. $guests = sfa_create_usergroup_row('Guests', 'Default Usergroup for guests of the forum.', '0', false);
  445. $keys[0]['usergroup'] = $wpdb->insert_id;
  446. $keys[0]['permission'] = $roleid;
  447. $actions = array();
  448. $actions['Can view forum'] = 1;
  449. $actions['Can start new topics'] = 1;
  450. $actions['Can reply to topics'] = 1;
  451. $actions['Can create linked topics'] = 0;
  452. $actions['Can break linked topics'] = 0;
  453. $actions['Can edit topic titles'] = 0;
  454. $actions['Can pin topics'] = 0;
  455. $actions['Can move topics'] = 0;
  456. $actions['Can move posts'] = 0;
  457. $actions['Can lock topics'] = 0;
  458. $actions['Can delete topics'] = 0;
  459. $actions['Can edit own posts forever'] = 0;
  460. $actions['Can edit own posts until reply'] = 1;
  461. $actions['Can edit any posts'] = 0;
  462. $actions['Can delete any posts'] = 0;
  463. $actions['Can pin posts'] = 0;
  464. $actions['Can view users email addresses'] = 0;
  465. $actions['Can view members profiles'] = 1;
  466. $actions['Can report posts'] = 1;
  467. $actions['Can sort most recent posts'] = 0;
  468. $actions['Can bypass spam control'] = 0;
  469. $actions['Can bypass post moderation'] = 1;
  470. $actions['Can bypass post moderation once'] = 1;
  471. $actions['Can upload images'] = 0;
  472. $actions['Can upload media'] = 0;
  473. $actions['Can upload files'] = 0;
  474. $actions['Can use signatures'] = 1;
  475. $actions['Can use images in signatures'] = 1;
  476. $actions['Can upload avatars'] = 1;
  477. $actions['Can use private messaging'] = 1;
  478. $actions['Can subscribe'] = 1;
  479. $actions['Can moderate pending posts'] = 0;
  480. $role_name = 'Standard Access';
  481. $role_desc = 'Permission with access to reply and start topics with advanced features such as signatures and private messaging.';
  482. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  483. $roleid = $wpdb->insert_id;
  484. # Create default 'Members' user group data
  485. $members = sfa_create_usergroup_row('Members', 'Default Usergroup for registered users of the forum.', '0', false);
  486. $keys[1]['usergroup'] = $members;
  487. $keys[1]['permission'] = $roleid;
  488. $actions = array();
  489. $actions['Can view forum'] = 1;
  490. $actions['Can start new topics'] = 1;
  491. $actions['Can reply to topics'] = 1;
  492. $actions['Can create linked topics'] = 0;
  493. $actions['Can break linked topics'] = 0;
  494. $actions['Can edit topic titles'] = 0;
  495. $actions['Can pin topics'] = 0;
  496. $actions['Can move topics'] = 0;
  497. $actions['Can move posts'] = 0;
  498. $actions['Can lock topics'] = 0;
  499. $actions['Can delete topics'] = 0;
  500. $actions['Can edit own posts forever'] = 1;
  501. $actions['Can edit own posts until reply'] = 1;
  502. $actions['Can edit any posts'] = 0;
  503. $actions['Can delete any posts'] = 0;
  504. $actions['Can pin posts'] = 0;
  505. $actions['Can view users email addresses'] = 0;
  506. $actions['Can view members profiles'] = 1;
  507. $actions['Can report posts'] = 1;
  508. $actions['Can sort most recent posts'] = 0;
  509. $actions['Can bypass spam control'] = 1;
  510. $actions['Can bypass post moderation'] = 1;
  511. $actions['Can bypass post moderation once'] = 1;
  512. $actions['Can upload images'] = 1;
  513. $actions['Can upload media'] = 1;
  514. $actions['Can upload files'] = 1;
  515. $actions['Can use signatures'] = 1;
  516. $actions['Can use images in signatures'] = 1;
  517. $actions['Can upload avatars'] = 1;
  518. $actions['Can use private messaging'] = 1;
  519. $actions['Can subscribe'] = 1;
  520. $actions['Can moderate pending posts'] = 0;
  521. $role_name = 'Full Access';
  522. $role_desc = 'Permission with Standard Access features plus image uploading and spam control bypass.';
  523. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  524. $actions = array();
  525. $actions['Can view forum'] = 1;
  526. $actions['Can start new topics'] = 1;
  527. $actions['Can reply to topics'] = 1;
  528. $actions['Can create linked topics'] = 1;
  529. $actions['Can break linked topics'] = 1;
  530. $actions['Can edit topic titles'] = 1;
  531. $actions['Can pin topics'] = 1;
  532. $actions['Can move topics'] = 1;
  533. $actions['Can move posts'] = 1;
  534. $actions['Can lock topics'] = 1;
  535. $actions['Can delete topics'] = 1;
  536. $actions['Can edit own posts forever'] = 1;
  537. $actions['Can edit own posts until reply'] = 1;
  538. $actions['Can edit any posts'] = 1;
  539. $actions['Can delete any posts'] = 1;
  540. $actions['Can pin posts'] = 1;
  541. $actions['Can view users email addresses'] = 1;
  542. $actions['Can view members profiles'] = 1;
  543. $actions['Can report posts'] = 1;
  544. $actions['Can sort most recent posts'] = 1;
  545. $actions['Can bypass spam control'] = 1;
  546. $actions['Can bypass post moderation'] = 1;
  547. $actions['Can bypass post moderation once'] = 1;
  548. $actions['Can upload images'] = 1;
  549. $actions['Can upload media'] = 1;
  550. $actions['Can upload files'] = 1;
  551. $actions['Can use signatures'] = 1;
  552. $actions['Can use images in signatures'] = 1;
  553. $actions['Can upload avatars'] = 1;
  554. $actions['Can use private messaging'] = 1;
  555. $actions['Can subscribe'] = 1;
  556. $actions['Can moderate pending posts'] = 1;
  557. $role_name = 'Moderator Access';
  558. $role_desc = 'Permission with access to all Forum features.';
  559. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  560. $roleid = $wpdb->insert_id;
  561. # Create default 'Moderators' user group data
  562. $moderators = sfa_create_usergroup_row('Moderators', 'Default Usergroup for moderators of the forum.', '1', false);
  563. $keys[2]['usergroup'] = $moderators;
  564. $keys[2]['permission'] = $roleid;
  565. # ensure all users have a display name set
  566. sf_check_all_display_names();
  567. # set up the current userbase into default groups etc
  568. sf_setup_usergroup_data($members, $moderators, true, $keys);
  569. update_option('sfbuild', $section);
  570. echo $section;
  571. die();
  572. }
  573. $section = 300;
  574. if($build < $section)
  575. {
  576. $wpdb->query("ALTER TABLE ".SFGROUPS." DROP group_view;");
  577. $wpdb->query("ALTER TABLE ".SFFORUMS." DROP forum_view;");
  578. add_option('sfdefgroup', $members);
  579. add_option('sfbadwords', '');
  580. add_option('sfreplacementwords', '');
  581. add_option('sfpaging', 4);
  582. add_option('sfadminbar', true);
  583. # change sftitle
  584. $sftitle = array();
  585. $sftitle['sfinclude'] = sf_opcheck(get_option('sftitle'));
  586. $sftitle['sfnotitle'] = false;
  587. $sftitle['sfbanner'] = '';
  588. update_option('sftitle', $sftitle);
  589. $pm = array();
  590. $pm['sfpmemail'] = false;
  591. $pm['sfpmmax'] = 0;
  592. add_option('sfpm', $pm);
  593. $sfquicklinks = array();
  594. $sfquicklinks['sfqlshow'] = true;
  595. $sfquicklinks['sfqlcount'] = 15;
  596. add_option('sfquicklinks', $sfquicklinks);
  597. $sfcustom = array();
  598. $sfcustom[0]['custext']='';
  599. $sfcustom[0]['cuslink']='';
  600. $sfcustom[0]['cusicon']='';
  601. $sfcustom[1]['custext']='';
  602. $sfcustom[1]['cuslink']='';
  603. $sfcustom[1]['cusicon']='';
  604. $sfcustom[2]['custext']='';
  605. $sfcustom[2]['cuslink']='';
  606. $sfcustom[2]['cusicon']='';
  607. add_option('sfcustom', $sfcustom);
  608. # remove unwanted options
  609. delete_option('sfmodusers');
  610. delete_option('sfsubscriptions');
  611. delete_option('sfusersig');
  612. delete_option('sfstopedit');
  613. delete_option('sfmoderate');
  614. delete_option('sfmodonce');
  615. delete_option('sfavatars');
  616. delete_option('sfspam');
  617. delete_option('sflinkuse');
  618. delete_option('sfmodmembers');
  619. delete_option('sfadminspam');
  620. delete_option('sfmemberspam');
  621. $icons=sf_opcheck(get_option('sfshowicon'));
  622. if(strpos($icons, '@Moderation Queue') === false)
  623. {
  624. $icons.= '@Moderation Queue;1';
  625. update_option('sfshowicon', $icons);
  626. }
  627. # RSS feed urls
  628. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_rss text)";
  629. sf_upgrade_database(SFFORUMS, 'forum_rss', $create_ddl);
  630. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_rss text)";
  631. sf_upgrade_database(SFGROUPS, 'group_rss', $create_ddl);
  632. # RSS feed urls
  633. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_icon varchar(25) default NULL)";
  634. sf_upgrade_database(SFFORUMS, 'forum_icon', $create_ddl);
  635. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_icon varchar(25) default NULL)";
  636. sf_upgrade_database(SFGROUPS, 'group_icon', $create_ddl);
  637. # custom message for editor
  638. $sfpostmsg = array();
  639. $sfpostmsg['sfpostmsgtext'] = '';
  640. $sfpostmsg['sfpostmsgtopic'] = false;
  641. $sfpostmsg['sfpostmsgpost'] = false;
  642. update_option('sfpostmsg', $sfpostmsg);
  643. add_option('sfeditormsg','');
  644. add_option('sfautoupdate');
  645. add_option('sfcheck', true);
  646. update_option('sfbuild', $section);
  647. echo $section;
  648. die();
  649. }
  650. $section = 320;
  651. if($build < $section)
  652. {
  653. # 3.0.3 =====================================================================================
  654. # extra icons
  655. $icons=sf_opcheck(get_option('sfshowicon'));
  656. if(strpos($icons, '@Lock this Topic;') === false)
  657. {
  658. $icons.= '@Lock this Topic;1@Pin this Topic;1@Create Linked Post;1@Pin this Post;1@Edit Timestamp;1';
  659. update_option('sfshowicon', $icons);
  660. }
  661. update_option('sfbuild', $section);
  662. echo $section;
  663. die();
  664. }
  665. $section = 321;
  666. if($build < $section)
  667. {
  668. # 3.1 =====================================================================================
  669. # post id added to forum and topic tables
  670. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (post_id bigint(20) default NULL)";
  671. sf_upgrade_database(SFFORUMS, 'post_id', $create_ddl);
  672. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (topic_count mediumint(8) default '0')";
  673. sf_upgrade_database(SFFORUMS, 'topic_count', $create_ddl);
  674. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (post_id bigint(20) default NULL)";
  675. sf_upgrade_database(SFTOPICS, 'post_id', $create_ddl);
  676. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (post_count mediumint(8) default '0')";
  677. sf_upgrade_database(SFTOPICS, 'post_count', $create_ddl);
  678. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (post_index mediumint(8) default '0')";
  679. sf_upgrade_database(SFPOSTS, 'post_index', $create_ddl);
  680. sf_build_lastposts();
  681. # new style array
  682. $sfstyle = array();
  683. $sfstyle['sfskin'] = sf_opcheck(get_option('sfskin'));
  684. $sfstyle['sficon'] = sf_opcheck(get_option('sficon'));
  685. $sfstyle['sflang'] = sf_opcheck(get_option('sflang'));
  686. $sfstyle['sfrtl'] = false;
  687. add_option('sfstyle', $sfstyle);
  688. delete_option('sfskin');
  689. delete_option('sficon');
  690. delete_option('sflang');
  691. # new login array
  692. $sflogin = array();
  693. $sflogin['sfshowlogin'] = sf_opcheck(get_option('sfshowlogin'));
  694. $sflogin['sfshowreg'] = sf_opcheck(get_option('sfshowlogin'));
  695. add_option('sflogin', $sflogin);
  696. delete_option('sfshowlogin');
  697. $sfadminsettings=array();
  698. $sfadminsettings['sfnotify']=sf_opcheck(get_option('sfnotify'));
  699. $sfadminsettings['sfadminbar']=sf_opcheck(get_option('sfadminbar'));
  700. $sfadminsettings['sfshownewadmin']=sf_opcheck(get_option('sfshownewadmin'));
  701. $sfadminsettings['sfmodasadmin']=sf_opcheck(get_option('sfmodasadmin'));
  702. $sfadminsettings['sfshowmodposts']=sf_opcheck(get_option('sfshowmodposts'));
  703. $sfadminsettings['sftools']=sf_opcheck(get_option('sfedit'));
  704. $sfadminsettings['sfqueue']=true;
  705. add_option('sfadminsettings', $sfadminsettings);
  706. delete_option('sfnotify');
  707. delete_option('sfadminbar');
  708. delete_option('sfshownewadmin');
  709. delete_option('sfmodasadmin');
  710. delete_option('sfshowmodposts');
  711. delete_option('sfedit');
  712. $sfauto=array();
  713. $sfauto['sfautoupdate']=sf_opcheck(get_option('sfautoupdate'));
  714. $sfauto['sfautotime']=300;
  715. add_option('sfauto', $sfauto);
  716. delete_option('sfautoupdate');
  717. $sffilters=array();
  718. $sffilters['sfnofollow']=false;
  719. $sffilters['sftarget']=true;
  720. add_option('sffilters', $sffilters);
  721. add_option('sfshowbreadcrumbs', true);
  722. update_option('sfbuild', $section);
  723. echo $section;
  724. die();
  725. }
  726. $section = 340;
  727. if($build < $section)
  728. {
  729. # sfmembers table def
  730. $sql = "
  731. CREATE TABLE IF NOT EXISTS ".SFMEMBERS." (
  732. user_id bigint(20) NOT NULL default '0',
  733. display_name varchar(100) default NULL,
  734. pm smallint(1) NOT NULL default '0',
  735. moderator smallint(1) NOT NULL default '0',
  736. quicktags smallint(1) NOT NULL default '0',
  737. usergroups longtext default NULL,
  738. avatar varchar(50) default NULL,
  739. signature tinytext default NULL,
  740. sigimage tinytext default NULL,
  741. posts int(4) NOT NULL default '0',
  742. lastvisit datetime default NULL,
  743. subscribe longtext,
  744. buddies longtext,
  745. newposts longtext,
  746. checktime datetime default NULL,
  747. PRIMARY KEY (user_id)
  748. ) ENGINE=MyISAM ".sf_charset().";";
  749. $wpdb->query($sql);
  750. sf_build_members_table('quicktags', 'upgrade');
  751. update_option('sfbuild', $section);
  752. echo $section;
  753. die();
  754. }
  755. $section = 356;
  756. if($build < $section)
  757. {
  758. # 3.1.3 ===================================================================================
  759. $sql = "UPDATE ".SFUSERGROUPS." SET usergroup_locked = '0'";
  760. $wpdb->query($sql);
  761. update_option('sfbuild', $section);
  762. echo $section;
  763. die();
  764. }
  765. $section = 360;
  766. if($build < $section)
  767. {
  768. # 4.0 =====================================================================================
  769. # add new Can view members profiles permission
  770. sf_upgrade_add_new_role('Can view members profiles', 0, true);
  771. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_rss_private smallint(1) NOT NULL default '0')";
  772. sf_upgrade_database(SFFORUMS, 'forum_rss_private', $create_ddl);
  773. $icons=sf_opcheck(get_option('sfshowicon'));
  774. if(strpos($icons, '@Subscribe to this Topic;') === false)
  775. {
  776. $icons.= '@Subscribe to this Topic;1';
  777. update_option('sfshowicon', $icons);
  778. }
  779. if (sf_opcheck(get_option('sfrss')))
  780. {
  781. $wpdb->query("UPDATE ".SFFORUMS." SET forum_rss_private=0");
  782. } else {
  783. $wpdb->query("UPDATE ".SFFORUMS." SET forum_rss_private=1");
  784. }
  785. delete_option('sfrss');
  786. update_option('sfbuild', $section);
  787. echo $section;
  788. die();
  789. }
  790. $section = 365;
  791. if($build < $section)
  792. {
  793. # take existing forum admin and grant all new spf capabilities
  794. $adminid = sf_opcheck(get_option('sfadmin'));
  795. $user = new WP_User($adminid);
  796. $user->add_cap('SPF Manage Options');
  797. $user->add_cap('SPF Manage Forums');
  798. $user->add_cap('SPF Manage User Groups');
  799. $user->add_cap('SPF Manage Permissions');
  800. $user->add_cap('SPF Manage Database');
  801. $user->add_cap('SPF Manage Components');
  802. $user->add_cap('SPF Manage Admins');
  803. $user->add_cap('SPF Manage Users');
  804. $create_ddl = "ALTER TABLE ".SFMEMBERS. " ADD (admin smallint(1) NOT NULL default '0')";
  805. sf_upgrade_database(SFMEMBERS, 'admin', $create_ddl);
  806. sf_update_member_item($adminid, 'admin', 1);
  807. delete_option('sfadmin');
  808. # sfmeta table def
  809. $sql = "
  810. CREATE TABLE IF NOT EXISTS ".SFMETA." (
  811. meta_id bigint(20) NOT NULL auto_increment,
  812. meta_type varchar(20) NOT NULL,
  813. meta_key varchar(100) default NULL,
  814. meta_value longtext,
  815. PRIMARY KEY (meta_id)
  816. ) ENGINE=MyISAM ".sf_charset().";";
  817. $wpdb->query($sql);
  818. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (topic_status_set bigint(20) default '0')";
  819. sf_upgrade_database(SFFORUMS, 'topic_status_set', $create_ddl);
  820. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_status_flag bigint(20) default '0')";
  821. sf_upgrade_database(SFTOPICS, 'topic_status_flag', $create_ddl);
  822. # admin bar fixed
  823. $sfadminsettings=array();
  824. $sfadminsettings=sf_opcheck(get_option('sfadminsettings'));
  825. $sfadminsettings['sfbarfix']=false;
  826. update_option('sfadminsettings', $sfadminsettings);
  827. $icons=sf_opcheck(get_option('sfshowicon'));
  828. if(strpos($icons, '@Close New Post List;') === false)
  829. {
  830. $icons.= '@Close New Post List;1';
  831. update_option('sfshowicon', $icons);
  832. }
  833. update_option('sfbuild', $section);
  834. echo $section;
  835. die();
  836. }
  837. $section = 380;
  838. if($build < $section)
  839. {
  840. # add new columns for tracking watched topics
  841. $create_ddl = "ALTER TABLE ".SFMEMBERS. " ADD (watches longtext)";
  842. sf_upgrade_database(SFMEMBERS, 'watches', $create_ddl);
  843. # add new Can follow topics permission
  844. sf_upgrade_add_new_role('Can watch topics', 0, true);
  845. # add new Can change topic status permission
  846. sf_upgrade_add_new_role('Can change topic status', 0, false, true);
  847. $icons=sf_opcheck(get_option('sfshowicon'));
  848. if(strpos($icons, '@Review Watched Topics;') === false)
  849. {
  850. $icons.= '@Review Watched Topics;1@End Topic Watch;1@Watch Topic;1';
  851. }
  852. update_option('sfshowicon', $icons);
  853. # remove usergroup locked column that is no longer used
  854. $wpdb->query("ALTER TABLE ".SFUSERGROUPS." DROP usergroup_locked;");
  855. # add new columns for tracking watched topics
  856. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_watches longtext)";
  857. sf_upgrade_database(SFTOPICS, 'topic_watches', $create_ddl);
  858. add_option('sfpostpaging', 4);
  859. $qt = sf_opcheck(get_option('sfquicktags'));
  860. $sfeditor = array();
  861. if($qt ? $c = 2 : $c = 1);
  862. $sfeditor['sfeditor'] = $c;
  863. $sfeditor['sfusereditor'] = false;
  864. add_option('sfeditor', $sfeditor);
  865. delete_option('sfquicktags');
  866. $sfpostratings = array();
  867. $sfpostratings['sfpostratings'] = false;
  868. $sfpostratings['sfratingsstyle'] = 1;
  869. add_option('sfpostratings', $sfpostratings);
  870. # add new Can rate post permission
  871. sf_upgrade_add_new_role('Can rate posts', 0, true);
  872. # change members 'quicktags' to 'editor'
  873. $sql = "ALTER TABLE ".SFMEMBERS." CHANGE quicktags editor SMALLINT(1) NOT NULL DEFAULT '1'";
  874. $wpdb->query($sql);
  875. $sql = "UPDATE ".SFMEMBERS." SET editor=2 WHERE editor=1";
  876. $wpdb->query($sql);
  877. $sql = "UPDATE ".SFMEMBERS." SET editor=1 WHERE editor=0";
  878. $wpdb->query($sql);
  879. update_option('sfbuild', $section);
  880. echo $section;
  881. die();
  882. }
  883. $section = 400;
  884. if($build < $section)
  885. {
  886. # sfpostratings table def
  887. $sql = "
  888. CREATE TABLE IF NOT EXISTS ".SFPOSTRATINGS." (
  889. rating_id bigint(20) NOT NULL auto_increment,
  890. post_id bigint(20) NOT NULL,
  891. vote_count bigint(20) NOT NULL,
  892. ratings_sum bigint(20) NOT NULL,
  893. ips longtext,
  894. members longtext,
  895. PRIMARY KEY (rating_id)
  896. ) ENGINE=MyISAM ".sf_charset().";";
  897. $wpdb->query($sql);
  898. # add new columns for posts users have voted in
  899. $create_ddl = "ALTER TABLE ".SFMEMBERS." ADD (posts_rated longtext)";
  900. sf_upgrade_database(SFMEMBERS, 'posts_rated', $create_ddl);
  901. # sfdefpermissions table def
  902. $sql = "
  903. CREATE TABLE IF NOT EXISTS ".SFDEFPERMISSIONS." (
  904. permission_id mediumint(8) unsigned NOT NULL auto_increment,
  905. group_id mediumint(8) unsigned NOT NULL default '0',
  906. usergroup_id mediumint(8) unsigned NOT NULL default '0',
  907. permission_role mediumint(8) unsigned NOT NULL default '0',
  908. PRIMARY KEY (permission_id)
  909. ) ENGINE=MyISAM ".sf_charset().";";
  910. $wpdb->query($sql);
  911. # fill in the default permissions for existing groups
  912. sf_group_def_perms();
  913. update_option('sfbuild', $section);
  914. echo $section;
  915. die();
  916. }
  917. $section = 480;
  918. if($build < $section)
  919. {
  920. # create new base smiley folder
  921. $smiley = sf_relocate_smileys();
  922. if($smiley != 0)
  923. {
  924. add_option('sfinstallsm', $smiley);
  925. }
  926. sf_build_base_smileys();
  927. # smileys control options
  928. $sfsmileys = array();
  929. $sfsmileys['sfsmallow'] = true;
  930. $sfsmileys['sfsmtype'] = 1;
  931. update_option('sfsmileys', $sfsmileys);
  932. update_option('sfbuild', $section);
  933. echo $section;
  934. die();
  935. }
  936. $section = 620;
  937. if($build < $section)
  938. {
  939. # if default Guests user group exists use it as default for guests - otherwise leave blank
  940. $guests = $wpdb->get_var("SELECT usergroup_id FROM ".SFUSERGROUPS." WHERE usergroup_name='Guests'");
  941. add_option('sfguestsgroup', $guests);
  942. $sfusersnewposts = array();
  943. $sfusersnewposts['sfshownewuser'] = sf_opcheck(get_option('sfshownewuser'));
  944. $sfusersnewposts['sfshownewcount'] = sf_opcheck(get_option('sfshownewcount'));
  945. $sfusersnewposts['sfshownewabove'] = sf_opcheck(get_option('sfshownewabove'));
  946. $sfusersnewposts['sfsortinforum'] = true;
  947. add_option('sfusersnewposts', $sfusersnewposts);
  948. delete_option('sfshownewuser');
  949. delete_option('sfshownewcount');
  950. delete_option('sfshownewabove');
  951. delete_option('sfallowguests');
  952. sf_build_tinymce_toolbar_arrays();
  953. # add new columns for options for users that are admins
  954. $create_ddl = "ALTER TABLE ".SFMEMBERS." ADD (admin_options longtext)";
  955. sf_upgrade_database(SFMEMBERS, 'admin_options', $create_ddl);
  956. $sfadminsettings = array();
  957. $sfadminsettings = sf_opcheck(get_option('sfadminsettings'));
  958. $sfnewadminsettings = array();
  959. $sfnewadminsettings['sftools'] = sf_opcheck($sfadminsettings['sftools']);
  960. $sfnewadminsettings['sfmodasadmin'] = sf_opcheck($sfadminsettings['sfmodasadmin']);
  961. $sfnewadminsettings['sfshowmodposts'] = sf_opcheck($sfadminsettings['sfshowmodposts']);
  962. $sfnewadminsettings['sfqueue'] = sf_opcheck($sfadminsettings['sfqueue']);
  963. update_option('sfadminsettings', $sfnewadminsettings);
  964. $sfadminoptions = array();
  965. $sfadminoptions['sfadminbar'] = sf_opcheck($sfadminsettings['sfadminbar']);
  966. $sfadminoptions['sfbarfix'] = sf_opcheck($sfadminsettings['sfbarfix']);
  967. if (isset($sfadminsettings['sfqueue']))
  968. {
  969. $sfadminoptions['sfnotify'] = sf_opcheck($sfadminsettings['sfnotify']);
  970. $sfadminoptions['sfshownewadmin'] = sf_opcheck($sfadminsettings['sfshownewadmin']);
  971. }
  972. sf_update_member_item($current_user->ID, 'admin_options', $sfadminoptions);
  973. # Style and Editor array changes
  974. $sfstyle = array();
  975. $sfrepstyle = array();
  976. $sfstyle = sf_opcheck(get_option('sfstyle'));
  977. $sfrepstyle['sfskin'] = sf_opcheck($sfstyle['sfskin']);
  978. $sfrepstyle['sficon'] = sf_opcheck($sfstyle['sficon']);
  979. $sfrepstyle['sfsize'] = '';
  980. update_option('sfstyle', $sfrepstyle);
  981. $sfeditor = array();
  982. $sfeditor = sf_opcheck(get_option('sfeditor'));
  983. $sfeditor['sfrejectformat'] = false;
  984. $sfeditor['sftmcontentCSS'] = 'content.css';
  985. $sfeditor['sftmuiCSS'] = 'ui.css';
  986. $sfeditor['sftmdialogCSS'] = 'dialog.css';
  987. $sfeditor['SFhtmlCSS'] = 'htmlEditor.css';
  988. $sfeditor['SFbbCSS'] = 'bbcodeEditor.css';
  989. $sfeditor['sflang'] = sf_opcheck($sfstyle['sflang']);
  990. if(get_bloginfo('text_direction') == 'rtl' ? $sfeditor['sfrtl'] = true : $sfeditor['sfrtl'] = false);
  991. update_option('sfeditor', $sfeditor);
  992. # Login array changes
  993. $sflogin = array();
  994. $sflogin = sf_opcheck(get_option('sflogin'));
  995. $sflogin['sfregmath'] = sf_opcheck(get_option('sfregmath'));
  996. $sflogin['sfinlogin'] = true;
  997. $sflogin['sfregtext'] = false;
  998. $sflogin['sfregcheck'] = false;
  999. $sflogin['sfloginskin'] = true;
  1000. update_option('sflogin', $sflogin);
  1001. delete_option('sfregmath');
  1002. add_option('sflinkcomments', false);
  1003. add_option('sfshoweditdata', true);
  1004. add_option('sfshoweditlast', false);
  1005. update_option('sfbuild', $section);
  1006. echo $section;
  1007. die();
  1008. }
  1009. $section = 693;
  1010. if($build < $section)
  1011. {
  1012. # add new columns for storing post-post edits
  1013. $create_ddl = "ALTER TABLE ".SFPOSTS." ADD (post_edit mediumtext)";
  1014. sf_upgrade_database(SFPOSTS, 'post_edit', $create_ddl);
  1015. add_option('sfavataruploads', true);
  1016. add_option('sfprivatemessaging', true);
  1017. add_option('sfsingleforum', false);
  1018. add_option('sftaggedforum', '');
  1019. # transfer forum rankins from options table to our sf meta table
  1020. $rankings = sf_opcheck(get_option('sfrankings'));
  1021. foreach ($rankings as $rank=>$posts)
  1022. {
  1023. $rankdata['posts'] = $posts;
  1024. $rankdata['usergroup'] = 'none';
  1025. $rankdata['image'] = 'none';
  1026. sf_add_sfmeta('forum_rank', $rank, serialize($rankdata));
  1027. }
  1028. delete_option('sfrankings');
  1029. # create new table for user group memberships
  1030. $sql = "
  1031. CREATE TABLE IF NOT EXISTS ".SFMEMBERSHIPS." (
  1032. membership_id mediumint(8) unsigned NOT NULL auto_increment,
  1033. user_id mediumint(8) unsigned NOT NULL default '0',
  1034. usergroup_id mediumint(8) unsigned NOT NULL default '0',
  1035. PRIMARY KEY (membership_id)
  1036. ) ENGINE=MyISAM ".sf_charset().";";
  1037. $wpdb->query($sql);
  1038. # Build the Memberships from the usergroup column in the members table
  1039. sf_build_memberships_table();
  1040. update_option('sfbuild', $section);
  1041. echo $section;
  1042. die();
  1043. }
  1044. $section = 820;
  1045. if($build < $section)
  1046. {
  1047. # remove usergroups column from members table
  1048. $wpdb->query("ALTER TABLE ".SFMEMBERS." DROP usergroups;");
  1049. $sfeditor = array();
  1050. $sfeditor = sf_opcheck(get_option('sfeditor'));
  1051. $sfeditor['sfrelative'] = true;
  1052. update_option('sfeditor', $sfeditor);
  1053. $sfaiosp = array();
  1054. $sfaiosp['sfaiosp_topic'] = true;
  1055. $sfaiosp['sfaiosp_forum'] = true;
  1056. $sfaiosp['sfaiosp_sep'] = '|';
  1057. add_option('sfaiosp', $sfaiosp);
  1058. $sfsigimagesize = array();
  1059. $sfsigimagesize['sfsigwidth'] = 0;
  1060. $sfsigimagesize['sfsigheight'] = 0;
  1061. add_option('sfsigimagesize', $sfsigimagesize);
  1062. add_option('sfmemberlistperms', true);
  1063. # correct id in sfmembers possible problem
  1064. $found = false;
  1065. $found = false;
  1066. foreach ($wpdb->get_col("DESC ".SFMEMBERS, 0) as $column )
  1067. {
  1068. if ($column == 'id')
  1069. {
  1070. $found = true;
  1071. }
  1072. }
  1073. if($found)
  1074. {
  1075. $wpdb->query("ALTER TABLE ".SFMEMBERS." DROP id;");
  1076. $wpdb->query("ALTER TABLE ".SFMEMBERS." ADD PRIMARY KEY (user_id);");
  1077. }
  1078. # gravatar rating of G by default
  1079. add_option('sfgmaxrating', 1);
  1080. update_option('sfbuild', $section);
  1081. echo $section;
  1082. die();
  1083. }
  1084. $section = 828;
  1085. if($build < $section)
  1086. {
  1087. # pm message slugs
  1088. $create_ddl = "ALTER TABLE ".SFMESSAGES. " ADD (message_slug text NOT NULL)";
  1089. sf_upgrade_database(SFMESSAGES, 'message_slug', $create_ddl);
  1090. $wpdb->query("ALTER TABLE ".SFMESSAGES." ADD UNIQUE mslug (message_slug);");
  1091. sf_create_message_slugs();
  1092. update_option('sfbuild', $section);
  1093. echo $section;
  1094. die();
  1095. }
  1096. $section = 873;
  1097. if($build < $section)
  1098. {
  1099. add_option('sfcbexclusions', '');
  1100. add_option('sfshowmemberlist', true);
  1101. # store ip for posts
  1102. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (poster_ip varchar(15) NOT NULL)";
  1103. sf_upgrade_database(SFPOSTS, 'poster_ip', $create_ddl);
  1104. update_option('sfbuild', $section);
  1105. echo $section;
  1106. die();
  1107. }
  1108. $section = 945;
  1109. if($build < $section)
  1110. {
  1111. # members icon text
  1112. $icons=sf_opcheck(get_option('sfshowicon'));
  1113. if(strpos($icons, '@Members;') === false)
  1114. {
  1115. $icons.= '@Members;1';
  1116. update_option('sfshowicon', $icons);
  1117. }
  1118. # remove name/title and description length limits from groups and forums
  1119. $wpdb->query("ALTER TABLE ".SFFORUMS." DROP INDEX fslug");
  1120. $wpdb->query("ALTER TABLE ".SFTOPICS." DROP INDEX tslug");
  1121. $wpdb->query("ALTER TABLE ".SFGROUPS." CHANGE group_name group_name TEXT NOT NULL");
  1122. $wpdb->query("ALTER TABLE ".SFGROUPS." CHANGE group_desc group_desc TEXT NULL DEFAULT NULL");
  1123. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_name forum_name TEXT NOT NULL");
  1124. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_desc forum_desc TEXT NULL DEFAULT NULL");
  1125. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_slug forum_slug TEXT NOT NULL");
  1126. $wpdb->query("ALTER TABLE ".SFTOPICS." CHANGE topic_name topic_name TEXT NOT NULL");
  1127. $wpdb->query("ALTER TABLE ".SFTOPICS." CHANGE topic_slug topic_slug TEXT NOT NULL");
  1128. # admin bar - force removal from bar only
  1129. $sfadminsettings=array();
  1130. $sfadminsettings=sf_opcheck(get_option('sfadminsettings'));
  1131. $sfadminsettings['sfbaronly']=false;
  1132. update_option('sfadminsettings', $sfadminsettings);
  1133. # add ability to turn off email settings
  1134. $sfmail = array();
  1135. $sfmail = sf_opcheck(get_option('sfmail'));
  1136. $sfmail['sfmailuse']=true;
  1137. update_option('sfmail', $sfmail);
  1138. add_option('sfwpavatar', false);
  1139. update_option('sfbuild', $section);
  1140. echo $section;
  1141. die();
  1142. }
  1143. # 4.0.1 =====================================================================================
  1144. $section = 1030;
  1145. if($build < $section)
  1146. {
  1147. # remove name/title and description length limits from user groups
  1148. $wpdb->query("ALTER TABLE ".SFUSERGROUPS." CHANGE usergroup_name usergroup_name TEXT NOT NULL");
  1149. $wpdb->query("ALTER TABLE ".SFUSERGROUPS." CHANGE usergroup_desc usergroup_desc TEXT NULL DEFAULT NULL");
  1150. update_option('sfbuild', $section);
  1151. echo $section;
  1152. die();
  1153. }
  1154. # 4.0.2 =====================================================================================
  1155. $section = 1360;
  1156. if($build < $section)
  1157. {
  1158. # Add blockquote to tm toolbar
  1159. sf_update_tmtoolbar_blockquote();
  1160. add_option('sfcheckformember', true);
  1161. # housekeeping routine to clean up duplicate memberships and members
  1162. sf_update_membership_cleanup();
  1163. update_option('sfbuild', $section);
  1164. echo $section;
  1165. die();
  1166. }
  1167. # 4.0.3 =====================================================================================
  1168. $section = 1373;
  1169. if($build < $section)
  1170. {
  1171. # dashboard settngs
  1172. $sfadminsettings=array();
  1173. $sfadminsettings=sf_opcheck(get_option('sfadminsettings'));
  1174. $sfadminsettings['sfdashboardposts']=true;
  1175. $sfadminsettings['sfdashboardstats']=true;
  1176. update_option('sfadminsettings', $sfadminsettings);
  1177. # Optional SPF New User Email
  1178. $sfmail = sf_opcheck(get_option('sfnewusermail'));
  1179. $sfmail['sfusespfreg'] = true;
  1180. update_option('sfnewusermail', $sfmail);
  1181. update_option('sfbuild', $section);
  1182. echo $section;
  1183. die();
  1184. }
  1185. # 4.1 =====================================================================================
  1186. $section = 1382;
  1187. if($build < $section)
  1188. {
  1189. # post linking excerpt options (1=full post, 2=full post excerpt, 3=WP Excerpt)
  1190. $sfpostlinking = array();
  1191. $excerpt = sf_opcheck(get_option('sflinkexcerpt'));
  1192. if ($excerpt ? $excerpt = 2 : $excerpt = 1);
  1193. $sfpostlinking['sflinkexcerpt'] = $excerpt;
  1194. $sfpostlinking['sflinksingle'] = false;
  1195. # combine all the post linking options into single array
  1196. $sfpostlinking['sflinkwords'] = sf_opcheck(get_option('sflinkwords'));
  1197. $sfpostlinking['sflinkblogtext'] = sf_opcheck(get_option('sflinkblogtext'));
  1198. $sfpostlinking['sflinkforumtext'] = sf_opcheck(get_option('sflinkforumtext'));
  1199. $sfpostlinking['sflinkabove'] = sf_opcheck(get_option('sflinkabove'));
  1200. $sfpostlinking['sflinkcomments'] = sf_opcheck(get_option('sflinkcomments'));
  1201. add_option('sfpostlinking', $sfpostlinking);
  1202. # remove old singular options
  1203. delete_option('sflinkexcerpt');
  1204. delete_option('sflinkwords');
  1205. delete_option('sflinkblogtext');
  1206. delete_option('sflinkforumtext');
  1207. delete_option('sflinkabove');
  1208. delete_option('sflinkcomments');
  1209. # add new columns for user options
  1210. $create_ddl = "ALTER TABLE ".SFMEMBERS." ADD (user_options longtext)";
  1211. sf_upgrade_database(SFMEMBERS, 'user_options', $create_ddl);
  1212. # build user options table with editor option
  1213. sf_create_user_options();
  1214. # drop the old editor column
  1215. $wpdb->query("ALTER TABLE ".SFMEMBERS." DROP editor;");
  1216. $icons=sf_opcheck(get_option('sfshowicon'));
  1217. if(strpos($icons, '@Unsubscribe;') === false)
  1218. {
  1219. $icons.= '@Unsubscribe;1';
  1220. update_option('sfshowicon', $icons);
  1221. }
  1222. # Add full text index for topic title search
  1223. $wpd

Large files files are truncated, but you can click here to view the full file