mirror of
https://github.com/e107inc/e107.git
synced 2025-07-30 19:30:25 +02:00
Merge branch 'e107inc:master' into master
This commit is contained in:
389
e107_admin/history.php
Normal file
389
e107_admin/history.php
Normal file
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
|
||||
// Generated e107 Plugin Admin Area
|
||||
|
||||
require_once('../class2.php');
|
||||
if (!getperms('0'))
|
||||
{
|
||||
e107::redirect('admin');
|
||||
exit;
|
||||
}
|
||||
|
||||
// e107::lan('history',true);
|
||||
e107::css('inline', " td.history-data pre { max-width: 800px; } }");
|
||||
|
||||
class history_adminArea extends e_admin_dispatcher
|
||||
{
|
||||
|
||||
protected $modes = array(
|
||||
|
||||
'main' => array(
|
||||
'controller' => 'admin_history_ui',
|
||||
'path' => null,
|
||||
'ui' => 'admin_history_form_ui',
|
||||
'uipath' => null
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
protected $adminMenu = array(
|
||||
|
||||
'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'),
|
||||
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
|
||||
|
||||
// 'main/div0' => array('divider'=> true),
|
||||
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P'),
|
||||
|
||||
);
|
||||
|
||||
protected $adminMenuAliases = array(
|
||||
'main/edit' => 'main/list'
|
||||
);
|
||||
|
||||
protected $menuTitle = 'History';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class admin_history_ui extends e_admin_ui
|
||||
{
|
||||
|
||||
protected $pluginTitle = 'History';
|
||||
protected $pluginName = 'myplugin';
|
||||
// protected $eventName = 'myplugin-admin_history'; // remove comment to enable event triggers in admin.
|
||||
protected $table = 'admin_history';
|
||||
protected $pid = 'history_id';
|
||||
protected $perPage = 10;
|
||||
protected $batchDelete = true;
|
||||
protected $batchExport = true;
|
||||
protected $batchCopy = false;
|
||||
|
||||
// protected $tabs = array('tab1'=>'Tab 1', 'tab2'=>'Tab 2'); // Use 'tab'=>'tab1' OR 'tab'=>'tab2' in the $fields below to enable.
|
||||
|
||||
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
|
||||
|
||||
protected $listOrder = 'history_id DESC';
|
||||
|
||||
protected $fields = array (
|
||||
'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => 'value', 'class' => 'center', 'toggle' => 'e-multiselect', 'readParms' => [], 'writeParms' => [],),
|
||||
// 'history_id' => array ( 'title' => LAN_ID, 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left',),
|
||||
'history_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'width' => '15%', 'filter' => true, 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left',),
|
||||
'history_table' => array ( 'title' => 'Table', 'type' => 'text', 'data' => 'safestr', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left',),
|
||||
'history_record_id' => array ( 'title' => LAN_ID, 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left',),
|
||||
'history_action' => array ( 'title' => 'Action', 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left', 'batch' => false,),
|
||||
'history_data' => array ( 'title' => 'Changed Data', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'history-data left', 'thclass' => 'left', 'filter' => false, 'batch' => false,),
|
||||
'history_user_id' => array ( 'title' => LAN_USER, 'type' => 'user', 'data' => 'int', 'width' => '5%', 'filter' => true, 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left',),
|
||||
'history_restored' => array ( 'title' => "Restored", 'type' => 'datestamp', 'data' => 'int', 'width' => '5%', 'filter' => true, 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'center', 'thclass' => 'center',),
|
||||
|
||||
'options' => array ( 'title' => LAN_OPTIONS, 'type' => 'method', 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => 'value', 'readParms' => [], 'writeParms' => [],),
|
||||
);
|
||||
|
||||
protected $fieldpref = array( 'history_datestamp', 'history_table', 'history_record_id','history_action', 'history_data', 'history_user_id', 'history_restored');
|
||||
|
||||
|
||||
// protected $preftabs = array('General', 'Other' );
|
||||
protected $prefs = array(
|
||||
);
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->fields['history_action']['writeParms']['optArray'] = [
|
||||
'delete' => "<span class='label label-danger'>". LAN_DELETE."</span>",
|
||||
'update' => "<span class='label label-success'>". LAN_UPDATE."</span>",
|
||||
'restore' => "<span class='label label-warning'>Restore</span>"
|
||||
];
|
||||
|
||||
|
||||
// Check for the "Restore" action
|
||||
if (!empty($_POST['restore_deleted']))
|
||||
{
|
||||
$restoreId = (int) key($_POST['restore_deleted']); // Retrieve the ID of the record to restore
|
||||
$this->processRestoreAction($restoreId, 'insert');
|
||||
}
|
||||
elseif (!empty($_POST['restore_updated']))
|
||||
{
|
||||
$restoreId = (int) key($_POST['restore_updated']); // Retrieve the ID of the record to restore
|
||||
$this->processRestoreAction($restoreId, 'update');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a previously recorded entry in the administrator history table.
|
||||
*
|
||||
* @param int $id The unique identifier of the record to restore.
|
||||
* @param string $action The type of action to perform (e.g., 'insert' or 'update') during restoration.
|
||||
* @return void
|
||||
*/
|
||||
private function processRestoreAction($id, $action)
|
||||
{
|
||||
|
||||
$db = e107::getDb();
|
||||
$message = e107::getMessage();
|
||||
|
||||
// Query the admin_history table for the record
|
||||
$historyRow = $db->retrieve('admin_history', '*', 'history_id = '.$id);
|
||||
|
||||
if ($historyRow)
|
||||
{
|
||||
$originalTable = $historyRow['history_table']; // The table where this record belongs
|
||||
$originalData = json_decode($historyRow['history_data'], true);
|
||||
$pid = $historyRow['history_pid'];
|
||||
$recordId = $historyRow['history_record_id'];
|
||||
|
||||
|
||||
|
||||
if (!empty($originalTable) && !empty($originalData) && !empty($pid) && !empty($recordId))
|
||||
{
|
||||
if($action === 'insert')
|
||||
{
|
||||
$originalData[$pid] = (int) $recordId;
|
||||
$result = $db->replace($originalTable, $originalData);
|
||||
}
|
||||
else // update
|
||||
{
|
||||
$backup = $db->retrieve($originalTable, '*', $pid. ' = '.(int) $recordId);
|
||||
if($changes = array_diff_assoc($originalData, $backup))
|
||||
{
|
||||
$old_changed_data = array_intersect_key($backup, $changes);
|
||||
$this->backupToHistory($originalTable, $pid, $recordId, 'restore', $old_changed_data, false);
|
||||
}
|
||||
|
||||
$originalData['WHERE'] = $pid .' = '. (int) $recordId;
|
||||
$result = $db->update($originalTable, $originalData);
|
||||
}
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$message->addSuccess("The record (ID: $id) has been successfully restored to the $originalTable table.", 'default', true);
|
||||
$db->update('admin_history', "history_restored = ".time()." WHERE history_id = $id");
|
||||
}
|
||||
elseif($result === 0)
|
||||
{
|
||||
$message->addInfo("No changes made", 'default', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message->addError("Failed to restore the record (ID: $id) to the $originalTable table.", 'default', true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message->addError("Restoration data is incomplete or invalid for Record ID: $id.", 'default', true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message->addError("Record ID: $id not found in the admin history table.", 'default', true);
|
||||
}
|
||||
|
||||
// Redirect back to avoid multiple form submissions
|
||||
e107::getRedirect()->go(e_SELF);
|
||||
}
|
||||
|
||||
|
||||
// ------- Customize Create --------
|
||||
|
||||
public function beforeCreate($new_data,$old_data)
|
||||
{
|
||||
return $new_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// left-panel help menu area. (replaces e_help.php used in old plugins)
|
||||
public function renderHelp()
|
||||
{
|
||||
$caption = LAN_HELP;
|
||||
$text = "
|
||||
<p>This page allows you to view the <strong>history of changes</strong> made to records in the system and restore records to a previous state when needed.</p>
|
||||
|
||||
<h4>Features of this page:</h4>
|
||||
<ul>
|
||||
<li><strong>View Changes:</strong> See details of updates and deletions, including who made the changes and when.</li>
|
||||
<li><strong>Revert Changes:</strong> Restore a record to its earlier version, undoing accidental or undesired modifications.</li>
|
||||
<li><strong>Audit Trail:</strong> Track all actions performed on records for accountability and transparency.</li>
|
||||
</ul>
|
||||
|
||||
<p>Use the filters to narrow down the history logs or locate specific changes. If a record can be restored, an option will be available in the Options menu.</p>
|
||||
";
|
||||
|
||||
return ['caption' => $caption, 'text' => $text];
|
||||
}
|
||||
|
||||
/*
|
||||
// optional - a custom page.
|
||||
public function customPage()
|
||||
{
|
||||
if($this->getPosted('custom-submit')) // after form is submitted.
|
||||
{
|
||||
e107::getMessage()->addSuccess('Changes made: '. $this->getPosted('example'));
|
||||
}
|
||||
|
||||
$this->addTitle('My Custom Title');
|
||||
|
||||
|
||||
$frm = $this->getUI();
|
||||
$text = $frm->open('my-form', 'post');
|
||||
|
||||
$tab1 = "<table class='table table-bordered adminform'>
|
||||
<colgroup>
|
||||
<col class='col-label'>
|
||||
<col class='col-control'>
|
||||
</colgroup>
|
||||
<tr>
|
||||
<td>Label ".$frm->help('A help tip')."</td>
|
||||
<td>".$frm->text('example', $this->getPosted('example'), 80, ['size'=>'xlarge'])."</td>
|
||||
</tr>
|
||||
</table>";
|
||||
|
||||
// Display Tab
|
||||
$text .= $frm->tabs([
|
||||
'general' => ['caption'=>LAN_GENERAL, 'text' => $tab1],
|
||||
]);
|
||||
|
||||
$text .= "<div class='buttons-bar text-center'>".$frm->button('custom-submit', 'submit', 'submit', LAN_CREATE)."</div>";
|
||||
$text .= $frm->close();
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Handle batch options as defined in admin_history_form_ui::history_data; 'handle' + action + field + 'Batch'
|
||||
// @important $fields['history_data']['batch'] must be true for this method to be detected.
|
||||
// @param $selected
|
||||
// @param $type
|
||||
function handleListHistoryDataBatch($selected, $type)
|
||||
{
|
||||
|
||||
$ids = implode(',', $selected);
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case 'custombatch_1':
|
||||
// do something
|
||||
e107::getMessage()->addSuccess('Executed custombatch_1');
|
||||
break;
|
||||
|
||||
case 'custombatch_2':
|
||||
// do something
|
||||
e107::getMessage()->addSuccess('Executed custombatch_2');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Handle filter options as defined in admin_history_form_ui::history_data; 'handle' + action + field + 'Filter'
|
||||
// @important $fields['history_data']['filter'] must be true for this method to be detected.
|
||||
// @param $selected
|
||||
// @param $type
|
||||
function handleListHistoryDataFilter($type)
|
||||
{
|
||||
|
||||
$this->listOrder = 'history_data ASC';
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case 'customfilter_1':
|
||||
// return ' history_data != 'something' ';
|
||||
e107::getMessage()->addSuccess('Executed customfilter_1');
|
||||
break;
|
||||
|
||||
case 'customfilter_2':
|
||||
// return ' history_data != 'something' ';
|
||||
e107::getMessage()->addSuccess('Executed customfilter_2');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class admin_history_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
public function options($parms, $value, $id, $att = [])
|
||||
{
|
||||
$controller = $this->getController();
|
||||
|
||||
$row = $controller->getListModel()->getData();
|
||||
|
||||
// Begin options group
|
||||
$text = "<div class='btn-group pull-right'>";
|
||||
|
||||
// Check if the record can be restored
|
||||
if (!empty($id))
|
||||
{
|
||||
// Generate Restore button
|
||||
$restoreTitle = "Restore this Record";
|
||||
|
||||
$type = $row['history_action'];
|
||||
$name = ($type === 'delete') ? "restore_deleted[$id]" : "restore_updated[$id]";
|
||||
$text .= "<button class='btn btn-default' type='submit' name='$name' title='{$restoreTitle}'><i class='admin-ui-option fa fa-undo fa-2x fa-fw'></i></button>";
|
||||
}
|
||||
|
||||
$att['readParms']['editClass'] = 999; // disable it.
|
||||
$text .= $this->renderValue('options', $value, $att, $id);
|
||||
|
||||
// End options group
|
||||
$text .= "</div>";
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Custom Method/Function
|
||||
function history_data($curVal,$mode)
|
||||
{
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 'read': // List Page
|
||||
case 'write':
|
||||
|
||||
return print_a($curVal,true);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'filter':
|
||||
return array('customfilter_1' => 'Custom Filter 1', 'customfilter_2' => 'Custom Filter 2');
|
||||
break;
|
||||
|
||||
case 'batch':
|
||||
return array('custombatch_1' => 'Custom Batch 1', 'custombatch_2' => 'Custom Batch 2');
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
new history_adminArea();
|
||||
|
||||
require_once(e_ADMIN."auth.php");
|
||||
e107::getAdminUI()->runPage();
|
||||
|
||||
require_once(e_ADMIN."footer.php");
|
||||
exit;
|
||||
|
@@ -24,7 +24,7 @@ $e_sub_cat = 'plug_manage';
|
||||
|
||||
define('PLUGIN_SHOW_REFRESH', FALSE);
|
||||
define('PLUGIN_SCAN_INTERVAL', !empty($_SERVER['E_DEV']) ? 0 : 360);
|
||||
define("ADMIN_GITSYNC_ICON", e107::getParser()->toGlyph('fa-refresh', array('size'=>'2x', 'fw'=>1)));
|
||||
define("ADMIN_GITSYNC_ICON", e107::getParser()->toGlyph('fa-refresh', array('class'=>'admin-ui-option', 'size'=>'2x', 'fw'=>1)));
|
||||
|
||||
|
||||
global $user_pref;
|
||||
|
@@ -131,6 +131,12 @@ e107::coreLan('userclass2', true);
|
||||
$this->fields['userclass_visibility']['writeParms']['default'] = e_UC_ADMIN;
|
||||
$this->fields['userclass_id']['writeParms']['default'] =$this->getUserClassAdmin()->findNewClassID();
|
||||
|
||||
if(getperms('0'))
|
||||
{
|
||||
$this->fields['userclass_editclass']['batch'] = true;
|
||||
$this->fields['userclass_visibility']['batch'] = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -211,6 +211,25 @@ CREATE TABLE generic (
|
||||
) ENGINE=InnoDB;
|
||||
# --------------------------------------------------------
|
||||
|
||||
CREATE TABLE admin_history (
|
||||
history_id int(10) unsigned NOT NULL auto_increment,
|
||||
history_table varchar(64) NOT NULL default '',
|
||||
history_pid varchar(64) NOT NULL default '',
|
||||
history_record_id int(10) unsigned NOT NULL default '0',
|
||||
history_action enum('delete','restore','update') NOT NULL,
|
||||
history_data JSON DEFAULT NULL,
|
||||
history_user_id int(10) unsigned NOT NULL default '0',
|
||||
history_datestamp int(10) unsigned NOT NULL default '0',
|
||||
history_restored int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (history_id),
|
||||
KEY history_table_record (history_table, history_record_id),
|
||||
KEY history_datestamp (history_datestamp)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Table structure for table `links` (navigation)
|
||||
#
|
||||
|
@@ -124,20 +124,23 @@ $ADMIN_ICONS_TEMPLATE['E_16_PLUGIN'] = "<i class='S16 e-plugins-1
|
||||
$ADMIN_ICONS_TEMPLATE['E_16_PLUGMANAGER'] = "<i class='S16 e-plugmanager-16'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['E_16_THEMEMANAGER'] = "<i class='S16 e-themes-16'></i>";
|
||||
|
||||
$ADMIN_ICONS_TEMPLATE['E_16_UNDO'] = "<img class='icon S16' src='" . e_IMAGE . "admin_images/undo_16.png' alt='' />";
|
||||
$ADMIN_ICONS_TEMPLATE['E_32_UNDO'] = "<img class='icon S32' src='" . e_IMAGE . "admin_images/undo_32.png' alt='' />";
|
||||
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_WARNING_ICON'] = "<i class='fa fa-warning text-warning'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_GRID_ICON'] = "<i class='fa fa-th'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_LIST_ICON'] = "<i class='fas fa-list'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_ADD_ICON'] = "<i class='S32 e-add-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_INFO_ICON'] = "<i class='fa fa-question-circle'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_CONFIGURE_ICON'] = "<i class='S32 e-settings-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_VIEW_ICON'] = "<i class='S32 e-search-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_CONFIGURE_ICON'] = "<i class='admin-ui-option fa fa-cog fa-2x fa-fw'></i>"; //"<i class='S32 e-settings-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_VIEW_ICON'] = "<i class='admin-ui-option fa fa-search fa-2x fa-fw'></i>"; //"<i class='S32 e-search-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_URL_ICON'] = "<i class='S16 e-forums-16'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_INSTALLPLUGIN_ICON'] = "<i class='S32 e-plugin_install-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_UNINSTALLPLUGIN_ICON'] = "<i class='S32 e-plugin_uninstall-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_UPGRADEPLUGIN_ICON'] = "<i class='S32 e-up-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_REPAIRPLUGIN_ICON'] = "<i class='S32 e-configure-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_UP_ICON'] = "<i class='S32 e-up-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_DOWN_ICON'] = "<i class='S32 e-down-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_UNINSTALLPLUGIN_ICON'] = "<i class='admin-ui-option fa fa-trash fa-2x fa-fw'></i>"; // "<i class='S32 e-plugin_uninstall-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_UPGRADEPLUGIN_ICON'] = "<i class='admin-ui-option fa fa-arrow-up fa-2x fa-fw'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_REPAIRPLUGIN_ICON'] = "<i class='admin-ui-option fa fa-wrench fa-2x fa-fw'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_UP_ICON'] = "<i class='admin-ui-option fa fa-chevron-up fa-2x fa-fw'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_DOWN_ICON'] = "<i class='admin-ui-option fa fa-chevron-down fa-2x fa-fw'></i>";
|
||||
|
||||
// FOR BC
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_EDIT_ICON_PATH'] = e_IMAGE_ABS . "admin_images/edit_32.png";
|
||||
@@ -145,11 +148,11 @@ $ADMIN_ICONS_TEMPLATE['ADMIN_DELETE_ICON_PATH'] = e_IMAGE_ABS . "admin_image
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_WARNING_ICON_PATH'] = e_IMAGE_ABS . "admin_images/warning_32.png";
|
||||
|
||||
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_EDIT_ICON'] = "<i class='S32 e-edit-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_DELETE_ICON'] = "<i class='S32 e-delete-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_SORT_ICON'] = "<i class='S32 e-sort-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_EXECUTE_ICON'] = "<i class='S32 e-execute-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_PAGES_ICON'] = "<i class='S32 e-custom-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_EDIT_ICON'] = "<i class='admin-ui-option fa fa-edit fa-2x fa-fw' style='font-size: 24px; line-height: 32px;'></i>"; // "<i class='S32 e-edit-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_DELETE_ICON'] = "<i class='admin-ui-option fa fa-trash fa-2x fa-fw' style='font-size: 24px; line-height: 32px;'></i>"; // "<i class='S32 e-delete-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_SORT_ICON'] = "<i class='admin-ui-option fa fa-sort fa-2x fa-fw' style='font-size: 24px; line-height: 32px;'></i>"; //
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_EXECUTE_ICON'] = "<i class='admin-ui-option fa fa-play fa-2x fa-fw' style='font-size: 24px; line-height: 32px;'></i>"; // "<i class='S32 e-execute-32'></i>";
|
||||
$ADMIN_ICONS_TEMPLATE['ADMIN_PAGES_ICON'] = "<i class='admin-ui-option fa fa-file fa-2x fa-fw' style='font-size: 24px; line-height: 32px;'></i>"; //"<i class='S32 e-custom-32'></i>";
|
||||
|
||||
$ADMIN_ICONS_TEMPLATE['E_32_TRUE'] = "<i class='S32 e-true-32'></i>";
|
||||
|
||||
|
@@ -4579,9 +4579,53 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
return 'SELECT SQL_CALC_FOUND_ROWS * FROM `#' .$this->getTableName(). '` ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a backup record in the admin_history table for a given action on a specific record.
|
||||
*
|
||||
* @param string $table The name of the table where the record resides.
|
||||
* @param int $pid The primary ID field of the record.
|
||||
* @param int $id The ID of the specific record being backed up.
|
||||
* @param string $action The action performed on the record (e.g., 'update' or 'delete').
|
||||
* @param array $data An associative array of field data to be included in the history record.
|
||||
* @param bool $posted Whether the data has been posted and requires additional filter based on current $fields values or not.
|
||||
* @return bool True on successful creation of the backup record, false on failure.
|
||||
*/
|
||||
protected function backupToHistory($table, $pid, $id, $action, $data, $posted = true)
|
||||
{
|
||||
if($posted)
|
||||
{
|
||||
foreach($data as $field=>$var)
|
||||
{
|
||||
if(empty($this->fields[$field]['data'])) // exclude data not in the table.
|
||||
{
|
||||
unset($data[$field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$historyData = [
|
||||
'history_table' => $table,
|
||||
'history_pid' => $pid,
|
||||
'history_record_id' => $id,
|
||||
'history_action' => $action, // 'update' or 'delete'
|
||||
'history_data' => json_encode($data, JSON_PRETTY_PRINT),
|
||||
'history_user_id' => USERID,
|
||||
'history_datestamp' => time(),
|
||||
];
|
||||
|
||||
// Insert the record into the admin_history table
|
||||
if (!e107::getDb()->insert('admin_history', $historyData))
|
||||
{
|
||||
e107::getMessage()->addError("Failed to save history for table '{$table}', record ID {$id}");
|
||||
e107::getMessage()->addError(e107::getDb()->getLastErrorText());
|
||||
e107::getMessage()->addError(print_a($historyData, true));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Optional: Add debug logs for successful history creation
|
||||
e107::getMessage()->addDebug("History saved for table '{$table}', record ID {$id}");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -4611,6 +4655,9 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
$model->setPostedData($_posted);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($data && is_array($data))
|
||||
{
|
||||
// add to model data fields array if required
|
||||
@@ -4674,6 +4721,18 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
$model->setPostedData($_posted) // insert() or update() dbInsert();
|
||||
->save(true, $forceSave);
|
||||
|
||||
if ($id)
|
||||
{
|
||||
$new_data = $model->getData();
|
||||
|
||||
if($changes = array_diff_assoc($new_data, $old_data))
|
||||
{
|
||||
$old_changed_data = array_intersect_key($old_data, $changes);
|
||||
$this->backupToHistory($this->table, $this->getPrimaryName(), $id, 'update', $old_changed_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if(!empty($_POST))
|
||||
@@ -5622,6 +5681,12 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
if($model)
|
||||
{
|
||||
$data = $model->getData();
|
||||
|
||||
if($this->table !== 'admin_history')
|
||||
{
|
||||
$this->backupToHistory($this->table, $this->pid, $id, 'delete', $data);
|
||||
}
|
||||
|
||||
if($this->beforeDelete($data, $id))
|
||||
{
|
||||
$check = $this->getTreeModel()->delete($id);
|
||||
@@ -6288,6 +6353,12 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
if($model)
|
||||
{
|
||||
$data = $model->getData();
|
||||
|
||||
if($this->table !== 'admin_history')
|
||||
{
|
||||
$this->backupToHistory($this->table, $this->pid, $id,'delete',$data);
|
||||
}
|
||||
|
||||
if($this->beforeDelete($data, $id))
|
||||
{
|
||||
|
||||
|
@@ -1311,6 +1311,7 @@ TEMPLATE;
|
||||
case 'blob':
|
||||
case 'mediumblob':
|
||||
case 'longblob':
|
||||
default:
|
||||
$array = array(
|
||||
'textarea' => EPL_ADLAN_208,
|
||||
'bbarea' => EPL_ADLAN_209,
|
||||
@@ -1323,8 +1324,6 @@ TEMPLATE;
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
$array = [];
|
||||
}
|
||||
|
||||
// asort($array);
|
||||
|
@@ -960,6 +960,8 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; }
|
||||
// 7 => array(e_ADMIN.'download.php', ADLAN_24, ADLAN_25, 'R', 3, E_16_DOWNL, E_32_DOWNL),
|
||||
8 => array(e_ADMIN_ABS.'emoticon.php', ADLAN_58, ADLAN_59, 'F', 1, E_16_EMOTE, E_32_EMOTE),
|
||||
// 9 => array(e_ADMIN.'filemanager.php', ADLAN_30, ADLAN_31, '6', 5, E_16_FILE, E_32_FILE), // replaced by media-manager
|
||||
9 => array(e_ADMIN.'history.php', LAN_HISTORY, LAN_HISTORY, '7', 4, E_16_UNDO, E_32_UNDO),
|
||||
|
||||
10 => array(e_ADMIN_ABS.'frontpage.php', ADLAN_60, ADLAN_61, 'G', 1, E_16_FRONT, E_32_FRONT),
|
||||
11 => array(e_ADMIN_ABS.'image.php', LAN_MEDIAMANAGER, LAN_MEDIAMANAGER, 'A', 5, E_16_IMAGES, E_32_IMAGES),
|
||||
12 => array(e_ADMIN_ABS.'links.php', LAN_NAVIGATION, ADLAN_139, 'I', 1, E_16_LINKS, E_32_LINKS),
|
||||
|
@@ -1964,11 +1964,13 @@ class e_userperms
|
||||
|
||||
// Tools
|
||||
"Y" => array(ADLAN_147,E_16_INSPECT, E_32_INSPECT), // File inspector
|
||||
"7" => array(defset('LAN_HISTORY', 'History'), E_16_UNDO, E_32_UNDO), // History/Undo
|
||||
"9" => array(ADLAN_40, E_16_MAINTAIN, E_32_MAINTAIN), // Take Down site for Maintenance
|
||||
"O" => array(ADLAN_149,E_16_NOTIFY, E_32_NOTIFY), // Notify
|
||||
"U" => array(ADLAN_157,E_16_CRON, E_32_CRON), // Schedule Tasks
|
||||
"S" => array(ADLAN_155,E_16_ADMINLOG, E_32_ADMINLOG), // System Logging
|
||||
|
||||
|
||||
// Manage
|
||||
"B" => array(LAN_COMMENTMAN,E_16_COMMENT, E_32_COMMENT), // Moderate Comments
|
||||
"6" => array(LAN_MEDIAMANAGER,E_16_FILE, E_32_FILE), // File-Manager - Upload /manage files -
|
||||
|
@@ -601,4 +601,6 @@ define("LAN_META_DESCRIPTION", "Meta Description");
|
||||
|
||||
define("LAN_SYSTEM_NOTIFICATIONS_X", "[x] System Notification(s)");
|
||||
define("LAN_PHP_OUTDATED", "Your website is currently running an [outdated version of PHP], which may pose a security risk. If your plugins will allow it, we recommend upgrading to [x] to ensure that your website is secure and up-to-date.");
|
||||
define("LAN_DATABASE_UPDATE", "An update is available for your database. We recommend [running this update] as soon as possible to ensure that your database is secure and up-to-date.");
|
||||
define("LAN_DATABASE_UPDATE", "An update is available for your database. We recommend [running this update] as soon as possible to ensure that your database is secure and up-to-date.");
|
||||
|
||||
define("LAN_HISTORY", "History");
|
||||
|
@@ -75,10 +75,10 @@ class siteinfo_shortcodesTest extends \Codeception\Test\Unit
|
||||
|
||||
$result2 = $this->sc->sc_sitelogo(['type'=>'url']);
|
||||
self::assertStringContainsString('http', $result2);
|
||||
self::assertStringContainsString('logoHD.png', $result2);
|
||||
self::assertStringContainsString('logo', $result2);
|
||||
|
||||
$result3 = $this->sc->sc_sitelogo(['type'=>'email']);
|
||||
self::assertStringContainsString('{e_IMAGE}logoHD.png', $result3);
|
||||
self::assertStringContainsString('IMAGE}', $result3);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1138,7 +1138,7 @@ i.e-safari-32{ background-position: -427px 0; width: 32px; height: 32px; }
|
||||
i.e-seamonkey-16{ background-position: -464px 0; width: 16px; height: 16px; }
|
||||
i.e-seamonkey-32{ background-position: -485px 0; width: 32px; height: 32px; }
|
||||
|
||||
|
||||
i.admin-ui-option { font-size:24px; line-height:32px }
|
||||
|
||||
/* NEw */
|
||||
|
||||
|
Reference in New Issue
Block a user