Beispiel #1
0
 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()
 {
     $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');
 }
Beispiel #3
0
 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');
 }
Beispiel #4
0
 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);
 }
Beispiel #5
0
 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);
 }
Beispiel #6
0
 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');
 }
Beispiel #8
0
 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');
 }
Beispiel #9
0
 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);
 }
Beispiel #11
0
 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');
 }
 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);
 }
Beispiel #13
0
 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);
 }