{site}.inc.php is the base for all jobs.
[platal.git] / include / vcard.inc.php
index f858b8a..a4366fc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -84,7 +84,7 @@ class VCardIterator implements PlIterator
              INNER JOIN auth_user_quick  ON ( user_id = {?} AND emails_alias_pub = 'public' )
                   WHERE ( redirect={?} OR redirect={?} )
                         AND alias LIKE '%@{$globals->mail->alias_dom}'",
-                S::v('uid'),
+                $user['user_id'],
                 $user['forlife'].'@'.$globals->mail->domain,
                 $user['forlife'].'@'.$globals->mail->domain2);
 
@@ -127,9 +127,9 @@ class VCard
     public static function escape($text)
     {
         if (VCard::$windows) {
-            return preg_replace('/;/', '\\\\$0', $text);
+            return str_replace(';', '\\\\;', $text);
         } else {
-            return preg_replace('/[,;]/', '\\\\$0', $text);
+            return str_replace(array(';', ','), array('\\\\;', '\\\\,'), $text);
         }
     }
 
@@ -141,11 +141,11 @@ class VCard
         $adr = trim("$adr\n$adr2");
         $adr = trim("$adr\n$adr3");
         return VCard::text_encode(';;'
-                . VCard::escape($adr) . ';'
-                . VCard::escape($city) . ';'
-                . VCard::escape($region) . ';'
-                . VCard::escape($postcode) . ';'
-                . VCard::escape($country), false);
+                . (VCard::$windows ? VCard::escape($adr) : $adr) . ';'
+                . (VCard::$windows ? VCard::escape($city) : $city) . ';'
+                . (VCard::$windows ? VCard::escape($region) : $region) . ';'
+                . (VCard::$windows ? VCard::escape($postcode) : $postcode) . ';'
+                . (VCard::$windows ? VCard::escape($country) : $country), false);
     }
 
     public static function text_encode($text, $escape = true)
@@ -159,7 +159,7 @@ class VCard
         if (VCard::$windows) {
             $text = utf8_decode($text);
         }
-        return preg_replace("/(\r\n|\n|\r)/", '\n', $text);
+        return str_replace(array("\r\n", "\n", "\r"), '\n', $text);
     }
 
     public function do_page(&$page)