Esempio n. 1
0
 public function edit($nNavigationMenuId, $aData)
 {
     $oModelNavigationResource = new Admin_Model_NavigationResource();
     $oModelNavigationOption = new Admin_Model_NavigationOption();
     $oGenereteSessionId = new AppCms2_GenereteSessionId();
     try {
         $this->_db->beginTransaction();
         $oRow = $this->find($nNavigationMenuId)->current();
         if ($oRow instanceof Zend_Db_Table_Row_Abstract) {
             $oRow->label = $aData["label"];
             $oRow->desc = $aData["desc"];
             $oRow->image_id = $aData["image_id"];
             $oRow->visible = $aData["visible"];
             if ($oRow->save()) {
                 $aGenereteSessionId = $oGenereteSessionId->generatePassword();
                 $sNavigationResource = "menu_resource_{$aData["navigation_module_id"]}_{$aData["navigation_controller_id"]}_{$aData["navigation_action_id"]}_{$aGenereteSessionId["user_password"]}";
                 $nNavigationResourceId = $oModelNavigationResource->add($sNavigationResource);
                 if (isset($nNavigationResourceId)) {
                     $aData["navigation_resource_id"] = $nNavigationResourceId;
                     $nNavigationOptionId = $oRow->navigation_option_id;
                     if ($oModelNavigationOption->edit($nNavigationOptionId, $aData)) {
                         $this->_db->commit();
                         return $nNavigationOptionId;
                     }
                 }
             }
         }
         $this->_db->rollBack();
         return null;
     } catch (Zend_Exception $e) {
         $this->_db->rollBack();
         return null;
     }
 }
 public function subsubmenuAction()
 {
     $oFormNavigationSubsubmenu = new Admin_Form_NavigationSubsubmenu();
     $oModelNavigationModule = new Admin_Model_NavigationModule();
     $oModelNavigationOption = new Admin_Model_NavigationOption();
     $oModelNavigationSubsubmenu = new Admin_Model_NavigationSubsubmenu();
     $oModelNavigationOptionUserRole = new Admin_Model_NavigationOptionUserRole();
     $oModelVSiteLayout = new Admin_Model_VSiteLayout();
     $oModelSite = new Admin_Model_Site();
     $oSite = new AppCms2_Controller_Plugin_FormLayoutAbstract();
     if ($this->_request->isPost()) {
         $aPostData = $this->_request->getPost();
         if ($oFormNavigationSubsubmenu->isValid($aPostData)) {
             $nNavigationSubsubmenuId = (int) $aPostData["navigation_subsubmenu_edit_id"];
             $aUserRole = $aPostData["user_role"];
             if ($nNavigationSubsubmenuId != 0) {
                 $nNavigationOptionId = $oModelNavigationSubsubmenu->edit($nNavigationSubsubmenuId, $aPostData);
                 $oModelNavigationOptionUserRole->deleteUserRole($nNavigationOptionId);
                 if (isset($aUserRole) && isset($nNavigationOptionId)) {
                     foreach ($aUserRole as $nRoleId) {
                         $oModelNavigationOptionUserRole->add($nNavigationOptionId, $nRoleId);
                     }
                 }
                 $oRow = $oModelNavigationOption->getRow($nNavigationOptionId);
                 $sLayoutName = $oModelVSiteLayout->getSiteLayoutId($nNavigationSubsubmenuId)->layout_name;
                 if ($oRow->navigation_module_id == 2 && $sLayoutName != $aPostData["layout_name"]) {
                     $aPostData["menu_id"] = $nNavigationSubsubmenuId;
                     $sClassName = $oSite->getClassName($aPostData["layout_name"]);
                     if (isset($sClassName)) {
                         $oObjectReflection = new ReflectionClass($sClassName);
                         $oFormInstance = $oObjectReflection->newInstanceArgs();
                         $aSiteFileds = $oFormInstance->getSiteFields();
                         $oModelSite->newSite($aPostData, $aSiteFileds);
                     }
                 }
                 $oFormNavigationSubsubmenu->clearForm();
             } else {
                 $nNavigationOptionId = $oModelNavigationSubsubmenu->add($aPostData);
                 if (isset($aUserRole) && isset($nNavigationOptionId)) {
                     foreach ($aUserRole as $nRoleId) {
                         $oModelNavigationOptionUserRole->add($nNavigationOptionId, $nRoleId);
                     }
                 }
                 $oRow = $oModelNavigationOption->getRow($nNavigationOptionId);
                 if ($oRow->navigation_module_id == 2) {
                     $nNavigationSubmenuId = $oModelNavigationSubsubmenu->findSubsubmenuId($nNavigationOptionId);
                     $aPostData["menu_id"] = $nNavigationSubmenuId;
                     $sClassName = $oSite->getClassName($aPostData["layout_name"]);
                     if (isset($sClassName)) {
                         $oObjectReflection = new ReflectionClass($sClassName);
                         $oFormInstance = $oObjectReflection->newInstanceArgs();
                         $aSiteFileds = $oFormInstance->getSiteFields();
                         $oModelSite->newSite($aPostData, $aSiteFileds);
                     }
                 }
                 $oFormNavigationSubsubmenu->clearForm();
             }
         }
     }
     $aAllModule = $oModelNavigationModule->getAll()->toArray();
     if (count($aAllModule)) {
         foreach ($aAllModule as $aValue) {
             $aNavigation[$aValue["value"]] = $this->prepareNavigation($aValue["value"]);
         }
     }
     $this->view->oFormNavigationElement = $oFormNavigationSubsubmenu;
     $this->view->aNavigation = $aNavigation;
 }