diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php
index e647f4b30..d1b48f371 100644
--- a/airtime_mvc/application/controllers/LibraryController.php
+++ b/airtime_mvc/application/controllers/LibraryController.php
@@ -37,6 +37,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
@@ -56,6 +57,7 @@ class LibraryController extends Zend_Controller_Action
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
if (isset($obj_sess->id)) {
+ $objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
Logging::info($obj_sess->id);
Logging::info($obj_sess->type);
$objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php
index 5494d6d0b..755781e45 100644
--- a/airtime_mvc/application/controllers/ScheduleController.php
+++ b/airtime_mvc/application/controllers/ScheduleController.php
@@ -74,6 +74,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');
diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php
index 666a06c2f..6f02a1467 100644
--- a/airtime_mvc/application/controllers/ShowbuilderController.php
+++ b/airtime_mvc/application/controllers/ShowbuilderController.php
@@ -50,6 +50,7 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php
index a7b39869e..d7de15ca7 100644
--- a/airtime_mvc/application/models/Block.php
+++ b/airtime_mvc/application/models/Block.php
@@ -451,6 +451,10 @@ EOT;
$this->block->save($this->con);
$this->con->commit();
+
+ //check if block is in any playlists and update the playlist's length
+ Application_Model_Playlist::updatePlaylistsLengthWithBlock($this->id, $this->getLength());
+
} catch (Exception $e) {
$this->con->rollback();
throw $e;
@@ -562,6 +566,11 @@ EOT;
$this->block->save($this->con);
$this->con->commit();
+
+
+ //check if block is in any playlists and update the playlist's length
+ Application_Model_Playlist::updatePlaylistsLengthWithBlock($this->id, $this->getLength());
+
} catch (Exception $e) {
$this->con->rollback();
throw $e;
@@ -1166,6 +1175,9 @@ EOT;
// multiply 1000 because we store only number value
// e.g 192kps is stored as 192000
$spCriteriaValue = $criteria['value']*1000;
+ if (isset($criteria['extra'])) {
+ $criteria['extra'] *= 1000;
+ }
} else {
$spCriteriaValue = addslashes($criteria['value']);
}
diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php
index c4ec7df35..5989a0d83 100644
--- a/airtime_mvc/application/models/Datatables.php
+++ b/airtime_mvc/application/models/Datatables.php
@@ -2,12 +2,74 @@
class Application_Model_Datatables
{
+ private static function buildWhereClauseForAdvancedSearch($dbname2searchTerm)
+ {
+ $where = array();
+ foreach ($dbname2searchTerm as $dbname=>$term) {
+ $isRange = false;
+ if (strstr($term, '~')) {
+ $info = explode('~', $term);
+ $input1 = isset($info[0])?$info[0]:null;
+ $input2 = isset($info[1])?$info[1]:null;
+ $isRange = true;
+ } else {
+ $input1 = $term;
+ }
+
+ if ($isRange) {
+ $sub = array();
+ if ($input1 != null) {
+ $sub[] = $dbname." >= '".$input1."'";
+ }
+ if ($input2 != null) {
+ $sub[] = $dbname." <= '".$input2."'";
+ }
+ if (!empty($sub)) {
+ $where[] = "(".implode(' AND ', $sub).")";
+ }
+ } else {
+ if (trim($input1) !== "") {
+ $where[] = $dbname." ILIKE "."'%".$input1."%'";
+ }
+ }
+ }
+ return implode(" AND ", $where);
+ }
/*
* query used to return data for a paginated/searchable datatable.
*/
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
{
+ $librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
+
+ // map that maps original column position to db name
+ $current2dbname = array();
+ // array of search terms
+ $orig2searchTerm= array();
+ foreach ($data as $key=>$d) {
+ if (strstr($key, "mDataProp_")) {
+ list($dump, $index) = explode("_", $key);
+ $current2dbname[$index] = $d;
+ } else if (strstr($key, "sSearch_")) {
+ list($dump, $index) = explode("_", $key);
+ $orig2searchTerm[$index] = $d;
+ }
+ }
+ // map that maps current column position to original position
+ $current2orig = $librarySetting['ColReorder'];
+
+ // map that maps dbname to searchTerm
+ $dbname2searchTerm = array();
+ foreach ($current2dbname as $currentPos=>$dbname) {
+ $dbname2searchTerm[$dbname] = $orig2searchTerm[$current2orig[$currentPos]];
+ }
+
$where = array();
+
+ $advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
+ if ($advancedWhere != "") {
+ $where[] = $advancedWhere;
+ }
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php
index 5d716b107..17fc1907f 100644
--- a/airtime_mvc/application/models/Playlist.php
+++ b/airtime_mvc/application/models/Playlist.php
@@ -913,6 +913,26 @@ SQL;
{
CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
}
+
+ /**
+ * After items get deleted/added from/to a block
+ * this function updates the length of playlists
+ * that contain that block
+ */
+ public static function updatePlaylistsLengthWithBlock($p_blockId, $p_blockLength) {
+ $playlists = CcPlaylistQuery::create()->find();
+ foreach ($playlists as $pl) {
+ $contents = CcPlaylistcontentsQuery::create()->findByDbPlaylistId($pl->getDbId());
+ //check if the block is in each playlist
+ foreach ($contents as $item) {
+ if ($item->getDbBlockId() == $p_blockId) {
+ $item->setDbCliplength($p_blockLength);
+ $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
+ $item->save($con);
+ }
+ }
+ }
+ }
} // class Playlist
diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php
index 60ece9575..8d37df41e 100644
--- a/airtime_mvc/application/models/Preference.php
+++ b/airtime_mvc/application/models/Preference.php
@@ -1099,4 +1099,8 @@ class Application_Model_Preference
return true;
}
}
+
+ public static function getCurrentLibraryTableSetting(){
+ return unserialize(self::getValue("library_datatable"));
+ }
}
diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php
index 642212fc5..9be0e51b0 100644
--- a/airtime_mvc/application/models/StoredFile.php
+++ b/airtime_mvc/application/models/StoredFile.php
@@ -853,58 +853,55 @@ class Application_Model_StoredFile
{
$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname;
Logging::info('copyFileToStor: moving file '.$audio_file);
- $md5 = md5_file($audio_file);
- $duplicate = Application_Model_StoredFile::RecallByMd5($md5, true);
- $result = null;
- if ($duplicate) {
- if (file_exists($duplicate->getFilePath())) {
- $duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE');
- $result = array( "code" => 106, "message" => "An identical audioclip named '$duplicateName' already exists on the server.");
+ $storDir = Application_Model_MusicDir::getStorDir();
+ $stor = $storDir->getDirectory();
+ // check if "organize" dir exists and if not create one
+ if (!file_exists($stor."/organize")) {
+ if (!mkdir($stor."/organize", 0777)) {
+ return array(
+ "code" => 109,
+ "message" => "Failed to create 'organize' directory.");
}
}
- if (!isset($result)) {//The file has no duplicate, so proceed to copy.
- $storDir = Application_Model_MusicDir::getStorDir();
- $stor = $storDir->getDirectory();
- // check if "organize" dir exists and if not create one
- if (!file_exists($stor."/organize")) {
- if (!mkdir($stor."/organize", 0777)) {
- $result = array("code" => 109, "message" => "Failed to create 'organize' directory.");
-
- return $result;
- }
- }
-
- if (chmod($audio_file, 0644) === false) {
- Logging::info("Warning: couldn't change permissions of $audio_file to 0644");
- }
-
- //check to see if there is enough space in $stor to continue.
- if (self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
- $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
-
- if (self::liquidsoapFilePlayabilityTest($audio_file)) {
-
- Logging::info("copyFileToStor: moving file $audio_file to $audio_stor");
-
- //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
- if (@rename($audio_file, $audio_stor) === false) {
- #something went wrong likely there wasn't enough space in the audio_stor to move the file too.
- #warn the user that the file wasn't uploaded and they should check if there is enough disk space.
- unlink($audio_file);//remove the file after failed rename
- $result = array("code" => 108, "message" => "The file was not uploaded, this error can occur if the computer hard drive does not have enough disk space or the stor directory does not have correct write permissions.");
- }
- } else {
- $result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library.");
- }
-
- } else {
- $result = array("code" => 107, "message" => "The file was not uploaded, there is ".$freeSpace."MB of disk space left and the file you are uploading has a size of ".$fileSize."MB.");
- }
+ if (chmod($audio_file, 0644) === false) {
+ Logging::info("Warning: couldn't change permissions of $audio_file to 0644");
}
- return $result;
+ // Check if we have enough space before copying
+ if(!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
+ $freeSpace = disk_free_space($stor);
+ return array("code" => 107,
+ "message" => "The file was not uploaded, there is
+ ".$freeSpace."MB of disk space left and the file you are
+ uploading has a size of ".$fileSize."MB.");
+ }
+
+ // Check if liquidsoap can play this file
+ if(!self::liquidsoapFilePlayabilityTest($audio_file)) {
+ return array(
+ "code" => 110,
+ "message" => "This file appears to be corrupted and will not
+ be added to media library.");
+ }
+
+ // Did all the checks for realz, now trying to copy
+ $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
+ Logging::info("copyFileToStor: moving file $audio_file to $audio_stor");
+ //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
+ if (@rename($audio_file, $audio_stor) === false) {
+ #something went wrong likely there wasn't enough space in the audio_stor to move the file too.
+ #warn the user that the file wasn't uploaded and they should check if there is enough disk space.
+ unlink($audio_file);//remove the file after failed rename
+ return array(
+ "code" => 108,
+ "message" => "
+ The file was not uploaded, this error can occur if the computer
+ hard drive does not have enough disk space or the stor
+ directory does not have correct write permissions. ");
+ }
+ return null;
}
/*
diff --git a/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml b/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml
index 7e4770332..4a7baecad 100644
--- a/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml
+++ b/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml
@@ -5,7 +5,7 @@
\ No newline at end of file
diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml
index a66b9f94a..dc95ac2da 100644
--- a/airtime_mvc/application/views/scripts/playlist/update.phtml
+++ b/airtime_mvc/application/views/scripts/playlist/update.phtml
@@ -24,6 +24,10 @@ if ($item['type'] == 2) {