#!/usr/bin/env php . */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'i:n:a'; $longoptions = array('id=', 'nickname=', 'all', 'dry-run'); $helptext = <<whereAdd('uri IS NULL'); if ($group->find()) { while ($group->fetch()) { updateGroupUri($group); } } } else { show_help(); exit(1); } } catch (Exception $e) { print $e->getMessage()."\n"; exit(1); } function updateGroupUri($group) { if (!have_option('q', 'quiet')) { print "Updating URI for group '".$group->nickname."' (".$group->id.")..."; } if (empty($group->uri)) { // Using clone here was screwing up the group->find() iteration $orig = User_group::staticGet('id', $group->id); $group->uri = $group->getUri(); if (have_option('dry_run')) { echo " would have set $group->uri "; } else { if (!$group->update($orig)) { throw new Exception("Can't update uri for group " . $group->nickname . "."); } echo " set $group->uri "; } } else { print " already set, keeping $group->uri "; } if (have_option('v', 'verbose')) { print "DONE."; } if (!have_option('q', 'quiet') || have_option('v', 'verbose')) { print "\n"; } }