diff --git a/scripts/clear_jabber.php b/scripts/clear_jabber.php new file mode 100755 index 0000000000..5ec53caf0e --- /dev/null +++ b/scripts/clear_jabber.php @@ -0,0 +1,92 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i::n::y'; +$longoptions = array('id=', 'nickname=', 'yes', 'all', 'dry-run'); + +$helptext = <<whereAdd("jabber != ''"); + $user->find(true); + if ($user->N == 0) { + print "No users with registered Jabber addresses in database.\n"; + exit(1); + } +} else { + print "You must provide either an ID or a nickname.\n"; + print "\n"; + print $helptext; + exit(1); +} + +function clear_jabber($id) +{ + $user = User::staticGet('id', $id); + if ($user && $user->jabber) { + echo "clearing user $id's user.jabber, was: $user->jabber"; + if (have_option('dry-run')) { + echo " (SKIPPING)"; + } else { + $original = clone($user); + $user->jabber = null; + $result = $user->updateKeys($original); + } + echo "\n"; + } else if (!$user) { + echo "Missing user for $id\n"; + } else { + echo "Cleared jabber already for $id\n"; + } +} + +do { + clear_jabber($user->id); +} while ($user->fetch()); + +print "DONE.\n";