public function editWidgetAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $request = $this->getRequest();
     $usersNs = new Zend_Session_Namespace("members");
     $mapCode = "fdWidget";
     $mapId1 = $usersNs->userId;
     if ($request->isPost()) {
         $model1 = new Security_Model_SystemMaster();
         $model = $model1->fetchAll("master_code='fdWidget'");
         $model2 = new Security_Model_SystemMapping();
         $model2->delete("map_code='{$mapCode}' and map_id1='{$mapId1}'");
         foreach ($model as $_row) {
             $disC = "display" . $_row->getMasterId();
             $ordC = "order" . $_row->getMasterId();
             $intval1 = $_POST[$disC];
             $intval2 = $_POST[$ordC];
             if (empty($intval2)) {
                 $intval2 = 0;
             }
             if (empty($intval1)) {
                 $intval1 = 0;
             } else {
                 $intval1 = 1;
             }
             $mapId2 = $_row->getMasterId();
             $model2->setMapCode($mapCode)->setMapId1($mapId1)->setMapId2($mapId2)->setIntval1($intval1)->setIntval2($intval2)->save();
         }
         $this->_flashMessenger->addMessage(array('success' => 'Widgets updated successfully!'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/widget/manage'));
     }
 }
Example #2
0
 public function genSystemMasterId($master_code)
 {
     $model = new Security_Model_SystemMaster();
     $table = $model->getMapper()->getDbTable();
     $select = $table->select()->from(array("a" => 'system_master'), array('max_id' => 'MAX(master_id)'))->where("master_code='{$master_code}'");
     $row = $table->fetchRow($select);
     $max_id = $row->max_id + 1;
     return $max_id;
     //echo $select->__toString(); exit;
 }
Example #3
0
 public function getMasterValuesArr($code)
 {
     $model = new Security_Model_SystemMaster();
     $table = $model->getMapper()->getDbTable();
     $select = $table->select()->setIntegrityCheck(false)->from(array("s" => 'system_master'))->order("master_value")->where("status='1' and master_code='{$code}'");
     $sql = $select->__toString($select);
     $rows = $model->fetchAll($select);
     foreach ($rows as $row) {
         $arr[$row->getMasterId()] = $row->getMasterValue();
     }
     return $arr;
 }
 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 == "fdAction") {
         $objMap = new Security_Model_SystemMapping();
         $objMap->delete("map_code='fdActionGroupMap' and  map_id1='{$child_master_id}'");
         $objMap->delete("map_code='fdActionSubGroupMap' and map_id1='{$child_master_id}'");
         $objMap->delete("map_code='fdActionRoleMap' and map_id1='{$child_master_id}'");
         $objMap->delete("map_code='fdActionUserMap' and map_id1='{$child_master_id}'");
         $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));
 }
 public function dashboardAction()
 {
     //Start Dashboard bookmark listing
     $code1 = "fdUserBookmark";
     $usersNs = new Zend_Session_Namespace("members");
     $mapId1 = $usersNs->userId;
     $model = new Security_Model_SystemMapping();
     $strOrderBy = "s.map_id3";
     $this->view->sortOptions = array();
     $this->view->linkArray = array();
     $table = $model->getMapper()->getDbTable();
     $select = $table->select()->setIntegrityCheck(false)->from(array("sm" => 'system_master'), array("master_value", "strval1", "strval3"))->join(array("s" => "system_mapping"), "s.map_code='{$code1}' and s.map_id1='{$mapId1}'  and sm.master_code='fdMenu' and sm.strval1!='' and sm.master_id=s.map_id2", array("map_id1" => 'map_id1', "map_id2" => 'map_id2', "map_id3" => 'map_id3'))->group("s.map_id2")->order($strOrderBy);
     $this->view->bookmarks = $table->fetchAll($select);
     //End Dashboard bookmark listing
     //start dashboard Widgets
     $code2 = "fdWidget";
     $model = new Security_Model_SystemMaster();
     $table2 = $model->getMapper()->getDbTable();
     $select = $table2->select()->setIntegrityCheck(false)->from(array("s" => 'system_master'), array("master_value"))->join(array("sm" => "system_mapping"), "sm.map_code='{$code2}' and sm.map_id1='{$mapId1}'  and s.master_code=sm.map_code and s.master_id=sm.map_id2 and sm.intval1=1", array("master_id" => 'map_id2', "intval1" => 'intval1', "intval2" => 'intval2'))->order("sm.map_id3");
     $this->view->widgets = $table2->fetchAll($select);
     //End widgets listing
     $this->view->pageHeading = "Dashboard";
 }
Example #6
0
 public function getGroups($status=1)
 {
     $model=new Security_Model_SystemMaster();
     return $model->fetchAll("status='{$status}' and master_code='fdUserGroup'");
 }
 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));
 }
Example #8
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);
 }
Example #9
0
 public function getMasterArray($masterCode, $status = '1')
 {
     $arr = array("" => "--Select--");
     $model = new Security_Model_SystemMaster();
     $res = $model->fetchAll("status='{$status}' and master_code='{$masterCode}'");
     if (count($res) > 0) {
         foreach ($res as $_row) {
             $arr[$_row->getMasterId()] = $_row->getMasterValue();
         }
     }
     return $arr;
 }
Example #10
0
 public function changeChildStatus($id, $status)
 {
     $model=new Security_Model_SystemMaster();
     $row=$model->fetchRow("master_id='{$id}' and master_code='fdMenu'");
     if(false===$row)
         return false;
     
     $row->setBlnval1($status);
     return $row->save();
 }
Example #11
0
 public function getMenuItems($status = 1)
 {
     $model = new Security_Model_SystemMaster();
     return $model->fetchAll("status='{$status}' and master_code='fdMenu'");
 }
 public function changeStatusAction()
 {
     $this->view->layout()->disableLayout();
     //$search = trim($this->_getParam('master_code'));
     //$this->view->assign('searchText',$search);
     $this->_helper->viewRenderer->setNoRender(true);
     $id = $this->_getParam('masterCode');
     $model1 = new Security_Model_SystemMaster();
     $model = $model1->fetchAll("master_code='{$id}'");
     $status = $this->_getParam('status');
     if ($status == 0) {
         $status = 1;
     } else {
         $status = 0;
     }
     foreach ($model as $_row) {
         $_row->setStatus($status);
         $res = $_row->save();
     }
     if (false === $res) {
         $arrResult = array("result" => 0);
     } else {
         $arrResult = array("result" => 1);
     }
     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));
 }
Example #14
0
 public function getMenuItemByUri($uri)
 {
     $model = new Security_Model_SystemMaster();
     return $model->fetchRow("master_code='fdMenu' and strval1='{$uri}'");
 }
Example #15
0
 public function deleteMenuItemAction()
 {
     $id = $this->_getParam('id');
     $menu = new Base_Security_Menu();
     $pages = $menu->getChildPages($id, 0);
     $arrChild[] = $id;
     for ($i = 0; $i < count($pages); $i++) {
         $arrChild[] = $pages[$i]['menu_id'];
     }
     $strMenuIds = implode(',', $arrChild);
     $model1 = new Security_Model_SystemMaster();
     $model1->setMasterCode("fdMenu");
     $model1->delete("master_id IN ({$strMenuIds}) AND master_code ='" . $model1->getMasterCode() . "'");
     $this->_flashMessenger->addMessage(array('success' => 'Menu item deleted successfully!'));
     $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/'));
 }
Example #16
0
 public function setModel($row)
 {
     $model = new Security_Model_SystemMaster();
     $model->setMasterCode($row->master_code)->setMasterId($row->master_id)->setMasterValue($row->master_value)->setStatus($row->status)->setIntval1($row->intval1)->setIntval2($row->intval2)->setStrval1($row->strval1)->setStrval2($row->strval2)->setBlnval1($row->blnval1)->setBlnval2($row->blnval2)->setDblval1($row->dblval1)->setDblval2($row->dblval2)->setCreatedOn($row->created_on)->setCreatedBy($row->created_by)->setUpdatedOn($row->updated_on)->setUpdatedBy($row->updated_by)->setRowGuid($row->row_guid)->setRowVersion($row->row_version);
     return $model;
 }
Example #17
0
 public function getActionTree($parent_id)
 {
     $model = new Security_Model_SystemMaster();
     $result = $model->fetchAll("master_code='fdAction' and intval1='{$parent_id}'");
     $str = "";
     if (count($result) > 0) {
         $str .= "<ul>";
         foreach ($result as $row) {
             $str .= " <li id='fdAction_{$row->getMasterId()}' rel='action' >";
             $str .= "     <a href='{$row->getStrval1()}'>{$row->getMasterValue()}</a>";
             //check child tree
             $modelC = new Security_Model_SystemMaster();
             $resultC = $model->fetchAll("master_code='fdAction' and intval1='{$row->getMasterId()}'");
             if (count($resultC) > 0) {
                 //has childs
                 $str .= $this->getActionTree($row->getMasterId());
             }
             $str .= " </li>";
         }
         $str .= "</ul>";
         return $str;
     }
 }