Skip to content
This repository has been archived by the owner on Apr 10, 2022. It is now read-only.

Commit

Permalink
records editing fix AFF-5662
Browse files Browse the repository at this point in the history
  • Loading branch information
hexus committed Sep 18, 2019
1 parent 1326359 commit 599143d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,26 @@ public function store()
$selects = \Input::get('select', []);

foreach($fields as $field=>$value) {
krsort($value);
$comment = isset($comments[$field]) ? $comments[$field] : '';
$select = isset($selects[$field]) ? $selects[$field] : '';
if($select){krsort($value);}

\DB::transaction(function () use ($field, $value, $comment, $select) {
$oldValue = \DbConfig::get($field);
$oldComment = \DbConfig::get($field . '_comment');
$oldSelect = \DbConfig::get($field . '_select');
if(!empty($select)) {
$oldSelect = \DbConfig::get($field . '_select');
\DbConfig::forget($field . '_select');
}

\DbConfig::forget($field);
\DbConfig::forget($field . '_comment');
\DbConfig::forget($field . '_select');

foreach($value as $key=>$v)
{
$value[$key] = preg_replace('/[^A-Za-z0-9\-\.\*\@]/', '', $v);
isset($oldValue[$key]) or $oldValue[$key] = '';
isset($oldComment[$key]) or $oldComment[$key] = '';
isset($oldSelect[$key]) or $oldSelect[$key] = '';
}

\DbConfig::store($field, $value);
Expand All @@ -65,11 +66,11 @@ public function store()
$newData = '';
foreach($oldValue as $k=>$v)
{
$oldData .= $v.' - '.$oldComment[$k].( ($oldSelect && key_exists($k, $oldSelect)) ? ' - '.json_encode($oldSelect[$k]) : '')."\n";
$oldData .= $v.' - '.$oldComment[$k].( (!empty($oldSelect) && key_exists($k, $oldSelect)) ? ' - '.json_encode($oldSelect[$k]) : '')."\n";
}
foreach($value as $k=>$v)
{
$newData .= $v.' - '.$comment[$k].(($select && key_exists($k, $select)) ? ' - '.json_encode($select[$k]) : '')."\n";
$newData .= $v.' - '.$comment[$k].( (!empty($select) && key_exists($k, $select) ) ? ' - '.json_encode($select[$k]) : '')."\n";
}

$diff = Diff::compare($oldData, $newData);
Expand Down

0 comments on commit 599143d

Please sign in to comment.