upgrade_2-1_postgresql.sql 38 KB

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