upgrade_2-1_sqlite.sql 39 KB

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