public function addMenuItemAction() { $request = $this->getRequest(); $form = new Security_Form_Menu(); if ($request->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $model = new Security_Model_SystemMaster(); $model->setMasterCode("fdMenu"); $model->setMasterValue($options['title']); $model->setStatus($options['isActive']); $model->setStrval1($options['path']); $model->setStrval2($options['toolTip']); $model->setIntval1($options['parentMenuId']); $model->setBlnval1($options['isChild']); $id = $model->save(); if ($id) { $this->_flashMessenger->addMessage(array('success' => 'Menu item added successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } else { $this->_flashMessenger->addMessage(array('error' => 'Failed to add menu item!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } $form->reset(); } else { $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function createAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $parent_node_id = $this->_getParam('parent_node_id'); $child_master_value = $this->_getParam('node_title'); $arrNode = explode("_", $parent_node_id); $parent_master_code = $arrNode[0]; $parent_master_id = $arrNode[1]; $model = new Security_Model_SystemMaster(); if ($parent_master_code == "noderoot") { // create group $child_master_code = "fdUserGroup"; } else { if ($parent_master_code == "fdUserGroup") { //create sub group $child_master_code = "fdUserSubGroup"; $map_code = "fdGroupSubGroupMap"; } else { if ($parent_master_code == "fdUserSubGroup") { //create new role $child_master_code = "fdUserRole"; $map_code = "fdSubGroupRoleMap"; } } } $model->setMasterCode($child_master_code); $model->setMasterValue($child_master_value); $node_id = $model->save(); if ($parent_master_code !== "noderoot") { //mapping start $objMapping = new Security_Model_SystemMapping(); $objMapping->setMapId1($parent_master_id); $objMapping->setMapId2($node_id); $objMapping->setMapCode($map_code); if (true === $objMapping->save()) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } else { if ($node_id) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } echo $result; }
public function addMenuItemAction() { $request = $this->getRequest(); $form = new Security_Form_Menu(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); //$element->removeDecorator('Errors'); } //echo $this->getFrontController()->getBaseUrl(); $this->getIconsList(); if ($request->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $model = new Security_Model_SystemMaster(); $model->setMasterCode("fdMenu"); $model->setMasterValue($options['title']); $model->setStatus($options['isActive']); $model->setStrval1($options['path']); $model->setStrval2($options['toolTip']); $model->setIntval1($options['parentMenuId']); $model->setBlnval1($options['isChild']); $model->setBlnval2($options['isAction']); $model->setStrval3($options['menuIcon']); $id = $model->save(); if ($id) { $this->_flashMessenger->addMessage(array('success' => 'Menu item added successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } else { $this->_flashMessenger->addMessage(array('error' => 'Failed to add menu item!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } $form->reset(); } else { $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function createAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $parent_node_id = $this->_getParam('parent_node_id'); $child_master_value = $this->_getParam('node_title'); $arrNode = explode("_", $parent_node_id); $parent_master_code = $arrNode[0]; $parent_master_id = $arrNode[1]; $model = new Security_Model_SystemMaster(); if ($parent_master_code == "noderoot") { // create group $child_master_code = "fdAction"; } $model->setMasterCode($child_master_code); $model->setMasterValue($child_master_value); $node_id = $model->save(); if ($node_id) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } echo $result; }
public function createAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $parent_node_id = $this->_getParam('parent_node_id'); //print_r ($parent_node_id); $child_master_value = $this->_getParam('node_title'); $arrNode = explode("_", $parent_node_id); $parent_master_code = $arrNode[0]; $parent_master_id = $arrNode[1]; $model = new Security_Model_SystemMaster(); $entry_in_master_tbl = 'Yes'; if ($parent_master_code == "noderoot") { // create group $child_master_code = "fdAnimal"; $where = "master_value = '{$child_master_value}'"; $already_exists_validation = $model->fetchRow($where); if ($already_exists_validation) { return 0; } } else { if ($parent_master_code == "fdAnimal") { //create sub group $parent_master_id = $arrNode[1]; $child_master_code = "fdAnimalType"; $map_code = "fdAnimalAnimalTypeAnimalColorMap"; $where = "master_value = '{$child_master_value}'"; $already_exists_validation = $model->fetchRow($where); if ($already_exists_validation) { $entry_in_master_tbl = 'No'; } } else { if ($parent_master_code == "fdAnimalType") { //create new role $parent_master_id = $arrNode[2]; $child_master_id = $arrNode[1]; $child_master_code = "fdAnimalColor"; $map_code = "fdAnimalAnimalTypeAnimalColorMap"; $where = "master_value = '{$child_master_value}'"; $already_exists_validation = $model->fetchRow($where); if ($already_exists_validation) { $entry_in_master_tbl = 'No'; } } } } echo $entry_in_master_tbl; if ($entry_in_master_tbl == 'Yes') { $model->setMasterCode($child_master_code); $model->setMasterValue($child_master_value); $node_id = $model->save(); } else { if ($entry_in_master_tbl == 'No') { $node_id = $already_exists_validation->masterId; } } //echo $node_id ; if ($parent_master_code !== "noderoot") { //mapping start $objMapping = new Security_Model_SystemMapping(); $objMapping->setMapId1($parent_master_id); if ($child_master_id) { $objMapping->setMapId2($child_master_id); $objMapping->setMapId3($node_id); $objMapping->setMapCode($map_code); //$objMapping->UpdateMapId3_MapId2($map_code,$parent_master_id,$child_master_id,$node_id); $objMapping->save(); $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $objMapping->setMapId2($node_id); $objMapping->setMapCode($map_code); if (true === $objMapping->save()) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } } else { if ($node_id) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } return $result; }