From: Jan Schneider Date: Mon, 5 Jul 2010 09:52:57 +0000 (+0200) Subject: Sort duplicates by modification date. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d9b35dddc50bbb413e3975068a8285ecb22ca995;p=horde.git Sort duplicates by modification date. Show duplicates as inline-block. Add merge button. --- diff --git a/turba/lib/Object.php b/turba/lib/Object.php index c3a0663ca..f651afc40 100644 --- a/turba/lib/Object.php +++ b/turba/lib/Object.php @@ -188,6 +188,42 @@ class Turba_Object { } /** + * Returns the timestamp of the last modification, whether this was the + * creation or editing of the object and stores it as the attribute + * __modified. The value is cached for the lifetime of the object. + * + * @return integer The timestamp of the last modification or zero. + */ + function lastModification() + { + $time = $this->getValue('__modified'); + if (!is_null($time)) { + return $time; + } + + if (!$this->getValue('__uid')) { + $this->setValue('__modified', 0); + return 0; + } + + $time = 0; + try { + $log = $GLOBALS['injector'] + ->getInstance('Horde_History') + ->getHistory($this->getGuid()); + foreach ($log as $entry) { + if ($entry['action'] == 'add' || $entry['action'] == 'modify') { + + $time = max($time, $entry['ts']); + } + } + } catch (Exception $e) {} + $this->setValue('__modified', $time); + + return $time; + } + + /** * Returns history information about this contact. * * @return array A hash with the optional entries 'created' and 'modified' diff --git a/turba/lib/View/Duplicates.php b/turba/lib/View/Duplicates.php index f9d3d3f87..2f357f557 100644 --- a/turba/lib/View/Duplicates.php +++ b/turba/lib/View/Duplicates.php @@ -81,8 +81,14 @@ class Turba_View_Duplicates echo $view->render('header'); $view->contactUrl = Horde::applicationUrl('contact.php'); + $view->first = true; $duplicate = $this->_duplicates[$this->_type][$this->_duplicate]; while ($contact = $duplicate->next()) { + $contact->lastModification(); + } + $duplicate->sort(array(array('field' => '__modified', 'ascending' => false))); + $view->mergeInto = $duplicate->reset()->getValue('__key'); + while ($contact = $duplicate->next()) { $view->source = $contact->getSource(); $view->id = $contact->getValue('__key'); $history = $contact->getHistory(); @@ -95,6 +101,7 @@ class Turba_View_Duplicates $contactView = new Turba_Form_Contact($vars, $contact, false); $contactView->renderInactive(new Horde_Form_Renderer(), $vars); echo $view->render('contact_footer'); + $view->first = false; } echo $view->render('footer'); diff --git a/turba/templates/search/duplicate/contact_header.html.php b/turba/templates/search/duplicate/contact_header.html.php index f50993bd0..65d8c4e8c 100644 --- a/turba/templates/search/duplicate/contact_header.html.php +++ b/turba/templates/search/duplicate/contact_header.html.php @@ -1,13 +1,32 @@
-
-

- changed): ?> - changed ?> - + changed): ?> +

+ changed ?> +

+ +
+ first): ?> + + + + + + + " /> + + +
+ + + + " /> +
+
- - - " class="button" /> -

-
+ + + + " /> + +
diff --git a/turba/themes/ie6_or_less.css b/turba/themes/ie6_or_less.css new file mode 100644 index 000000000..d20a0953e --- /dev/null +++ b/turba/themes/ie6_or_less.css @@ -0,0 +1,9 @@ +/** + * CSS corrections for IE 6 and below. + */ + +/* Fixes broken inline-block. */ +.turba-duplicate-contact { + zoom: 1; + display: inline; +} diff --git a/turba/themes/ie7.css b/turba/themes/ie7.css new file mode 100644 index 000000000..53a20d25f --- /dev/null +++ b/turba/themes/ie7.css @@ -0,0 +1,9 @@ +/** + * CSS corrections for IE 7. + */ + +/* Fixes broken inline-block. */ +.turba-duplicate-contact { + zoom: 1; + display: inline; +} diff --git a/turba/themes/screen.css b/turba/themes/screen.css index 8b14af7eb..f4edcf8df 100644 --- a/turba/themes/screen.css +++ b/turba/themes/screen.css @@ -71,16 +71,24 @@ table#addressbook-list th.sortdown { /* Duplicates */ .turba-duplicate { + overflow-y: hidden; overflow-x: auto; white-space: nowrap; + vertical-align: top; } .turba-duplicate-contact { - float: left; + display: inline-block; margin-top: 8px; margin-right: 8px; } .turba-duplicate-contact p { - padding: 8px; + margin: 8px; +} +.turba-duplicate-contact form { + display: inline; +} +.turba-duplicate-forms { + margin: 8px; } /* Preferences pages */