From b5cb229ae8ad45c40ca2c16ca7629d282ff0de3b Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Tue, 11 Dec 2012 06:44:28 -0500
Subject: [PATCH] - Added customer no. to client and reseller lists.

---
 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..c501173 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; // return the currently set prefix for this entry (# = no prefix set yet)
+        
+        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