]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttUser.class.php
Wrote ttUser::getUserPartForHeader and included on behalf group in output.
[timetracker.git] / WEB-INF / lib / ttUser.class.php
index ab5bdbff48905f175223b3b52e43c30f317f4355..f89bba684d47c26f40d2a525263801c219d5bbdd 100644 (file)
@@ -652,4 +652,23 @@ class ttUser {
 
     return $max_rank;
   }
+
+  // getUserPartForHeader constructs a string for user to display on pages header.
+  // It changes with "on behalf" attributes for both user and group.
+  function getUserPartForHeader() {
+    global $i18n;
+
+    $user_part = htmlspecialchars($this->name);
+    $user_part .= ' - '.htmlspecialchars($this->role_name);
+    if ($this->behalf_id) {
+      $user_part .= ' <span class="onBehalf">'.$i18n->get('label.on_behalf').' '.htmlspecialchars($this->behalf_name).'</span>';
+    }
+    if ($this->behalf_group_id) {
+      $user_part .= ',  <span class="onBehalf">'.$i18n->get('label.on_behalf').' '.htmlspecialchars($this->behalf_group_name).'</span>';
+    } else {
+      if ($this->group_name) // Note: we did not require group names in the past.
+        $user_part .= ', '.$this->group_name;
+    }
+    return $user_part;
+  }
 }