/** * adding selected widgets to the first column of the portal page/removing deselected widgets from portal page */ public function executeChangePortalWidgets() { $config = $this->hasRequestParameter('config') ? $this->getRequestParameter('config') : false; $selections = $this->hasRequestParameter('selections') ? json_decode($this->getRequestParameter('selections')) : false; $portalWidgets = $this->hasRequestParameter('portalWidgets') ? $this->getRequestParameter('portalWidgets') : false; if ($selections) { foreach ($selections as $selectionsParam) { if (!empty($selectionsParam[0])) { $selectedWidgets[] = $selectionsParam[0]; } } } else { $selectedWidgets = array(); } if ($config && $portalWidgets) { /** * getting the unique keys from selectedWidgets */ $selectedWidgets = array_unique($selectedWidgets); $portalWidgets = json_decode($portalWidgets); foreach ($portalWidgets as $pwi => $portalWidgetsFielset) { foreach ($portalWidgetsFielset->widgets as $pfwi => $widget) { $allWidgets[] = $widget; } } $allWidgets = array_unique($allWidgets); $unselectedWidgets = array(); $unselectedWidgets = array_diff($allWidgets, $selectedWidgets); $config = json_decode($config); $content = get_object_vars($config->content); unset($config->content); $config->content[$config->layoutItem] = $content; unset($content); $afPortalStateObj = afPortalStatePeer::updateWidgetsToState($config, $selectedWidgets, $unselectedWidgets); } $info = array('success' => true, 'redirect' => $this->getRequest()->getReferer()); $info = json_encode($info); return $this->renderText($info); }