public function editBookmarkAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $request = $this->getRequest();
     $usersNs = new Zend_Session_Namespace("members");
     $mapCode = "fdUserBookmark";
     $mapId1 = $usersNs->userId;
     if ($request->isPost()) {
         $model1 = new Security_Model_SystemMapping();
         $rows = $model1->fetchAll("map_code='{$mapCode}' and map_id1='{$mapId1}'");
         $model1->delete("map_code='{$mapCode}' and map_id1='{$mapId1}'");
         // $model2=new Security_Model_SystemMapping();
         // $model2->delete("map_code='{$mapCode}' and map_id1='{$mapId1}'");
         foreach ($rows as $_row) {
             $mapID2 = $_row->getMapId2();
             if (!empty($mapID2)) {
                 $ordC = "order" . $mapID2;
                 $orderval = $_POST[$ordC];
                 if (empty($orderval)) {
                     $orderval = 1;
                 } else {
                     $orderval = (int) $orderval;
                 }
                 $model1->setMapId1($mapId1);
                 //user id
                 $model1->setMapId2($mapID2);
                 //master id
                 $model1->setMapId3($orderval);
                 //order value
                 $model1->setMapCode($mapCode);
                 //map code
                 $model1->save();
                 //echo $_row->getMapId2()."----".$orderval;
                 //echo "<br>";
             }
         }
         $this->_flashMessenger->addMessage(array('success' => 'Bookmark order updated successfully!'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/bookmark/index'));
     }
 }
 public function removeAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $child_node_id = $this->_getParam('child_node_id');
     $arrChildNode = explode("_", $child_node_id);
     $child_master_code = $arrChildNode[0];
     $child_master_id = $arrChildNode[1];
     $parent_node_id = $this->_getParam('parent_node_id');
     $arrParentNode = explode("_", $parent_node_id);
     $parent_master_code = $arrParentNode[0];
     $parent_master_id = $arrParentNode[1];
     if ($child_master_code == "fdLegendsVal") {
         //delete role
         $objMap = new Security_Model_SystemMapping();
         $objMap->delete("map_code='fdLegendsLegendsValMap' and map_id1='{$parent_master_id}' and map_id2='{$child_master_id}'");
         $objMaster = new Security_Model_SystemMaster();
         $objMaster->delete("master_code='{$child_master_code}' and master_id='{$child_master_id}'");
     } else {
         if ($child_master_code == "fdLegends") {
             //fetch roles and delete them
             $objMap = new Security_Model_SystemMapping();
             $result = $objMap->fetchAll("map_code='fdLegendsLegendsValMap' and map_id1='{$child_master_id}'");
             if (count($result) > 0) {
                 foreach ($result as $_row) {
                     $objMaster = new Security_Model_SystemMaster();
                     $objMaster->delete("master_code='fdLegendsVal' and master_id='{$_row->getMapId2()}'");
                 }
             }
             $objMap->delete("map_code='fdLegendsLegendsValMap' and map_id1='{$child_master_id}'");
             // now delete sub group from master
             $objMaster = new Security_Model_SystemMaster();
             $objMaster->delete("master_code='{$child_master_code}' and master_id='{$child_master_id}'");
         }
     }
     echo $result = Zend_Json::encode(array("status" => true));
 }
Exemple #3
0
 public function initACL()
 {
     $model = new Security_Model_SystemMaster();
     $result = $model->fetchAll("master_code='fdMenu' and status='1'");
     $acl = new Base_Acl();
     foreach ($result as $row) {
         $arrUrl = explode("/", $row->getStrval1());
         $module = $arrUrl[1];
         $controller = $arrUrl[2];
         $action = $arrUrl[3];
         if (!$acl->has("{$module}:{$controller}")) {
             $acl->add(new Zend_Acl_Resource("{$module}:{$controller}"));
         }
         //$acl->deny('administrator', "$module:$controller", $action);
     }
     $acl->add(new Zend_Acl_Resource('default:error'))->add(new Zend_Acl_Resource('mps:auth'))->add(new Zend_Acl_Resource('default:index'));
     $acl->allow('guest', array('default:error', "mps:auth", 'default:index'));
     $acl->allow('administrator', array("mps:app"));
     // prototype
     $model = new Security_Model_SystemMapping();
     $userGroupId = $this->view->userGroupId;
     $userSubGroupId = $this->view->userSubGroupId;
     $userRoleId = $this->view->userRoleId;
     $userId = $this->view->userId;
     $arrG = array();
     $res = $model->fetchAll("map_code='fdMenuGroupMap' and map_id2='{$userGroupId}'");
     if (count($res) > 0) {
         foreach ($res as $_row) {
             $arrG[] = $_row->getMapId1();
         }
     }
     $res = $model->fetchAll("map_code='fdMenuSubGroupMap' and map_id2='{$userSubGroupId}'");
     if (count($res) > 0) {
         foreach ($res as $_row) {
             $arrG[] = $_row->getMapId1();
         }
     }
     $res = $model->fetchAll("map_code='fdMenuRoleMap' and map_id2='{$userRoleId}'");
     if (count($res) > 0) {
         foreach ($res as $_row) {
             $arrG[] = $_row->getMapId1();
         }
     }
     $res = $model->fetchAll("map_code='fdMenuUserMap' and map_id2='{$userId}'");
     if (count($res) > 0) {
         foreach ($res as $_row) {
             $arrG[] = $_row->getMapId1();
         }
     }
     $arrG = array_unique($arrG);
     $strid = implode("','", $arrG);
     $model = new Security_Model_SystemMaster();
     $result = $model->fetchAll("master_code='fdMenu' and master_id in ('{$strid}')");
     if (count($result) > 0) {
         foreach ($result as $row) {
             $arrUrl = explode("/", $row->getStrval1());
             $module = $arrUrl[1];
             $controller = $arrUrl[2];
             $action = $arrUrl[3];
             //                    echo "<pre>";
             //                    print_r($arrUrl);
             //                    echo "</pre>";
             $acl->allow('administrator', "{$module}:{$controller}", $action);
         }
     }
     $acl->allow('administrator', 'security:menu', array('get-permission', 'save-permission'));
     Zend_Registry::set('acl', $acl);
 }
 public function getPermissionAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $params = $this->_getAllParams();
     $rdo = $params['rdo'];
     //groupId, subGroupId, roleId, userId
     $mapId2 = $params[$rdo];
     $arrMapId1 = array();
     $mapCode = "";
     $arrResult = array("status" => 0);
     if ($rdo == "groupId") {
         $mapCode = "fdMenuGroupMap";
     } else {
         if ($rdo == "subGroupId") {
             $mapCode = "fdMenuSubGroupMap";
         } else {
             if ($rdo == "roleId") {
                 $mapCode = "fdMenuRoleMap";
             } else {
                 if ($rdo == "userId") {
                     $mapCode = "fdMenuUserMap";
                 }
             }
         }
     }
     $model = new Security_Model_SystemMapping();
     $res = $model->fetchAll("map_code='{$mapCode}' and map_id2='{$mapId2}'");
     if (count($res) > 0) {
         foreach ($res as $row) {
             $arrMapId1[] = $row->getMapId1();
         }
         $arrResult = array("status" => 1, "mapId1" => $arrMapId1);
     }
     echo Zend_Json::encode($arrResult);
 }
 public function removeAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $child_node_id = $this->_getParam('child_node_id');
     //print_r ($child_node_id);
     $arrChildNode = explode("_", $child_node_id);
     $child_master_code = $arrChildNode[0];
     $child_master_id = $arrChildNode[1];
     $parent_node_id = $this->_getParam('parent_node_id');
     $arrParentNode = explode("_", $parent_node_id);
     $parent_master_code = $arrParentNode[0];
     $parent_master_id = $arrParentNode[1];
     if ($child_master_code == "fdAnimalColor") {
         //delete role
         $objMap = new Security_Model_SystemMapping();
         //$objMap->delete("map_code='fdAnimalTypeAnimalColorMap' and map_id1='{$parent_master_id}' and map_id2='{$child_master_id}'");
         $objMap->updateanimal_color('fdAnimalAnimalTypeAnimalColorMap', $arrChildNode[1], $arrChildNode[2], $arrChildNode[3]);
         //$objMaster=new Security_Model_SystemMaster();
         //$objMaster->delete("master_code='{$child_master_code}' and master_id='{$child_master_id}'");
     } else {
         if ($child_master_code == "fdAnimalType") {
             //fetch roles and delete them
             $objMap = new Security_Model_SystemMapping();
             //$objMap->deleteanimal_type('fdAnimalAnimalTypeAnimalColorMap',$arrChildNode[1],$arrChildNode[2]);
             $objMap->delete("map_code='fdAnimalAnimalTypeAnimalColorMap' AND map_id2='{$arrChildNode['1']}' AND map_id1='{$arrChildNode['2']}'");
         } else {
             if ($child_master_code == "fdAnimal") {
                 // fetch sub groups and delete them
                 $objMap = new Security_Model_SystemMapping();
                 $result = $objMap->fetchAll("map_code='fdAnimalAnimalTypeMap' and map_id1='{$child_master_id}'");
                 if (count($result) > 0) {
                     foreach ($result as $_row) {
                         //fetch roles and delete them
                         $objMap1 = new Security_Model_SystemMapping();
                         $result1 = $objMap1->fetchAll("map_code='fdAnimalTypeAnimalColorMap' and map_id1='{$_row->getMapId2()}'");
                         if (count($result1) > 0) {
                             foreach ($result1 as $_row1) {
                                 $objMaster = new Security_Model_SystemMaster();
                                 $objMaster->delete("master_code='fdAnimalColor' and master_id='{$_row1->getMapId2()}'");
                             }
                         }
                         $objMap1->delete("map_code='fdAnimalTypeAnimalColorMap' and map_id1='{$_row->getMapId2()}'");
                         $objMaster = new Security_Model_SystemMaster();
                         $objMaster->delete("master_code='fdAnimalType' and master_id='{$_row->getMapId2()}'");
                     }
                 }
                 $objMap->delete("map_code='fdAnimalAnimalTypeMap' and map_id1='{$child_master_id}'");
                 // now delete group from master
                 $objMaster = new Security_Model_SystemMaster();
                 $objMaster->delete("master_code='{$child_master_code}' and master_id='{$child_master_id}'");
             }
         }
     }
     echo $result = Zend_Json::encode(array("status" => true));
 }