From e1b6ee8d46e31c89cb0750b4d564795096bd4cdf Mon Sep 17 00:00:00 2001
From: naomiaro <naomiaro@gmail.com>
Date: Thu, 11 Nov 2010 20:48:53 -0500
Subject: [PATCH] propel changes for playlist.

---
 backend/Playlist.php                          | 11 +--
 .../build/classes/campcaster/CcFiles.php      | 16 +++--
 .../classes/campcaster/CcPlaylistcontents.php | 70 +++++++++++--------
 .../build/classes/campcaster/Common.php       | 36 +++-------
 4 files changed, 66 insertions(+), 67 deletions(-)

diff --git a/backend/Playlist.php b/backend/Playlist.php
index 3babc461e..ce4b0601e 100644
--- a/backend/Playlist.php
+++ b/backend/Playlist.php
@@ -67,7 +67,8 @@ class Playlist {
          // Create the StoredPlaylist object
         $storedPlaylist = new Playlist();
         $storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s");
-    	$storedPlaylist->mtime = new DateTime("now");
+        $tz = ini_get('date.timezone');
+    	$storedPlaylist->mtime = new DateTime("now", new DateTimeZone($tz));
     
     	$pl = new CcPlaylist();
     	$pl->setDbName($storedPlaylist->name);
@@ -131,7 +132,7 @@ class Playlist {
     	    return FALSE;
     
     	$pl->setDbName($p_newname);
-    	$pl->setDbMtime(new DateTime("now"));
+    	$pl->setDbMtime(new DateTime("now", new DateTimeZone(ini_get('date.timezone'))));
     	$pl->save();
 
         $this->name = $p_newname;
@@ -174,7 +175,7 @@ class Playlist {
     	    return FALSE;  	
     	 
     	$pl->setDbState($p_state);
-    	$pl->setDbMtime(new DateTime("now"));
+    	$pl->setDbMtime(new DateTime("now", new DateTimeZone(ini_get('date.timezone'))));
     	
     	$eb = (!is_null($p_editedby) ? $p_editedby : NULL);
     	$pl->setDbEditedby($eb);
@@ -929,12 +930,14 @@ class Playlist {
         $row->setDbPlaylistId($plId);
         $row->setDbFileId($fileId);
         $row->setDbPosition($pos);
+        $row->save();
+        
         $row->setDbCliplength($clipLength);
         $row->setDbCuein($cuein);
         $row->setDbCueout($cueout);
         $row->setDbFadein($fadeIn);
         $row->setDbFadeout($fadeOut);
-        $row->save();
+        
 
         return TRUE;
     }
diff --git a/backend/propel-db/build/classes/campcaster/CcFiles.php b/backend/propel-db/build/classes/campcaster/CcFiles.php
index 6495e1ce7..edc51a659 100644
--- a/backend/propel-db/build/classes/campcaster/CcFiles.php
+++ b/backend/propel-db/build/classes/campcaster/CcFiles.php
@@ -16,14 +16,16 @@ require_once('Common.php');
 class CcFiles extends BaseCcFiles {
 
 	public function getDbLength()
-        {
-                return Common::getTimeInSub($this, 'LENGTH');
-        }
+    {
+        return $this->length;
+    }
 
-        public function setDbLength($time)
-        {
-                return Common::setTimeInSub($this, 'LENGTH', $time);
-        }
+    public function setDbLength($time)
+    {
+		$this->length = $time;
+		//$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH;
+        return Common::setTimeInSub($this, 'LENGTH', $time);
+    }
 
 
 } // CcFiles
diff --git a/backend/propel-db/build/classes/campcaster/CcPlaylistcontents.php b/backend/propel-db/build/classes/campcaster/CcPlaylistcontents.php
index e3f3bd45e..53b54fde1 100644
--- a/backend/propel-db/build/classes/campcaster/CcPlaylistcontents.php
+++ b/backend/propel-db/build/classes/campcaster/CcPlaylistcontents.php
@@ -17,53 +17,63 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
 
 	public function getDbFadein()
 	{
-		return Common::getTimeInSub($this, 'FADEIN');
+		return $this->fadein;
 	}
 
 	public function setDbFadein($time)
-        {
-                return Common::setTimeInSub($this, 'FADEIN', $time);
-        }
+    {
+		$this->fadein = $time;
+		//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
+        return Common::setTimeInSub($this, 'FADEIN', $time);
+    }
 
 	public function getDbFadeout()
-        {
-                return Common::getTimeInSub($this, 'FADEOUT');
-        }
+    {
+        return $this->fadeout;
+    }
 
 	public function setDbFadeout($time)
-        {
-                return Common::setTimeInSub($this, 'FADEOUT', $time);
-        }
+    {
+		$this->fadeout = $time;
+		//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
+        return Common::setTimeInSub($this, 'FADEOUT', $time);
+    }
 
 	public function getDbCuein()
-        {
-                return Common::getTimeInSub($this, 'CUEIN');
-        }
+    {
+        return $this->cuein;
+    }
 
 	public function setDbCuein($time)
-        {
-                return Common::setTimeInSub($this, 'CUEIN', $time);
-        }
+    {
+		$this->cuein = $time;
+		//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
+        return Common::setTimeInSub($this, 'CUEIN', $time);
+    }
 
 	public function getDbCueout()
-        {
-                return Common::getTimeInSub($this, 'CUEOUT');
-        }
+    {
+        return $this->cueout;
+    }
 
-        public function setDbCueout($time)
-        {
-                return Common::setTimeInSub($this, 'CUEOUT', $time);
-        }
+    public function setDbCueout($time)
+    {
+		$this->cueout = $time;
+		//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
+        return Common::setTimeInSub($this, 'CUEOUT', $time);
+    }
 
 	public function getDbCliplength()
-        {
-                return Common::getTimeInSub($this, 'CLIPLENGTH');
-        }
+    {
+        return $this->cliplength;
+    }
 
-        public function setDbCliplength($time)
-        {
-                return Common::setTimeInSub($this, 'CLIPLENGTH', $time);
-        }
+    public function setDbCliplength($time)
+    {
+        $this->cliplength = $time;
+		//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
+        return Common::setTimeInSub($this, 'CLIPLENGTH', $time);
+    }
 
 
 
diff --git a/backend/propel-db/build/classes/campcaster/Common.php b/backend/propel-db/build/classes/campcaster/Common.php
index bbe63b0d3..18b93ffcd 100644
--- a/backend/propel-db/build/classes/campcaster/Common.php
+++ b/backend/propel-db/build/classes/campcaster/Common.php
@@ -4,32 +4,16 @@ class Common {
 	
 	public static function setTimeInSub($row, $col, $time)
         {
-          	$class = get_class($row).'Peer';
-		
-		$con = Propel::getConnection($class::DATABASE_NAME);
+      	    $class = get_class($row).'Peer';
+	
+	        $con = Propel::getConnection($class::DATABASE_NAME);
 
-                $sql = 'UPDATE '.$class::TABLE_NAME
-                . ' SET '.$col.' = :f1'
-                . ' WHERE ' .$class::ID. ' = :p1';
-                $stmt = $con->prepare($sql);
-                $stmt->bindValue(':f1', $time);
-                $stmt->bindValue(':p1', $row->getDbId());
-                $stmt->execute();
+            $sql = 'UPDATE '.$class::TABLE_NAME
+            . ' SET '.$col.' = :f1'
+            . ' WHERE ' .$class::ID. ' = :p1';
+            $stmt = $con->prepare($sql);
+            $stmt->bindValue(':f1', $time);
+            $stmt->bindValue(':p1', $row->getDbId());
+            $stmt->execute();
         }
-
-        public static function getTimeInSub($row, $col)
-        {
-		$class = get_class($row).'Peer';
-
-                $con = Propel::getConnection($class::DATABASE_NAME);
-
-                $sql = 'SELECT '.$col
-                . ' FROM '.$class::TABLE_NAME
-                . ' WHERE ' .$class::ID. ' = :p1';
-                $stmt = $con->prepare($sql);
-                $stmt->bindValue(':p1', $row->getDbId());
-                $stmt->execute();
-                return $stmt->fetchColumn();
-        }
-
 }