function forGroup($group)
 {
     $gps = Group_privacy_settings::getKV('group_id', $group->id);
     if (empty($gps)) {
         // make a fake one with defaults
         $gps = new Group_privacy_settings();
         $gps->allow_privacy = Group_privacy_settings::SOMETIMES;
         $gps->allow_sender = Group_privacy_settings::MEMBER;
     }
     return $gps;
 }
 function onEndGroupSaveForm(Action $action)
 {
     // The Action class must contain this method
     assert(is_callable(array($action, 'getGroup')));
     $gps = null;
     if ($action->getGroup() instanceof User_group) {
         $gps = Group_privacy_settings::getKV('group_id', $action->getGroup()->id);
     }
     $orig = null;
     if (empty($gps)) {
         $gps = new Group_privacy_settings();
         $gps->group_id = $action->getGroup()->id;
     } else {
         $orig = clone $gps;
     }
     $gps->allow_privacy = $action->trimmed('allow_privacy');
     $gps->allow_sender = $action->trimmed('allow_sender');
     if (empty($orig)) {
         $gps->created = common_sql_now();
         $gps->insert();
     } else {
         $gps->update($orig);
     }
     return true;
 }