summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2016-04-09 12:03:54 +0100
committerGreg Roach <fisharebest@gmail.com>2016-04-09 14:41:53 +0100
commit782f6af03e3244928e45d08eb52f2084a2d7072a (patch)
tree3209f3f5f86ae2e15c8524a1d151b8dd2a7e2ff4 /app
parent0d5bcf9072a95f83d014be7701610ab554a1b880 (diff)
downloadwebtrees-782f6af03e3244928e45d08eb52f2084a2d7072a.tar.gz
webtrees-782f6af03e3244928e45d08eb52f2084a2d7072a.tar.bz2
webtrees-782f6af03e3244928e45d08eb52f2084a2d7072a.zip
Fix: #886 - user column on recent changes list/table
Diffstat (limited to 'app')
-rw-r--r--app/Functions/FunctionsPrintLists.php75
-rw-r--r--app/Module/RecentChangesModule.php13
2 files changed, 54 insertions, 34 deletions
diff --git a/app/Functions/FunctionsPrintLists.php b/app/Functions/FunctionsPrintLists.php
index b675220e80..4a95b4395a 100644
--- a/app/Functions/FunctionsPrintLists.php
+++ b/app/Functions/FunctionsPrintLists.php
@@ -1727,11 +1727,12 @@ class FunctionsPrintLists {
* Print a table of events
*
* @param string[] $change_ids
- * @param string $sort
+ * @param string $sort
+ * @param bool $show_user
*
* @return string
*/
- public static function changesList($change_ids, $sort) {
+ public static function changesList($change_ids, $sort, $show_user) {
global $WT_TREE;
$n = 0;
@@ -1768,8 +1769,13 @@ class FunctionsPrintLists {
$html .= '<a href="' . $value['record']->getHtmlUrl() . '" class="list_item">' . $value['record']->getAddName() . '</a>';
}
}
- $html .= /* I18N: [a record was] Changed on <date/time> by <user> */
- I18N::translate('Changed on %1$s by %2$s', $value['record']->lastChangeTimestamp(), Filter::escapeHtml($value['record']->lastChangeUser()));
+ if ($show_user) {
+ $html .= /* I18N: [a record was] Changed on <date/time> by <user> */
+ I18N::translate('Changed on %1$s by %2$s', $value['record']->lastChangeTimestamp(), Filter::escapeHtml($value['record']->lastChangeUser()));
+ } else {
+ $html .= /* I18N: [a record was] Changed on <date/time> */
+ I18N::translate('Changed on %1$s', $value['record']->lastChangeTimestamp());
+ }
$html .= '</div>';
}
@@ -1780,25 +1786,27 @@ class FunctionsPrintLists {
* Print a table of events
*
* @param string[] $change_ids
- * @param string $sort
+ * @param string $sort
+ * @param bool $show_user
*
* @return string
*/
- public static function changesTable($change_ids, $sort) {
+ public static function changesTable($change_ids, $sort, $show_user) {
global $controller, $WT_TREE;
$n = 0;
$table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page
switch ($sort) {
- case 'name': //name
- $aaSorting = "[5,'asc'], [4,'desc']";
- break;
- case 'date_asc': //date ascending
- $aaSorting = "[4,'asc'], [5,'asc']";
- break;
- case 'date_desc': //date descending
- $aaSorting = "[4,'desc'], [5,'asc']";
- break;
+ case 'name': //name
+ default:
+ $aaSorting = "[2,'asc'], [4,'desc']";
+ break;
+ case 'date_asc': //date ascending
+ $aaSorting = "[4,'asc'], [2,'asc']";
+ break;
+ case 'date_desc': //date descending
+ $aaSorting = "[4,'desc'], [2,'asc']";
+ break;
}
$html = '';
$controller
@@ -1816,12 +1824,12 @@ class FunctionsPrintLists {
jQueryUI: true,
sorting: [' . $aaSorting . '],
columns: [
- /* 0-Type */ { sortable: false, class: "center" },
- /* 1-Record */ { dataSort: 5 },
- /* 2-Change */ { dataSort: 4 },
- /* 3-By */ null,
- /* 4-DATE */ { visible: false },
- /* 5-SORTNAME */{ type: "unicode", visible: false }
+ /* 0-Type */ { sortable: false, class: "center" },
+ /* 1-Record */ { dataSort: 2 },
+ /* 2-SORTNAME */ { type: "unicode" },
+ /* 3-Change */ { dataSort: 4 },
+ /* 4-DATE */ null
+ ' . ($show_user ? ',/* 5-By */ null' : '') . '
]
});
');
@@ -1831,10 +1839,12 @@ class FunctionsPrintLists {
$html .= '<thead><tr>';
$html .= '<th></th>';
$html .= '<th>' . I18N::translate('Record') . '</th>';
+ $html .= '<th hidden>SORTNAME</th>';
$html .= '<th>' . GedcomTag::getLabel('CHAN') . '</th>';
- $html .= '<th>' . GedcomTag::getLabel('_WT_USER') . '</th>';
- $html .= '<th>DATE</th>'; //hidden by datatables code
- $html .= '<th>SORTNAME</th>'; //hidden by datatables code
+ $html .= '<th hidden>DATE</th>';
+ if ($show_user) {
+ $html .= '<th>' . GedcomTag::getLabel('_WT_USER') . '</th>';
+ }
$html .= '</tr></thead><tbody>';
//-- table body
@@ -1880,15 +1890,16 @@ class FunctionsPrintLists {
$html .= '<div class="indent"><a href="' . $record->getHtmlUrl() . '">' . $addname . '</a></div>';
}
}
- $html .= "</td>";
- //-- Last change date/time
+ $html .= '</td>';
+ $html .= '<td hidden>' . $record->getSortName() . '</td>';
+ // Last change date/time
$html .= '<td class="wrap">' . $record->lastChangeTimestamp() . '</td>';
- //-- Last change user
- $html .= '<td class="wrap">' . Filter::escapeHtml($record->lastChangeUser()) . '</td>';
- //-- change date (sortable) hidden by datatables code
- $html .= '<td>' . $record->lastChangeTimestamp(true) . '</td>';
- //-- names (sortable) hidden by datatables code
- $html .= '<td>' . $record->getSortName() . '</td></tr>';
+ $html .= '<td hidden>' . $record->lastChangeTimestamp(true) . '</td>';
+ if ($show_user) {
+ // Last change user
+ $html .= '<td class="wrap">' . Filter::escapeHtml($record->lastChangeUser()) . '</td>';
+ }
+ $html .= '</tr>';
}
$html .= '</tbody></table>';
diff --git a/app/Module/RecentChangesModule.php b/app/Module/RecentChangesModule.php
index d963c0fa59..53b561f3ec 100644
--- a/app/Module/RecentChangesModule.php
+++ b/app/Module/RecentChangesModule.php
@@ -55,6 +55,7 @@ class RecentChangesModule extends AbstractModule implements ModuleBlockInterface
$days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
$sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'date_desc');
+ $show_user = $this->getBlockSetting($block_id, 'show_user', '1');
$block = $this->getBlockSetting($block_id, 'block', '1');
$hide_empty = $this->getBlockSetting($block_id, 'hide_empty', '0');
@@ -87,11 +88,11 @@ class RecentChangesModule extends AbstractModule implements ModuleBlockInterface
ob_start();
switch ($infoStyle) {
case 'list':
- $content .= FunctionsPrintLists::changesList($found_facts, $sortStyle);
+ $content .= FunctionsPrintLists::changesList($found_facts, $sortStyle, $show_user);
break;
case 'table':
// sortable table
- $content .= FunctionsPrintLists::changesTable($found_facts, $sortStyle);
+ $content .= FunctionsPrintLists::changesTable($found_facts, $sortStyle, $show_user);
break;
}
$content .= ob_get_clean();
@@ -133,6 +134,7 @@ class RecentChangesModule extends AbstractModule implements ModuleBlockInterface
$this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS, self::DEFAULT_DAYS));
$this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table'));
$this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'name|date_asc|date_desc', 'date_desc'));
+ $this->setBlockSetting($block_id, 'show_user', Filter::postBool('show_user'));
$this->setBlockSetting($block_id, 'hide_empty', Filter::postBool('hide_empty'));
$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
}
@@ -140,6 +142,7 @@ class RecentChangesModule extends AbstractModule implements ModuleBlockInterface
$days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
$sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'date_desc');
+ $show_user = $this->getBlockSetting($block_id, 'show_user', '1');
$block = $this->getBlockSetting($block_id, 'block', '1');
$hide_empty = $this->getBlockSetting($block_id, 'hide_empty', '0');
@@ -167,6 +170,12 @@ class RecentChangesModule extends AbstractModule implements ModuleBlockInterface
echo '</td></tr>';
echo '<tr><td class="descriptionbox wrap width33">';
+ echo /* I18N: label for a yes/no option */ I18N::translate('Show the user who made the change');
+ echo '</td><td class="optionbox">';
+ echo FunctionsEdit::editFieldYesNo('show_user', $block);
+ echo '</td></tr>';
+
+ echo '<tr><td class="descriptionbox wrap width33">';
echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
echo '</td><td class="optionbox">';
echo FunctionsEdit::editFieldYesNo('block', $block);