          AND NOT EXISTS( SELECT 1 FROM relationship r3 WHERE r3.from_user = r1.to_user ) ;
 
   IF FOUND THEN
-    -- dbg := ''H-'';
-    -- RAISE NOTICE ''Permissions to shared group % '', out_confers;
+    -- dbg := 'H-';
+    -- RAISE NOTICE 'Permissions to shared group % ', out_confers;
     RETURN dbg || out_confers;
   END IF;
 
-  -- RAISE NOTICE ''No common group relationships between % and %'', in_from, in_to;
-
-  RETURN '''';
-END;
-' LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+  -- RAISE NOTICE 'No common group relationships between % and %', in_from, in_to;
+
+  RETURN '';
+END;
+$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
 
 
 -- Function to convert a PostgreSQL date into UTC + the format used by iCalendar
-CREATE or REPLACE FUNCTION to_ical_utc( TIMESTAMP WITH TIME ZONE ) RETURNS TEXT AS '
-  SELECT to_char( $1 at time zone ''UTC'', ''YYYYMMDD"T"HH24MISS"Z"'' )
-' LANGUAGE 'sql' IMMUTABLE STRICT;
+CREATE or REPLACE FUNCTION to_ical_utc( TIMESTAMP WITH TIME ZONE ) RETURNS TEXT AS $$
+  SELECT to_char( $1 at time zone 'UTC', 'YYYYMMDD"T"HH24MISS"Z"' )
+$$ LANGUAGE 'sql' IMMUTABLE STRICT;
 
 -- Function to set an arbitrary DAV property
-CREATE or REPLACE FUNCTION set_dav_property( TEXT, INTEGER, TEXT, TEXT ) RETURNS BOOLEAN AS '
+CREATE or REPLACE FUNCTION set_dav_property( TEXT, INTEGER, TEXT, TEXT ) RETURNS BOOLEAN AS $$
 DECLARE
   path ALIAS FOR $1;
   user ALIAS FOR $2;

      END IF;
    END LOOP;
  END LOOP;
  IF out_confers ~* ''A'' OR (out_confers ~* ''B'' AND out_confers ~* ''F'' AND out_confers ~* ''R'' AND out_confers ~* ''W'' AND out_confers ~* ''U'') THEN
    out_confers := ''A'';
  END IF;
  IF out_confers != '''' THEN
    RETURN dbg || out_confers;
  END IF;

  -- RAISE NOTICE ''No complex relationships between % and %'', in_from, in_to;

  SELECT rt1.confers INTO out_confers, tmp_confers1 FROM relationship r1 JOIN relationship_type rt1 ON ( r1.rt_id = rt1.rt_id )
              LEFT OUTER JOIN relationship r2 ON ( rt1.rt_id = r2.rt_id )


    -- Having calculated the right day of the month, we now apply that back to in_time
    -- which contains the otherwise-unobtainable timezone detail (and the time)
    our_answer = our_answer - (dd::text || 'days')::interval;
    dd := extract( 'day' from our_answer) - extract( 'day' from in_time);
    our_answer := in_time + (dd::text || 'days')::interval;

    IF weeks > 1 THEN
      weeks := weeks - 1;
      our_answer := our_answer - (weeks::text || 'weeks')::interval;
    END IF;

  ELSE

    -- Shift our date to the correct day of week..
    our_dow := extract( 'dow' from in_time);
    our_dow := our_dow - dow;
    dd := extract( 'day' from in_time);
    IF our_dow >= dd THEN
      our_dow := our_dow - 7;
    END IF;
    our_answer := in_time - (our_dow::text || 'days')::interval;
    dd = extract( 'day' from our_answer);

    -- Shift the date to the correct week...
    dd := weeks - ((dd+6) / 7);
    IF dd != 0 THEN
      our_answer := our_answer + ((dd::text || 'weeks')::interval);
    END IF;

  END IF;
