Bug 11263: Use all languages instead of just the translated ones
[koha_fer] / serials / subscription-add.pl
index fd338b0..e31b8f2 100755 (executable)
@@ -69,7 +69,8 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
 
     my $subscriptionid = $query->param('subscriptionid');
     $subs = GetSubscription($subscriptionid);
-## FIXME : Check rights to edit if mod. Could/Should display an error message.
+
+    ## FIXME : Check rights to edit if mod. Could/Should display an error message.
     if ($subs->{'cannotedit'} && $op eq 'modify'){
       carp "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
       print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
@@ -124,10 +125,14 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
     }
 }
 
-my $onlymine=C4::Context->preference('IndependantBranches') &&
-             C4::Context->userenv &&
-             C4::Context->userenv->{flags} % 2 !=1 &&
-             C4::Context->userenv->{branch};
+my $onlymine =
+     C4::Context->preference('IndependentBranches')
+  && C4::Context->userenv
+  && !C4::Context->IsSuperLibrarian
+  && (
+    not C4::Auth::haspermission( C4::Context->userenv->{id}, { serials => 'superserials' } )
+  )
+  && C4::Context->userenv->{branch};
 my $branches = GetBranches($onlymine);
 my $branchloop;
 for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
@@ -208,15 +213,14 @@ if ($op eq 'addsubscription') {
     }
     $template->param(numberpatterns => \@numberpatternloop);
 
-    # Get installed locales
-    # FIXME this will not work with all environments.
-    # If call to locale fails, @locales will be an empty array, which is fine.
-    my @locales = map {
-        chomp;
-        # we don't want POSIX and C locales
-        /^C|^POSIX$/ ? () : $_
-    } `locale -a`;
-    $template->param(locales => \@locales);
+    my $languages = [ map {
+        {
+            language => $_->{iso639_2_code},
+            description => $_->{language_description} || $_->{language}
+        }
+    } @{ C4::Languages::getAllLanguages() } ];
+
+    $template->param( locales => $languages );
 
     output_html_with_http_headers $query, $cookie, $template->output;
 }