[vhffs-dev] [1046] History is now sorted in reverse order...

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


Revision: 1046
Author:   beuss
Date:     2007-10-28 22:25:43 +0000 (Sun, 28 Oct 2007)

Log Message:
-----------
History is now sorted in reverse order...

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Panel/Object.pm
    trunk/vhffs-panel/admin/object/edit.pl
    trunk/vhffs-panel/group/history.pl
    trunk/vhffs-panel/history.pl
    trunk/vhffs-panel/templates/admin/object/edit.tmpl
    trunk/vhffs-panel/templates/admin/object/editembedded.tmpl
    trunk/vhffs-panel/templates/group/history.tmpl
    trunk/vhffs-panel/templates/group/history_part.tmpl
    trunk/vhffs-panel/templates/misc/history_part.tmpl
    trunk/vhffs-panel/themes/vhffs/main.css


Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2007-10-28 22:25:43 UTC (rev 1046)
@@ -647,17 +647,20 @@
     return $class->SUPER::_fill_object($obj, $sql);
 }
 
+=head2 get_full_history
 
-# Returns a hashref which contains all the history
+Returns an array containing all history entries for this group and its objects,
+descending ordered by date.
+
+=cut
+
 sub get_full_history
 {
 	my $self = shift;
 
-	my $query = 'SELECT o.object_id,o.type,h.history_id,h.date,h.message FROM vhffs_history h INNER JOIN vhffs_object o ON o.object_id=h.object_id WHERE o.owner_gid=?';
-	my $request = $self->{'db'}->prepare( $query );
-	return undef unless( $request->execute( $self->{'gid'} ) );
-
-	return $request->fetchall_hashref('history_id');
+	my $sql = 'SELECT o.object_id,o.type,h.history_id,h.date,h.message FROM vhffs_history h INNER JOIN vhffs_object o ON o.object_id=h.object_id WHERE o.owner_gid=? ORDER BY date DESC';
+    my $dbh = $self->get_db_object;
+    return $dbh->selectall_arrayref($sql, {Slice => {}}, $self->{gid});
 }
 
 

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2007-10-28 22:25:43 UTC (rev 1046)
@@ -364,15 +364,9 @@
 	use Vhffs::Functions;
 	my $self = shift;
 
-	my $result;
-	my $key;
-	my $value;
-
-	my $query = 'SELECT * FROM vhffs_history WHERE object_id=?';
-	my $request = $self->{'db'}->prepare( $query );
-
-	return undef unless $request->execute( $self->{'object_id'} );
-	return $request->fetchall_hashref('history_id');
+    my $dbh = $self->get_db_object;
+    my $sql = 'SELECT history_id, message, date FROM vhffs_history WHERE object_id = ? ORDER BY date DESC';
+    return $dbh->selectall_arrayref($sql, {Slice => {}}, $self->{object_id});
 }
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Object.pm	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-api/src/Vhffs/Panel/Object.pm	2007-10-28 22:25:43 UTC (rev 1046)
@@ -196,27 +196,26 @@
 
 	# Print history
 	$template->param( HISTORY_TITLE => gettext("History of this object") );
-	my $output = "";
 	my $string;
 	my $history = $object->get_history;
-	unless( defined $history )
-	{
-		$template->param( HISTORY => gettext("No event about this object") );
-	}   
-	else
-	{
-	        foreach( keys %{$history} )
-	        {
-			my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/misc/history_part.tmpl' );
-			use DateTime;
-			use DateTime::Locale;
-			$subtemplate->param( DATE => DateTime->from_epoch( epoch => $history->{$_}{date} , locale => $user->get_lang )->strftime("%a, %d %b %Y %H:%M:%S %z") );
-			$subtemplate->param( EVENT => $history->{$_}{message} );
-			$output .= $subtemplate->output;
-		}
-		$template->param( HISTORY => $output );
-	}
 
+    unless( @{$history} ) {
+        $template->param( HISTORY_PART => gettext('No event about this object') );
+    } else {
+        my $output = '';
+        my $history_tmpl = new HTML::Template( filename => $templatedir.'/panel/misc/history_part.tmpl' );
+        use DateTime;
+        use DateTime::Locale;
+        my $loc = DateTime::Locale->load($user->get_lang);
+        foreach (@{$history}) {
+            my $dt = DateTime->from_epoch( epoch => $_->{date});
+            $history_tmpl->param( DATE => $dt->strftime($loc->short_date_format().' %H:%M' ));
+            $history_tmpl->param( EVENT => $_->{message} );
+            $output .= $history_tmpl->output;
+        }
+        $template->param( HISTORY_PART => $output );
+    }
+
 	return $template;
 }
 

Modified: trunk/vhffs-panel/admin/object/edit.pl
===================================================================
--- trunk/vhffs-panel/admin/object/edit.pl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/admin/object/edit.pl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -199,25 +199,24 @@
 	my $output = "";
 	my $string;
 	my $history = $object->get_history;
-	if( ! defined $history )
-    {
-        $template->param( HISTORY => gettext("No event about this object") );
-    }   
-    else
-    {
-        foreach( keys %{$history} )
-        {
-            my $subtemplate = new HTML::Template( filename => $templatesdir."/panel/misc/history_part.tmpl" );
-            use DateTime;
-            use DateTime::Locale;
-            $subtemplate->param( DATE => DateTime->from_epoch( epoch => $history->{$_}{date} , locale => $user->get_lang )->strftime("%a, %d %b %Y %H:%M:%S %z") );
-            $subtemplate->param( EVENT => $history->{$_}{message} );
-            $output .= $subtemplate->output;
+
+    unless( @{$history} ) {
+        $template->param( HISTORY_PART => gettext('No event about this object') );
+    } else {
+        my $output = '';
+        my $history_tmpl = new HTML::Template( filename => $templatesdir.'/panel/misc/history_part.tmpl' );
+        use DateTime;
+        use DateTime::Locale;
+        my $loc = DateTime::Locale->load($user->get_lang);
+        foreach (@{$history}) {
+            my $dt = DateTime->from_epoch( epoch => $_->{date});
+            $history_tmpl->param( DATE => $dt->strftime($loc->short_date_format().' %H:%M' ));
+            $history_tmpl->param( EVENT => $_->{message} );
+            $output .= $history_tmpl->output;
         }
-        $template->param( HISTORY => $output );
+        $template->param( HISTORY_PART => $output );
     }
 
-
 }
 
 $panel->build( $template );

Modified: trunk/vhffs-panel/group/history.pl
===================================================================
--- trunk/vhffs-panel/group/history.pl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/group/history.pl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -70,10 +70,7 @@
 	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
 	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
 } else {
-
-	my $subtemplate;
 	my $history = $group->get_full_history;
-	my $output = '';
 
 	$panel->set_title( gettext('Project History') );
 	$template = new HTML::Template( filename => $templatedir.'/panel/group/history.tmpl', global_vars => 1 );
@@ -82,24 +79,23 @@
 	$template->param( HNAME => gettext('Name') );
 	$template->param( HEVENT => gettext('Event') );
 
-	unless( defined $history )
-	{
+	unless(@{$history}) {
 		$template->param( HISTORY_PART => gettext('No event about this group') );
-	}
-	else
-	{
-		foreach( sort { $a <=> $b } keys %{$history} )
-		{
-			$subtemplate = new HTML::Template( filename => $templatedir.'/panel/group/history_part.tmpl' );
-			use DateTime;
-			use DateTime::Locale;
-			$subtemplate->param( DATE => DateTime->from_epoch( epoch => $history->{$_}{date}, locale => $user->get_lang )->strftime('%a, %d %b %Y %H:%M:%S %z') );
-			$subtemplate->param( TYPE => Vhffs::Functions::type_string_from_type_id( $history->{$_}{type} ) );
-			my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $history->{$_}{object_id} );
-			$subtemplate->param( NAME => $object->get_label );
-			$subtemplate->param( EVENT => $history->{$_}{message} );
-			$output .= $subtemplate->output;
-		}
+	} else {
+        my $output = '';
+        my $history_tmpl = new HTML::Template( filename => $templatedir.'/panel/group/history_part.tmpl' );
+        use DateTime;
+        use DateTime::Locale;
+        my $loc = DateTime::Locale->load($user->get_lang);
+        foreach (@{$history}) {
+            my $dt = DateTime->from_epoch( epoch => $_->{date});
+            $history_tmpl->param( DATE => $dt->strftime($loc->short_date_format().' %H:%M' ));
+            $history_tmpl->param( TYPE => Vhffs::Functions::type_string_from_type_id( $_->{type} ) );
+            my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $_->{object_id} );
+            $history_tmpl->param( NAME => $object->get_label );
+            $history_tmpl->param( EVENT => $_->{message} );
+            $output .= $history_tmpl->output;
+        }
 		$template->param( HISTORY_PART => $output );
 	}
 }

Modified: trunk/vhffs-panel/history.pl
===================================================================
--- trunk/vhffs-panel/history.pl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/history.pl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -79,55 +79,46 @@
 my $templatesdir = $vhffs->get_config->get_templatedir;
 
 
-if( ! defined $oid )
-{
+if( ! defined $oid ) {
 	$template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
 	$message = gettext( "CGI Error !");
 	$template->param( MESSAGE => $message );
-}
-elsif( !defined $object )
-{
+} elsif( !defined $object ) {
 
 	$template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
 	$message = gettext("Cannot get information on this object");
 	$template->param( MESSAGE => $message );
 
-}
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $object , $vhffs ) < Vhffs::Constants::ACL_VIEW ) && ( $user->is_admin != 1 ) && ( $user->is_moderator != 1 ) )
-{
+} elsif( !$user->can_view($object) ) {
 	$template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
 	$message = gettext("You're not allowed to view this object's ACL");
 	$template->param( MESSAGE => $message );
-}
-else
-{
+} else {
 	$template = new HTML::Template( filename => $templatesdir."/panel/misc/history.tmpl" );
+    $panel->set_title( gettext("History") );
 
-	$template->param( TITLE => gettext("History") );
-
 	my $subtemplate;
 	my $history = $object->get_history;
-	my $output = "";
 	my $string;
 	my $date;
 
-	if( ! defined $history )
-	{
-		$template->param( HISTORY_PART => gettext("No event about this object") );
-	}
-	else
-	{
-		foreach( sort { $a <=> $b } keys %{$history} )
-		{
-			$subtemplate = new HTML::Template( filename => $templatesdir."/panel/misc/history_part.tmpl" );
-			use DateTime;
-			use DateTime::Locale;
-			$subtemplate->param( DATE => DateTime->from_epoch( epoch => $history->{$_}{date} , locale => $user->get_lang )->strftime("%a, %d %b %Y %H:%M:%S %z") );
-			$subtemplate->param( EVENT => $history->{$_}{message} );
-			$output .= $subtemplate->output;
-		}
-		$template->param( HISTORY_PART => $output );
-	}
+    unless(@{$history}) {
+        $template->param( HISTORY_PART => gettext('No event about this object') );
+    } else {
+        my $output = '';
+        my $history_tmpl = new HTML::Template( filename => $templatesdir.'/panel/misc/history_part.tmpl' );
+        use DateTime;
+        use DateTime::Locale;
+        my $loc = DateTime::Locale->load($user->get_lang);
+        foreach (@{$history}) {
+            my $dt = DateTime->from_epoch( epoch => $_->{date});
+            $history_tmpl->param( DATE => $dt->strftime($loc->short_date_format().' %H:%M' ));
+            $history_tmpl->param( EVENT => $_->{message} );
+            $output .= $history_tmpl->output;
+        }
+        $template->param( HISTORY_PART => $output );
+    }
+
 }
 
 $panel->build( $template );

Modified: trunk/vhffs-panel/templates/admin/object/edit.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/object/edit.tmpl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/templates/admin/object/edit.tmpl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -56,7 +56,7 @@
 
 <h2><TMPL_VAR NAME="HISTORY_TITLE"></h2>
 <table>
-	<TMPL_VAR NAME="HISTORY">
+	<TMPL_VAR NAME="HISTORY_PART">
 </table>
 
 <h2><TMPL_VAR NAME="AVATAR_TITLE"></h2>

Modified: trunk/vhffs-panel/templates/admin/object/editembedded.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/object/editembedded.tmpl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/templates/admin/object/editembedded.tmpl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -56,7 +56,7 @@
 
 <h2><TMPL_VAR NAME="HISTORY_TITLE"></h2>
 <table>
-	<TMPL_VAR NAME="HISTORY">
+	<TMPL_VAR NAME="HISTORY_PART">
 </table>
 
 <h2><TMPL_VAR NAME="AVATAR_TITLE"></h2>

Modified: trunk/vhffs-panel/templates/group/history.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/history.tmpl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/templates/group/history.tmpl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -1,5 +1,4 @@
 <table>
-<div class="history">
 <thead>
 	<tr>
 		<th>
@@ -11,13 +10,12 @@
 		<th>
 			<tmpl_var name="HNAME">
 		</th>
-		<th class="mainColumn">
+		<th>
 			<tmpl_var name="HEVENT">
 		</th>
 	</tr>
 </thead>
 <tbody>
         <tmpl_var name="HISTORY_PART">
-<tbody>
-</div>
+</tbody>
 </table>

Modified: trunk/vhffs-panel/templates/group/history_part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/history_part.tmpl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/templates/group/history_part.tmpl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -8,7 +8,7 @@
 		<td>
 			<tmpl_var name="NAME">
 		</td>
-		<td class="mainColumn">
+		<td>
 			<tmpl_var name="EVENT">
 		</td>
 	</tr>

Modified: trunk/vhffs-panel/templates/misc/history_part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/misc/history_part.tmpl	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/templates/misc/history_part.tmpl	2007-10-28 22:25:43 UTC (rev 1046)
@@ -2,7 +2,7 @@
 		<td>
 			<tmpl_var name="DATE">
 		</td>
-		<td class="mainColumn">
+		<td>
 			<tmpl_var name="EVENT">
 		</td>
 	</tr>

Modified: trunk/vhffs-panel/themes/vhffs/main.css
===================================================================
--- trunk/vhffs-panel/themes/vhffs/main.css	2007-10-28 16:00:28 UTC (rev 1045)
+++ trunk/vhffs-panel/themes/vhffs/main.css	2007-10-28 22:25:43 UTC (rev 1046)
@@ -360,17 +360,6 @@
 
 }
 
-table td
-{
-
-	width:15%;
-}
-.mainColumn
-{
-	min-width:30%;
-
-}
-
 #misc h1
 {
 	text-align: right;
@@ -828,6 +817,3 @@
     float:none;
 }
 
-.history {
-	text-align: right;
-}


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