public function viewAction() { $id = $this->getParam('id'); $station = Station::find($id); if ($station->is_active) { throw new \DF\Exception\DisplayOnly('This station has already been reviewed and is active.'); } $station_form = new \DF\Form($this->module_config['frontend']->forms->submit_station); $station_form->populate($station->toArray()); $form = new \DF\Form($this->current_module_config->forms->vote); if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); $data['name'] = $this->vote_name; $intake_votes = (array) $station->intake_votes; if ($data['decision'] == 'Abstain') { unset($intake_votes[$this->vote_hash]); } else { $intake_votes[$this->vote_hash] = $data; } $station->intake_votes = $intake_votes; $station->save(); $this->alert('Your vote has been submitted. Thank you for your feedback.', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); return; } $this->view->station_form = $station_form; $this->view->form = $form; }
public function editAction() { $form_config = $this->current_module_config->forms->artist->toArray(); unset($form_config['groups']['intro']); $form = new \DF\Form($form_config); if ($this->hasParam('id')) { $id = (int) $this->getParam('id'); $record = Record::find($id); $form->setDefaults($record->toArray(TRUE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof Record) { $record = new Record(); } $files = $form->processFiles('artists'); foreach ($files as $file_field => $file_paths) { $data[$file_field] = $file_paths[1]; } $record->fromArray($data); $record->save(); $this->alert('Changes saved.', 'green'); $origin = $this->getParam('origin', 'admin'); if ($origin == 'profile') { return $this->redirectToRoute(array('module' => 'default', 'controller' => 'artists', 'action' => 'view', 'id' => $record->id)); } else { return $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); } } $this->renderForm($form, 'edit', 'Edit Record'); }
public function editAction() { $form_config = $this->current_module_config->forms->source; $form = new \DF\Form($form_config); if ($this->hasParam('id')) { $record = PodcastSource::getRepository()->findOneBy(array('id' => $this->getParam('id'), 'podcast_id' => $this->podcast->id)); $form->setDefaults($record->toArray()); } if (!empty($_POST) && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof PodcastSource) { $record = new PodcastSource(); $record->podcast = $this->podcast; } $record->fromArray($data); $record->save(); // Clear cache. \DF\Cache::remove('podcasts'); // Immediately re-process this podcast. \PVL\PodcastManager::processPodcast($this->podcast); $this->alert('<b>Podcast source updated.</b>', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); return; } $title = ($this->hasParam('id') ? 'Edit' : 'Add') . ' Podcast Source'; $this->renderForm($form, 'edit', $title); }
public function editAction() { $form = new \DF\Form($this->current_module_config->forms->rotator); if ($this->hasParam('id')) { $id = (int) $this->getParam('id'); $record = Record::find($id); $form->setDefaults($record->toArray(FALSE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof Record) { $record = new Record(); } $files = $form->processFiles('rotators'); foreach ($files as $file_field => $file_paths) { if (!empty($file_paths)) { $data[$file_field] = $file_paths[1]; } } if ($data['image_url']) { \DF\Image::resizeImage($data['image_url'], $data['image_url'], 336, 280); } $record->fromArray($data); $record->save(); $this->alert('Changes saved.', 'green'); return $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); } $this->renderForm($form, 'edit', 'Edit Record'); }
public function editAction() { $form = new \DF\Form($this->current_module_config->forms->song); if ($this->hasParam('id')) { $id = $this->getParam('id'); $record = Record::find($id); $form->setDefaults($record->toArray(TRUE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof Record) { $record = new Record(); } /* $files = $form->processFiles('songs'); foreach($files as $file_field => $file_paths) $data[$file_field] = $file_paths[1]; */ $record->fromArray($data); $record->save(); $this->alert('Changes saved.', 'green'); return $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); } $this->renderForm($form, 'edit', 'Edit Record'); }
public function editAction() { if ($this->station->category == 'video') { $form_config = $this->current_module_config->forms->video_stream; } else { $form_config = $this->current_module_config->forms->radio_stream; } $form = new \DF\Form($form_config); if ($this->hasParam('id')) { $record = StationStream::getRepository()->findOneBy(array('id' => $this->getParam('id'), 'station_id' => $this->station->id)); $form->setDefaults($record->toArray()); } if (!empty($_POST) && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof StationStream) { $record = new StationStream(); $record->station = $this->station; } $record->fromArray($data); $record->save(); // Ensure at least one stream is default. $this->station->checkDefaultStream(); // Clear station cache. \DF\Cache::remove('stations'); // Immediately load "Now Playing" data for the added/updated stream. if ($data['is_active'] == 0) { $record->save(); $this->alert('<b>Stream updated, but is currently inactive.</b><br>The system will not retrieve Now Playing data about this stream until it is activated.', 'red'); } elseif ($this->station->category == 'video') { $np = \PVL\NowPlaying::processVideoStream($record, $this->station, true); $record->save(); if ($np['meta']['status'] == 'online') { $this->alert('<b>Stream updated, and currently showing as online.</b>', 'green'); } else { $this->alert('<b>Stream updated, but is currently offline.</b>', 'red'); } } else { $np = \PVL\NowPlaying::processAudioStream($record, $this->station, true); $record->save(); if ($np['status'] != 'offline') { $song = $np['current_song']; $this->alert('<b>Stream updated and successfully connected.</b><br>The currently playing song is reporting as "' . $song['title'] . '" by "' . $song['artist'] . '" with ' . $np['listeners']['current'] . ' tuned in.', 'green'); } else { $this->alert('<b>Stream updated, but is currently offline.</b><br>The system could not retrieve now-playing information about this stream. Verify that the station is online and the URLs are correct.', 'red'); } } $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); return; } $title = ($this->hasParam('id') ? 'Edit' : 'Add') . ' Station Stream'; $this->renderForm($form, 'edit', $title); }
public function timezoneAction() { $form = new \DF\Form($this->current_module_config->forms->timezone); $form->setDefaults(array('timezone' => \PVL\Customization::get('timezone'))); if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); \PVL\Customization::set('timezone', $data['timezone']); $this->alert('Time zone updated!', 'green'); $this->redirectToStoredReferrer('customization'); return; } $this->storeReferrer('customization'); $this->view->setVar('title', 'Set Time Zone'); $this->renderForm($form); }
public function indexAction() { $form = new \DF\Form($this->current_module_config->forms->settings->form); $existing_settings = Settings::fetchArray(FALSE); $form->setDefaults($existing_settings); if (!empty($_POST) && $form->isValid($_POST)) { $data = $form->getValues(); foreach ($data as $key => $value) { Settings::setSetting($key, $value); } Settings::clearCache(); $this->alert('Settings updated!'); return $this->redirectHere(); } $this->renderForm($form, 'edit', 'Site Settings'); }
public function editAction() { $form = new \DF\Form($this->current_module_config->forms->block->form); if ($this->hasParam('id')) { $id = (int) $this->getParam('id'); $record = Block::find($id); $form->setDefaults($record->toArray(TRUE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof Block) { $record = new Block(); } $record->fromArray($data); $record->save(); $this->alert('Changes saved.'); return $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); } $this->renderForm($form, 'edit', 'Edit Content Block'); }
public function editAction() { $form = new \DF\Form($this->current_module_config->forms->user_edit->form); if ($this->hasParam('id')) { $record = User::find($this->getParam('id')); $record_defaults = $record->toArray(TRUE, TRUE); unset($record_defaults['auth_password']); $form->setDefaults($record_defaults); } if (!empty($_POST) && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof User) { $record = new User(); } $record->fromArray($data); $record->save(); $this->alert('User updated.', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL, 'csrf' => NULL)); return; } $this->renderForm($form, 'edit', 'Edit Record'); }
public function editroleAction() { $form_config = $this->current_module_config->forms->role->form->toArray(); $form = new \DF\Form($form_config); if ($this->hasParam('id')) { $record = Role::find($this->getParam('id')); $form->setDefaults($record->toArray(TRUE, TRUE)); } if (!empty($_POST) && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof Role) { $record = new Role(); } $record->fromArray($data); $record->save(); $this->alert('<b>Role updated!</b>', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL, 'csrf' => NULL)); return; } $this->view->setVar('title', 'Add/Edit Role'); $this->renderForm($form); }
public function editAction() { $form = new \DF\Form($this->current_module_config->forms->url); if ($this->hasParam('id')) { $record = ShortUrl::getRepository()->find($this->getParam('id')); $form->setDefaults($record->toArray()); } if (!empty($_POST) && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof ShortUrl) { $record = new ShortUrl(); } $record->fromArray($data); if (!$record->checkUrl()) { throw new \DF\Exception\DisplayOnly('This URL is already taken! Please go back and try another.'); } $record->save(); $this->alert('Record updated.', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); return; } $this->renderForm($form, 'edit', $this->hasParam('id') ? 'Edit Short URL' : 'Add Short URL'); }
/** * Submit a new show/podcast. * * @throws \DF\Exception */ public function showAction() { $this->em->getFilters()->disable('softdelete'); $user = $this->auth->getLoggedInUser(); // Check for existing submissions. $existing_submissions = $this->em->createQuery('SELECT p, u FROM Entity\\Podcast p JOIN p.managers u WHERE (p.deleted_at IS NULL OR p.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 shows to the system:</b>'; $message .= '<ul>'; foreach ($existing_submissions as $podcast) { if ($podcast['deleted_at']) { $status = 'Declined'; } elseif ($podcast['is_approved']) { $status = 'Approved'; } else { $status = 'Pending Review'; } $message .= '<li><b>' . $podcast['name'] . ':</b> ' . $status . '</li>'; } $message .= '</ul>'; $message .= 'Please contact the PVL team for questions related to these shows, and do not resubmit them!'; $this->flash($message, 'info'); } // Initialize the form. $form = new \DF\Form($this->current_module_config->forms->submit_show); if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); $files = $form->processFiles('podcasts'); foreach ($files as $file_field => $file_paths) { $data[$file_field] = $file_paths[1]; } // Check for existing podcast by name. $existing_podcast = Podcast::getRepository()->findOneBy(array('name' => $data['name'])); if ($existing_podcast instanceof Podcast) { throw new \DF\Exception('A podcast with this name already exists! Please do not submit duplicate stations.'); } // Set up initial station record. $record = new Podcast(); $record->fromArray($data); $record->is_approved = false; $record->contact_email = $user->email; $record->save(); // Make the current user an administrator of the new podcast. if (!$this->acl->isAllowed('administer all')) { $user->podcasts->add($record); $user->save(); } // Notify all existing managers. $network_administrators = Action::getUsersWithAction('administer all'); $email_to = Utilities::ipull($network_administrators, 'email'); if ($email_to) { \DF\Messenger::send(array('to' => $email_to, 'subject' => 'New Podcast/Show Submitted For Review', 'template' => 'newshow', 'vars' => array('form' => $form->populate($_POST)))); } $this->alert('Your show 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 Show'); }
public function editarchiveAction() { $con = $this->_getConvention(); $form = new \DF\Form($this->current_module_config->forms->conventionarchive); if ($this->hasParam('id')) { $id = (int) $this->getParam('id'); $record = ConventionArchive::find($id); $form->setDefaults($record->toArray(TRUE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof ConventionArchive) { $record = new ConventionArchive(); $record->convention = $con; } $record->fromArray($data); $record->save(); $record->process(); $this->alert('Changes saved.', 'green'); $this->redirectFromHere(array('action' => 'archives', 'convention' => $con->id, 'id' => NULL)); return; } $this->view->setVar('title', 'Edit Convention Archive Item'); $this->renderForm($form); }
public function profileAction() { $this->acl->checkPermission('is logged in'); $user = $this->auth->getLoggedInUser(); $form_config = $this->module_config['admin']->forms->artist->toArray(); unset($form_config['groups']['admin']); $form = new \DF\Form($form_config); if ($user->artist instanceof Artist) { $record = $user->artist; $form->setDefaults($record->toArray(TRUE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); $files = $form->processFiles('artists'); foreach ($files as $file_field => $file_paths) { $data[$file_field] = $file_paths[1]; } if (!$record instanceof Artist) { // Check for existing artist with same name. $record = Artist::findAbandonedByName($data['name']); if ($record instanceof Artist) { $record->user = $user; } else { $record = new Artist(); $record->is_approved = false; $record->user = $user; } } $record->fromArray($data); $record->save(); $this->alert('<b>Your artist profile has been submitted!</b><br>After review, your profile will be listed on the Ponyville Live network artist directory. Thank you for your submission.', 'green'); $this->redirectFromHere(array('action' => 'index')); return; } if ($user->is_artist) { $title = 'Update Artist Profile'; } else { $title = 'Submit an Artist Profile'; } $this->renderForm($form, 'edit', $title); }
public function indexAction() { // Assemble list of stations. $all_stations = $this->em->createQuery('SELECT s, u FROM Entity\\Station s LEFT JOIN s.managers u WHERE s.is_active = 1')->getArrayResult(); $station_select = array(); $station_contacts = array(); foreach ($all_stations as $station) { $station_id = $station['id']; $station_contact = array(); if (!empty($station['contact_email'])) { $station_contact[] = strtolower($station['contact_email']); } if (!empty($station['managers'])) { foreach ($station['managers'] as $manager) { $station_contact[] = strtolower($manager['email']); } } if (!empty($station_contact)) { $station_text = $station['name']; } else { $station_text = '<span class="text-disabled" title="No e-mail addresses on file!">' . $station['name'] . '</span>'; } $station_select[$station_id] = $station_text; $station_contacts[$station_id] = array_unique($station_contact); } // Assemble list of podcasts. $all_podcasts = $this->em->createQuery('SELECT p, u FROM Entity\\Podcast p LEFT JOIN p.managers u WHERE p.is_approved = 1')->getArrayResult(); $podcast_select = array(); $podcast_contacts = array(); foreach ($all_podcasts as $podcast) { $podcast_id = $podcast['id']; $podcast_contact = array(); if (!empty($podcast['contact_email'])) { $podcast_contact[] = strtolower($podcast['contact_email']); } if (!empty($podcast['managers'])) { foreach ($podcast['managers'] as $manager) { $podcast_contact[] = strtolower($podcast['email']); } } if (!empty($podcast_contact)) { $podcast_text = $podcast['name']; } else { $podcast_text = '<span class="text-disabled" title="No e-mail addresses on file!">' . $podcast['name'] . '</span>'; } $podcast_select[$podcast_id] = $podcast_text; $podcast_contacts[$podcast_id] = array_unique($podcast_contact); } // Assemble contact form. $form_info = $this->current_module_config->forms->contact->form->toArray(); $form_info['groups']['recipients']['elements']['stations'][1]['multiOptions'] = $station_select; $form_info['groups']['recipients']['elements']['podcasts'][1]['multiOptions'] = $podcast_select; $form = new \DF\Form($form_info); if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); $email_to = array(); foreach ((array) $data['stations'] as $station_id) { $email_to = array_merge($email_to, $station_contacts[$station_id]); } foreach ((array) $data['podcasts'] as $podcast_id) { $email_to = array_merge($email_to, $podcast_contacts[$podcast_id]); } $email_to = array_unique($email_to); \DF\Messenger::send(array('to' => $email_to, 'subject' => $data['subject'], 'template' => 'bulkcontact', 'vars' => array('body' => nl2br($data['body'])))); $this->alert('<b>Message sent to ' . count($email_to) . ' recipient(s)!</b>', 'green'); return $this->redirectHere(); } $this->view->form = $form; }
public function forgotAction() { $form = new \DF\Form($this->current_module_config->forms->forgot); if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); $user = User::getRepository()->findOneBy(array('email' => $data['contact_email'])); if ($user instanceof User) { $user->generateAuthRecoveryCode(); $user->save(); \DF\Messenger::send(array('to' => $user->email, 'subject' => 'Password Recovery Code', 'template' => 'forgotpw', 'vars' => array('record' => $user))); } $this->alert('<b>A password recovery link has been sent to your e-mail address.</b><br>Click the link in the e-mail to reset your password.', 'green'); $this->redirectHome(); return; } $this->view->setVar('title', 'Forgot My Password'); $this->renderForm($form); }