public function executeGConfigSuperAdmin(sfWebRequest $request) { $this->setLayout('gestio'); $this->IDS = $this->getUser()->getSessionPar('idS'); $this->accio = $request->getParameter('accio', 'C'); $RSITES = $request->getParameter('sites', array('site_id' => 1)); $this->FSITES = SitesPeer::initialize($RSITES['site_id']); $this->SITE = $request->getParameter('SITE', ''); if ($request->hasParameter('BSAVESITE')) { $this->accio = 'SAVE_SITE'; } if ($request->hasParameter('BDELETESITE')) { $this->accio = 'DELETE_SITE'; } if ($request->hasParameter('BSAVEUSERSITE')) { $this->accio = 'SAVE_USER_SITE'; } if ($request->hasParameter('BDELETEUSERSITE')) { $this->accio = 'DELETE_USER_SITE'; } if ($request->hasParameter('BSEARCHUSERSITES')) { $this->accio = 'SEARCH_USER_SITES'; } if ($request->hasParameter('BSAVEUSERMENU')) { $this->accio = 'SAVE_USER_MENU'; } switch ($this->accio) { case 'SAVE_SITE': $this->FSITES->bind($RSITES); if ($this->FSITES->isValid()) { $this->FSITES->save(); $this->getUser()->addLogAction($this->accio, 'gConfigSuperAdmin', $this->FSITES->getObject()); $this->FSITES = SitesPeer::initialize($this->FSITES->getObject()->getSiteId()); } break; case 'DELETE_SITE': $this->FSITES->getObject()->setActiu(false)->save(); $this->getUser()->addLogAction($this->accio, 'gConfigSuperAdmin', $this->FSITES->getObject()); $this->FESPAIS = SitesPeer::initialize(0, $this->IDS); break; case 'SAVE_USER_SITE': $RP = $request->getParameter('dades'); foreach ($RP as $RS) { if ($RS['IDU'] > 0 && $RS['IDN'] > 0 && $this->SITE > 0) { $OUS = UsuarisSitesPeer::initialize($RS['IDU'], $this->SITE, false)->getObject(); $OUS->setNivellId($RS['IDN']); $OUS->setActiu(true); $OUS->save(); } } $this->LUSERSITES = UsuarisSitesPeer::getSitesUsers($this->SITE, true); break; case 'DELETE_USER_SITE': $USUARI = $request->getParameter('USUARI'); $SITE = $request->getParameter('SITE'); $OUS = UsuarisSitesPeer::initialize($USUARI, $SITE)->getObject(); if (!$OUS->isNew()) { $OUS->setActiu(false); $OUS->save(); $this->LUSERSITES = UsuarisSitesPeer::getUserSites($this->SITE); } break; case 'SAVE_USER_MENU': $IDS = $request->getParameter('MENU_SITES'); $IDU = $request->getParameter('MENU_USUARIS'); $LMENUS = $request->getParameter('MENU_DISPONIBLES'); if (!empty($LMENUS)) { UsuarisMenusPeer::doUpdateMy($IDU[0], $IDS[0], $LMENUS); } break; case 'SEARCH_USER_SITES': $IDS = $this->FMENUUSUARI->getValue('IDS'); $IDU = $this->FMENUUSUARI->getValue('IDU'); if (!empty($IDS)) { $this->FMENUUSUARI->setWidgetUsers(); if (!empty($IDU)) { $this->LMENUSUSUARI = GestioMenusPeer::getMenusUsuariArray($IDU, $IDS); } } break; default: break; } //Cerquem per SITE, que és més fàcil //Mirem quins usuaris hi ha a un SITE relacionats com a adminstradors //Mirem quins menús tenen els usuaris d'un SITE en general (els menús del primer usuari) $OS = SitesPeer::retrieveByPK($this->SITE); if ($OS instanceof Sites) { $this->LUSERSITES = UsuarisSitesPeer::getSitesUsers($this->SITE, true); $this->LMENUSUSUARI = GestioMenusPeer::getMenusUsuariArray($this->USUARI, $this->SITE); } else { $this->USUARI = 0; $this->LUSERSITES = array(); $this->LMENUSUSUARI = array(); } $this->FMENUUSUARI = new ConfigSuperAdminMenusForm(null, array('IDS' => $this->IDS)); $this->FMENUUSUARI->bind($request->getParameter('super_admin_menus')); }