Пример #1
0
 public function makeContextMenuAction()
 {
     $id = $this->_getParam('id');
     $today_timestamp = date("Y-m-d H:i:s");
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new User($userInfo->id);
     $show = new ShowInstance($id);
     $params = '/format/json/id/#id#';
     if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
         if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST), $show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) {
             $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog' . $params, 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content');
             $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
         }
     }
     if (!$show->isRecorded()) {
         $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog' . $params, 'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content');
     }
     if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp) && is_null($show->getSoundCloudFileId()) && $show->isRecorded() && Application_Model_Preference::GetDoSoundCloudUpload()) {
         $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['uploadToSoundCloud']({$id})"), 'title' => 'Upload to Soundcloud');
     }
     if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) && strtotime($today_timestamp) < strtotime($show->getShowEnd()) && $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
         $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['confirmCancelShow']({$id})"), 'title' => 'Cancel Current Show');
     }
     if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
         if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
             $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/' . $id, 'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show');
             $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
             $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
         }
     }
     //returns format jjmenu is looking for.
     die(json_encode($menu));
 }