[vhffs-dev] [617] New ACL layout, added dependency check for HTML::Template::Expr.

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


Revision: 617
Author:   beuss
Date:     2007-05-19 14:03:06 +0000 (Sat, 19 May 2007)

Log Message:
-----------
New ACL layout, added dependency check for HTML::Template::Expr.

Modified Paths:
--------------
    branches/vhffs-design/vhffs-api/src/Vhffs/Acl.pm
    branches/vhffs-design/vhffs-panel/acl/submit.pl
    branches/vhffs-design/vhffs-panel/acl/view.pl
    branches/vhffs-design/vhffs-panel/templates/acl/view.tmpl
    branches/vhffs-design/vhffs-panel/templates/acl/view_each.tmpl
    branches/vhffs-design/vhffs-test-dependencies.in

Property Changed:
----------------
    branches/vhffs-design/vhffs-intl/result/


Modified: branches/vhffs-design/vhffs-api/src/Vhffs/Acl.pm
===================================================================
--- branches/vhffs-design/vhffs-api/src/Vhffs/Acl.pm	2007-05-19 13:28:07 UTC (rev 616)
+++ branches/vhffs-design/vhffs-api/src/Vhffs/Acl.pm	2007-05-19 14:03:06 UTC (rev 617)
@@ -39,6 +39,16 @@
 
 package Vhffs::Acl;
 
+=pod
+
+=head1 NAME
+
+Vhffs::Acl - Handle Access Control Lists in VHFFS.
+
+=head1 METHODS
+
+=cut
+
 sub what_perm_for_user
 {
 	my $user;
@@ -152,6 +162,7 @@
 
     my $dbh = $main->get_db_object();
 
+    
     $dbh->begin_work();
     my $sql = 'DELETE FROM vhffs_acl WHERE oid_src = ? AND oid_dst = ?';
     my $sth = $dbh->prepare( $sql );
@@ -172,35 +183,50 @@
 	return 1;
 }
 
+=pod
 
+=head2 getall_acl_for_user_per_object
+
+    my $rights = Vhffs::Acl::getall_acl_for_user_per_object($object, $vhffs);
+
+Get all users acl for a given object.
+Returns an array of hashref with keys 'oid_src, name, perm'.
+
+=cut
+
 sub getall_acl_for_user_per_object
 {
 	my ( $obj , $main ) = @_;
 	return -1 unless( defined $obj );
 
-    my $query = 'SELECT u.username, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_users u ON u.object_id = acl.oid_src WHERE oid_dst=?';
-	my $request = $main->{'db'}->prepare( $query );
-	return undef if( !$request->execute( $obj->{'object_id'} ) );
-	return ( $request->fetchall_hashref('username') );
+    my $sql = 'SELECT acl.oid_src, u.username AS name, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_users u ON u.object_id = acl.oid_src WHERE oid_dst = ?';
+    my $dbh = $main->get_db_object;
+    my $sth = $dbh->prepare($sql);
+    return undef unless($sth->execute($obj->get_oid));
+    return $sth->fetchall_arrayref({});
 }
 
+=pod
 
+=head2 getall_acl_for_group_per_object
+
+    my $rights = Vhffs::Acl::getall_acl_for_group_per_object($object, $vhffs);
+
+Get all groups acl for a given object.
+Returns an array of hashref with keys 'oid_src, name, perm'.
+
+=cut
+
 sub getall_acl_for_group_per_object
 {
-	my $obj;
-	my $main;
-	my $query;
-	my $request;
-
-	$obj		=	shift;
-	$main		=	shift;
-
+	my ( $obj , $main ) = @_;
 	return -1 unless( defined $obj );
 
-    $query = 'SELECT g.groupname, perm FROM vhffs_acl acl INNER JOIN vhffs_groups g ON acl.oid_src = g.object_id WHERE acl.oid_dst = ?';
-	$request = $main->{'db'}->prepare( $query );
-	return undef if( !$request->execute($obj->{'object_id'}) );
-	return ( $request->fetchall_hashref('groupname') );
+    my $sql = 'SELECT acl.oid_src, g.groupname AS name, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_groups g ON acl.oid_src = g.object_id WHERE acl.oid_dst = ?';
+    my $dbh = $main->get_db_object;
+	my $sth = $dbh->prepare( $sql );
+	return undef unless( $sth->execute($obj->get_oid) );
+	return $sth->fetchall_arrayref({});
 }
 
 


Property changes on: branches/vhffs-design/vhffs-intl/result
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


Modified: branches/vhffs-design/vhffs-panel/acl/submit.pl
===================================================================
--- branches/vhffs-design/vhffs-panel/acl/submit.pl	2007-05-19 13:28:07 UTC (rev 616)
+++ branches/vhffs-design/vhffs-panel/acl/submit.pl	2007-05-19 14:03:06 UTC (rev 617)
@@ -63,7 +63,7 @@
 my $name = $cgi->param("NAME");
 my $oid_src = $cgi->param( "OID_SRC" );
 my $oid_dst = $cgi->param( "OID_DST" );
-my $acl_level = $cgi->param( "ACL_TYPE" );
+my $acl_level = $cgi->param( "acl$oid_src" );
 my $template;
 
 my $object;

Modified: branches/vhffs-design/vhffs-panel/acl/view.pl
===================================================================
--- branches/vhffs-design/vhffs-panel/acl/view.pl	2007-05-19 13:28:07 UTC (rev 616)
+++ branches/vhffs-design/vhffs-panel/acl/view.pl	2007-05-19 14:03:06 UTC (rev 617)
@@ -32,6 +32,7 @@
 
 use POSIX qw(locale_h);
 use HTML::Template;
+use HTML::Template::Expr;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -66,7 +67,6 @@
 my $message;
 my $object;
 my $ok = 1;
-my $title;
 
 my $g;
 my $u;
@@ -144,138 +144,55 @@
 	else
 	{
 		$template = new HTML::Template( filename => $templatedir."/acl/view.tmpl" );
-	
-		$template->param( TITLE => gettext('ACL Administration') );
 
-		$template->param( TEXT_USERNAME => gettext("Username" ) . ": ");
-		$template->param( TEXT_GROUPNAME => gettext("Groupname" ) . ": ");
+        $panel->set_title( gettext('ACL Administration') );
 
+		$template->param( TEXT_USERNAME => gettext('Username:' ) );
+		$template->param( TEXT_GROUPNAME => gettext('Groupname:' ) );
 
+        $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_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 );
 
-
-        $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( TEXT_ACL_LEVEL => gettext('ACL level') );
         
-		$template->param( TEXT_ACL_LEVEL => gettext("ACL level") );
-        
 		$template->param( OIDDST => $object->get_oid );
-		$template->param( SEND => gettext("Send it") );
-
-		my $output_user = "";
-		my $output_group = "";
+		$template->param( SEND => gettext('Send it') );
 		my $user_rights = Vhffs::Acl::getall_acl_for_user_per_object( $object , $vhffs );
 		my $group_rights = Vhffs::Acl::getall_acl_for_group_per_object( $object , $vhffs );
 
-		my $subtemplate;
+		my $subtemplate = new HTML::Template::Expr( filename => $templatedir.'/acl/view_each.tmpl', global_vars => 1 );
+        $subtemplate->param( VALUE_ACL_DENIED => Vhffs::Constants::ACL_DENIED );
+        $subtemplate->param( VALUE_ACL_VIEW => Vhffs::Constants::ACL_VIEW );
+        $subtemplate->param( VALUE_ACL_MODIFY => Vhffs::Constants::ACL_MODIFY );
+        $subtemplate->param( VALUE_ACL_MANAGEACL => Vhffs::Constants::ACL_MANAGEACL );
+        $subtemplate->param( VALUE_ACL_DELETE => Vhffs::Constants::ACL_DELETE );
 
-		foreach( keys %{$user_rights} )
-		{
-			$u = Vhffs::User::get_by_username( $vhffs , $user_rights->{$_}{'username'} );
+        $subtemplate->param( TEXT_ACL_DENIED => gettext('Can\'t access') );
+        $subtemplate->param( TEXT_ACL_VIEW => gettext('Can view this service') );
+        $subtemplate->param( TEXT_ACL_MODIFY => gettext('Can modify this service') );
+        $subtemplate->param( TEXT_ACL_MANAGEACL => gettext('Can manage ACL for this service') );
+        $subtemplate->param( TEXT_ACL_DELETE => gettext('Can destroy this service') );
+        $subtemplate->param( TEXT_MODIFY => gettext('Modify') );
 
-			$subtemplate = new HTML::Template( filename => $templatedir."/acl/view_each.tmpl" );
-			$subtemplate->param( NAME => $user_rights->{$_}{'username'} );
-			$subtemplate->param( TEXT_ACL_DENIED => gettext("Can't access") );
-			$subtemplate->param( TEXT_ACL_VIEW => gettext("Can view this service") );
-			$subtemplate->param( TEXT_ACL_MODIFY => gettext("Can modify this service") );
-			$subtemplate->param( TEXT_ACL_MANAGEACL => gettext("Can manage ACL for this service") );
-			$subtemplate->param( TEXT_ACL_DELETE => gettext("Can destroy this service") );
-			$subtemplate->param( SEND => gettext("Modify this ACL") );
+		$subtemplate->param( OIDDST => $object->get_oid );
+    
+        # fills users ACL
+        $subtemplate->param( TEXT_TYPE => gettext('Username') );
+        $subtemplate->param( rights => $user_rights );
+		$template->param( USERS_TABLE => $subtemplate->output );
 
-			$subtemplate->param( VALUE_ACL_DENIED => Vhffs::Constants::ACL_DENIED );
-			$subtemplate->param( VALUE_ACL_VIEW => Vhffs::Constants::ACL_VIEW );
-			$subtemplate->param( VALUE_ACL_MODIFY => Vhffs::Constants::ACL_MODIFY );
-			$subtemplate->param( VALUE_ACL_MANAGEACL => Vhffs::Constants::ACL_MANAGEACL );
-			$subtemplate->param( VALUE_ACL_DELETE => Vhffs::Constants::ACL_DELETE );
-
-			if( $user_rights->{$_}{'perm'} == Vhffs::Constants::ACL_DELETE )
-			{
-				$subtemplate->param( DELETE_SELECTED => "selected" );
-			}
-			elsif( $user_rights->{$_}{'perm'} == Vhffs::Constants::ACL_MANAGEACL )
-			{
-				$subtemplate->param( MANAGEACL_SELECTED => "selected" );
-			}
-			elsif( $user_rights->{$_}{'perm'} == Vhffs::Constants::ACL_MODIFY )
-			{
-				$subtemplate->param( MODIFY_SELECTED => "selected" );
-			}
-			elsif( $user_rights->{$_}{'perm'} == Vhffs::Constants::ACL_VIEW )
-			{
-				$subtemplate->param( VIEW_SELECTED => "selected" );
-			}
-			elsif( $user_rights->{$_}{'perm'} == Vhffs::Constants::ACL_DENIED )
-			{
-				$subtemplate->param( DENIED_SELECTED => "selected" );
-			}
-
-			$subtemplate->param( OIDDST => $object->get_oid );
-			$subtemplate->param( OIDSRC => $u->get_oid );
-
-			$output_user .= $subtemplate->output;
-		}
-
-        foreach( keys %{$group_rights} )
-        {   
-			$g = Vhffs::Group::get_by_groupname($vhffs , $group_rights->{$_}{'groupname'} );
-
-            $subtemplate = new HTML::Template( filename => $templatedir."/acl/view_each.tmpl" );
-            $subtemplate->param( NAME => $group_rights->{$_}{'groupname'} );
-
-            $subtemplate->param( TEXT_ACL_DENIED => gettext("Can't access") );
-            $subtemplate->param( TEXT_ACL_VIEW => gettext("Can view this service") );
-            $subtemplate->param( TEXT_ACL_MODIFY => gettext("Can modify this service") );
-            $subtemplate->param( TEXT_ACL_MANAGEACL => gettext("Can manage ACL for this service") );
-            $subtemplate->param( TEXT_ACL_DELETE => gettext("Can destroy this service") );
-            $subtemplate->param( SEND => gettext("Modify this ACL") );
-
-
-			$subtemplate->param( VALUE_ACL_DENIED => Vhffs::Constants::ACL_DENIED );
-			$subtemplate->param( VALUE_ACL_VIEW => Vhffs::Constants::ACL_VIEW );
-			$subtemplate->param( VALUE_ACL_MODIFY => Vhffs::Constants::ACL_MODIFY );
-			$subtemplate->param( VALUE_ACL_MANAGEACL => Vhffs::Constants::ACL_MANAGEACL );
-			$subtemplate->param( VALUE_ACL_DELETE => Vhffs::Constants::ACL_DELETE );
-
-
-            if( $group_rights->{$_}{'perm'} == Vhffs::Constants::ACL_DELETE )
-            {   
-                $subtemplate->param( DELETE_SELECTED => "selected" );
-            }
-            elsif( $group_rights->{$_}{'perm'} == Vhffs::Constants::ACL_MANAGEACL )
-            {   
-                $subtemplate->param( MANAGEACL_SELECTED => "selected" );
-            }
-            elsif( $group_rights->{$_}{'perm'} == Vhffs::Constants::ACL_MODIFY )
-            {   
-                $subtemplate->param( MODIFY_SELECTED => "selected" );
-            }
-            elsif( $group_rights->{$_}{'perm'} == Vhffs::Constants::ACL_VIEW )
-            {   
-                $subtemplate->param( VIEW_SELECTED => "selected" );
-            }
-            elsif( $group_rights->{$_}{'perm'} == Vhffs::Constants::ACL_DENIED )
-            {   
-                $subtemplate->param( DENIED_SELECTED => "selected" );
-            }
-            
-			$subtemplate->param( OIDDST => $object->get_oid );
-			$subtemplate->param( OIDSRC => $g->get_oid );
-
-            $output_group .= $subtemplate->output;
-        }
-
-
-		$template->param( USERS_TABLE => $output_user );	
-		$template->param( GROUPS_TABLE => $output_group );	
-	
-	
+        $subtemplate->param( TEXT_TYPE => gettext('Groupname') );
+        $subtemplate->param( rights => $group_rights );
+		$template->param( GROUPS_TABLE => $subtemplate->output );	
 	}
 }
 

Modified: branches/vhffs-design/vhffs-panel/templates/acl/view.tmpl
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/acl/view.tmpl	2007-05-19 13:28:07 UTC (rev 616)
+++ branches/vhffs-design/vhffs-panel/templates/acl/view.tmpl	2007-05-19 14:03:06 UTC (rev 617)
@@ -1,11 +1,6 @@
-
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
 <h2>ACL for Users</h2>
 
-<table>
-	<TMPL_VAR NAME="USERS_TABLE">
-</table>
+<TMPL_VAR NAME="USERS_TABLE">
 
 <h3>Add an ACL for a User</h3>
 
@@ -37,9 +32,7 @@
 
 <h2>ACL for Groups</h2>
 
-<table>
-	<TMPL_VAR NAME="GROUPS_TABLE">
-</table>
+<TMPL_VAR NAME="GROUPS_TABLE">
 
 <h3>Add an ACL for a Group</h3>
 

Modified: branches/vhffs-design/vhffs-panel/templates/acl/view_each.tmpl
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/acl/view_each.tmpl	2007-05-19 13:28:07 UTC (rev 616)
+++ branches/vhffs-design/vhffs-panel/templates/acl/view_each.tmpl	2007-05-19 14:03:06 UTC (rev 617)
@@ -1,21 +1,35 @@
-
-<tr>
-	<td>
-		<TMPL_VAR NAME="NAME">: 
-	</td>
-	<td class="mainColumn">
-		<form method="post" action="submit.pl">
-			<select name="ACL_TYPE">
-				<option value="<TMPL_VAR NAME="VALUE_ACL_DENIED">" <TMPL_VAR NAME="DENIED_SELECTED">><TMPL_VAR NAME="TEXT_ACL_DENIED"></option>
-				<option value="<TMPL_VAR NAME="VALUE_ACL_VIEW">" <TMPL_VAR NAME="VIEW_SELECTED">><TMPL_VAR NAME="TEXT_ACL_VIEW"></option>
-				<option value="<TMPL_VAR NAME="VALUE_ACL_MODIFY">" <TMPL_VAR NAME="MODIFY_SELECTED">><TMPL_VAR NAME="TEXT_ACL_MODIFY"></option>
-				<option value="<TMPL_VAR NAME="VALUE_ACL_MANAGEACL">" <TMPL_VAR NAME="MANAGEACL_SELECTED">><TMPL_VAR NAME="TEXT_ACL_MANAGEACL"></option>
-				<option value="<TMPL_VAR NAME="VALUE_ACL_DELETE">" <TMPL_VAR NAME="DELETE_SELECTED">><TMPL_VAR NAME="TEXT_ACL_DELETE"></option>
-			</select> 
-			<input type="hidden" NAME="OID_SRC" VALUE="<TMPL_VAR NAME="OIDSRC">" />
-			<input type="hidden" NAME="OID_DST" VALUE="<TMPL_VAR NAME="OIDDST">" />
-			<input type="submit" value="<TMPL_VAR NAME="SEND">" />
-		</form>
-	</td>
-</tr>
-
+<tmpl_if name="rights">
+<div class="acltable">
+<div class="tableheader">
+  <p>
+    <span><tmpl_var name="TEXT_TYPE"></span>
+    <span><tmpl_var name="TEXT_ACL_DENIED"></span>
+    <span><tmpl_var name="TEXT_ACL_VIEW"></span>
+    <span><tmpl_var name="TEXT_ACL_MODIFY"></span>
+    <span><tmpl_var name="TEXT_ACL_MANAGEACL"></span>
+    <span><tmpl_var name="TEXT_ACL_DELETE"></span>
+    <span><tmpl_var name="TEXT_MODIFY"></span>
+  </p>
+</div>
+<div class="tablebody">
+<tmpl_loop name="rights">
+  <form method="post" action="submit.pl">
+    <p>
+      <span><TMPL_VAR NAME="NAME"></span>
+      <span><input type="radio" name="acl<TMPL_VAR NAME="OID_SRC">" value="<TMPL_VAR NAME="VALUE_ACL_DENIED">" <tmpl_if expr="perm==VALUE_ACL_DENIED">checked="checked"</tmpl_if>/></span>
+      <span><input type="radio" name="acl<TMPL_VAR NAME="OID_SRC">" value="<TMPL_VAR NAME="VALUE_ACL_VIEW">" <tmpl_if expr="perm==VALUE_ACL_VIEW">checked="checked"</tmpl_if>/></span>
+      <span><input type="radio" name="acl<TMPL_VAR NAME="OID_SRC">" value="<TMPL_VAR NAME="VALUE_ACL_MODIFY">" <tmpl_if expr="perm==VALUE_ACL_MODIFY">checked="checked"</tmpl_if>/></span>
+      <span><input type="radio" name="acl<TMPL_VAR NAME="OID_SRC">" value="<TMPL_VAR NAME="VALUE_ACL_MANAGEACL">" <tmpl_if expr="perm==VALUE_ACL_MANAGEACL">checked="checked"</tmpl_if>/></span>
+      <span><input type="radio" name="acl<TMPL_VAR NAME="OID_SRC">" value="<TMPL_VAR NAME="VALUE_ACL_DELETE">" <tmpl_if expr="perm==VALUE_ACL_DELETE">checked="checked"</tmpl_if>/></span>
+	  <span>
+        <input type="hidden" NAME="OID_SRC" VALUE="<TMPL_VAR NAME="OID_SRC">" />
+        <input type="hidden" NAME="OID_DST" VALUE="<TMPL_VAR NAME="OIDDST">" />
+        <input type="submit" value="<TMPL_VAR NAME="TEXT_MODIFY">" />
+      </span>
+    </p>
+  </form>
+</tmpl_loop>
+<span class="clear">&nbsp;</span>
+</div>
+</div>
+</tmpl_if>

Modified: branches/vhffs-design/vhffs-test-dependencies.in
===================================================================
--- branches/vhffs-design/vhffs-test-dependencies.in	2007-05-19 13:28:07 UTC (rev 616)
+++ branches/vhffs-design/vhffs-test-dependencies.in	2007-05-19 14:03:06 UTC (rev 617)
@@ -39,7 +39,8 @@
 
 $dep{'panel'} = [
 	('GD', ''),
-	('GD::Text::Wrap', '')];
+	('GD::Text::Wrap', ''),
+    ('HTML::Template::Expr', '')];
 
 $dep{'robots'} = [
     ('SVN::Notify', '')];


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