Lines 2840-2884
sub subscriptionCurrentlyOnOrder {
Link Here
|
2840 |
|
2840 |
|
2841 |
$can = can_edit_subscription( $subscriptionid[, $userid] ); |
2841 |
$can = can_edit_subscription( $subscriptionid[, $userid] ); |
2842 |
|
2842 |
|
2843 |
Return 1 if the subscription is editable by the current logged user (or a given $userid), else 0. |
2843 |
Return 1 if the subscription can be edited by the current logged user (or a given $userid), else 0. |
2844 |
|
2844 |
|
2845 |
=cut |
2845 |
=cut |
2846 |
|
2846 |
|
2847 |
sub can_edit_subscription { |
2847 |
sub can_edit_subscription { |
2848 |
my ( $subscription, $userid ) = @_; |
2848 |
my ( $subscription, $userid ) = @_; |
2849 |
return 0 unless C4::Context->userenv; |
2849 |
return _can_do_on_subscription( $subscription, $userid, 'edit_subscription' ); |
2850 |
my $flags = C4::Context->userenv->{flags}; |
|
|
2851 |
$userid ||= C4::Context->userenv->{'id'}; |
2852 |
|
2853 |
if ( C4::Context->preference('IndependentBranches') ) { |
2854 |
return 1 |
2855 |
if C4::Context->IsSuperLibrarian() |
2856 |
or |
2857 |
C4::Auth::haspermission( $userid, { serials => 'superserials' } ) |
2858 |
or ( |
2859 |
C4::Auth::haspermission( $userid, |
2860 |
{ serials => 'edit_subscription' } ) |
2861 |
and ( not defined $subscription->{branchcode} |
2862 |
or $subscription->{branchcode} eq '' |
2863 |
or $subscription->{branchcode} eq |
2864 |
C4::Context->userenv->{'branch'} ) |
2865 |
); |
2866 |
} |
2867 |
else { |
2868 |
return 1 |
2869 |
if C4::Context->IsSuperLibrarian() |
2870 |
or |
2871 |
C4::Auth::haspermission( $userid, { serials => 'superserials' } ) |
2872 |
or C4::Auth::haspermission( |
2873 |
$userid, { serials => 'edit_subscription' } |
2874 |
), |
2875 |
; |
2876 |
} |
2877 |
return 0; |
2878 |
} |
2850 |
} |
2879 |
|
2851 |
|
|
|
2852 |
=head2 can_show_subscription |
2853 |
|
2854 |
$can = can_show_subscription( $subscriptionid[, $userid] ); |
2855 |
|
2856 |
Return 1 if the subscription can be shown by the current logged user (or a given $userid), else 0. |
2857 |
|
2858 |
=cut |
2859 |
|
2880 |
sub can_show_subscription { |
2860 |
sub can_show_subscription { |
2881 |
my ( $subscription, $userid ) = @_; |
2861 |
my ( $subscription, $userid ) = @_; |
|
|
2862 |
return _can_do_on_subscription( $subscription, $userid, '*' ); |
2863 |
} |
2864 |
|
2865 |
sub _can_do_on_subscription { |
2866 |
my ( $subscription, $userid, $permission ) = @_; |
2882 |
return 0 unless C4::Context->userenv; |
2867 |
return 0 unless C4::Context->userenv; |
2883 |
my $flags = C4::Context->userenv->{flags}; |
2868 |
my $flags = C4::Context->userenv->{flags}; |
2884 |
$userid ||= C4::Context->userenv->{'id'}; |
2869 |
$userid ||= C4::Context->userenv->{'id'}; |
Lines 2890-2896
sub can_show_subscription {
Link Here
|
2890 |
C4::Auth::haspermission( $userid, { serials => 'superserials' } ) |
2875 |
C4::Auth::haspermission( $userid, { serials => 'superserials' } ) |
2891 |
or ( |
2876 |
or ( |
2892 |
C4::Auth::haspermission( $userid, |
2877 |
C4::Auth::haspermission( $userid, |
2893 |
{ serials => '*' } ) |
2878 |
{ serials => $permission } ) |
2894 |
and ( not defined $subscription->{branchcode} |
2879 |
and ( not defined $subscription->{branchcode} |
2895 |
or $subscription->{branchcode} eq '' |
2880 |
or $subscription->{branchcode} eq '' |
2896 |
or $subscription->{branchcode} eq |
2881 |
or $subscription->{branchcode} eq |
Lines 2903-2909
sub can_show_subscription {
Link Here
|
2903 |
or |
2888 |
or |
2904 |
C4::Auth::haspermission( $userid, { serials => 'superserials' } ) |
2889 |
C4::Auth::haspermission( $userid, { serials => 'superserials' } ) |
2905 |
or C4::Auth::haspermission( |
2890 |
or C4::Auth::haspermission( |
2906 |
$userid, { serials => '*' } |
2891 |
$userid, { serials => $permission } |
2907 |
), |
2892 |
), |
2908 |
; |
2893 |
; |
2909 |
} |
2894 |
} |
2910 |
- |
|
|