+use C4::Auth; # get_template_and_user
+use C4::Output;
+use C4::VirtualShelves;
+use C4::Branch; # GetBranches
+use C4::Members; # GetMember
+use C4::NewsChannels; # get_opac_news
+use C4::Acquisition; # GetRecentAcqui
+use C4::Languages qw(getTranslatedLanguages accept_language);
+
+my $input = new CGI;
+my $dbh = C4::Context->dbh;
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "opac-main.tmpl",
+ type => "opac",
+ query => $input,
+ authnotrequired => 1,
+ flagsrequired => { borrow => 1 },
+ }
+);
+
+my $casAuthentication = C4::Context->preference('casAuthentication');
+$template->param(
+ casAuthentication => $casAuthentication,
+);
+
+
+my $borrower = GetMember( borrowernumber=>$borrowernumber );
+$template->param(
+ textmessaging => $borrower->{textmessaging},
+) if (ref($borrower) eq "HASH");
+
+# display news
+# use cookie setting for language, bug default to syspref if it's not set
+(my $theme) = themelanguage(C4::Context->config('opachtdocs'),'opac-main.tmpl','opac',$input);
+
+my $translations = getTranslatedLanguages('opac',$theme);
+my @languages = ();
+foreach my $trans (@$translations)
+{
+ push(@languages, $trans->{rfc4646_subtag});
+}