Created
February 20, 2012 15:31
-
-
Save kamermans/1869680 to your computer and use it in GitHub Desktop.
Subscribe all phpBB3 moderators to all forums/topics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/** | |
* This script subscribes all global moderators to all forums. | |
* Put this in your phpBB3 directory and do "chmod 0700 auto_subscribe_moderators.php" | |
* You can use crontab to run this script so your moderators stay subscribed! | |
*/ | |
// Path to the phpBB3 Config Script | |
require dirname(__FILE__).'/config.php'; | |
$dbcon = new mysqli($dbhost, $dbuser, $dbpasswd, $dbname); | |
if (mysqli_connect_errno()) { | |
printf("Connect failed: %s\n", mysqli_connect_error()); | |
exit(1); | |
} | |
$query =<<<EOL | |
INSERT INTO phpbb_forums_watch (forum_id, user_id, notify_status) | |
SELECT f.forum_id, u.user_id, 0 | |
/* You can run the query below with this SELECT statement to see what would be added: | |
SELECT u.username, u.user_id, f.forum_id, f.forum_name | |
*/ | |
FROM phpbb_users u | |
INNER JOIN phpbb_user_group ug ON u.user_id = ug.user_id | |
INNER JOIN phpbb_groups g ON ug.group_id = g.group_id | |
INNER JOIN phpbb_forums f | |
LEFT JOIN phpbb_forums_watch w ON f.forum_id = w.forum_id AND u.user_id = w.user_id | |
/* Specify the users from this group will be added */ | |
WHERE g.group_name = 'GLOBAL_MODERATORS' | |
/* If you leave the next line commented out, users will be subscribed to all forums */ | |
/* AND f.forum_name = 'Exact Forum Name' */ | |
AND w.forum_id IS NULL | |
ORDER BY u.user_id, f.forum_id | |
EOL; | |
if (!$dbcon->query($query)) { | |
printf("Query Error: %s\n", $dbcon->error); | |
exit(1); | |
} | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment