upgrade_2-1_sqlite.sql 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /* ATTENTION: You don't need to run or use this file! The upgrade.php script does everything for you! */
  2. /******************************************************************************/
  3. --- Adding new settings...
  4. /******************************************************************************/
  5. ---# Adding login history...
  6. CREATE TABLE IF NOT EXISTS {$db_prefix}member_logins (
  7. id_login integer NOT NULL auto_increment,
  8. id_member integer NOT NULL,
  9. time integer NOT NULL,
  10. ip varchar(255) NOT NULL default '',
  11. ip2 varchar(255) NOT NULL default '',
  12. PRIMARY KEY id_login(id_login)
  13. KEY id_member (id_member)
  14. KEY time (time)
  15. );
  16. ---#
  17. ---# Copying the current package backup setting...
  18. ---{
  19. if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['package_make_backups']))
  20. upgrade_query("
  21. INSERT INTO {$db_prefix}settings
  22. (variable, value)
  23. VALUES
  24. ('package_make_full_backups', '" . $modSettings['package_make_backups'] . "')");
  25. ---}
  26. ---#
  27. ---# Copying the current "allow users to disable word censor" setting...
  28. ---{
  29. if (!isset($modSettings['allow_no_censored']))
  30. {
  31. $request = upgrade_query("
  32. SELECT value
  33. FROM {$db_prefix}settings
  34. WHERE variable='allow_no_censored'
  35. AND id_theme = 1 OR id_theme = '$modSettings[theme_default]'
  36. ");
  37. // Is it set for either "default" or the one they've set as default?
  38. while ($row = $smcFunc['db_fetch_assoc']($request))
  39. {
  40. if ($row['value'] == 1)
  41. {
  42. upgrade_query("
  43. INSERT INTO {$db_prefix}settings
  44. VALUES ('allow_no_censored', 1)
  45. ");
  46. // Don't do this twice...
  47. break;
  48. }
  49. }
  50. }
  51. ---}
  52. ---#
  53. ---# Adding new "topic_move_any" setting
  54. INSERT INTO {$db_prefix}settings (variable, value) VALUES ('topic_move_any', '1');
  55. ---#
  56. ---# Adding new "browser_cache" setting
  57. INSERT INTO {$db_prefix}settings (variable, value) VALUES ('browser_cache', '?alph21');
  58. ---#
  59. /******************************************************************************/
  60. --- Updating legacy attachments...
  61. /******************************************************************************/
  62. ---# Converting legacy attachments.
  63. ---{
  64. // Need to know a few things first.
  65. $custom_av_dir = !empty($modSettings['custom_avatar_dir']) ? $modSettings['custom_avatar_dir'] : $GLOBALS['boarddir'] .'/custom_avatar';
  66. // This little fellow has to cooperate...
  67. if (!is_writable($custom_av_dir))
  68. @chmod($custom_av_dir, 0777);
  69. $request = upgrade_query("
  70. SELECT MAX(id_attach)
  71. FROM {$db_prefix}attachments");
  72. list ($step_progress['total']) = $smcFunc['db_fetch_row']($request);
  73. $smcFunc['db_free_result']($request);
  74. $_GET['a'] = isset($_GET['a']) ? (int) $_GET['a'] : 0;
  75. $step_progress['name'] = 'Converting legacy attachments';
  76. $step_progress['current'] = $_GET['a'];
  77. // We may be using multiple attachment directories.
  78. if (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings['attachmentUploadDir']))
  79. $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
  80. $is_done = false;
  81. while (!$is_done)
  82. {
  83. nextSubStep($substep);
  84. $fileHash = '';
  85. $request = upgrade_query("
  86. SELECT id_attach, id_folder, filename, file_hash, mime_type
  87. FROM {$db_prefix}attachments
  88. WHERE attachment_type != 1
  89. LIMIT $_GET[a], 100");
  90. // Finished?
  91. if ($smcFunc['db_num_rows']($request) == 0)
  92. $is_done = true;
  93. while ($row = $smcFunc['db_fetch_assoc']($request))
  94. {
  95. // The current folder.
  96. $currentFolder = !empty($modSettings['currentAttachmentUploadDir']) ? $modSettings['attachmentUploadDir'][$row['id_folder']] : $modSettings['attachmentUploadDir'];
  97. // Old School?
  98. if (empty($row['file_hash']))
  99. {
  100. // Remove international characters (windows-1252)
  101. // These lines should never be needed again. Still, behave.
  102. if (empty($db_character_set) || $db_character_set != 'utf8')
  103. {
  104. $row['filename'] = strtr($row['filename'],
  105. "\x8a\x8e\x9a\x9e\x9f\xc0\xc1\xc2\xc3\xc4\xc5\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xd9\xda\xdb\xdc\xdd\xe0\xe1\xe2\xe3\xe4\xe5\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xff",
  106. 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
  107. $row['filename'] = strtr($row['filename'], array("\xde" => 'TH', "\xfe" =>
  108. 'th', "\xd0" => 'DH', "\xf0" => 'dh', "\xdf" => 'ss', "\x8c" => 'OE',
  109. "\x9c" => 'oe', "\xc6" => 'AE', "\xe6" => 'ae', "\xb5" => 'u'));
  110. }
  111. // Sorry, no spaces, dots, or anything else but letters allowed.
  112. $row['filename'] = preg_replace(array('/\s/', '/[^\w_\.\-]/'), array('_', ''), $row['filename']);
  113. // Create a nice hash.
  114. $fileHash = sha1(md5($row['filename'] . time()) . mt_rand());
  115. // The old file, we need to know if the filename was encrypted or not.
  116. if (file_exists($currentFolder . '/' . $row['id_attach']. '_' . strtr($row['filename'], '.', '_') . md5($row['filename'])))
  117. $oldFile = $currentFolder . '/' . $row['id_attach']. '_' . strtr($row['filename'], '.', '_') . md5($row['filename']);
  118. else if (file_exists($currentFolder . '/' . $row['filename']));
  119. $oldFile = $currentFolder . '/' . $row['filename'];
  120. // Build the new file.
  121. $newFile = $currentFolder . '/' . $row['id_attach'] . '_' . $fileHash .'.dat';
  122. }
  123. // Just rename the file.
  124. else
  125. {
  126. $oldFile = $currentFolder . '/' . $row['id_attach'] . '_' . $row['file_hash'];
  127. $newFile = $currentFolder . '/' . $row['id_attach'] . '_' . $row['file_hash'] .'.dat';
  128. }
  129. // Check if the av is an attachment
  130. if ($row['id_member'] != 0)
  131. if (rename($oldFile, $custom_av_dir . '/' . $row['filename']))
  132. upgrade_query("
  133. UPDATE {$db_prefix}attachments
  134. SET file_hash = '', attachment_type = 1
  135. WHERE id_attach = $row[id_attach]");
  136. // Just a regular attachment.
  137. else
  138. rename($oldFile, $newFile);
  139. // Only update this if it was successful and the file was using the old system.
  140. if (empty($row['file_hash']) && !empty($fileHash) && file_exists($newFile) && !file_exists($oldFile))
  141. upgrade_query("
  142. UPDATE {$db_prefix}attachments
  143. SET file_hash = '$fileHash'
  144. WHERE id_attach = $row[id_attach]");
  145. // While we're here, do we need to update the mime_type?
  146. if (empty($row['mime_type']) && file_exists($newFile))
  147. {
  148. $size = @getimagesize($newFile);
  149. if (!empty($size['mime']))
  150. $smcFunc['db_query']('', '
  151. UPDATE {db_prefix}attachments
  152. SET mime_type = {string:mime_type}
  153. WHERE id_attach = {int:id_attach}',
  154. array(
  155. 'id_attach' => $row['id_attach'],
  156. 'mime_type' => substr($size['mime'], 0, 20),
  157. )
  158. );
  159. }
  160. }
  161. $smcFunc['db_free_result']($request);
  162. $_GET['a'] += 100;
  163. $step_progress['current'] = $_GET['a'];
  164. }
  165. unset($_GET['a']);
  166. ---}
  167. ---#
  168. ---# Fixing invalid sizes on attachments
  169. ---{
  170. $attachs = array();
  171. // If id_member = 0, then it's not an avatar
  172. // If attachment_type = 0, then it's also not a thumbnail
  173. // Theory says there shouldn't be *that* many of these
  174. $request = $smcFunc['db_query']('', '
  175. SELECT id_attach, mime_type, width, height
  176. FROM {db_prefix}attachments
  177. WHERE id_member = 0
  178. AND attachment_type = 0');
  179. while ($row = $smcFunc['db_fetch_assoc']($request))
  180. {
  181. if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
  182. $attachs[] = $row['id_attach'];
  183. }
  184. $smcFunc['db_free_result']($request);
  185. if (!empty($attachs))
  186. $smcFunc['db_query']('', '
  187. UPDATE {db_prefix}attachments
  188. SET width = 0,
  189. height = 0
  190. WHERE id_attach IN ({array_int:attachs})',
  191. array(
  192. 'attachs' => $attachs,
  193. )
  194. );
  195. ---}
  196. ---#
  197. /******************************************************************************/
  198. --- Adding support for IPv6...
  199. /******************************************************************************/
  200. ---# Adding new columns to ban items...
  201. ALTER TABLE {$db_prefix}ban_items
  202. ADD COLUMN ip_low5 smallint(255) unsigned NOT NULL DEFAULT '0',
  203. ADD COLUMN ip_high5 smallint(255) unsigned NOT NULL DEFAULT '0',
  204. ADD COLUMN ip_low6 smallint(255) unsigned NOT NULL DEFAULT '0',
  205. ADD COLUMN ip_high6 smallint(255) unsigned NOT NULL DEFAULT '0',
  206. ADD COLUMN ip_low7 smallint(255) unsigned NOT NULL DEFAULT '0',
  207. ADD COLUMN ip_high7 smallint(255) unsigned NOT NULL DEFAULT '0',
  208. ADD COLUMN ip_low8 smallint(255) unsigned NOT NULL DEFAULT '0',
  209. ADD COLUMN ip_high8 smallint(255) unsigned NOT NULL DEFAULT '0';
  210. ---#
  211. ---# Changing existing columns to ban items...
  212. ALTER TABLE {$db_prefix}ban_items
  213. CHANGE ip_low1 ip_low1 smallint(255) unsigned NOT NULL DEFAULT '0',
  214. CHANGE ip_high1 ip_high1 smallint(255) unsigned NOT NULL DEFAULT '0',
  215. CHANGE ip_low2 ip_low2 smallint(255) unsigned NOT NULL DEFAULT '0',
  216. CHANGE ip_high2 ip_high2 smallint(255) unsigned NOT NULL DEFAULT '0',
  217. CHANGE ip_low3 ip_low3 smallint(255) unsigned NOT NULL DEFAULT '0',
  218. CHANGE ip_high3 ip_high3 smallint(255) unsigned NOT NULL DEFAULT '0',
  219. CHANGE ip_low4 ip_low4 smallint(255) unsigned NOT NULL DEFAULT '0',
  220. CHANGE ip_high4 ip_high4 smallint(255) unsigned NOT NULL DEFAULT '0';
  221. ---#
  222. /******************************************************************************/
  223. --- Adding support for logging who fulfils a group request.
  224. /******************************************************************************/
  225. ---# Adding new columns to log_group_requests
  226. ALTER TABLE {$db_prefix}log_group_requests
  227. ADD COLUMN status smallint unsigned NOT NULL default '0',
  228. ADD COLUMN id_member_acted int unsigned NOT NULL default '0',
  229. ADD COLUMN member_name_acted varchar(255) NOT NULL default '',
  230. ADD COLUMN time_acted int unsigned NOT NULL default '0',
  231. ADD COLUMN act_reason text NOT NULL;
  232. ---#
  233. ---# Adjusting the indexes for log_group_requests
  234. DROP INDEX {$db_prefix}log_group_requests_id_member;
  235. CREATE INDEX {$db_prefix}log_group_requests_id_member ON {$db_prefix}log_group_requests (id_member, id_group);
  236. ---#
  237. /******************************************************************************/
  238. --- Adding support for <credits> tag in package manager
  239. /******************************************************************************/
  240. ---# Adding new columns to log_packages ..
  241. ALTER TABLE {$db_prefix}log_packages
  242. ADD COLUMN credits varchar(255) NOT NULL DEFAULT '';
  243. ---#
  244. /******************************************************************************/
  245. --- Adding more space for session ids
  246. /******************************************************************************/
  247. ---# Altering the session_id columns...
  248. ALTER TABLE {$db_prefix}log_online
  249. CHANGE `session` `session` varchar(64) NOT NULL DEFAULT '';
  250. ALTER TABLE {$db_prefix}log_errors
  251. CHANGE `session` `session` char(64) NOT NULL default ' ';
  252. ALTER TABLE {$db_prefix}sessions
  253. CHANGE `session_id` `session_id` char(64) NOT NULL;
  254. ---#
  255. /******************************************************************************/
  256. --- Adding new columns for MOVED topic updates
  257. /******************************************************************************/
  258. ---# Adding new custom fields columns.
  259. ---{
  260. $smcFunc['db_alter_table']('{db_prefix}topics', array(
  261. 'add' => array(
  262. 'redirect_expires' => array(
  263. 'name' => 'redirect_expires',
  264. 'null' => false,
  265. 'default' => '0',
  266. 'type' => 'int',
  267. 'auto' => false,
  268. ),
  269. )
  270. ));
  271. $smcFunc['db_alter_table']('{db_prefix}topics', array(
  272. 'add' => array(
  273. 'id_redirect_topic' => array(
  274. 'name' => 'id_redirect_topic',
  275. 'null' => false,
  276. 'default' => '0',
  277. 'type' => 'int',
  278. 'auto' => false,
  279. ),
  280. )
  281. ));
  282. ---}
  283. ---#
  284. /******************************************************************************/
  285. --- Adding new scheduled tasks
  286. /******************************************************************************/
  287. ---# Adding new scheduled tasks
  288. INSERT INTO {$db_prefix}scheduled_tasks
  289. (next_time, time_offset, time_regularity, time_unit, disabled, task)
  290. VALUES
  291. (0, 120, 1, 'd', 0, 'remove_temp_attachments');
  292. INSERT INTO {$db_prefix}scheduled_tasks
  293. (next_time, time_offset, time_regularity, time_unit, disabled, task)
  294. VALUES
  295. (0, 180, 1, 'd', 0, 'remove_topic_redirect');
  296. INSERT INTO {$db_prefix}scheduled_tasks
  297. (next_time, time_offset, time_regularity, time_unit, disabled, task)
  298. VALUES
  299. (0, 240, 1, 'd', 0, 'remove_old_drafts');
  300. ---#
  301. /******************************************************************************/
  302. ---- Adding background tasks support
  303. /******************************************************************************/
  304. ---# Adding the new table
  305. CREATE TABLE IF NOT EXISTS {$db_prefix}background_tasks (
  306. id_task integer primary key,
  307. task_file varchar(255) NOT NULL default '',
  308. task_class varchar(255) NOT NULL default '',
  309. task_data text NOT NULL,
  310. claimed_time int NOT NULL default '0',
  311. PRIMARY KEY (id_task)
  312. );
  313. ---#
  314. /******************************************************************************/
  315. ---- Replacing MSN with Skype
  316. /******************************************************************************/
  317. ---# Modifying the "msn" column...
  318. ALTER TABLE {$db_prefix}members
  319. CHANGE msn skype varchar(255) NOT NULL DEFAULT '';
  320. ---#
  321. /******************************************************************************/
  322. --- Adding support for deny boards access
  323. /******************************************************************************/
  324. ---# Adding new columns to boards...
  325. ---{
  326. $smcFunc['db_alter_table']('{db_prefix}boards', array(
  327. 'add' => array(
  328. 'deny_member_groups' => array(
  329. 'name' => 'deny_member_groups',
  330. 'null' => false,
  331. 'default' => '',
  332. 'type' => varchar,
  333. 'size' => 255,
  334. 'auto' => false,
  335. ),
  336. )
  337. ));
  338. ---}
  339. ---#
  340. /******************************************************************************/
  341. --- Updating board access rules
  342. /******************************************************************************/
  343. ---# Updating board access rules
  344. ---{
  345. $member_groups = array(
  346. 'allowed' => array(),
  347. 'denied' => array(),
  348. );
  349. $request = $smcFunc['db_query']('', '
  350. SELECT id_group, add_deny
  351. FROM {db_prefix}permissions
  352. WHERE permission = {string:permission}',
  353. array(
  354. 'permission' => 'manage_boards',
  355. )
  356. );
  357. while ($row = $smcFunc['db_fetch_assoc']($request))
  358. $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
  359. $smcFunc['db_free_result']($request);
  360. $member_groups = array_diff($member_groups['allowed'], $member_groups['denied']);
  361. if (!empty($member_groups))
  362. {
  363. $count = count($member_groups);
  364. $changes = array();
  365. $request = $smcFunc['db_query']('', '
  366. SELECT id_board, member_groups
  367. FROM {db_prefix}boards');
  368. while ($row = $smcFunc['db_fetch_assoc']($request))
  369. {
  370. $current_groups = explode(',', $row['member_groups']);
  371. if (count(array_intersect($current_groups, $member_groups)) != $count)
  372. {
  373. $new_groups = array_unique(array_merge($current_groups, $member_groups));
  374. $changes[$row['id_board']] = implode(',', $new_groups);
  375. }
  376. }
  377. $smcFunc['db_free_result']($request);
  378. if (!empty($changes))
  379. {
  380. foreach ($changes as $id_board => $member_groups)
  381. $smcFunc['db_query']('', '
  382. UPDATE {db_prefix}boards
  383. SET member_groups = {string:member_groups}
  384. WHERE id_board = {int:id_board}',
  385. array(
  386. 'member_groups' => $member_groups,
  387. 'id_board' => $id_board,
  388. )
  389. );
  390. }
  391. }
  392. ---}
  393. ---#
  394. /******************************************************************************/
  395. --- Adding support for category descriptions
  396. /******************************************************************************/
  397. ---# Adding new columns to categories...
  398. ---{
  399. $smcFunc['db_alter_table']('{db_prefix}log_topics', array(
  400. 'add' => array(
  401. 'description' => array(
  402. 'name' => 'description',
  403. 'null' => false,
  404. 'type' => 'text',
  405. 'auto' => false,
  406. ),
  407. )
  408. ));
  409. ---}
  410. ---#
  411. /******************************************************************************/
  412. --- Adding support for alerts
  413. /******************************************************************************/
  414. ---# Adding the count to the members table...
  415. ---{
  416. $smcFunc['db_alter_table']('{db_prefix}members', array(
  417. 'add' => array(
  418. 'alerts' => array(
  419. 'name' => 'ualerts',
  420. 'null' => false,
  421. 'default' => 0,
  422. 'type' => 'int',
  423. 'auto' => false,
  424. ),
  425. )
  426. ));
  427. ---}
  428. ---#
  429. ---# Adding the new table for alerts.
  430. CREATE TABLE IF NOT EXISTS {$db_prefix}user_alerts (
  431. id_alert int primary key,
  432. alert_time int unsigned NOT NULL default '0',
  433. id_member int unsigned NOT NULL default '0',
  434. id_member_started int unsigned NOT NULL default '0',
  435. member_name varchar(255) NOT NULL default '',
  436. content_type varchar(255) NOT NULL default '',
  437. content_id int unsigned NOT NULL default '0',
  438. content_action varchar(255) NOT NULL default '',
  439. is_read int unsigned NOT NULL default '0',
  440. extra text NOT NULL,
  441. PRIMARY KEY (id_alert)
  442. );
  443. CREATE INDEX {$db_prefix}user_alerts_id_member ON {$db_prefix}user_alerts (id_member);
  444. CREATE INDEX {$db_prefix}user_alerts_alert_time ON {$db_prefix}user_alerts (alert_time);
  445. ---#
  446. ---# Adding alert preferences.
  447. CREATE TABLE IF NOT EXISTS {$db_prefix}user_alerts_prefs (
  448. id_member int unsigned NOT NULL default '0',
  449. alert_pref varchar(32) NOT NULL default '',
  450. alert_value tinyint(3) NOT NULL default '0',
  451. PRIMARY KEY (id_member, alert_pref)
  452. );
  453. INSERT INTO {$db_prefix}user_alerts_prefs (id_member, alert_pref, alert_value) VALUES (0, 'member_group_request', 1);
  454. INSERT INTO {$db_prefix}user_alerts_prefs (id_member, alert_pref, alert_value) VALUES (0, 'member_register', 1);
  455. INSERT INTO {$db_prefix}user_alerts_prefs (id_member, alert_pref, alert_value) VALUES (0, 'msg_like', 1);
  456. INSERT INTO {$db_prefix}user_alerts_prefs (id_member, alert_pref, alert_value) VALUES (0, 'msg_report', 1);
  457. INSERT INTO {$db_prefix}user_alerts_prefs (id_member, alert_pref, alert_value) VALUES (0, 'msg_report_reply', 1);
  458. ---#
  459. /******************************************************************************/
  460. --- Adding support for topic unwatch
  461. /******************************************************************************/
  462. ---# Adding new columns to log_topics...
  463. ---{
  464. $smcFunc['db_alter_table']('{db_prefix}log_topics', array(
  465. 'add' => array(
  466. 'unwatched' => array(
  467. 'name' => 'unwatched',
  468. 'null' => false,
  469. 'default' => 0,
  470. 'type' => 'int',
  471. 'auto' => false,
  472. ),
  473. )
  474. ));
  475. UPDATE {$db_prefix}log_topics
  476. SET unwatched = 0;
  477. INSERT INTO {$db_prefix}settings
  478. (variable, value)
  479. VALUES
  480. ('enable_unwatch', 0);
  481. ---}
  482. ---#
  483. ---# Fixing column name change...
  484. ---{
  485. $smcFunc['db_alter_table']('{db_prefix}log_topics', array(
  486. 'change' => array(
  487. 'disregarded' => array(
  488. 'name' => 'unwatched',
  489. 'null' => false,
  490. 'default' => 0,
  491. 'type' => 'int',
  492. 'auto' => false,
  493. ),
  494. )
  495. ));
  496. ---}
  497. ---#
  498. /******************************************************************************/
  499. --- Name changes
  500. /******************************************************************************/
  501. ---# Altering the membergroup stars to icons
  502. ---{
  503. upgrade_query("
  504. ALTER TABLE {$db_prefix}membergroups
  505. CHANGE `stars` `icons` varchar(255) NOT NULL DEFAULT ''");
  506. ---}
  507. ---#
  508. ---# Renaming default theme...
  509. UPDATE {$db_prefix}themes
  510. SET value = 'SMF Default Theme - Curve2'
  511. WHERE value LIKE 'SMF Default Theme%';
  512. ---#
  513. ---# Adding the enableThemes setting.
  514. INSERT INTO {$db_prefix}settings
  515. (variable, value)
  516. VALUES
  517. ('enableThemes', '1');
  518. ---#
  519. ---# Setting "default" as the default...
  520. UPDATE {$db_prefix}settings
  521. SET value = '1'
  522. WHERE variable = 'theme_guests';
  523. UPDATE {$db_prefix}boards
  524. SET id_theme = 0;
  525. UPDATE {$db_prefix}members
  526. SET id_theme = 0;
  527. ---#
  528. /******************************************************************************/
  529. --- Cleaning up after old themes...
  530. /******************************************************************************/
  531. ---# Checking for "core" and removing it if necessary...
  532. ---{
  533. // Do they have "core" installed?
  534. if (file_exists($GLOBALS['boarddir'] . '/Themes/core'))
  535. {
  536. $core_dir = $GLOBALS['boarddir'] . '/Themes/core';
  537. $theme_request = upgrade_query("
  538. SELECT id_theme
  539. FROM {$db_prefix}themes
  540. WHERE variable = 'theme_dir'
  541. AND value ='$core_dir'");
  542. // Don't do anything if this theme is already uninstalled
  543. if ($smcFunc['db_num_rows']($theme_request) == 1)
  544. {
  545. list($id_theme) = $smcFunc['db_fetch_row']($theme_request, 0);
  546. $smcFunc['db_free_result']($theme_request);
  547. $known_themes = explode(', ', $modSettings['knownThemes']);
  548. // Remove this value...
  549. $known_themes = array_diff($known_themes, array($id_theme));
  550. // Change back to a string...
  551. $known_themes = implode(', ', $known_themes);
  552. // Update the database
  553. upgrade_query("
  554. UPDATE {$db_prefix}settings
  555. SET value = '$known_themes'
  556. WHERE variable = 'knownThemes'");
  557. // Delete any info about this theme
  558. upgrade_query("
  559. DELETE FROM {$db_prefix}themes
  560. WHERE id_theme = $id_theme");
  561. }
  562. }
  563. /******************************************************************************/
  564. --- Adding support for drafts
  565. /******************************************************************************/
  566. ---# Creating drafts table.
  567. CREATE TABLE IF NOT EXISTS {$db_prefix}user_drafts (
  568. id_draft int unsigned NOT NULL auto_increment,
  569. id_topic int unsigned NOT NULL default '0',
  570. id_board smallint unsigned NOT NULL default '0',
  571. id_reply int unsigned NOT NULL default '0',
  572. type smallint NOT NULL default '0',
  573. poster_time int unsigned NOT NULL default '0',
  574. id_member int unsigned NOT NULL default '0',
  575. subject varchar(255) NOT NULL default '',
  576. smileys_enabled smallint NOT NULL default '1',
  577. body text NOT NULL,
  578. icon varchar(16) NOT NULL default 'xx',
  579. locked smallint NOT NULL default '0',
  580. is_sticky smallint NOT NULL default '0',
  581. to_list varchar(255) NOT NULL default '',
  582. PRIMARY KEY (id_draft)
  583. );
  584. CREATE UNIQUE INDEX {$db_prefix}user_drafts_id_member ON {$db_prefix}user_drafts (id_member, id_draft, type);
  585. ---#
  586. ---# Adding draft permissions...
  587. ---{
  588. // We cannot do this twice
  589. if (@$modSettings['smfVersion'] < '2.1')
  590. {
  591. // Anyone who can currently post unapproved topics we assume can create drafts as well ...
  592. $request = upgrade_query("
  593. SELECT id_group, id_board, add_deny, permission
  594. FROM {$db_prefix}board_permissions
  595. WHERE permission = 'post_unapproved_topics'");
  596. $inserts = array();
  597. while ($row = $smcFunc['db_fetch_assoc']($request))
  598. {
  599. $inserts[] = "($row[id_group], $row[id_board], 'post_draft', $row[add_deny])";
  600. $inserts[] = "($row[id_group], $row[id_board], 'post_autosave_draft', $row[add_deny])";
  601. }
  602. $smcFunc['db_free_result']($request);
  603. if (!empty($inserts))
  604. {
  605. foreach ($inserts AS $insert)
  606. {
  607. upgrade_query("
  608. INSERT INTO {$db_prefix}board_permissions
  609. (id_group, id_board, permission, add_deny)
  610. VALUES
  611. " . $insert);
  612. }
  613. }
  614. // Next we find people who can send PMs, and assume they can save pm_drafts as well
  615. $request = upgrade_query("
  616. SELECT id_group, add_deny, permission
  617. FROM {$db_prefix}permissions
  618. WHERE permission = 'pm_send'");
  619. $inserts = array();
  620. while ($row = $smcFunc['db_fetch_assoc']($request))
  621. {
  622. $inserts[] = "($row[id_group], 'pm_draft', $row[add_deny])";
  623. $inserts[] = "($row[id_group], 'pm_autosave_draft', $row[add_deny])";
  624. }
  625. $smcFunc['db_free_result']($request);
  626. if (!empty($inserts))
  627. {
  628. foreach ($inserts AS $insert)
  629. {
  630. upgrade_query("
  631. INSERT INTO {$db_prefix}permissions
  632. (id_group, permission, add_deny)
  633. VALUES
  634. " . $insert);
  635. }
  636. }
  637. }
  638. ---}
  639. INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_autosave_enabled', '1');
  640. INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_show_saved_enabled', '1');
  641. INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_keep_days', '7');
  642. INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_autosave_enabled', '1');
  643. INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_show_saved_enabled', '1');
  644. ---#
  645. /******************************************************************************/
  646. --- Adding support for likes
  647. /******************************************************************************/
  648. ---# Creating likes table.
  649. CREATE TABLE IF NOT EXISTS {$db_prefix}user_likes (
  650. id_member int NOT NULL default '0',
  651. content_type char(6) default '',
  652. content_id int NOT NULL default '0',
  653. like_time int NOT NULL default '0',
  654. PRIMARY KEY (content_id, content_type, id_member)
  655. );
  656. CREATE INDEX {$db_prefix}user_likes_content ON {$db_prefix}user_likes (content_id, content_type);
  657. CREATE INDEX {$db_prefix}user_likes_liker ON {$db_prefix}user_likes (id_member);
  658. ---#
  659. ---# Adding count to the messages table.
  660. ALTER TABLE {$db_prefix}messages
  661. ADD COLUMN likes smallint NOT NULL default '0';
  662. ---#
  663. /******************************************************************************/
  664. --- Adding support for group-based board moderation
  665. /******************************************************************************/
  666. ---# Creating moderator_groups table
  667. CREATE TABLE IF NOT EXISTS {$db_prefix}moderator_groups (
  668. id_board smallint NOT NULL default '0',
  669. id_group smallint NOT NULL default '0',
  670. PRIMARY KEY (id_board, id_group)
  671. );
  672. ---#
  673. /******************************************************************************/
  674. --- Cleaning up integration hooks
  675. /******************************************************************************/
  676. ---#
  677. DELETE FROM {$db_prefix}settings
  678. WHERE variable LIKE 'integrate_%';
  679. ---#
  680. /******************************************************************************/
  681. --- Cleaning up old settings
  682. /******************************************************************************/
  683. ---# Updating the default time format
  684. ---{
  685. if (!empty($modSettings['time_format']))
  686. {
  687. // First, use the shortened form of the month in the date.
  688. $time_format = str_replace('%B', '%b', $modSettings['time_format']);
  689. // Second, shorten the time to stop including seconds.
  690. $time_format = str_replace(':%S', '', $time_format);
  691. // Then, update the database.
  692. $smcFunc['db_query']('', '
  693. UPDATE {db_prefix}settings
  694. SET value = {string:new_format}
  695. WHERE variable = {literal:time_format}',
  696. array(
  697. 'new_format' => $time_format,
  698. )
  699. );
  700. }
  701. ---}
  702. ---#
  703. ---# Fixing a deprecated option.
  704. UPDATE {$db_prefix}settings
  705. SET value = 'option_css_resize'
  706. WHERE variable = 'avatar_action_too_large'
  707. AND (value = 'option_html_resize' OR value = 'option_js_resize');
  708. ---#
  709. ---# Cleaning up the old Core Features page.
  710. ---{
  711. // First get the original value
  712. $request = $smcFunc['db_query']('', '
  713. SELECT value
  714. FROM {db_prefix}settings
  715. WHERE variable = {literal:admin_features}');
  716. if ($smcFunc['db_num_rows']($request) > 0 && $row = $smcFunc['db_fetch_assoc']($request))
  717. {
  718. // Some of these *should* already be set but you never know.
  719. $new_settings = array();
  720. $admin_features = explode(',', $row['value']);
  721. // Now, let's just recap something.
  722. // cd = calendar, should also have set cal_enabled already
  723. // cp = custom profile fields, which already has several fields that cover tracking
  724. // k = karma, should also have set karmaMode already
  725. // ps = paid subs, should also have set paid_enabled already
  726. // rg = reports generation, which is now permanently on
  727. // sp = spider tracking, should also have set spider_mode already
  728. // w = warning system, which will be covered with warning_settings
  729. // The rest we have to deal with manually.
  730. // Moderation log - modlog_enabled itself should be set but we have others now
  731. if (in_array('ml', $admin_features))
  732. {
  733. $new_settings[] = array('adminlog_enabled', '1');
  734. $new_settings[] = array('userlog_enabled', '1');
  735. }
  736. // Post moderation
  737. if (in_array('pm', $admin_features))
  738. {
  739. $new_settings[] = array('postmod_active', '1');
  740. }
  741. // And now actually apply it.
  742. if (!empty($new_settings))
  743. {
  744. $smcFunc['db_insert']('replace',
  745. '{db_prefix}settings',
  746. array('variable' => 'string', 'value' => 'string'),
  747. $new_settings,
  748. array('variable')
  749. );
  750. }
  751. }
  752. $smcFunc['db_free_result']($request);
  753. ---}
  754. ---#
  755. ---# Cleaning up old settings.
  756. DELETE FROM {$db_prefix}settings
  757. WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch', 'enableVBStyleLogin');
  758. ---#
  759. ---# Cleaning up old theme settings.
  760. DELETE FROM {$db_prefix}themes
  761. WHERE variable IN ('show_board_desc', 'no_new_reply_warning', 'display_quick_reply', 'show_mark_read', 'show_member_bar', 'linktree_link');
  762. ---#
  763. /******************************************************************************/
  764. --- Updating files that fetched from simplemachines.org
  765. /******************************************************************************/
  766. ---# We no longer call on several files.
  767. DELETE FROM {$db_prefix}admin_info_files
  768. WHERE filename IN ('latest-packages.js', 'latest-support.js', 'latest-themes.js')
  769. AND path = '/smf/';
  770. ---#
  771. ---# But we do need new files.
  772. ---{
  773. $smcFunc['db_insert']('',
  774. '{db_prefix}admin_info_files',
  775. array('filename' => 'string', 'path' => 'string', 'parameters' => 'string', 'data' => 'string', 'filetype' => 'string'),
  776. array('latest-versions.txt', '/smf/', 'version=%3$s', '', 'text/plain'),
  777. array('id_file')
  778. );
  779. ---}
  780. ---#
  781. /******************************************************************************/
  782. --- Upgrading "verification questions" feature
  783. /******************************************************************************/
  784. ---# Creating qanda table
  785. CREATE TABLE IF NOT EXISTS {$db_prefix}qanda (
  786. id_question smallint(5) unsigned NOT NULL auto_increment,
  787. lngfile varchar(255) NOT NULL default '',
  788. question varchar(255) NOT NULL default '',
  789. answers text NOT NULL,
  790. PRIMARY KEY (id_question),
  791. KEY lngfile (lngfile)
  792. );
  793. ---#
  794. ---# Moving questions and answers to the new table
  795. ---{
  796. $questions = array();
  797. $get_questions = upgrade_query("
  798. SELECT body AS question, recipient_name AS answer
  799. FROM {$db_prefix}log_comments
  800. WHERE comment_type = 'ver_test'");
  801. while ($row = $smcFunc['db_fetch_assoc']($get_questions))
  802. $questions[] = array($language, $row['question'], serialize(array($row['answer'])));
  803. $smcFunc['db_free_result']($get_questions);
  804. if (!empty($questions))
  805. {
  806. $smcFunc['db_insert']('',
  807. '{db_prefix}qanda',
  808. array('lngfile' => 'string', 'question' => 'string', 'answers' => 'string'),
  809. $questions,
  810. array('id_question')
  811. );
  812. // Delete the questions from log_comments now
  813. upgrade_query("
  814. DELETE FROM {$db_prefix}log_comments
  815. WHERE comment_type = 'ver_test'
  816. ");
  817. }
  818. ---}
  819. ---#
  820. /******************************************************************************/
  821. --- Marking packages as uninstalled...
  822. /******************************************************************************/
  823. ---# Updating log_packages
  824. UPDATE {$db_prefix}log_packages
  825. SET install_state = 0;
  826. ---#
  827. /******************************************************************************/
  828. --- Updating profile permissions...
  829. /******************************************************************************/
  830. ---# Removing the old "view your own profile" permission
  831. DELETE FROM {$db_prefix}permissions
  832. WHERE permission = 'profile_view_own';
  833. ---#
  834. ---# Updating the old "view any profile" permission
  835. UPDATE {$db_prefix}permissions
  836. SET permission = 'profile_view'
  837. WHERE permission = 'profile_view_any';
  838. ---#
  839. ---# Removing the old notification permissions
  840. DELETE FROM {$db_prefix}board_permissions
  841. WHERE permission = 'mark_notify' OR permission = 'mark_any_notify';
  842. ---#
  843. ---# Removing the send-topic permission
  844. DELETE FROM {$db_prefix}board_permissions
  845. WHERE permission = 'send_topic';
  846. ---#
  847. ---# Adding "profile_password_own"
  848. ---{
  849. $inserts = array();
  850. $request = upgrade_query("
  851. SELECT id_group, add_deny
  852. FROM {$db_prefix}permissions
  853. WHERE permission = 'profile_identity_own'");
  854. while ($row = $smcFunc['db_fetch_assoc']($request))
  855. {
  856. $inserts[] = "($row[id_group], 'profile_password_own', $row[add_deny])";
  857. }
  858. $smcFunc['db_free_result']($request);
  859. if (!empty($inserts))
  860. {
  861. foreach ($inserts as $insert)
  862. {
  863. upgrade_query("
  864. INSERT INTO {$db_prefix}permissions
  865. (id_group, permission, add_deny)
  866. VALUES
  867. " . $insert);
  868. }
  869. }
  870. ---}
  871. ---#
  872. ---# Adding other profile permissions
  873. ---{
  874. $inserts = array();
  875. $request = upgrade_query("
  876. SELECT id_group, add_deny
  877. FROM {$db_prefix}permissions
  878. WHERE permission = 'profile_extra_own'");
  879. while ($row = $smcFunc['db_fetch_assoc']($request))
  880. {
  881. $inserts[] = "($row[id_group], 'profile_blurb_own', $row[add_deny])";
  882. $inserts[] = "($row[id_group], 'profile_displayed_name_own', $row[add_deny])";
  883. $inserts[] = "($row[id_group], 'profile_forum_own', $row[add_deny])";
  884. $inserts[] = "($row[id_group], 'profile_other_own', $row[add_deny])";
  885. $inserts[] = "($row[id_group], 'profile_signature_own', $row[add_deny])";
  886. }
  887. $smcFunc['db_free_result']($request);
  888. if (!empty($inserts))
  889. {
  890. foreach ($inserts as $insert)
  891. {
  892. upgrade_query("
  893. INSERT INTO {$db_prefix}permissions
  894. (id_group, permission, add_deny)
  895. VALUES
  896. " . $insert);
  897. }
  898. }
  899. ---}
  900. ---#
  901. /******************************************************************************/
  902. --- Upgrading PM labels...
  903. /******************************************************************************/
  904. ---# Adding pm_labels table...
  905. CREATE TABLE IF NOT EXISTS {$db_prefix}pm_labels (
  906. id_label integer primary key,
  907. id_member int NOT NULL default '0',
  908. name varchar(30) NOT NULL default '',
  909. );
  910. ---#
  911. ---# Adding pm_labeled_messages table...
  912. CREATE TABLE IF NOT EXISTS {$db_prefix}pm_labeled_messages (
  913. id_label int NOT NULL default '0',
  914. id_pm int NOT NULL default '0',
  915. PRIMARY KEY (id_label, id_pm)
  916. );
  917. ---#
  918. ---# Adding "in_inbox" column to pm_recipients
  919. ALTER TABLE {$db_prefix}pm_recipients
  920. ADD COLUMN in_inbox tinyint(3) NOT NULL default '1';
  921. ---#
  922. ---# Moving label info to new tables and updating rules...
  923. ---{
  924. // First see if we still have a message_labels column
  925. $results = $smcFunc['db_list_columns']('{db_prefix}members');
  926. if (in_array('message_labels', $results))
  927. {
  928. // They've still got it, so pull the label info
  929. $get_labels = $smcFunc['db_query']('', '
  930. SELECT id_member, message_labels
  931. FROM {db_prefix}members
  932. WHERE message_labels != {string:blank}',
  933. array(
  934. 'blank' => '',
  935. )
  936. );
  937. $inserts = array();
  938. $label_info = array();
  939. while ($row = $smcFunc['db_fetch_assoc']($get_labels))
  940. {
  941. // Stick this in an array
  942. $labels = explode(',', $row['message_labels']);
  943. // Build some inserts
  944. foreach ($labels AS $index => $label)
  945. {
  946. // Keep track of the index of this label - we'll need that in a bit...
  947. $label_info[$row['id_member']][$label] = $index;
  948. $inserts[] = array($row['id_member'], $label);
  949. }
  950. }
  951. $smcFunc['db_free_result']($get_labels);
  952. if (!empty($inserts))
  953. {
  954. $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'int'), $inserts, array());
  955. // Clear this out for our next query below
  956. $inserts = array();
  957. }
  958. // This is the easy part - update the inbox stuff
  959. $smcFunc['db_query']('', '
  960. UPDATE {db_prefix}pm_recipients
  961. SET in_inbox = {int:in_inbox}
  962. WHERE FIND_IN_SET({int:minus_one}, labels)',
  963. array(
  964. 'in_inbox' => 1,
  965. 'minus_one' => -1,
  966. )
  967. );
  968. // Now we go pull the new IDs for each label
  969. $get_new_label_ids = $smcFunc['db_query']('', '
  970. SELECT *
  971. FROM {db_prefix}pm_labels',
  972. array(
  973. )
  974. );
  975. $label_info_2 = array();
  976. while ($label_row = $smcFunc['db_fetch_assoc']($get_new_label_ids))
  977. {
  978. // Map the old index values to the new ID values...
  979. $old_index = $label_info[$row['id_member']][$row['label_name']];
  980. $label_info_2[$row['id_member']][$old_index] = $row['id_label'];
  981. }
  982. $smcFunc['db_free_result']($get_new_label_ids);
  983. // Pull label info from pm_recipients
  984. // Ignore any that are only in the inbox
  985. $get_pm_labels = $smcFunc['db_query']('', '
  986. SELECT id_pm, id_member, labels
  987. FROM {db_prefix}pm_recipients
  988. WHERE deleted = {int:not_deleted}
  989. AND labels != {string:minus_one}',
  990. array(
  991. 'not_deleted' => 0,
  992. 'minus_one' => -1,
  993. )
  994. );
  995. while ($row = $smcFunc['db_fetch_assoc']($get_pm_labels))
  996. {
  997. $labels = explode(',', $row['labels']);
  998. foreach ($labels as $a_label)
  999. {
  1000. if ($a_label == '-1')
  1001. continue;
  1002. $new_label_info = $label_info_2[$row['id_member']][$a_label];
  1003. $inserts[] = array($row['id_pm'], $new_label_info);
  1004. }
  1005. }
  1006. $smcFunc['db_free_result']($get_pm_labels);
  1007. // Insert the new data
  1008. if (!empty($inserts))
  1009. {
  1010. $smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm', 'id_label'), $inserts, array());
  1011. }
  1012. // Final step of this ridiculously massive process
  1013. $get_pm_rules = $smcFunc['db_query']('', '
  1014. SELECT id_member, id_rule, actions
  1015. FROM {db_prefix}pm_rules',
  1016. array(
  1017. ),
  1018. );
  1019. // Go through the rules, unserialize the actions, then figure out if there's anything we can use
  1020. while ($row = $smcFunc['db_fetch_assoc']($get_pm_rules))
  1021. {
  1022. // Turn this into an array...
  1023. $actions = unserialize($row['actions']);
  1024. // Loop through the actions and see if we're applying a label anywhere
  1025. foreach ($actions as $index => $action)
  1026. {
  1027. if ($action['t'] == 'lab')
  1028. {
  1029. // Update the value of this label...
  1030. $actions[$index]['v'] = $label_info_2[$row['id_member']][$action['v']];
  1031. }
  1032. }
  1033. // Put this back into a string
  1034. $actions = serialize($actions);
  1035. $smcFunc['db_query']('', '
  1036. UPDATE {db_prefix}pm_rules
  1037. SET actions = {string:actions}
  1038. WHERE id_rule = {int:id_rule}',
  1039. array(
  1040. 'actions' => $actions,
  1041. 'id_rule' => $row['id_rule'],
  1042. )
  1043. );
  1044. }
  1045. $smcFunc['db_free_result']($get_pm_rules);
  1046. // Lastly, we drop the old columns
  1047. $smcFunc['db_remove_column']('{db_prefix}members', 'message_labels');
  1048. $smcFunc['db_remove_column']('{db_prefix}pm_recipients', 'labels');
  1049. }
  1050. }
  1051. ******************************************************************************/
  1052. --- Adding support for edit reasons
  1053. /******************************************************************************/
  1054. ---# Adding "modified_reason" column to messages
  1055. ALTER TABLE {$db_prefix}messages
  1056. ADD COLUMN modified_reason varchar(255) NOT NULL default '';
  1057. ---#
  1058. /******************************************************************************/
  1059. --- Cleaning up guest permissions
  1060. /******************************************************************************/
  1061. ---# Removing permissions guests can no longer have...
  1062. ---{
  1063. $illegal_board_permissions = array(
  1064. 'announce_topic',
  1065. 'delete_any',
  1066. 'lock_any',
  1067. 'make_sticky',
  1068. 'merge_any',
  1069. 'modify_any',
  1070. 'modify_replies',
  1071. 'move_any',
  1072. 'poll_add_any',
  1073. 'poll_edit_any',
  1074. 'poll_lock_any',
  1075. 'poll_remove_any',
  1076. 'remove_any',
  1077. 'report_any',
  1078. 'split_any'
  1079. );
  1080. $illegal_permissions = array('calendar_edit_any', 'moderate_board', 'moderate_forum', 'send_email_to_members');
  1081. $smcFunc['db_query']('', '
  1082. DELETE FROM {db_prefix}board_permissions
  1083. WHERE id_group = {int:guests}
  1084. AND permission IN ({array_string:illegal_board_perms})',
  1085. array(
  1086. 'guests' => -1,
  1087. 'illegal_board_perms' => $illegal_board_permissions,
  1088. )
  1089. );
  1090. $smcFunc['db_query']('', '
  1091. DELETE FROM {db_prefix}permissions
  1092. WHERE id_group = {int:guests}
  1093. AND permission IN ({array_string:illegal_perms})',
  1094. array(
  1095. 'guests' => -1,
  1096. 'illegal_perms' => $illegal_permissions,
  1097. )
  1098. );
  1099. ---}
  1100. ---#
  1101. /******************************************************************************/
  1102. --- Adding mail queue settings
  1103. /******************************************************************************/
  1104. ---#
  1105. ---{
  1106. if (empty($modSettings['mail_limit']))
  1107. {
  1108. $smcFunc['db_insert']('replace',
  1109. '{db_prefix}settings',
  1110. array('variable' => 'string-255', 'value' => 'string'),
  1111. array(
  1112. array('mail_limit', '5'),
  1113. array('mail_quantity', '5'),
  1114. ),
  1115. array('variable')
  1116. );
  1117. }
  1118. ---}
  1119. ---#