Index: admin/media.php
===================================================================
--- admin/media.php	(revision 2751)
+++ admin/media.php	(revision 2764)
@@ -75,6 +75,6 @@
 $popup = (integer) !empty($_GET['popup']);
 
-$page_url = $core->adminurl->get("admin.media",array('popup' => $popup,'post_id' => $post_id, 'plugin_id' => $plugin_id));
-if (($temp = $core->callBehavior('adminMediaURL',$page_url))!='') {
+$page_url = $core->adminurl->get("admin.media",array('popup' => $popup,'post_id' => $post_id));
+if (($temp = $core->callBehavior('adminMediaURL',$page_url.'&plugin_id='.$plugin_id))!='') {
 	$page_url = $temp;
 }
@@ -137,5 +137,5 @@
 			html::escapeHTML($_POST['newdir']))
 		);
-		http::redirect($page_url.'&d='.rawurlencode($d));
+		http::redirect($page_url.'&plugin_id='.$plugin_id.'&d='.rawurlencode($d));
 	} catch (Exception $e) {
 		$core->error->add($e->getMessage());
@@ -164,5 +164,5 @@
 				'name' => $upfile['name'],
 				'size' => $upfile['size'],
-				'html' => mediaItemLine($core->media->getFile($new_file_id), 1, $plugin_id)
+				'html' => mediaItemLine($core->media->getFile($new_file_id), 1)
 			);
 		} catch (Exception $e) {
@@ -184,5 +184,5 @@
 
 			dcPage::addSuccessNotice(__('Files have been successfully uploaded.'));
-			http::redirect($page_url.'&d='.rawurlencode($d));
+			http::redirect($page_url.'&plugin_id='.$plugin_id.'&d='.rawurlencode($d));
 		} catch (Exception $e) {
 			$core->error->add($e->getMessage());
@@ -205,5 +205,5 @@
 			)
 		);
-		http::redirect($page_url.'&d='.rawurlencode($d));
+		http::redirect($page_url.'&plugin_id='.$plugin_id.'&d='.rawurlencode($d));
 	} catch (Exception $e) {
 		$core->error->add($e->getMessage());
@@ -224,5 +224,5 @@
 		$core->media->removeItem($_POST['remove']);
 		dcPage::addSuccessNotice($msg);
-		http::redirect($page_url.'&d='.rawurlencode($d));
+		http::redirect($page_url.'&plugin_id='.$plugin_id.'&d='.rawurlencode($d));
 	} catch (Exception $e) {
 		$core->error->add($e->getMessage());
@@ -240,5 +240,5 @@
 			html::escapeHTML($d))
 		);
-		http::redirect($page_url.'&d='.rawurlencode($d));
+		http::redirect($page_url.'&plugin_id='.$plugin_id.'&d='.rawurlencode($d));
 	} catch (Exception $e) {
 		$core->error->add($e->getMessage());
@@ -289,5 +289,5 @@
 	);
 } else {
-	$breadcrumb_media = $core->media->breadCrumb(html::escapeURL($page_url).'&amp;d=%s','<span class="page-title">%s</span>');
+	$breadcrumb_media = $core->media->breadCrumb(html::escapeURL($page_url).'&amp;plugin_id='.$plugin_id.'&amp;d=%s','<span class="page-title">%s</span>');
 	if ($breadcrumb_media == '') {
 		$breadcrumb = dcPage::breadcrumb(
@@ -302,5 +302,5 @@
 			array(
 				html::escapeHTML($core->blog->name) => '',
-				__('Media manager') => html::escapeURL($page_url.'&d='),
+				__('Media manager') => html::escapeURL($page_url.'&plugin_id='.$plugin_id.'&d='),
 				$breadcrumb_media => ''
 			),
@@ -423,7 +423,7 @@
 	{
 		if ($items[$i]->d) {
-			$dgroup .= mediaItemLine($items[$i],$j,$plugin_id);
+			$dgroup .= mediaItemLine($items[$i],$j);
 		} else {
-			$fgroup .= mediaItemLine($items[$i],$j,$plugin_id);
+			$fgroup .= mediaItemLine($items[$i],$j);
 		}
 	}
@@ -466,5 +466,6 @@
 		form::field(array('newdir','newdir'),35,255).'</p>'.
 		'<p><input type="submit" value="'.__('Create').'" />'.
-		form::hidden(array('d'),html::escapeHTML($d)).'</p>'.
+		form::hidden(array('d'),html::escapeHTML($d)).
+		form::hidden(array('plugin_id'),$plugin_id).'</p>'.
 		'</div>'.
 		'</form>';
@@ -546,5 +547,5 @@
 '<div>'.
 form::hidden('rmyes',1).form::hidden('d',html::escapeHTML($d)).
-form::hidden('remove','').
+form::hidden(array('plugin_id'),$plugin_id).form::hidden('remove','').
 $core->formNonce().
 '</div>'.
@@ -564,7 +565,7 @@
 
 /* ----------------------------------------------------- */
-function mediaItemLine($f,$i,$plugin_id)
-{
-	global $core, $page_url, $popup, $post_id;
+function mediaItemLine($f,$i)
+{
+	global $core, $page_url, $popup, $post_id, $plugin_id;
 
 	$fname = $f->basename;
@@ -573,5 +574,5 @@
 
 	if ($f->d) {
-		$link = html::escapeURL($page_url).'&amp;d='.html::sanitizeURL($f->relname);
+		$link = html::escapeURL($page_url).'&amp;plugin_id='.$plugin_id.'&amp;d='.html::sanitizeURL($f->relname);
 		if ($f->parent) {
 			$fname = '..';
@@ -636,5 +637,5 @@
 		} else {
 			$act .= '<a class="media-remove" '.
-			'href="'.html::escapeURL($page_url).'&amp;d='.
+			'href="'.html::escapeURL($page_url).'&amp;plugin_id='.$plugin_id.'&amp;d='.
 			rawurlencode($GLOBALS['d']).'&amp;remove='.rawurlencode($f->basename).'">'.
 			'<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>';
