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')); } }
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 getChildPages($parent_id, $psno) { $model=new Security_Model_SystemMaster(); $result=$model->fetchAll("master_code='fdMenu' and intval1='$parent_id'"); $arrParentResult=array(); if(count($result)>0) { $sno=0; foreach($result as $row) { $sno++; if($psno == "0" ) $snod=$sno; else $snod=$psno.".".$sno; $i=count($arrParentResult); $arrParentResult[$i]['menu_sno']=$snod; $arrParentResult[$i]['menu_id']=$row->getMasterId(); $arrParentResult[$i]['menu_title']=$row->getMasterValue(); $arrParentResult[$i]['menu_code']=$row->getMasterCode(); $arrParentResult[$i]['menu_is_active']=$row->getStatus(); $arrParentResult[$i]['menu_parent_id']=$parent_id; $arrParentResult[$i]['menu_is_child']=$row->getBlnval1(); $arrParentResult[$i]['menu_path']=$row->getStrval1(); $arrChildResult=$this->getChildPages($row->getMasterId(), $snod); //$arrParentResult[$i]['menu_childs']=array(); if(is_array($arrChildResult)) $arrParentResult = array_merge($arrParentResult,$arrChildResult); // if(count($arrChildResult)>0) // { // $arrParentResult[$i]['menu_childs']=$arrChildResult; // } } } return $arrParentResult; }
public function getGroups($status=1) { $model=new Security_Model_SystemMaster(); return $model->fetchAll("status='{$status}' and master_code='fdUserGroup'"); }
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 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; } }
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 getMenuArray($parent_id, $request_uri, $level) { //blnval2='1' isAction $level++; $model = new Security_Model_SystemMaster(); if ($level == 1 || $level == 2) { $result = $model->fetchAll("master_code='fdMenu' and intval1='{$parent_id}' and \tblnval2<>'1' "); } else { $result = $model->fetchAll("master_code='fdMenu' and intval1='{$parent_id}' "); } $arr = array(); if (count($result) > 0) { foreach ($result as $row) { $page['label'] = $row->getMasterValue(); $page['id'] = $row->getMasterId(); $arrUrl = explode("/", $row->getStrval1()); if (count($arrUrl) == 4) { $page['type'] = 'Base_Navigation_Page_Mvc'; $page['module'] = $arrUrl[1]; $page['controller'] = $arrUrl[2]; $page['action'] = $arrUrl[3]; $page['resource'] = $page['module'] . ":" . $page['controller']; $page['privilege'] = $page['action']; if ($row->getStatus() == 0) { $page['visible'] = false; } else { $page['visible'] = true; } //check child tree $modelC = new Security_Model_SystemMaster(); if ($level == 1 || $level == 2) { $resultC = $modelC->fetchAll("master_code='fdMenu' and intval1='{$row->getMasterId()}' and blnval2<>'1'"); } else { $resultC = $modelC->fetchAll("master_code='fdMenu' and intval1='{$row->getMasterId()}' "); } if (count($resultC) > 0) { $arrC = $this->getMenuArray($row->getMasterId(), $request_uri, $level); $page["pages"] = $arrC; } else { unset($page["pages"]); } } // else // { // $page['type']='Base_Navigation_Page_Uri'; // $page['uri']=$row->getStrval1(); // if($request_uri==$row->getStrval1()) // $page['active']=true; // } $arr[] = $page; } return $arr; } }
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; }