From defaa3b332c74741bb6df129cc51df825986a08b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Nov 2010 13:26:42 -0800 Subject: clear_jabber.php script to clear confirmed jabber/xmpp addresses from one or more accounts --- scripts/clear_jabber.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 scripts/clear_jabber.php diff --git a/scripts/clear_jabber.php b/scripts/clear_jabber.php new file mode 100755 index 000000000..5ec53caf0 --- /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"; -- cgit v1.2.3