diff --git a/.zfproject.xml b/.zfproject.xml
index 5c6ac36f8..aa444e92a 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -58,6 +58,7 @@
+
@@ -194,6 +195,9 @@
+
+
+
diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
index 2bdfab913..bb0c3dda7 100644
--- a/application/controllers/ScheduleController.php
+++ b/application/controllers/ScheduleController.php
@@ -17,7 +17,8 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('move-show', 'json')
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
- ->addActionContext('schedule-show', 'json')
+ ->addActionContext('schedule-show', 'json')
+ ->addActionContext('clear-show', 'json')
->initContext();
}
@@ -41,6 +42,7 @@ class ScheduleController extends Zend_Controller_Action
$eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete');
$eventHostMenu[] = array('action' => '/Schedule/schedule-show', 'text' => 'Schedule');
+ $eventHostMenu[] = array('action' => '/Schedule/clear-show', 'text' => 'Clear');
$this->view->eventHostMenu = $eventHostMenu;
}
@@ -121,7 +123,7 @@ class ScheduleController extends Zend_Controller_Action
public function deleteShowAction()
{
$showId = $this->_getParam('showId');
-
+
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type));
@@ -135,23 +137,44 @@ class ScheduleController extends Zend_Controller_Action
public function scheduleShowAction()
{
- $request = $this->getRequest();
-
+ $request = $this->getRequest();
+
if($request->isPost()) {
$plId = $this->_getParam('plId');
$start = $this->_getParam('start');
+ $showId = $this->_getParam('showId');
- $sched = new ScheduleGroup();
- $this->view->res = $sched->add($start, null, $plId);
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $user = new User($userInfo->id, $userInfo->type);
+
+ if($user->isHost($showId)) {
+
+ $sched = new ScheduleGroup();
+ $this->view->res = $sched->add($start, null, $plId);
+ }
}
else {
- $showId = $this->_getParam('showId');
$length = $this->_getParam('length');
$this->view->playlists = Playlist::findPlaylistMaxLength($length);
}
}
+ public function clearShowAction()
+ {
+ $start = $this->_getParam('start');
+ $showId = $this->_getParam('showId');
+
+ $userInfo = Zend_Auth::getInstance()->getStorage()->read();
+ $user = new User($userInfo->id, $userInfo->type);
+
+ if($user->isHost($showId)) {
+
+ $sched = new ScheduleGroup();
+ $this->view->res = $sched->removeAtTime($start);
+ }
+ }
+
}
@@ -171,3 +194,5 @@ class ScheduleController extends Zend_Controller_Action
+
+
diff --git a/application/models/Schedule.php b/application/models/Schedule.php
index 822375482..6e2c2aa71 100644
--- a/application/models/Schedule.php
+++ b/application/models/Schedule.php
@@ -174,6 +174,22 @@ class ScheduleGroup {
}
+ public function removeAtTime($p_datetime) {
+ global $CC_CONFIG, $CC_DBC;
+
+ $id = $this->dateToId($p_datetime);
+
+ $sql = "SELECT group_id FROM ".$CC_CONFIG["scheduleTable"]." WHERE id = ".$id;
+ $groupId = $CC_DBC->GetOne($sql);
+
+ if($groupId === NULL)
+ return;
+
+ $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
+ ." WHERE group_id = ".$groupId;
+ $CC_DBC->query($sql);
+ }
+
/**
* Remove the group from the schedule.
* Note: does not check if it is in the past, you can remove anything.
diff --git a/public/js/campcaster/schedule/schedule.js b/public/js/campcaster/schedule/schedule.js
index 6ee2f4767..04d37df8f 100644
--- a/public/js/campcaster/schedule/schedule.js
+++ b/public/js/campcaster/schedule/schedule.js
@@ -89,29 +89,37 @@ function closeDialog(event, ui) {
}
function schedulePlaylist() {
- var li, pl_id, url, start, dialog;
+ var li, pl_id, url, event, start, dialog;
dialog = $(this);
li = $("#schedule_playlist_dialog").find(".ui-state-active");
+
+ if(li.length === 0) {
+ dialog.remove();
+ return;
+ }
+
pl_id = li.data('pl_id');
- start = li.data('start');
+ event = li.parent().data('event');
+ start = event.start;
var sy, sm, sd, h, m, s;
- sy = start.getFullYear();
- sm = start.getMonth() + 1;
- sd = start.getDate();
- h = start.getHours();
- m = start.getMinutes();
- s = start.getSeconds();
+ sy = start.getFullYear();
+ sm = start.getMonth() + 1;
+ sd = start.getDate();
+ h = start.getHours();
+ m = start.getMinutes();
+ s = start.getSeconds();
- start_date = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
+ start_date = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
url = '/Schedule/schedule-show/format/json';
$.post(url,
- {plId: pl_id, start: start_date},
+ {plId: pl_id, start: start_date, showId: event.id},
function(json){
dialog.remove();
+ $("#schedule_calendar").fullCalendar( 'refetchEvents' );
});
}
@@ -154,7 +162,7 @@ function makeScheduleDialog(playlists, event) {
ol = $('');
$.each(playlists, function(i, val){
li = $('')
- .addClass('ui-widget-content ui-selectee')
+ .addClass('ui-widget-content')
.append(''+val.name+'
')
.append(''+val.description+'
')
.click(function(){
@@ -162,10 +170,11 @@ function makeScheduleDialog(playlists, event) {
$(this).addClass("ui-state-active");
});
- li.data({'pl_id': val.id, 'start': event.start});
+ li.data({'pl_id': val.id});
ol.append(li);
});
-
+
+ ol.data({'event': event});
dialog.append(ol);
dialog.dialog({
@@ -180,6 +189,30 @@ function makeScheduleDialog(playlists, event) {
return dialog;
}
+function openShowDialog() {
+ var url;
+
+ url = '/Schedule/add-show-dialog/format/json';
+
+ $.get(url, function(json){
+ var dialog = makeShowDialog(json.form);
+ dialog.dialog('open');
+ });
+}
+
+function openScheduleDialog(event, time) {
+ var url;
+
+ url = '/Schedule/schedule-show/format/json';
+
+ $.get(url,
+ {length: time},
+ function(json){
+ var dialog = makeScheduleDialog(json.playlists, event);
+ dialog.dialog('open');
+ });
+}
+
function eventMenu(action, el, pos) {
var method = action.split('/').pop(),
event;
@@ -206,6 +239,27 @@ function eventMenu(action, el, pos) {
openScheduleDialog(event, time);
}
+ else if (method === 'clear-show') {
+ start = event.start;
+
+ var sy, sm, sd, h, m, s, start_date;
+ sy = start.getFullYear();
+ sm = start.getMonth() + 1;
+ sd = start.getDate();
+ h = start.getHours();
+ m = start.getMinutes();
+ s = start.getSeconds();
+
+ start_date = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
+
+ url = '/Schedule/clear-show/format/json';
+
+ $.post(url,
+ {start: start_date, showId: event.id},
+ function(json){
+ $("#schedule_calendar").fullCalendar( 'refetchEvents' );
+ });
+ }
}
/**
@@ -284,30 +338,6 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
});
}
-function openShowDialog() {
- var url;
-
- url = '/Schedule/add-show-dialog/format/json';
-
- $.get(url, function(json){
- var dialog = makeShowDialog(json.form);
- dialog.dialog('open');
- });
-}
-
-function openScheduleDialog(event, time) {
- var url;
-
- url = '/Schedule/schedule-show/format/json';
-
- $.get(url,
- {showId: event.id, length: time},
- function(json){
- var dialog = makeScheduleDialog(json.playlists, event);
- dialog.dialog('open');
- });
-}
-
$(document).ready(function() {
$('#schedule_calendar').fullCalendar({