From: hickert Date: Wed, 20 Oct 2010 15:24:46 +0000 (+0000) Subject: Updated releaseSelector to generate unique pids X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bd0bc970568bcf5fc5c3e877e533ad8aa6ecd46e;p=gosa.git Updated releaseSelector to generate unique pids -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 --- diff --git a/gosa-core/include/class_releaseSelector.inc b/gosa-core/include/class_releaseSelector.inc index 1f4f2e2db..5e8d934f2 100644 --- a/gosa-core/include/class_releaseSelector.inc +++ b/gosa-core/include/class_releaseSelector.inc @@ -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);