Code

Updated releaseSelector to generate unique pids
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 15:24:46 +0000 (15:24 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 15:24:46 +0000 (15:24 +0000)
-We can now have two widgets on a single site.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20108 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_releaseSelector.inc

index 1f4f2e2db4115060ac841b0948ada7af09c0a523..5e8d934f211c34e08c2ccef9ce4f35c9ba773f31 100644 (file)
@@ -38,6 +38,28 @@ class releaseSelector {
         // Initialize pid
         $this->pid= preg_replace("/[^0-9]/", "", microtime(TRUE));
 
+        // Get list of used IDs
+        if(!session::is_set('releaseSelector_USED_IDS')){
+            session::set('releaseSelector_USED_IDS',array());
+        }
+        $usedIds = session::get('releaseSelector_USED_IDS');
+
+        // Generate instance wide unique ID
+        $pid = "";
+        while($pid == "" || in_array($pid, $usedIds)){
+
+            // Wait 1 msec to ensure that we definately get a new id
+            if($pid != "") usleep(1);
+            $tmp= gettimeofday();
+            $pid =  'l'.md5(microtime().$tmp['sec']);
+        }
+
+        // Only keep the last 10 list IDsi
+        $usedIds = array_slice($usedIds, count($usedIds) -10, 10);
+        $usedIds[] = $pid;
+        session::set('releaseSelector_USED_IDS',$usedIds);
+        $this->pid = $pid;
+
         // Transfer data
         $this->releaseBase = $releaseBase; 
         $this->setBases($bases);