upgrade_2-1_postgresql.sql 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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 smallint 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');
  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. ---# Adding "profile_password_own"
  801. ---{
  802. $inserts = array();
  803. $request = upgrade_query("
  804. SELECT id_group, add_deny
  805. FROM {$db_prefix}permissions
  806. WHERE permission = 'profile_identity_own'");
  807. while ($row = $smcFunc['db_fetch_assoc']($request))
  808. {
  809. $inserts[] = "($row[id_group], 'profile_password_own', $row[add_deny])";
  810. }
  811. $smcFunc['db_free_result']($request);
  812. if (!empty($inserts))
  813. {
  814. foreach ($inserts as $insert)
  815. {
  816. upgrade_query("
  817. INSERT INTO {$db_prefix}permissions
  818. (id_group, permission, add_deny)
  819. VALUES
  820. " . $insert);
  821. }
  822. }
  823. ---}
  824. ---#
  825. ---# Adding other profile permissions
  826. ---{
  827. $inserts = array();
  828. $request = upgrade_query("
  829. SELECT id_group, add_deny
  830. FROM {$db_prefix}permissions
  831. WHERE permission = 'profile_extra_own'");
  832. while ($row = $smcFunc['db_fetch_assoc']($request))
  833. {
  834. $inserts[] = "($row[id_group], 'profile_blurb_own', $row[add_deny])";
  835. $inserts[] = "($row[id_group], 'profile_displayed_name_own', $row[add_deny])";
  836. $inserts[] = "($row[id_group], 'profile_forum_own', $row[add_deny])";
  837. $inserts[] = "($row[id_group], 'profile_other_own', $row[add_deny])";
  838. $inserts[] = "($row[id_group], 'profile_signature_own', $row[add_deny])";
  839. }
  840. $smcFunc['db_free_result']($request);
  841. if (!empty($inserts))
  842. {
  843. foreach ($inserts as $insert)
  844. {
  845. upgrade_query("
  846. INSERT INTO {$db_prefix}permissions
  847. (id_group, permission, add_deny)
  848. VALUES
  849. " . $insert
  850. );
  851. }
  852. }
  853. ---}
  854. ---#
  855. /******************************************************************************/
  856. --- Upgrading PM labels...
  857. /******************************************************************************/
  858. ---# Creating pm_labels sequence...
  859. CREATE SEQUENCE {$db_prefix}pm_labels_sequence;
  860. ---#
  861. ---# Adding pm_labels table...
  862. CREATE TABLE {$db_prefix}pm_labels (
  863. id_label int NOT NULL default nextval('{$db_prefix}pm_labels_seq'),
  864. id_member int NOT NULL default '0',
  865. name varchar(30) NOT NULL default '',
  866. PRIMARY KEY (id_label)
  867. );
  868. ---#
  869. ---# Adding pm_labeled_messages table...
  870. CREATE TABLE {$db_prefix}pm_labeled_messages (
  871. id_label int NOT NULL default '0',
  872. id_pm int NOT NULL default '0',
  873. PRIMARY KEY (id_label, id_pm)
  874. );
  875. ---#
  876. ---# Adding "in_inbox" column to pm_recipients
  877. ALTER TABLE {$db_prefix}pm_recipients
  878. ADD COLUMN in_inbox smallint NOT NULL default '1';
  879. ---#
  880. ---# Moving label info to new tables and updating rules...
  881. ---{
  882. // First see if we still have a message_labels column
  883. $results = $smcFunc['db_list_columns']('{db_prefix}members', false);
  884. if (in_array('message_labels', $results))
  885. {
  886. // They've still got it, so pull the label info
  887. $get_labels = $smcFunc['db_query']('', '
  888. SELECT id_member, message_labels
  889. FROM {db_prefix}members
  890. WHERE message_labels != {string:blank}',
  891. array(
  892. 'blank' => '',
  893. )
  894. );
  895. $inserts = array();
  896. $label_info = array();
  897. while ($row = $smcFunc['db_fetch_assoc']($get_labels))
  898. {
  899. // Stick this in an array
  900. $labels = explode(',', $row['message_labels']);
  901. // Build some inserts
  902. foreach ($labels AS $index => $label)
  903. {
  904. // Keep track of the index of this label - we'll need that in a bit...
  905. $label_info[$row['id_member']][$label] = $index;
  906. $inserts[] = array($row['id_member'], $label);
  907. }
  908. }
  909. $smcFunc['db_free_result']($get_labels);
  910. if (!empty($inserts))
  911. {
  912. $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array());
  913. // Clear this out for our next query below
  914. $inserts = array();
  915. }
  916. // This is the easy part - update the inbox stuff
  917. $smcFunc['db_query']('', '
  918. UPDATE {db_prefix}pm_recipients
  919. SET in_inbox = {int:in_inbox}
  920. WHERE FIND_IN_SET({int:minus_one}, labels)',
  921. array(
  922. 'in_inbox' => 1,
  923. 'minus_one' => -1,
  924. )
  925. );
  926. // Now we go pull the new IDs for each label
  927. $get_new_label_ids = $smcFunc['db_query']('', '
  928. SELECT *
  929. FROM {db_prefix}pm_labels',
  930. array(
  931. )
  932. );
  933. $label_info_2 = array();
  934. while ($label_row = $smcFunc['db_fetch_assoc']($get_new_label_ids))
  935. {
  936. // Map the old index values to the new ID values...
  937. $old_index = $label_info[$row['id_member']][$row['label_name']];
  938. $label_info_2[$row['id_member']][$old_index] = $row['id_label'];
  939. }
  940. $smcFunc['db_free_result']($get_new_label_ids);
  941. // Pull label info from pm_recipients
  942. // Ignore any that are only in the inbox
  943. $get_pm_labels = $smcFunc['db_query']('', '
  944. SELECT id_pm, id_member, labels
  945. FROM {db_prefix}pm_recipients
  946. WHERE deleted = {int:not_deleted}
  947. AND labels != {string:minus_one}',
  948. array(
  949. 'not_deleted' => 0,
  950. 'minus_one' => -1,
  951. )
  952. );
  953. while ($row = $smcFunc['db_fetch_assoc']($get_pm_labels))
  954. {
  955. $labels = explode(',', $row['labels']);
  956. foreach ($labels as $a_label)
  957. {
  958. if ($a_label == '-1')
  959. continue;
  960. $new_label_info = $label_info_2[$row['id_member']][$a_label];
  961. $inserts[] = array($row['id_pm'], $new_label_info);
  962. }
  963. }
  964. $smcFunc['db_free_result']($get_pm_labels);
  965. // Insert the new data
  966. if (!empty($inserts))
  967. {
  968. $smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm' => 'int', 'id_label' => 'int'), $inserts, array());
  969. }
  970. // Final step of this ridiculously massive process
  971. $get_pm_rules = $smcFunc['db_query']('', '
  972. SELECT id_member, id_rule, actions
  973. FROM {db_prefix}pm_rules',
  974. array(
  975. ),
  976. );
  977. // Go through the rules, unserialize the actions, then figure out if there's anything we can use
  978. while ($row = $smcFunc['db_fetch_assoc']($get_pm_rules))
  979. {
  980. // Turn this into an array...
  981. $actions = unserialize($row['actions']);
  982. // Loop through the actions and see if we're applying a label anywhere
  983. foreach ($actions as $index => $action)
  984. {
  985. if ($action['t'] == 'lab')
  986. {
  987. // Update the value of this label...
  988. $actions[$index]['v'] = $label_info_2[$row['id_member']][$action['v']];
  989. }
  990. }
  991. // Put this back into a string
  992. $actions = serialize($actions);
  993. $smcFunc['db_query']('', '
  994. UPDATE {db_prefix}pm_rules
  995. SET actions = {string:actions}
  996. WHERE id_rule = {int:id_rule}',
  997. array(
  998. 'actions' => $actions,
  999. 'id_rule' => $row['id_rule'],
  1000. )
  1001. );
  1002. }
  1003. $smcFunc['db_free_result']($get_pm_rules);
  1004. // Lastly, we drop the old columns
  1005. $smcFunc['db_remove_column']('{db_prefix}members', 'message_labels');
  1006. $smcFunc['db_remove_column']('{db_prefix}pm_recipients', 'labels');
  1007. }
  1008. }
  1009. /******************************************************************************/
  1010. --- Adding support for edit reasons
  1011. /******************************************************************************/
  1012. ---# Adding "modified_reason" column to messages
  1013. ALTER TABLE {$db_prefix}messages
  1014. ADD COLUMN modified_reason varchar(255) NOT NULL default '';
  1015. ---#
  1016. /******************************************************************************/
  1017. --- Cleaning up guest permissions
  1018. /******************************************************************************/
  1019. ---# Removing permissions guests can no longer have...
  1020. ---{
  1021. $illegal_board_permissions = array(
  1022. 'announce_topic',
  1023. 'delete_any',
  1024. 'lock_any',
  1025. 'make_sticky',
  1026. 'merge_any',
  1027. 'modify_any',
  1028. 'modify_replies',
  1029. 'move_any',
  1030. 'poll_add_any',
  1031. 'poll_edit_any',
  1032. 'poll_lock_any',
  1033. 'poll_remove_any',
  1034. 'remove_any',
  1035. 'report_any',
  1036. 'split_any'
  1037. );
  1038. $illegal_permissions = array('calendar_edit_any', 'moderate_board', 'moderate_forum', 'send_email_to_members');
  1039. $smcFunc['db_query']('', '
  1040. DELETE FROM {db_prefix}board_permissions
  1041. WHERE id_group = {int:guests}
  1042. AND permission IN ({array_string:illegal_board_perms})',
  1043. array(
  1044. 'guests' => -1,
  1045. 'illegal_board_perms' => $illegal_board_permissions,
  1046. )
  1047. );
  1048. $smcFunc['db_query']('', '
  1049. DELETE FROM {db_prefix}permissions
  1050. WHERE id_group = {int:guests}
  1051. AND permission IN ({array_string:illegal_perms})',
  1052. array(
  1053. 'guests' => -1,
  1054. 'illegal_perms' => $illegal_permissions,
  1055. )
  1056. );
  1057. ---}
  1058. ---#
  1059. /******************************************************************************/
  1060. --- Adding mail queue settings
  1061. /******************************************************************************/
  1062. ---#
  1063. ---{
  1064. if (empty($modSettings['mail_limit']))
  1065. {
  1066. $smcFunc['db_insert']('replace',
  1067. '{db_prefix}settings',
  1068. array('variable' => 'string-255', 'value' => 'string'),
  1069. array(
  1070. array('mail_limit', '5'),
  1071. array('mail_quantity', '5'),
  1072. ),
  1073. array('variable')
  1074. );
  1075. }
  1076. ---}
  1077. ---#