public function editAction()
 {
     $form = new \DF\Form($this->current_module_config->forms->convention);
     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('conventions');
         foreach ($files as $file_field => $file_paths) {
             $data[$file_field] = $file_paths[1];
         }
         $record->fromArray($data);
         $record->save();
         $this->_flushConventionCache();
         $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 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);
 }
Beispiel #5
0
 /**
  * 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');
 }