Merge branch 'master' into CC-2301

This commit is contained in:
Naomi 2013-05-01 11:04:14 -04:00
commit 92ef0608d6
673 changed files with 53058 additions and 259758 deletions

View file

@ -64,13 +64,8 @@ class ApiController extends Zend_Controller_Action
public function versionAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$jsonStr = json_encode( array(
$this->_helper->json->sendJson( array(
"version" => Application_Model_Preference::GetAirtimeVersion()));
echo $jsonStr;
}
/**
@ -79,9 +74,6 @@ class ApiController extends Zend_Controller_Action
*/
public function calendarInitAction()
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if (is_null(Zend_Auth::getInstance()->getStorage()->read())) {
header('HTTP/1.0 401 Unauthorized');
print _('You are not allowed to access this resource.');
@ -96,6 +88,8 @@ class ApiController extends Zend_Controller_Action
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
);
$this->_helper->json->sendJson(array());
}
/**
@ -106,13 +100,9 @@ class ApiController extends Zend_Controller_Action
*/
public function getMediaAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$fileId = $this->_getParam("file");
$media = Application_Model_StoredFile::Recall($fileId);
$media = Application_Model_StoredFile::RecallById($fileId);
if ($media != null) {
$filepath = $media->getFilePath();
@ -150,7 +140,7 @@ class ApiController extends Zend_Controller_Action
}
}
return;
$this->_helper->json->sendJson(array());
}
/**
@ -358,21 +348,15 @@ class ApiController extends Zend_Controller_Action
public function scheduleAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$data = Application_Model_Schedule::getSchedule();
header("Content-Type: application/json");
echo json_encode($data, JSON_FORCE_OBJECT);
$this->_helper->json->sendJson($data, false, true);
}
public function notifyMediaItemStartPlayAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$media_id = $this->_getParam("media_id");
Logging::debug("Received notification of new media item start: $media_id");
Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
@ -385,7 +369,7 @@ class ApiController extends Zend_Controller_Action
$file_id = Application_Model_Schedule::GetFileId($media_id);
if (!is_null($file_id)) {
//we are dealing with a file not a stream
$file = Application_Model_StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::RecallById($file_id);
$now = new DateTime("now", new DateTimeZone("UTC"));
$file->setLastPlayedTime($now);
}
@ -402,7 +386,7 @@ class ApiController extends Zend_Controller_Action
Logging::info($e);
}
echo json_encode(array("status"=>1, "message"=>""));
$this->_helper->json->sendJson(array("status"=>1, "message"=>""));
}
public function recordedShowsAction()
@ -460,7 +444,7 @@ class ApiController extends Zend_Controller_Action
public function uploadRecordedActionParam($show_instance_id, $file_id)
{
$showCanceled = false;
$file = Application_Model_StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::RecallById($file_id);
//$show_instance = $this->_getParam('show_instance');
try {
@ -490,10 +474,6 @@ class ApiController extends Zend_Controller_Action
public function mediaMonitorSetupAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory();
$watchedDirs = Application_Model_MusicDir::getWatchedDirs();
@ -508,81 +488,88 @@ class ApiController extends Zend_Controller_Action
{
$return_hash = array();
Application_Model_Preference::SetImportTimestamp();
//Logging::info("--->Mode: $mode || file: {$md['MDATA_KEY_FILEPATH']} ");
//Logging::info( $md );
// create also modifies the file if it exists
if ($mode == "create") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = Application_Common_OsPath::normpath($filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$file = Application_Model_StoredFile::Insert($md);
} else {
// If the file already exists we will update and make sure that
// it's marked as 'exists'.
$file->setFileExistsFlag(true);
$file->setFileHiddenFlag(false);
$file->setMetadata($md);
}
if ($md['is_record'] != 0) {
$this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId());
}
} elseif ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$con->beginTransaction();
try {
// create also modifies the file if it exists
if ($mode == "create") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = Application_Common_OsPath::normpath($filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
if (is_null($file)) {
$file = Application_Model_StoredFile::Insert($md, $con);
} else {
// If the file already exists we will update and make sure that
// it's marked as 'exists'.
$file->setFileExistsFlag(true);
$file->setFileHiddenFlag(false);
$file->setMetadata($md);
}
if ($md['is_record'] != 0) {
$this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId());
}
} elseif ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
//File is not in database anymore.
if (is_null($file)) {
$return_hash['error'] = _("File does not exist in Airtime.");
//File is not in database anymore.
if (is_null($file)) {
$return_hash['error'] = _("File does not exist in Airtime.");
return $return_hash;
}
//Updating a metadata change.
else {
$file->setMetadata($md);
}
} elseif ($mode == "moved") {
$file = Application_Model_StoredFile::RecallByFilepath(
$md['MDATA_KEY_ORIGINAL_PATH']);
return $return_hash;
}
//Updating a metadata change.
else {
$file->setMetadata($md);
}
} elseif ($mode == "moved") {
$file = Application_Model_StoredFile::RecallByFilepath(
$md['MDATA_KEY_ORIGINAL_PATH'], $con);
if (is_null($file)) {
$return_hash['error'] = _('File does not exist in Airtime');
} else {
if (is_null($file)) {
$return_hash['error'] = _('File does not exist in Airtime');
} else {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$file->setFilePath($filepath);
}
} elseif ($mode == "delete") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
if (is_null($file)) {
$return_hash['error'] = _("File doesn't exist in Airtime.");
Logging::warn("Attempt to delete file that doesn't exist.
Path: '$filepath'");
return $return_hash;
} else {
$file->deleteByMediaMonitor();
}
} elseif ($mode == "delete_dir") {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$file->setFilePath($filepath);
}
} elseif ($mode == "delete") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath, $con);
if (is_null($file)) {
$return_hash['error'] = _("File doesn't exist in Airtime.");
Logging::warn("Attempt to delete file that doesn't exist.
Path: '$filepath'");
foreach ($files as $file) {
$file->deleteByMediaMonitor();
}
$return_hash['success'] = 1;
return $return_hash;
} else {
$file->deleteByMediaMonitor();
}
} elseif ($mode == "delete_dir") {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
foreach ($files as $file) {
$file->deleteByMediaMonitor();
}
$return_hash['success'] = 1;
return $return_hash;
$return_hash['fileid'] = is_null($file) ? '-1' : $file->getId();
$con->commit();
} catch (Exception $e) {
Logging::warn("rolling back");
Logging::warn($e->getMessage());
$con->rollback();
$return_hash['error'] = $e->getMessage();
}
$return_hash['fileid'] = is_null($file) ? '-1' : $file->getId();
return $return_hash;
}
@ -601,6 +588,7 @@ class ApiController extends Zend_Controller_Action
// least 1 digit
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
$info_json = json_decode($raw_json, $assoc = true);
// Log invalid requests
if ( !array_key_exists('mode', $info_json) ) {
Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:");
@ -624,7 +612,12 @@ class ApiController extends Zend_Controller_Action
// Removing 'mode' key from $info_json might not be necessary...
$mode = $info_json['mode'];
unset( $info_json['mode'] );
$response = $this->dispatchMetadata($info_json, $mode);
try {
$response = $this->dispatchMetadata($info_json, $mode);
} catch (Exception $e) {
Logging::warn($e->getMessage());
Logging::warn(gettype($e));
}
// We tack on the 'key' back to every request in case the would like to associate
// his requests with particular responses
$response['key'] = $k;
@ -726,7 +719,7 @@ class ApiController extends Zend_Controller_Action
{
$request = $this->getRequest();
$msg = $request->getParam('msg');
$msg = $request->getParam('msg_post');
$stream_id = $request->getParam('stream_id');
$boot_time = $request->getParam('boot_time');
@ -922,72 +915,72 @@ class ApiController extends Zend_Controller_Action
* out a message to pypo that a potential change has been made. */
public function getFilesWithoutReplayGainAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$dir_id = $this->_getParam('dir_id');
//connect to db and get get sql
$rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100);
echo json_encode($rows);
$this->_helper->json->sendJson($rows);
}
public function getFilesWithoutSilanValueAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
//connect to db and get get sql
$rows = Application_Model_StoredFile::getAllFilesWithoutSilan();
echo json_encode($rows);
$this->_helper->json->sendJson($rows);
}
public function updateReplayGainValueAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$data = json_decode($request->getParam('data'));
foreach ($data as $pair) {
list($id, $gain) = $pair;
// TODO : move this code into model -- RG
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
$file = Application_Model_StoredFile::RecallById($p_id = $id)->getPropelOrm();
$file->setDbReplayGain($gain);
$file->save();
}
$this->view->msg = "OK";
$this->_helper->json->sendJson(array());
}
public function updateCueValuesBySilanAction()
{
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$data = json_decode($request->getParam('data'));
$data = json_decode($request->getParam('data'), $assoc = true);
foreach ($data as $pair) {
list($id, $info) = $pair;
// TODO : move this code into model -- RG
$cuein = $info->cuein;
$cueout = $info->cueout;
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
$file = Application_Model_StoredFile::RecallById($p_id = $id)->getPropelOrm();
//What we are doing here is setting a more accurate length that was
//calculated with silan by actually scanning the entire file. This
//process takes a really long time, and so we only do it in the background
//after the file has already been imported -MK
$length = $file->getDbLength();
if (isset($info['length'])) {
$length = $info['length'];
//length decimal number in seconds. Need to convert it to format
//HH:mm:ss to get around silly PHP limitations.
$length = Application_Common_DateHelper::secondsToPlaylistTime($length);
$file->setDbLength($length);
}
$cuein = isset($info['cuein']) ? $info['cuein'] : 0;
$cueout = isset($info['cueout']) ? $info['cueout'] : $length;
$file->setDbCuein($cuein);
$file->setDbCueout($cueout);
$file->setDbSilanCheck(true);
$file->save();
}
echo json_encode(array());
$this->_helper->json->sendJson(array());
}
public function notifyWebstreamDataAction()
@ -1056,5 +1049,4 @@ class ApiController extends Zend_Controller_Action
Application_Model_StreamSetting::SetListenerStatError($k, $v);
}
}
}

View file

@ -47,7 +47,7 @@ class AudiopreviewController extends Zend_Controller_Action
if ($type == "audioclip") {
$uri = $baseUrl."api/get-media/file/".$audioFileID;
$media = Application_Model_StoredFile::Recall($audioFileID);
$media = Application_Model_StoredFile::RecallById($audioFileID);
$mime = $media->getPropelOrm()->getDbMime();
} elseif ($type == "stream") {
$webstream = CcWebstreamQuery::create()->findPk($audioFileID);

View file

@ -90,10 +90,6 @@ class DashboardController extends Zend_Controller_Action
}
}
public function switchOffSource()
{
}
public function streamPlayerAction()
{
$CC_CONFIG = Config::getConfig();

View file

@ -195,7 +195,7 @@ class LibraryController extends Zend_Controller_Action
if ($type === "audioclip") {
$file = Application_Model_StoredFile::Recall($id);
$file = Application_Model_StoredFile::RecallById($id);
$menu["play"]["mime"] = $file->getPropelOrm()->getDbMime();
@ -353,7 +353,7 @@ class LibraryController extends Zend_Controller_Action
foreach ($files as $id) {
$file = Application_Model_StoredFile::Recall($id);
$file = Application_Model_StoredFile::RecallById($id);
if (isset($file)) {
try {
@ -425,7 +425,7 @@ class LibraryController extends Zend_Controller_Action
$request = $this->getRequest();
$file_id = $this->_getParam('id', null);
$file = Application_Model_StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::RecallById($file_id);
if (!$isAdminOrPM && $file->getFileOwnerId() != $user->getId()) {
return;
@ -467,7 +467,7 @@ class LibraryController extends Zend_Controller_Action
try {
if ($type == "audioclip") {
$file = Application_Model_StoredFile::Recall($id);
$file = Application_Model_StoredFile::RecallById($id);
$this->view->type = $type;
$md = $file->getMetadata();
@ -551,7 +551,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->error_code = $file->getSoundCloudErrorCode();
$this->view->error_msg = $file->getSoundCloudErrorMsg();
} elseif ($type == "file") {
$file = Application_Model_StoredFile::Recall($id);
$file = Application_Model_StoredFile::RecallById($id);
$this->view->sc_id = $file->getSoundCloudId();
$this->view->error_code = $file->getSoundCloudErrorCode();
$this->view->error_msg = $file->getSoundCloudErrorMsg();

View file

@ -165,16 +165,25 @@ class PreferenceController extends Zend_Controller_Action
foreach ($temp as $t) {
$setting[$t['keyname']] = $t['value'];
}
$name_map = array('ogg' => 'Ogg Vorbis',
'aacplus' => 'AAC+',
'aac' => 'AAC',
'opus' => 'Opus',
'mp3' => 'MP3'
);
// get predefined type and bitrate from pref table
$temp_types = Application_Model_Preference::GetStreamType();
$stream_types = array();
foreach ($temp_types as $type) {
if (trim($type) == "ogg") {
$temp = "OGG/VORBIS";
$type = strtolower(trim($type));
if (isset($name_map[$type])) {
$name = $name_map[$type];
} else {
$temp = strtoupper(trim($type));
$name = $type;
}
$stream_types[trim($type)] = $temp;
$stream_types[$type] = $name;
}
$temp_bitrate = Application_Model_Preference::GetStreamBitrate();

View file

@ -16,21 +16,21 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('edit-show', 'json')
->addActionContext('move-show', 'json')
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('delete-show-instance', 'json')
->addActionContext('show-content-dialog', 'json')
->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json')
->addActionContext('remove-group', 'json')
->addActionContext('populate-show-form', 'json')
->addActionContext('populate-show-instance-form', 'json')
->addActionContext('cancel-show', 'json')
->addActionContext('populate-repeating-show-instance-form', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('cancel-current-show', 'json')
->addActionContext('get-form', 'json')
->addActionContext('upload-to-sound-cloud', 'json')
->addActionContext('content-context-menu', 'json')
->addActionContext('set-time-scale', 'json')
->addActionContext('set-time-interval', 'json')
->addActionContext('edit-show-instance', 'json')
->addActionContext('edit-repeating-show-instance', 'json')
->addActionContext('dj-edit-show', 'json')
->addActionContext('calculate-duration', 'json')
->addActionContext('get-current-show', 'json')
@ -90,13 +90,14 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
//End Show builder JS/CSS requirements
$this->createShowFormAction(true);
Application_Model_Schedule::createNewFormSections($this->view);
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$this->view->preloadShowForm = true;
}
$this->view->addNewShow = true;
$this->view->headScript()->appendScript(
"var calendarPref = {};\n".
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
@ -111,16 +112,17 @@ class ScheduleController extends Zend_Controller_Action
public function eventFeedAction()
{
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
$start = new DateTime($this->_getParam('start', null));
$start->setTimezone(new DateTimeZone("UTC"));
$end = new DateTime($this->_getParam('end', null));
$end->setTimezone(new DateTimeZone("UTC"));
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$events = &Application_Model_Show::getFullCalendarEvents($start, $end,
$currentUser->isAdminOrPM());
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
$this->view->events = $events;
}
@ -161,22 +163,16 @@ class ScheduleController extends Zend_Controller_Action
{
$deltaDay = $this->_getParam('day');
$deltaMin = $this->_getParam('min');
$showInstanceId = $this->_getParam('showInstanceId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
try {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
} catch (Exception $e) {
$this->view->show_error = true;
return false;
}
$error = $showInstance->moveShow($deltaDay, $deltaMin);
try {
$service_calendar = new Application_Service_CalendarService(
$this->_getParam('showInstanceId'));
} catch (Exception $e) {
$this->view->show_error = true;
return false;
}
$error = $service_calendar->moveShow($deltaDay, $deltaMin);
if (isset($error)) {
$this->view->error = $error;
}
@ -207,28 +203,17 @@ class ScheduleController extends Zend_Controller_Action
}
}
public function deleteShowAction()
public function deleteShowInstanceAction()
{
$showInstanceId = $this->_getParam('id');
$instanceId = $this->_getParam('id');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$service_show = new Application_Service_ShowService();
$showId = $service_show->deleteShow($instanceId, true);
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
try {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
} catch (Exception $e) {
Logging::info($e->getMessage());
$this->view->show_error = true;
return false;
}
$showInstance->delete();
$this->view->show_id = $showInstance->getShowId();
if (!$showId) {
$this->view->show_error = true;
}
$this->view->show_id = $showId;
}
public function uploadToSoundCloudAction()
@ -251,124 +236,23 @@ class ScheduleController extends Zend_Controller_Action
public function makeContextMenuAction()
{
$id = $this->_getParam('id');
$menu = array();
$epochNow = time();
$baseUrl = Application_Common_OsPath::getBaseDir();
$instanceId = $this->_getParam('instanceId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
try {
$instance = new Application_Model_ShowInstance($id);
} catch (Exception $e) {
$this->view->show_error = true;
$service_calendar = new Application_Service_CalendarService($instanceId);
return false;
}
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$isDJ = $user->isHostOfShow($instance->getShowId());
$showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
$showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
if ($instance->isRecorded() && $epochNow > $showEndLocalDT->getTimestamp()) {
$file = $instance->getRecordedFile();
$fileId = $file->getId();
$menu["view_recorded"] = array("name" => _("View Recorded File Metadata"), "icon" => "overview",
"url" => $baseUrl."library/edit-file-md/id/".$fileId);
}
if ($epochNow < $showStartLocalDT->getTimestamp()) {
if ( ($isAdminOrPM || $isDJ)
&& !$instance->isRecorded()
&& !$instance->isRebroadcast()) {
$menu["schedule"] = array("name"=> _("Add / Remove Content"), "icon" => "add-remove-content",
"url" => $baseUrl."showbuilder/builder-dialog/");
$menu["clear"] = array("name"=> _("Remove All Content"), "icon" => "remove-all-content",
"url" => $baseUrl."schedule/clear-show");
}
}
if (!$instance->isRecorded()) {
$menu["content"] = array("name"=> _("Show Content"), "icon" => "overview", "url" => $baseUrl."schedule/show-content-dialog");
}
if ($showEndLocalDT->getTimestamp() <= $epochNow
&& $instance->isRecorded()
&& Application_Model_Preference::GetUploadToSoundcloudOption()) {
$file = $instance->getRecordedFile();
$fileId = $file->getId();
$scid = $instance->getSoundCloudFileId();
if ($scid > 0) {
$url = $file->getSoundCloudLinkToFile();
$menu["soundcloud_view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $url);
}
$text = is_null($scid) ? _('Upload to SoundCloud') : _('Re-upload to SoundCloud');
$menu["soundcloud_upload"] = array("name"=> $text, "icon" => "soundcloud");
}
if ($showStartLocalDT->getTimestamp() <= $epochNow &&
$epochNow < $showEndLocalDT->getTimestamp() && $isAdminOrPM) {
if ($instance->isRecorded()) {
$menu["cancel_recorded"] = array("name"=> _("Cancel Current Show"), "icon" => "delete");
} else {
if (!$instance->isRebroadcast()) {
$menu["edit"] = array("name"=> _("Edit Show"), "icon" => "edit", "_type"=>"all", "url" => $baseUrl."Schedule/populate-show-form");
}
$menu["cancel"] = array("name"=> _("Cancel Current Show"), "icon" => "delete");
}
}
if ($epochNow < $showStartLocalDT->getTimestamp()) {
if (!$instance->isRebroadcast() && $isAdminOrPM) {
$menu["edit"] = array("name"=> _("Edit Show"), "icon" => "edit", "_type"=>"all", "url" => $baseUrl."Schedule/populate-show-form");
}
if ($instance->getShow()->isRepeating() && $isAdminOrPM) {
//create delete sub menu.
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "items" => array());
$menu["del"]["items"]["single"] = array("name"=> _("Delete This Instance"), "icon" => "delete", "url" => $baseUrl."schedule/delete-show");
$menu["del"]["items"]["following"] = array("name"=> _("Delete This Instance and All Following"), "icon" => "delete", "url" => $baseUrl."schedule/cancel-show");
} elseif ($isAdminOrPM) {
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."schedule/delete-show");
}
}
$this->view->items = $menu;
$this->view->items = $service_calendar->makeContextMenu();
}
public function clearShowAction()
{
$showInstanceId = $this->_getParam('id');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
try {
$show = new Application_Model_ShowInstance($showInstanceId);
} catch (Exception $e) {
$this->view->show_error = true;
$instanceId = $this->_getParam('id');
$service_scheduler = new Application_Service_SchedulerService();
if (!$service_scheduler->emptyShowContent($instanceId)) {
$this->view->show_error = true;
return false;
}
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)) || $user->isHostOfShow($show->getShowId()))
$show->clearShow();
}
public function getCurrentPlaylistAction()
@ -416,32 +300,6 @@ class ScheduleController extends Zend_Controller_Action
$this->view->show_name = isset($show[0])?$show[0]["name"]:"";
}
public function removeGroupAction()
{
$showInstanceId = $this->sched_sess->showInstanceId;
$group_id = $this->_getParam('groupId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
try {
$show = new Application_Model_ShowInstance($showInstanceId);
} catch (Exception $e) {
$this->view->show_error = true;
return false;
}
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)) || $user->isHostOfShow($show->getShowId())) {
$show->removeGroupFromShow($group_id);
}
$this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled();
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
unset($this->view->showContent);
}
public function showContentDialogAction()
{
$showInstanceId = $this->_getParam('id');
@ -484,256 +342,66 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->showContent);
}
// we removed edit show instance option in menu item
// this feature is disabled in 2.1 and should be back in 2.2
/*public function populateShowInstanceFormAction(){
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
public function populateRepeatingShowInstanceFormAction()
{
$showId = $this->_getParam('showId');
$instanceId = $this->_getParam('instanceId');
$service_showForm = new Application_Service_ShowFormService($showId, $instanceId);
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$forms = $this->createShowFormAction();
$service_showForm->delegateShowInstanceFormPopulation($forms);
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$this->view->live = $formLive;
$this->view->addNewShow = false;
$showInstanceId = $this->_getParam('id');
$show_instance = CcShowInstancesQuery::create()->findPK($showInstanceId);
$show = new Application_Model_Show($show_instance->getDbShowId());
$starts_string = $show_instance->getDbStarts();
$ends_string = $show_instance->getDbEnds();
$starts_datetime = new DateTime($starts_string, new DateTimeZone("UTC"));
$ends_datetime = new DateTime($ends_string, new DateTimeZone("UTC"));
$starts_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$ends_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$instance_duration = $starts_datetime->diff($ends_datetime);
$formWhat->populate(array('add_show_id' => $show->getId(),
'add_show_instance_id' => $showInstanceId,
'add_show_name' => $show->getName(),
'add_show_url' => $show->getUrl(),
'add_show_genre' => $show->getGenre(),
'add_show_description' => $show->getDescription()));
$formWhen->populate(array('add_show_start_date' => $starts_datetime->format("Y-m-d"),
'add_show_start_time' => $starts_datetime->format("H:i"),
'add_show_end_date_no_repeat' => $ends_datetime->format("Y-m-d"),
'add_show_end_time' => $ends_datetime->format("H:i"),
'add_show_duration' => $instance_duration->format("%h")));
$formWhat->disable();
$formWho->disable();
$formWhen->disableRepeatCheckbox();
$formRepeats->disable();
$formStyle->disable();
//$formRecord->disable();
//$formAbsoluteRebroadcast->disable();
//$formRebroadcast->disable();
$this->view->action = "edit-show-instance";
$this->view->action = "edit-repeating-show-instance";
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
}*/
}
public function populateShowFormAction()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
$showInstanceId = $this->_getParam('id');
$this->view->action = "edit-show";
try {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
} catch (Exception $e) {
$this->view->show_error = true;
return false;
}
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$isDJ = $user->isHostOfShow($showInstance->getShowId());
if (!($isAdminOrPM || $isDJ)) {
return;
}
$showId = $this->_getParam('showId');
$instanceId = $this->_getParam('instanceId');
$service_showForm = new Application_Service_ShowFormService($showId, $instanceId);
$isAdminOrPM = $currentUser->isAdminOrPM();
/*$isHostOfShow = $currentUser->isHostOfShow($showId);
// in case a user was once a dj and had been assigned to a show
// but was then changed to an admin user we need to allow
// the user to edit the show as an admin (CC-4925)
if ($isDJ && !$isAdminOrPM) {
if ($isHostOfShow && !$isAdminOrPM) {
$this->view->action = "dj-edit-show";
}
}*/
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$forms = $this->createShowFormAction();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$this->view->live = $formLive;
$this->view->addNewShow = false;
$show = new Application_Model_Show($showInstance->getShowId());
$formWhat->populate(array('add_show_id' => $show->getId(),
'add_show_instance_id' => $showInstanceId,
'add_show_name' => $show->getName(),
'add_show_url' => $show->getUrl(),
'add_show_genre' => $show->getGenre(),
'add_show_description' => $show->getDescription()));
$startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone("UTC"));
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$formWhen->populate(array('add_show_start_date' => $startsDateTime->format("Y-m-d"),
'add_show_start_time' => $startsDateTime->format("H:i"),
'add_show_end_date_no_repeat' => $endsDateTime->format("Y-m-d"),
'add_show_end_time' => $endsDateTime->format("H:i"),
'add_show_duration' => $show->getDuration(true),
'add_show_repeats' => $show->isRepeating() ? 1 : 0));
if ($show->isStartDateTimeInPast()) {
// for a non-repeating show, we should never allow user to change the start time.
// for the repeating show, we should allow because the form works as repeating template form
if (!$showInstance->getShow()->isRepeating()) {
$formWhen->disableStartDateAndTime();
} else {
$nextFutureRepeatShow = $show->getNextFutureRepeatShowTime();
$formWhen->getElement('add_show_start_date')->setValue($nextFutureRepeatShow["starts"]->format("Y-m-d"));
$formWhen->getElement('add_show_start_time')->setValue($nextFutureRepeatShow["starts"]->format("H:i"));
$formWhen->getElement('add_show_end_date_no_repeat')->setValue($nextFutureRepeatShow["ends"]->format("Y-m-d"));
$formWhen->getElement('add_show_end_time')->setValue($nextFutureRepeatShow["ends"]->format("H:i"));
}
}
//need to get the days of the week in the php timezone (for the front end).
$days = array();
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
foreach ($showDays as $showDay) {
$showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone()));
$showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get()));
array_push($days, $showStartDay->format('w'));
}
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone()));
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
$formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(),
'add_show_day_check' => $days,
'add_show_end_date' => $displayedEndDate->format("Y-m-d"),
'add_show_no_end' => ($show->getRepeatingEndDate() == '')));
$hosts = array();
$showHosts = CcShowHostsQuery::create()->filterByDbShow($showInstance->getShowId())->find();
foreach ($showHosts as $showHost) {
array_push($hosts, $showHost->getDbHost());
}
$formWho->populate(array('add_show_hosts' => $hosts));
$formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(),
'add_show_color' => $show->getColor()));
$formLive->populate($show->getLiveStreamInfo());
$formRecord = new Application_Form_AddShowRR();
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
$formRecord->removeDecorator('DtDdWrapper');
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
$formRebroadcast->removeDecorator('DtDdWrapper');
$this->view->rr = $formRecord;
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
$this->view->rebroadcast = $formRebroadcast;
$formRecord->populate(array('add_show_record' => $show->isRecorded(),
'add_show_rebroadcast' => $show->isRebroadcast()));
$formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
$rebroadcastsRelative = $show->getRebroadcastsRelative();
$rebroadcastFormValues = array();
$i = 1;
foreach ($rebroadcastsRelative as $rebroadcast) {
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Application_Common_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
$i++;
}
$formRebroadcast->populate($rebroadcastFormValues);
$rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
$rebroadcastAbsoluteFormValues = array();
$i = 1;
foreach ($rebroadcastsAbsolute as $rebroadcast) {
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = $rebroadcast['start_time'];
$i++;
}
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
if (!$isAdminOrPM) {
$formRecord->disable();
$formAbsoluteRebroadcast->disable();
$formRebroadcast->disable();
}
$service_showForm->delegateShowFormPopulation($forms);
if (!$isAdminOrPM) {
$formWhat->disable();
$formWho->disable();
$formWhen->disable();
$formRepeats->disable();
$formStyle->disable();
foreach ($forms as $form) {
$form->disable();
}
}
$this->view->action = "edit-show";
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
$this->view->entries = 5;
}
public function getFormAction()
{
$user = Application_Model_User::getCurrentUser();
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
Application_Model_Schedule::createNewFormSections($this->view);
if ($currentUser->isAdminOrPM()) {
$this->createShowFormAction(true);
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}
public function djEditShowAction()
/*public function djEditShowAction()
{
$js = $this->_getParam('data');
$data = array();
@ -751,30 +419,9 @@ class ScheduleController extends Zend_Controller_Action
$show->setCustomPassword($data["custom_password"]);
$this->view->edit = true;
}
/*public function editShowInstanceAction(){
$js = $this->_getParam('data');
$data = array();
//need to convert from serialized jQuery array.
foreach ($js as $j) {
$data[$j["name"]] = $j["value"];
}
$success = Application_Model_Schedule::updateShowInstance($data, $this);
if ($success) {
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} else {
$this->view->addNewShow = false;
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}*/
public function editShowAction()
{
//1) Get add_show_start_date since it might not have been sent
public function editRepeatingShowInstanceAction(){
$js = $this->_getParam('data');
$data = array();
@ -783,6 +430,53 @@ class ScheduleController extends Zend_Controller_Action
$data[$j["name"]] = $j["value"];
}
$data['add_show_hosts'] = $this->_getParam('hosts');
$service_showForm = new Application_Service_ShowFormService(
$data["add_show_id"], $data["add_show_instance_id"]);
$service_show = new Application_Service_ShowService(null, $data);
$forms = $this->createShowFormAction();
list($data, $validateStartDate, $validateStartTime, $originalShowStartDateTime) =
$service_showForm->preEditShowValidationCheck($data);
if ($service_showForm->validateShowForms($forms, $data, $validateStartDate,
$originalShowStartDateTime, true, $data["add_show_instance_id"])) {
$service_show->createShowFromRepeatingInstance($data);
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} else {
if (!$validateStartDate) {
$this->view->when->getElement('add_show_start_date')->setOptions(array('disabled' => true));
}
if (!$validateStartTime) {
$this->view->when->getElement('add_show_start_time')->setOptions(array('disabled' => true));
}
$this->view->rr->getElement('add_show_record')->setOptions(array('disabled' => true));
$this->view->addNewShow = false;
$this->view->action = "edit-show";
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}
}
public function editShowAction()
{
$js = $this->_getParam('data');
$data = array();
//need to convert from serialized jQuery array.
foreach ($js as $j) {
$data[$j["name"]] = $j["value"];
}
$service_showForm = new Application_Service_ShowFormService(
$data["add_show_id"]);
$service_show = new Application_Service_ShowService(null, $data, true);
//TODO: move this to js
$data['add_show_hosts'] = $this->_getParam('hosts');
$data['add_show_day_check'] = $this->_getParam('days');
@ -790,43 +484,16 @@ class ScheduleController extends Zend_Controller_Action
$data['add_show_day_check'] = null;
}
$show = new Application_Model_Show($data['add_show_id']);
$forms = $this->createShowFormAction();
$validateStartDate = true;
$validateStartTime = true;
if (!array_key_exists('add_show_start_date', $data)) {
//Changing the start date was disabled, since the
//array key does not exist. We need to repopulate this entry from the db.
//The start date will be returned in UTC time, so lets convert it to local time.
$dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime());
$data['add_show_start_date'] = $dt->format("Y-m-d");
list($data, $validateStartDate, $validateStartTime, $originalShowStartDateTime) =
$service_showForm->preEditShowValidationCheck($data);
if (!array_key_exists('add_show_start_time', $data)) {
$data['add_show_start_time'] = $dt->format("H:i");
$validateStartTime = false;
}
$validateStartDate = false;
}
$data['add_show_record'] = $show->isRecorded();
if ($service_showForm->validateShowForms($forms, $data, $validateStartDate,
$originalShowStartDateTime, true, $data["add_show_instance_id"])) {
if ($show->isRepeating()) {
$nextFutureRepeatShow = $show->getNextFutureRepeatShowTime();
$originalShowStartDateTime = $nextFutureRepeatShow["starts"];
} else {
$originalShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime(
$show->getStartDateAndTime());
}
$service_show->addUpdateShow($data);
$success = Application_Model_Schedule::addUpdateShow($data, $this,
$validateStartDate, $originalShowStartDateTime, true,
$data['add_show_instance_id']);
if ($success) {
$scheduler = new Application_Model_Scheduler();
$showInstances = CcShowInstancesQuery::create()->filterByDbShowId($data['add_show_id'])->find();
foreach ($showInstances as $si) {
$scheduler->removeGaps($si->getDbId());
}
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} else {
@ -845,6 +512,9 @@ class ScheduleController extends Zend_Controller_Action
public function addShowAction()
{
$service_showForm = new Application_Service_ShowFormService(null);
//$service_show = new Application_Service_ShowService();
$js = $this->_getParam('data');
$data = array();
@ -853,6 +523,9 @@ class ScheduleController extends Zend_Controller_Action
$data[$j["name"]] = $j["value"];
}
$service_show = new Application_Service_ShowService(null, $data);
// TODO: move this to js
$data['add_show_hosts'] = $this->_getParam('hosts');
$data['add_show_day_check'] = $this->_getParam('days');
@ -860,42 +533,60 @@ class ScheduleController extends Zend_Controller_Action
$data['add_show_day_check'] = null;
}
$validateStartDate = true;
$success = Application_Model_Schedule::addUpdateShow($data, $this,
$validateStartDate);
$forms = $this->createShowFormAction();
$this->view->addNewShow = true;
if ($service_showForm->validateShowForms($forms, $data)) {
$service_show->addUpdateShow($data);
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
//send new show forms to the user
$this->createShowFormAction(true);
if ($success) {
$this->view->addNewShow = true;
$this->view->newForm = $this->view->render(
'schedule/add-show-form.phtml');
Logging::debug("Show creation succeeded");
} else {
$this->view->addNewShow = true;
$this->view->form = $this->view->render(
'schedule/add-show-form.phtml');
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
Logging::debug("Show creation failed");
}
}
public function cancelShowAction()
public function createShowFormAction($populateDefaults=false)
{
$user = Application_Model_User::getCurrentUser();
$service_showForm = new Application_Service_ShowFormService();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
$forms = $service_showForm->createShowForms();
try {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
} catch (Exception $e) {
$this->view->show_error = true;
return false;
}
$show = new Application_Model_Show($showInstance->getShowId());
$show->cancelShow($showInstance->getShowInstanceStart());
$this->view->show_id = $showInstance->getShowId();
// populate forms with default values
if ($populateDefaults) {
$service_showForm->populateNewShowForms(
$forms["what"], $forms["when"], $forms["repeats"]);
}
$this->view->what = $forms["what"];
$this->view->when = $forms["when"];
$this->view->repeats = $forms["repeats"];
$this->view->live = $forms["live"];
$this->view->rr = $forms["record"];
$this->view->absoluteRebroadcast = $forms["abs_rebroadcast"];
$this->view->rebroadcast = $forms["rebroadcast"];
$this->view->who = $forms["who"];
$this->view->style = $forms["style"];
return $forms;
}
public function deleteShowAction()
{
$instanceId = $this->_getParam('id');
$service_show = new Application_Service_ShowService();
$showId = $service_show->deleteShow($instanceId);
if (!$showId) {
$this->view->show_error = true;
}
$this->view->show_id = $showId;
}
public function cancelCurrentShowAction()
@ -931,7 +622,7 @@ class ScheduleController extends Zend_Controller_Action
$id = $this->_getParam('id');
$file_id = $this->_getParam('id', null);
$file = Application_Model_StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::RecallById($file_id);
$baseUrl = $this->getRequest()->getBaseUrl();
$url = $file->getRelativeFileUrl($baseUrl).'download/true';
@ -962,32 +653,9 @@ class ScheduleController extends Zend_Controller_Action
public function calculateDurationAction()
{
$startParam = $this->_getParam('startTime');
$endParam = $this->_getParam('endTime');
try {
$startDateTime = new DateTime($startParam);
$endDateTime = new DateTime($endParam);
$UTCStartDateTime = $startDateTime->setTimezone(new DateTimeZone('UTC'));
$UTCEndDateTime = $endDateTime->setTimezone(new DateTimeZone('UTC'));
$duration = $UTCEndDateTime->diff($UTCStartDateTime);
$day = intval($duration->format('%d'));
if ($day > 0) {
$hour = intval($duration->format('%h'));
$min = intval($duration->format('%i'));
$hour += $day * 24;
$hour = min($hour, 99);
$sign = $duration->format('%r');
$result = sprintf('%s%02dh %02dm', $sign, $hour, $min);
} else {
$result = $duration->format('%r%Hh %Im');
}
} catch (Exception $e) {
$result = "Invalid Date";
}
$service_showForm = new Application_Service_ShowFormService();
$result = $service_showForm->calculateDuration($this->_getParam('startTime'),
$this->_getParam('endTime'));
echo Zend_Json::encode($result);
exit();