Exemple #1
0
 /**
  * Sets up the permissions for the plugin. It sets up permissions for every show that's in the database.
  *
  * @return array The permissions array.
  */
 public function registerPermissions()
 {
     $permissions = ['cosmicradiotv.podcast.access_release_types' => ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.general', 'label' => 'cosmicradiotv.podcast::lang.permissions.labels.access_release_types'], 'cosmicradiotv.podcast.access_tags' => ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.general', 'label' => 'cosmicradiotv.podcast::lang.permissions.labels.access_tags'], 'cosmicradiotv.podcast.access_shows_all' => ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.general', 'label' => 'cosmicradiotv.podcast::lang.permissions.labels.access_shows_all'], 'cosmicradiotv.podcast.access_shows' => ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.general', 'label' => 'cosmicradiotv.podcast::lang.permissions.labels.access_shows'], 'cosmicradiotv.podcast.access_episodes_all' => ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.general', 'label' => 'cosmicradiotv.podcast::lang.permissions.labels.access_episodes_all'], 'cosmicradiotv.podcast.access_episodes' => ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.general', 'label' => 'cosmicradiotv.podcast::lang.permissions.labels.access_episodes']];
     // Add the permissions for individual shows
     $shows = Show::all();
     foreach ($shows as $show) {
         $permissions['cosmicradiotv.podcast.access_show_' . $show->slug] = ['tab' => 'cosmicradiotv.podcast::lang.permissions.tab_labels.shows', 'label' => e(trans('cosmicradiotv.podcast::lang.permissions.labels.access_show')) . ' ' . $show->name];
     }
     return $permissions;
 }
Exemple #2
0
 public function listExtendQuery($query, $definition = null)
 {
     $user = BackendAuth::getUser();
     if (!$user->hasAccess(['cosmicradiotv.podcast.access_episodes_all'])) {
         $shows = Show::all();
         $show_ids_allowed = [];
         foreach ($shows as $show) {
             if ($user->hasAccess(['cosmicradiotv.podcast.access_show_' . $show->slug])) {
                 $show_ids_allowed[] = $show->id;
             }
         }
         $query->whereIn('show_id', $show_ids_allowed);
     }
 }