/** * Save dashboard configuration (AJAX call) * * @param TBGRequest $request */ public function runDashboardSave(TBGRequest $request) { $i18n = TBGContext::getI18n(); $login_referer = array_key_exists('HTTP_REFERER', $_SERVER) && isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $this->login_referer = htmlentities($login_referer, ENT_COMPAT, TBGContext::getI18n()->getCharset()); $this->options = $request->getParameters(); try { if (TBGContext::getRequest()->isAjaxCall() || TBGContext::getRequest()->getRequestedFormat() == 'json') { if ($request->getMethod() == TBGRequest::POST) { if ($request->hasParameter('id')) { $views = array(); foreach (explode(';', $request['id']) as $view) { array_push($views, array('type' => strrev(mb_strstr(strrev($view), '_', true)), 'id' => mb_strstr($view, '_', true))); } array_pop($views); TBGDashboardView::setViews($request['tid'], $request['target_type'], $views); return $this->renderJSON(array('message' => $i18n->__('Dashboard configuration saved'))); } else { throw new Exception($i18n->__('An internal error has occured')); } } else { throw new Exception($i18n->__('An internal error has occured')); } } else { throw new Exception($i18n->__('An internal error has occured')); } } catch (Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $i18n->__($e->getMessage()), 'referer' => htmlentities($request['tbg3_referer'], ENT_COMPAT, TBGContext::getI18n()->getCharset()))); } }