Show duplicates as inline-block.
Add merge button.
}
/**
+ * 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'
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();
$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');
<div class="turba-duplicate-contact solidbox">
- <form action="<?= $this->contactUrl ?>">
- <p>
- <? if ($this->changed): ?>
- <?= _("Last change: ") . $this->changed ?>
- <? endif; ?>
+ <? if ($this->changed): ?>
+ <p>
+ <?= _("Last change: ") . $this->changed ?>
+ </p>
+ <? endif; ?>
+ <div class="turba-duplicate-forms">
+ <? if (!$this->first): ?>
+ <form action="<?= $this->contactUrl ?>">
+ <input type="hidden" name="source" value="<?= $this->source ?>" />
+ <input type="hidden" name="key" value="<?= $this->h($this->id) ?>" />
+ <input type="hidden" name="url" value="<?= Horde::selfUrl(true) ?>" />
+ <input type="hidden" name="merge_into" value="<?= $this->h($this->mergeTarget) ?>" />
+ <input type="hidden" name="actionID" value="merge" />
+ <input type="submit" class="button" value="<?= _("<< Merge this into the first contact") ?>" />
+ </form>
+ <? endif; ?>
+ <form action="<?= $this->contactUrl ?>">
+ <input type="hidden" name="source" value="<?= $this->source ?>" />
+ <input type="hidden" name="key" value="<?= $this->h($this->id) ?>" />
+ <input type="hidden" name="url" value="<?= Horde::selfUrl(true) ?>" />
<input type="hidden" name="view" value="DeleteContact" />
+ <input type="submit" class="button" value="<?= _("Delete") ?>" />
+ </form>
+ <form action="<?= $this->contactUrl ?>">
<input type="hidden" name="source" value="<?= $this->source ?>" />
- <input type="hidden" name="key" value="<?= $this->id ?>" />
- <input type="hidden" name="url" value="<?= Horde::selfUrl(true, true, true) ?>" />
- <input type="submit" value="<?= _("Delete") ?>" class="button" />
- </p>
- </form>
+ <input type="hidden" name="key" value="<?= $this->h($this->id) ?>" />
+ <input type="hidden" name="url" value="<?= Horde::selfUrl(true) ?>" />
+ <input type="hidden" name="view" value="EditContact" />
+ <input type="submit" class="button" value="<?= _("Edit") ?>" />
+ </form>
+ </div>
--- /dev/null
+/**
+ * CSS corrections for IE 6 and below.
+ */
+
+/* Fixes broken inline-block. */
+.turba-duplicate-contact {
+ zoom: 1;
+ display: inline;
+}
--- /dev/null
+/**
+ * CSS corrections for IE 7.
+ */
+
+/* Fixes broken inline-block. */
+.turba-duplicate-contact {
+ zoom: 1;
+ display: inline;
+}
/* 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 */