From e439d1c66e7cf115fd628309d575f9721e60f1f4 Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Mon, 10 Dec 2012 12:57:34 -0500
Subject: [PATCH] Fixed:  FS#2066 - Check if problems can occur ins ervices when the default prefix is manually changed  - Notes:    once the entry was created or modified after applying this update the current prefix is stored with the entry and kept even if the global prefix changes

---
 interface/lib/classes/tools_sites.inc.php |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/interface/lib/classes/tools_sites.inc.php b/interface/lib/classes/tools_sites.inc.php
index b440754..403f323 100644
--- a/interface/lib/classes/tools_sites.inc.php
+++ b/interface/lib/classes/tools_sites.inc.php
@@ -54,7 +54,29 @@
         }
         return $name;
     }
-
+    
+    function removePrefix($name, $currentPrefix, $globalPrefix) {
+        if($name == "") return "";
+        
+        if($currentPrefix == '#') return $name; // # = empty prefix, do not change name
+        if($currentPrefix === '') $currentPrefix = $globalPrefix; // entry has no prefix set, maybe it was created before this function was introduced
+        
+        if($currentPrefix === '') return $name; // no current prefix and global prefix is empty -> nothing to remove here.
+        
+        return preg_replace('/^' . preg_quote($currentPrefix, '/') . '/', '', $name); // return name without prefix
+    }
+    
+    function getPrefix($currentPrefix, $userPrefix, $adminPrefix = false) {
+        global $app;
+        
+        if($currentPrefix !== '') return ($currentPrefix == '#' ? '' : $currentPrefix); // return the currently set prefix for this entry (# = empty)
+        
+        if($adminPrefix === false) $adminPrefix = $userPrefix;
+        
+        if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) return $adminPrefix;
+        else return $userPrefix;
+    }
+    
     function getClientName($dataRecord) {
         global $app, $conf;
         if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {

--
Gitblit v1.9.1