From 9dcae446eebd071af8ab15fec13b30c8fe854d27 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Tue, 12 Jun 2012 16:48:09 +0200
Subject: [PATCH] fixed #78

---
 hsarback/src/de/hsadmin/core/model/Transaction.java |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hsarback/src/de/hsadmin/core/model/Transaction.java b/hsarback/src/de/hsadmin/core/model/Transaction.java
index 98a5f5e..ad57110 100644
--- a/hsarback/src/de/hsadmin/core/model/Transaction.java
+++ b/hsarback/src/de/hsadmin/core/model/Transaction.java
@@ -208,7 +208,7 @@
 			return true;		// 2-letter hostmaster
 		}
 		String hostmasterAccountPrefix = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-";
-		if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 9) {
+		if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) {
 			return true;		// hsh01 hostmaster
 		}
 		if (ticketUser != null && ticketUser.length() == 5) {
@@ -218,10 +218,10 @@
 			String pacName = unixUser.getPac().getName();
 			return ticketUser.equals(pacName);  // pac-admin
 		}
-		if (ticketUser != null && ticketUser.length() == 3) {
-			String memberAccountPrefix = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-";
+		String memberAccountPrefix = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-";
+		if (ticketUser != null && (ticketUser.length() == 3 || (ticketUser.length() == 9 && ticketUser.startsWith(memberAccountPrefix)))) {
 			Query memberQuery = getEntityManager().createQuery("SELECT c FROM Customers c WHERE c.name = :membername");
-			memberQuery.setParameter("membername", memberAccountPrefix + ticketUser);
+			memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser);
 			Customer member = (Customer) memberQuery.getSingleResult();
 			Set<Pac> pacs = member.getPacs();
 			for (Pac p : pacs) {

--
Gitblit v1.9.1