Example #1
0
 public function testAction()
 {
     $this->doNotRender();
     set_time_limit(0);
     ini_set('memory_limit', '-1');
     Debug::setEchoMode();
     // -------- START HERE -------- //
     \PVL\CentovaCast::sync();
     Debug::log('CCast Sync Complete');
     $station = \Entity\Station::getRepository()->findOneBy(array('name' => 'PonyvilleFM'));
     $tracks = \PVL\CentovaCast::fetchTracks($station);
     Debug::print_r($tracks);
     // -------- END HERE -------- //
     Debug::log('Done!');
 }
Example #2
0
 public static function showSpecialEventsMode()
 {
     if (Settings::getSetting('special_event', 0) == 1) {
         return true;
     } elseif (Settings::getSetting('special_event_if_stream_active', 0) == 1) {
         $stream = Station::getRepository()->findOneBy(array('name' => 'PVL Special Events'));
         if ($stream instanceof Station) {
             return $stream->isPlaying();
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #3
0
 /**
  * Submit a new station.
  *
  * @throws \DF\Exception
  */
 public function stationAction()
 {
     $this->em->getFilters()->disable('softdelete');
     $user = $this->auth->getLoggedInUser();
     // Check for existing submissions.
     $existing_submissions = $this->em->createQuery('SELECT s, u FROM Entity\\Station s JOIN s.managers u
         WHERE (s.deleted_at IS NULL OR s.deleted_at IS NOT NULL)
         AND u.id = :user_id')->setParameter('user_id', $user->id)->getArrayResult();
     if ($existing_submissions) {
         $message = '<b>You have already submitted the following stations to the system:</b>';
         $message .= '<ul>';
         foreach ($existing_submissions as $station) {
             if ($station['deleted_at']) {
                 $status = 'Declined';
             } elseif ($station['is_active']) {
                 $status = 'Approved';
             } else {
                 $status = 'Pending Review';
             }
             $message .= '<li><b>' . $station['name'] . ':</b> ' . $status . '</li>';
         }
         $message .= '</ul>';
         $message .= 'Please contact the PVL team for questions related to these stations, and do not resubmit them!';
         $this->flash($message, 'info');
     }
     // Initialize the form.
     $form = new \DF\Form($this->current_module_config->forms->submit_station);
     if ($_POST && $form->isValid($_POST)) {
         $data = $form->getValues();
         $stream = $data['stream'];
         unset($data['stream']);
         $files = $form->processFiles('stations');
         foreach ($files as $file_field => $file_paths) {
             $data[$file_field] = $file_paths[1];
         }
         // Check for existing station by name.
         $existing_station = Station::getRepository()->findOneBy(array('name' => $data['name']));
         if ($existing_station instanceof Station) {
             throw new \DF\Exception('A station with this name already exists! Please do not submit duplicate stations.');
         }
         // Set up initial station record.
         $record = new Station();
         $record->fromArray($data);
         $record->is_active = false;
         $record->save();
         // Set up first stream, connected to station.
         $stream_record = new StationStream();
         $stream_record->fromArray($stream);
         $stream_record->name = 'Primary Stream';
         $stream_record->station = $record;
         $stream_record->is_default = 1;
         $stream_record->is_active = 1;
         $stream_record->save();
         // Make the current user an administrator of the new station.
         if (!$this->acl->isAllowed('administer all')) {
             $user->stations->add($record);
             $user->save();
         }
         /*
         * Now notify only PR account.
         *
                     // Notify all existing managers.
                     $station_managers_raw = StationManager::getAllActiveManagers();
                     $station_emails = Utilities::ipull($station_managers_raw, 'email');
         
                     $network_administrators = Action::getUsersWithAction('administer all');
                     $network_emails = Utilities::ipull($network_administrators, 'email');
         
                     $email_to = array_merge($station_emails, $network_emails);
         */
         $email_to = array('*****@*****.**');
         if ($email_to) {
             \DF\Messenger::send(array('to' => $email_to, 'subject' => 'New Station Submitted For Review', 'template' => 'newstation', 'vars' => array('form' => $form->populate($_POST))));
         }
         $this->alert('Your station has been submitted. Thank you! We will contact you with any questions or additional information.', 'green');
         $this->redirectHome();
         return;
     }
     $this->renderForm($form, 'edit', 'Submit Your Station');
 }