From 23c0504927ed174a5fa361f4f734b6ca284efa18 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 18 Dec 2015 15:39:14 -0600
Subject: [PATCH] queue: Fix install on clusters, add left-clip truncate

The lclip truncate method allows for trimming the beginnging of the text.
This trimming will only work properly for left-to-right languages because it
changes the CSS `direction` property. Writing a rtl language ltr will
probably not be legible.
---
 include/class.i18n.php  |  4 ++++
 include/class.queue.php | 22 +++++++++-------------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/class.i18n.php b/include/class.i18n.php
index 5d411a086..b9bac6202 100644
--- a/include/class.i18n.php
+++ b/include/class.i18n.php
@@ -384,6 +384,10 @@ class Internationalization {
         return self::getDefaultLanguage();
     }
 
+    static function getCurrentLanguageInfo($user=false) {
+        return static::getLanguageInfo(static::getCurrentLanguage($user));
+    }
+
     static function getCurrentLocale($user=false) {
         global $thisstaff, $cfg;
 
diff --git a/include/class.queue.php b/include/class.queue.php
index 6068f7049..3cdd0f0a6 100644
--- a/include/class.queue.php
+++ b/include/class.queue.php
@@ -848,13 +848,17 @@ extends VerySimpleModel {
             $offset += $a->getWidth($row);
 
         $width = $this->width - $offset;
+        $class = array();
         switch ($this->truncate) {
-        case 'ellipsis':
-            return sprintf('<span class="%s" style="max-width:%dpx">%s</span>',
-                'truncate', $width, $text);
+        case 'lclip':
+            $linfo = Internationalization::getCurrentLanguageInfo();
+            $class[] = $linfo['direction'] == 'rtl' ? 'ltr' : 'rtl';
         case 'clip':
+            $class[] = 'bleed';
+        case 'ellipsis':
+            $class[] = 'truncate';
             return sprintf('<span class="%s" style="max-width:%dpx">%s</span>',
-                'truncate bleed', $width, $text);
+                implode(' ', $class), $width, $text);
         default:
         case 'wrap':
             return $text;
@@ -1019,15 +1023,6 @@ extends VerySimpleModel {
         $this->annotations = JsonDataEncoder::encode($annotations);
         $this->conditions = JsonDataEncoder::encode($conditions);
     }
-
-    function save($refetch=false) {
-        if ($this->__new__ && isset($this->id))
-            // The ID is used to synchrize the POST data with the forms API.
-            // It should not be assumed to be a valid or unique database ID
-            // number
-            unset($this->id);
-        return parent::save($refetch);
-    }
 }
 
 class QueueColumnGlue
@@ -1242,6 +1237,7 @@ extends AbstractForm {
                     'wrap' => __("Wrap Lines"),
                     'ellipsis' => __("Add Ellipsis"),
                     'clip' => __("Clip Text"),
+                    'lclip' => __("Clip Beginning Text"),
                 ),
                 'default' => 'wrap',
                 'layout' => new GridFluidCell(4),
-- 
GitLab