コード例 #1
0
 public function deleteAction()
 {
     $record = Record::find($this->getParam('id'));
     if ($record) {
         $record->delete();
     }
     $this->alert('Record deleted.', 'green');
     $this->redirectFromHere(array('action' => 'index', 'id' => NULL, 'csrf' => NULL));
 }
コード例 #2
0
ファイル: ArtistType.php プロジェクト: Lavoaster/PVLive
 public static function getTypeTotals()
 {
     $totals = \DF\Cache::get('artist_totals');
     if (!$totals) {
         $totals = array();
         $records = self::fetchAll();
         foreach ($records as $record) {
             $totals['types'][$record->id] = array('name' => $record->name, 'icon' => $record->icon, 'count' => count($record->artists));
         }
         $totals['overall'] = array('count' => count(Artist::fetchArray()));
         \DF\Cache::save($totals, 'artist_totals', array(), 600);
     }
     return $totals;
 }
コード例 #3
0
ファイル: ArchiveSong.php プロジェクト: Lavoaster/PVLive
 public function setArtist($artist)
 {
     $this->artist = $artist;
     $this->artists->clear();
     $artist_parts = explode(',', $artist);
     foreach ((array) $artist_parts as $artist_name) {
         $artist_name = trim($artist_name);
         if (!empty($artist_name)) {
             $artist_obj = Artist::getRepository()->findOneByName($artist_name);
             if ($artist_obj instanceof Artist) {
                 $this->artists->add($artist_obj);
             }
         }
     }
 }
コード例 #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);
 }