From bd966915eefffb4f5d8c4597a74037ec0e84532c Mon Sep 17 00:00:00 2001
From: denise <denise@denise-DX4860.(none)>
Date: Fri, 10 Aug 2012 11:56:01 -0400
Subject: [PATCH] CC-4207: Smart Playlists: Criteria is lost on 'Shuffle' click

-fixed
---
 .../application/controllers/PlaylistController.php    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php
index 07f1eee21..424f13883 100644
--- a/airtime_mvc/application/controllers/PlaylistController.php
+++ b/airtime_mvc/application/controllers/PlaylistController.php
@@ -565,8 +565,15 @@ class PlaylistController extends Zend_Controller_Action
     {
         $request = $this->getRequest();
         $params = $request->getPost();
-        $bl = new Application_Model_Block($params['obj_id']);
-        $result = $bl->shuffleSmartBlock();
+        $bl = new Application_Model_Block($params['obj_id']);
+        
+        //we need to save criteria in case user hasn't clicked Save or Generate yet
+        $result = $bl->saveSmartBlockCriteria($params['data']);
+        
+        //only shuffle if there are no criteria errors
+        if ($result['result'] == 0) {
+            $result = $bl->shuffleSmartBlock();
+        }
         if ($result['result'] == 0) {
             try {
                 die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));