From 817fe1353392f11c05b84d44b118fd0e20a11991 Mon Sep 17 00:00:00 2001
From: denise <denise@denise-DX4860.(none)>
Date: Fri, 17 Aug 2012 15:56:16 -0400
Subject: [PATCH] CC-4248: Playlist Builder: 'Something went wrong' error
 message when dragging playlist into playlist

-fixed
---
 .../controllers/PlaylistController.php           | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php
index 94e90744d..aa9dcd2f0 100644
--- a/airtime_mvc/application/controllers/PlaylistController.php
+++ b/airtime_mvc/application/controllers/PlaylistController.php
@@ -155,6 +155,11 @@ class PlaylistController extends Zend_Controller_Action
         $this->view->error = "You can only add tracks to smart playlists.";
         $this->createFullResponse($obj);
     }
+    
+    private function wrongTypeToPlaylist($obj) {
+        $this->view->error = "You can only add tracks and smart playlists to playlists.";
+        $this->createFullResponse($obj);
+    }
 
     public function indexAction()
     {
@@ -308,6 +313,13 @@ class PlaylistController extends Zend_Controller_Action
         try {
             $obj = $this->getPlaylist($obj_type);
             if ($obj_type == 'playlist') {
+                foreach($ids as $id) {
+                    if (is_array($id) && isset($id[1])) {
+                        if ($id[1] == 'playlist') {
+                            throw new WrongTypeToPlaylistException;
+                        }
+                    }
+                }
                 $obj->addAudioClips($ids, $afterItem, $addType);
             } else if ($obj->isStatic()) {
                 // if the dest is a block object
@@ -334,6 +346,9 @@ class PlaylistController extends Zend_Controller_Action
         catch (WrongTypeToBlockException $e) {
             $this->wrongTypeToBlock($obj);
         }
+        catch (WrongTypeToPlaylistException $e) {
+            $this->wrongTypeToPlaylist($obj);
+        }
         catch (BlockDynamicException $e) {
             $this->blockDynamic($obj);
         }
@@ -609,4 +624,5 @@ class PlaylistController extends Zend_Controller_Action
     }
 }
 class WrongTypeToBlockException extends Exception {}
+class WrongTypeToPlaylistException extends Exception {}
 class BlockDynamicException extends Exception {}