[vhffs-dev] [1724] No more HTML::Template in acl/view.pl

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1724
Author:   beuss
Date:     2011-05-14 11:34:05 +0200 (Sat, 14 May 2011)
Log Message:
-----------
No more HTML::Template in acl/view.pl

Modified Paths:
--------------
    trunk/vhffs-panel/acl/view.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/acl/view.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/acl/view.tmpl

Modified: trunk/vhffs-panel/acl/view.pl
===================================================================
--- trunk/vhffs-panel/acl/view.pl	2011-05-14 09:33:58 UTC (rev 1723)
+++ trunk/vhffs-panel/acl/view.pl	2011-05-14 09:34:05 UTC (rev 1724)
@@ -32,8 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
-use HTML::Template::Expr;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -42,11 +40,8 @@
 
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Services::Web;
 use Vhffs::Acl;
 use Vhffs::Constants;
 
@@ -67,13 +62,11 @@
 
 # Object does not exists
 unless( defined $object ) {
-    $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-    $template->param( MESSAGE => sprintf( gettext('Cannot get informations on object #%d'), $oid) );
+    $panel->render('misc/message.tt', { message => sprintf( gettext('Cannot get informations on object #%d'), $oid) } );
 } else {
     # Object exists, we need to know if access is granted to the user
     unless( $user->can_view( $object ) ) {
-        $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-        $template->param( MESSAGE => gettext('You\'re not allowed to view this object\'s ACL') );
+        $panel->render('misc/message.tt', { message => gettext('You\'re not allowed to view this object\'s ACL') } );
     } else {
         # access OK, let's see if some action was requested
         if(defined $cgi->param('update_acl_submit')) {
@@ -96,46 +89,27 @@
             }
         }
 
-	$panel->set_title( gettext('ACL Administration') );
+        $panel->set_title( gettext('ACL Administration') );
+        my $vars = {
+            target => $object
+        };
+        my $acls = Vhffs::Acl::get_object_acl( $vhffs, $object );
+        my $default_acl;
+        my $users_acl = [];
+        foreach my $acl ( @{$acls} )  {
+            if( defined $acl->{name} ) {
+                $acl->{perm} = Vhffs::Constants::ACL_UNDEFINED unless(defined $acl->{perm});
+                push( @$users_acl, $acl );
+            } else  {
+                $default_acl = {
+                    granted_oid => $acl->{granted_oid},
+                    'perm' => $acl->{perm}
+                 };
+            }
+        }
+        $vars->{default_acl} = $default_acl;
+        $vars->{users_acl} = $users_acl;
 
-	$template = new HTML::Template::Expr( filename => $templatedir.'/panel/acl/view.tmpl' , global_vars => 1 );
-
-	$template->param( TEXT_USER => gettext('User') );
-	$template->param( TARGET_OID => $object->get_oid );
-        $template->param( TEXT_MODIFY => gettext('Modify') );
-
-        $template->param( TEXT_DEFAULT => gettext('Default') );
-        $template->param( TEXT_ACL_UNDEF => gettext('Default') );
-        $template->param( TEXT_ACL_DENIED => gettext('Can\'t access') );
-        $template->param( TEXT_ACL_VIEW => gettext('Can view this service') );
-        $template->param( TEXT_ACL_MODIFY => gettext('Can modify this service') );
-        $template->param( TEXT_ACL_MANAGEACL => gettext('Can manage ACL for this service') );
-        $template->param( TEXT_ACL_DELETE => gettext('Can destroy this service') );
-
-	$template->param( VALUE_ACL_UNDEF => Vhffs::Constants::ACL_UNDEFINED );
-	$template->param( VALUE_ACL_DENIED => Vhffs::Constants::ACL_DENIED );
-	$template->param( VALUE_ACL_VIEW => Vhffs::Constants::ACL_VIEW );
-	$template->param( VALUE_ACL_MODIFY => Vhffs::Constants::ACL_MODIFY );
-	$template->param( VALUE_ACL_MANAGEACL => Vhffs::Constants::ACL_MANAGEACL );
-	$template->param( VALUE_ACL_DELETE => Vhffs::Constants::ACL_DELETE );
-
-	my $acls = Vhffs::Acl::get_object_acl( $vhffs, $object );
-	my @acldefault;
-	my @aclusers;
-	foreach my $acl ( @{$acls} )  {
-		if( defined $acl->{name} ) {
-			$acl->{perm} = Vhffs::Constants::ACL_UNDEFINED unless defined $acl->{perm};
-			push( @aclusers, { %$acl } );
-		}
-		else  {
-			push( @acldefault, { 'granted_oid' => $acl->{granted_oid} , 'perm' => $acl->{perm} } );
-		}
-	}
-
-	$template->param( ACL_DEFAULT => \@acldefault );
-	$template->param( ACL_USERS => \@aclusers );
+        $panel->render('acl/view.tt', $vars);
     }
 }
-
-$panel->build( $template );
-$panel->display;

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-14 09:33:58 UTC (rev 1723)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-14 09:34:05 UTC (rev 1724)
@@ -1,6 +1,5 @@
 paneltemplatesdir = @TEMPLATESDIR@/panel
 nobase_dist_paneltemplates_DATA = \
-	acl/view.tmpl \
 	admin/index.tmpl \
 	admin/bazaar/part.tmpl \
 	admin/bazaar/search.tmpl \
@@ -114,6 +113,7 @@
 	web/prefs.tmpl \
 	cron/create.tmpl \
 	cron/prefs.tmpl \
+	acl/view.tt \
 	admin/object/edit.tt \
 	anonymous/account_created.tt \
 	anonymous/login.tt \

Deleted: trunk/vhffs-panel/templates/acl/view.tmpl
===================================================================
--- trunk/vhffs-panel/templates/acl/view.tmpl	2011-05-14 09:33:58 UTC (rev 1723)
+++ trunk/vhffs-panel/templates/acl/view.tmpl	2011-05-14 09:34:05 UTC (rev 1724)
@@ -1,53 +0,0 @@
-<div class="acltable">
-<div class="tableheader">
-  <p>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_USER"></span>
-    <span><b><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_UNDEF"></b></span>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_DENIED"></span>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_VIEW"></span>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_MODIFY"></span>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_MANAGEACL"></span>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_DELETE"></span>
-    <span><TMPL_VAR ESCAPE=1 NAME="TEXT_MODIFY"></span>
-  </p>
-</div>
-<div class="tablebody">
-<TMPL_LOOP NAME="ACL_DEFAULT">
-  <form method="post" action="view.pl" accept-charset="utf-8">
-    <p>
-      <span><b><TMPL_VAR ESCAPE=1 NAME="TEXT_DEFAULT"></b></span>
-      <span> </span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_DENIED">" <TMPL_IF EXPR="perm==VALUE_ACL_DENIED">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_VIEW">" <TMPL_IF EXPR="perm==VALUE_ACL_VIEW">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_MODIFY">" <TMPL_IF EXPR="perm==VALUE_ACL_MODIFY">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_MANAGEACL">" <TMPL_IF EXPR="perm==VALUE_ACL_MANAGEACL">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_DELETE">" <TMPL_IF EXPR="perm==VALUE_ACL_DELETE">checked="checked"</TMPL_IF>/></span>
-      <span>
-        <input type="hidden" NAME="granted_oid" VALUE="<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" />
-        <input type="hidden" NAME="target_oid" VALUE="<TMPL_VAR ESCAPE=1 NAME="TARGET_OID">" />
-        <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_MODIFY">" name="update_acl_submit"/>
-      </span>
-    </p>
-  </form>
-</TMPL_LOOP>
-<TMPL_LOOP NAME="ACL_USERS">
-  <form method="post" action="view.pl" accept-charset="utf-8">
-    <p>
-      <span><TMPL_VAR ESCAPE=1 NAME="NAME"></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_UNDEF">" <TMPL_IF EXPR="perm==VALUE_ACL_UNDEF">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_DENIED">" <TMPL_IF EXPR="perm==VALUE_ACL_DENIED">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_VIEW">" <TMPL_IF EXPR="perm==VALUE_ACL_VIEW">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_MODIFY">" <TMPL_IF EXPR="perm==VALUE_ACL_MODIFY">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_MANAGEACL">" <TMPL_IF EXPR="perm==VALUE_ACL_MANAGEACL">checked="checked"</TMPL_IF>/></span>
-      <span><input type="radio" name="perm<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_ACL_DELETE">" <TMPL_IF EXPR="perm==VALUE_ACL_DELETE">checked="checked"</TMPL_IF>/></span>
-      <span>
-        <input type="hidden" NAME="granted_oid" VALUE="<TMPL_VAR ESCAPE=1 NAME="GRANTED_OID">" />
-        <input type="hidden" NAME="target_oid" VALUE="<TMPL_VAR ESCAPE=1 NAME="TARGET_OID">" />
-        <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_MODIFY">" name="update_acl_submit"/>
-      </span>
-    </p>
-  </form>
-</TMPL_LOOP>
-<span class="clear">&nbsp;</span>
-</div>
-</div>

Added: trunk/vhffs-panel/templates/acl/view.tt
===================================================================
--- trunk/vhffs-panel/templates/acl/view.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/acl/view.tt	2011-05-14 09:34:05 UTC (rev 1724)
@@ -0,0 +1,52 @@
+<p>[% 'ACL only describes right at panel level. They do not enforce any filesystem permissions, use FTP and/or SSH for this.' | i18n | html %]</p>
+<div class="acltable">
+<div class="tableheader">
+  <p>
+    <span>[% 'User' | i18n | html %]</span>
+    <span><b>[% 'Default' | i18n | html %]</b></span>
+    <span>[% 'Can\'t access' | i18n | html %]</span>
+    <span>[% 'Can view this service' | i18n | html %]</span>
+    <span>[% 'Can modify this service' | i18n | html %]</span>
+    <span>[% 'Can manage ACL for this service' | i18n | html %]</span>
+    <span>[% 'Can destroy this service' | i18n | html %]</span>
+    <span>[% 'Update' | i18n | html %]</span>
+  </p>
+</div>
+<div class="tablebody">
+  <form method="post" action="view.pl" accept-charset="utf-8">
+    <p>
+      <span><b>[% 'Default' | i18n | html %]</b></span>
+      <span> </span>
+      <span><input type="radio" name="perm[% default_acl.granted_oid %]" value="[% constants.acl.DENIED %]"[% ' checked="checked"' IF default_acl.perm == constants.acl.DENIED %]/></span>
+      <span><input type="radio" name="perm[% default_acl.granted_oid %]" value="[% constants.acl.item('VIEW') %]"[% ' checked="checked"' IF default_acl.perm == constants.acl.item('VIEW') %]/></span>
+      <span><input type="radio" name="perm[% default_acl.granted_oid %]" value="[% constants.acl.MODIFY %]"[% ' checked="checked"' IF default_acl.perm == constants.acl.MODIFY %]/></span>
+      <span><input type="radio" name="perm[% default_acl.granted_oid %]" value="[% constants.acl.MANAGEACL %]"[% ' checked="checked"' IF default_acl.perm == constants.acl.MANAGEACL %]/></span>
+      <span><input type="radio" name="perm[% default_acl.granted_oid %]" value="[% constants.acl.DELETE %]"[% ' checked="checked"' IF default_acl.perm == constants.acl.DELETE %]/></span>
+      <span>
+        <input type="hidden" NAME="granted_oid" VALUE="[% default_acl.granted_oid %]" />
+        <input type="hidden" NAME="target_oid" VALUE="[% target.get_oid %]" />
+        <input type="submit" value="[% 'Modify' | i18n | html %]" name="update_acl_submit"/>
+      </span>
+    </p>
+  </form>
+[% FOREACH acl IN users_acl %]
+  <form method="post" action="view.pl" accept-charset="utf-8">
+    <p>
+      <span>[% acl.name %]</span>
+      <span><input type="radio" name="perm[% acl.granted_oid %]" value="[% constants.acl.UNDEFINED %]"[% ' checked="checked"' IF acl.perm == constants.acl.UNDEFINED %]/></span>
+      <span><input type="radio" name="perm[% acl.granted_oid %]" value="[% constants.acl.DENIED %]"[% ' checked="checked"' IF acl.perm == constants.acl.DENIED %]/></span>
+      <span><input type="radio" name="perm[% acl.granted_oid %]" value="[% constants.acl.item('VIEW') %]"[% ' checked="checked"' IF acl.perm == constants.acl.item('VIEW') %]/></span>
+      <span><input type="radio" name="perm[% acl.granted_oid %]" value="[% constants.acl.MODIFY %]"[% ' checked="checked"' IF acl.perm == constants.acl.MODIFY %]/></span>
+      <span><input type="radio" name="perm[% acl.granted_oid %]" value="[% constants.acl.MANAGEACL %]"[% ' checked="checked"' IF acl.perm == constants.acl.MANAGEACL %]/></span>
+      <span><input type="radio" name="perm[% acl.granted_oid %]" value="[% constants.acl.DELETE %]"[% ' checked="checked"' IF acl.perm == constants.acl.DELETE %]/></span>
+      <span>
+        <input type="hidden" NAME="granted_oid" VALUE="[% acl.granted_oid %]" />
+        <input type="hidden" NAME="target_oid" VALUE="[% target.get_oid %]" />
+        <input type="submit" value="[% 'Modify' | i18n | html %]" name="update_acl_submit"/>
+      </span>
+    </p>
+  </form>
+[% END %]
+<span class="clear">&nbsp;</span>
+</div>
+</div>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/