Use Horde_Support_Guid.
authorJan Schneider <jan@horde.org>
Tue, 8 Sep 2009 21:59:44 +0000 (23:59 +0200)
committerJan Schneider <jan@horde.org>
Thu, 10 Sep 2009 21:16:37 +0000 (23:16 +0200)
kronolith/lib/Driver.php
kronolith/lib/Driver/Sql.php

index 823f4b1..e0e5f30 100644 (file)
@@ -92,21 +92,6 @@ class Kronolith_Driver
     }
 
     /**
-     * Generates a universal / unique identifier for a task.
-     *
-     * This is NOT something that we expect to be able to parse into a
-     * calendar and an event id.
-     *
-     * @return string  A nice unique string (should be 255 chars or less).
-     */
-    public function generateUID()
-    {
-        return date('YmdHis') . '.'
-            . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
-            . '@' . $GLOBALS['conf']['server']['name'];
-    }
-
-    /**
      * Renames a calendar.
      *
      * @param string $from  The current name of the calendar.
index fb0c1d7..1fc3328 100644 (file)
@@ -361,7 +361,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
             /* If the event did not have a UID before, we need to give
              * it one. */
             if (empty($row['event_uid'])) {
-                $row['event_uid'] = $this->generateUID();
+                $row['event_uid'] = (string)new Horde_Support_Guid;
 
                 /* Save the new UID for data integrity. */
                 $query = 'UPDATE ' . $this->_params['table'] . ' SET event_uid = ? WHERE event_id = ?';
@@ -597,7 +597,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
             if ($event->getUID()) {
                 $uid = $event->getUID();
             } else {
-                $uid = $this->generateUID();
+                $uid = (string)new Horde_Support_Guid;
                 $event->setUID($uid);
             }