mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 14:32:18 +00:00
Cleanup & uid from AuthLib
This commit is contained in:
@@ -76,93 +76,4 @@ class Widget extends Auth_Controller
|
||||
$this->outputJsonSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function addWidgetToUserOverride()
|
||||
{
|
||||
$input = json_decode($this->input->raw_input_stream);
|
||||
$dashboard_kurzbz = $input->db;
|
||||
$uid = $input->uid;
|
||||
$funktion = $input->funktion;
|
||||
|
||||
$override = $this->DashboardLib->getOverrideOrCreateEmptyOverride($dashboard_kurzbz, $uid);
|
||||
|
||||
$override_decoded = json_decode($override->override, true);
|
||||
$widgetid = isset($input->widgetid) ? array('widgetid' => $input->widgetid)
|
||||
: $this->DashboardLib->generateWidgetId($dashboard_kurzbz);
|
||||
|
||||
$override_decoded[$funktion][$widgetid['widgetid']] = $input->widget;
|
||||
|
||||
$override->override = json_encode($override_decoded);
|
||||
|
||||
$result = $this->DashboardLib->insertOrUpdateOverride($override);
|
||||
if( isError($result) ) {
|
||||
http_response_code(500);
|
||||
$this->terminateWithJsonError('override could not be saved');
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess($widgetid['widgetid']);
|
||||
}
|
||||
|
||||
public function updateWidgetsToUserOverride()
|
||||
{
|
||||
$input = json_decode($this->input->raw_input_stream, true);
|
||||
$dashboard_kurzbz = $input['db'];
|
||||
$uid = $input['uid'];
|
||||
$funktion = $input['funktion'];
|
||||
|
||||
$override = $this->DashboardLib->getOverrideOrCreateEmptyOverride($dashboard_kurzbz, $uid);
|
||||
|
||||
$override_decoded = json_decode($override->override, true);
|
||||
if ($override_decoded[$funktion])
|
||||
$override_decoded[$funktion] = array_replace_recursive($override_decoded[$funktion], $input['widgets']);
|
||||
else
|
||||
$override_decoded[$funktion] = $input['widgets'];
|
||||
|
||||
$override->override = json_encode($override_decoded);
|
||||
|
||||
$result = $this->DashboardLib->insertOrUpdateOverride($override);
|
||||
if( isError($result) ) {
|
||||
http_response_code(500);
|
||||
$this->terminateWithJsonError('override could not be saved');
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess(['msg' => 'override successfully updated.']);
|
||||
}
|
||||
|
||||
public function removeWidgetFromUserOverride()
|
||||
{
|
||||
$input = json_decode($this->input->raw_input_stream);
|
||||
$dashboard_kurzbz = $input->db;
|
||||
$uid = $input->uid;
|
||||
$funktion = $input->funktion;
|
||||
$widgetid = $input->widgetid;
|
||||
|
||||
$override = $this->DashboardLib->getOverride($dashboard_kurzbz, $uid);
|
||||
if( empty($override) ) {
|
||||
http_response_code(404);
|
||||
$this->terminateWithJsonError('userconfig for dashboard '
|
||||
. $dashboard_kurzbz . ' not found.');
|
||||
}
|
||||
|
||||
$override_decoded = json_decode($override->override, true);
|
||||
|
||||
if( array_key_exists($widgetid, $override_decoded[$funktion]) )
|
||||
{
|
||||
unset($override_decoded[$funktion][$widgetid]);
|
||||
}
|
||||
else
|
||||
{
|
||||
http_response_code(404);
|
||||
$this->terminateWithJsonError('widgetid ' . $widgetid . ' not found in funktion ' . $funktion);
|
||||
}
|
||||
|
||||
$override->override = json_encode($override_decoded);
|
||||
$result = $this->DashboardLib->insertOrUpdateOverride($override, $uid);
|
||||
if( isError($result) )
|
||||
{
|
||||
http_response_code(500);
|
||||
$this->terminateWithJsonError('failed to remove widget');
|
||||
}
|
||||
$this->outputJsonSuccess(array('msg' => 'override successfully updated.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user