public function createorremoveshortcutAction() { $auth = Zend_Auth::getInstance(); $role_id = 1; if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $role_id = $auth->getStorage()->read()->emprole; } $this->_helper->layout->disableLayout(); $settingsmodel = new Default_Model_Settings(); $privilege_model = new Default_Model_Privileges(); $menuid = $this->_request->getParam('menuid'); $shortcutflag = $this->_request->getParam('shortcutflag'); $date = new Zend_Date(); $where = ''; $menuidstring = ''; $error = ''; $id = ''; $idCsv = 0; $result = 'error'; if ($menuid) { $privilegesofObj = $privilege_model->getObjPrivileges($menuid, "", $role_id, $idCsv); if ($privilegesofObj['isactive'] == 1) { if ($shortcutflag == 1 || $shortcutflag == 2) { $settingsmenuArr = $settingsmodel->getMenuIds($loginUserId, 2); if (!empty($settingsmenuArr)) { $settingsmenustring = $settingsmenuArr[0]['menuid']; if (strlen($settingsmenustring) == 0) { $settingsmenuArray = array(); } else { $settingsmenuArray = explode(",", $settingsmenustring); } if (sizeof($settingsmenuArray) == 16 && $shortcutflag != 2) { $error = "Limit"; } else { if (in_array($menuid, $settingsmenuArray)) { $key = array_search($menuid, $settingsmenuArray); if ($key !== false) { unset($settingsmenuArray[$key]); } } else { array_push($settingsmenuArray, $menuid); } if (strlen($settingsmenustring) == 0) { $menuidstring = $menuid; } else { $menuidstring = implode(",", $settingsmenuArray); } $where = array('userid=?' => $loginUserId, 'flag=?' => 2, 'isactive=?' => 1); $data = array('menuid' => $menuidstring, 'modified' => $date->get('yyyy-MM-dd HH:mm:ss')); $id = $settingsmodel->addOrUpdateMenus($data, $where); } } } else { if ($shortcutflag == 3) { $data = array('userid' => $loginUserId, 'menuid' => $menuid, 'flag' => 2, 'isactive' => 1, 'created' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modified' => $date->get('yyyy-MM-dd HH:mm:ss')); $id = $settingsmodel->addOrUpdateMenus($data, $where); } } if ($id != '') { if ($id == 'update') { $result = 'update'; } else { $result = 'newrecord'; } } else { if ($error != '') { $result = 'limit'; } else { $result = 'error'; } } } else { $result = 'inactive'; } $this->_helper->_json(array('result' => $result)); } }
/** * * @param type $dataArray * @param type $ViewOnly * @return type */ public function employeegrid($dataArray, $ViewOnly = null) { $request = Zend_Controller_Front::getInstance(); $params = $request->getRequest()->getParams(); $employeeTabs = array('employee', 'dependencydetails', 'creditcarddetails', 'visaandimmigrationdetails', 'workeligibilitydetails', 'disabilitydetails', 'empcommunicationdetails', 'empskills', 'empleaves', 'empholidays', 'medicalclaims', 'educationdetails', 'experiencedetails', 'trainingandcertificationdetails', 'emppersonaldetails', 'myemployees', 'empperformanceappraisal', 'emppayslips', 'empbenefits', 'emprenumerationdetails', 'emprequisitiondetails', 'empadditionaldetails', 'empsecuritycredentials', 'empsalarydetails', 'empjobhistory'); $controllerNamesArr = array('empleaves', 'empholidays', 'myemployees'); $request = Zend_Controller_Front::getInstance(); $dynamiccontrollerName = $request->getRequest()->getControllerName(); //Give all 24tabs of employee. $view = Zend_Layout::getMvcInstance()->getView(); $session = new Zend_Auth_Storage_Session(); $data = $session->read(); $role_id = $data['emprole']; $group_id = $data['group_id']; $loggedinEmpId = $data['id']; $useridFromURL = $dataArray['userid']; $controllerName = $dataArray['objectname']; $menunamestr = ''; $sortStr = ""; $objId = ''; $context = ""; $actnArr = array(); $sortStr = $dataArray['by']; $actions_arr = array(); $privilegesofObj = array(); if (in_array($dataArray['objectname'], $employeeTabs)) { if (array_key_exists("context", $dataArray)) { $context = $dataArray['context']; if ($dataArray['context'] == "mydetails") { $objId = MYDETAILS; } else { if ($dataArray['context'] == "myteam") { $objId = MYEMPLOYEES; } else { if ($dataArray['context'] == "") { $objId = EMPLOYEE; } } } } else { $objId = EMPLOYEE; } if ($role_id != "") { $privilege_model = new Default_Model_Privileges(); //For grids... From mydetails controller,privileges are sending to grid in dataArray if (array_key_exists("actions_arr", $dataArray)) { $actions_arr = $dataArray['actions_arr']; array_push($actions_arr, $dataArray['menuName']); } else { $idCsv = 0; //flag - No id is single id not Csv... in dashboard we are sending CSV.... $privilegesofObj = $privilege_model->getObjPrivileges($objId, "", $role_id, $idCsv); if (!empty($privilegesofObj)) { //If the logged in employee is HR or Superadmin(role =1) or Employee himself want to edit his record..... if ($privilegesofObj['viewpermission'] == 'Yes') { array_push($actions_arr, 'view'); } //For Leaves,Holidays there shoould be only view privilege..... if (!in_array($controllerName, $controllerNamesArr)) { if ($privilegesofObj['editpermission'] == 'Yes') { array_push($actions_arr, 'edit'); } if ($privilegesofObj['deletepermission'] == 'Yes') { array_push($actions_arr, 'delete'); } if ($privilegesofObj['addpermission'] == 'Yes') { array_push($actions_arr, 'add'); } if ($privilegesofObj['uploadattachments'] == 'Yes') { array_push($actions_arr, 'upload'); } if ($privilegesofObj['viewattachments'] == 'Yes') { array_push($actions_arr, 'uploadview'); } } array_push($actions_arr, $dataArray['menuName']); } else { $actions_arr[0] = 'view'; $actions_arr[1] = $dataArray['menuName']; } } } } else { $actions_arr = array(); } $gridFieldsArr = array(); $tmpActionsArr = array(); $tmpActionsArr = $actions_arr; array_pop($tmpActionsArr); //last element of actions array is menuname so delete that & check the privileges are empty or not... $actnArr = $tmpActionsArr; if (($key = array_search('add', $actnArr)) !== false) { unset($actnArr[$key]); } if (empty($tmpActionsArr)) { $gridFieldsArr = $dataArray['tableheader']; unset($gridFieldsArr['action']); $dataArray['tableheader'] = $gridFieldsArr; } if (isset($dataArray['menuName'])) { $menuName = $dataArray['menuName']; } $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($dataArray['tablecontent'])); $paginator->setItemCountPerPage($dataArray['perPage'])->setCurrentPageNumber($dataArray['pageNo']); if (empty($dataArray['tableheader'])) { $widgetsModel = new Default_Model_Widgets(); $columnData = $widgetsModel->getTableFields('/' . $dataArray['objectname']); $dataArray['tableheader'] = json_decode($columnData['menufields'], true); } $msgtitle = $dataArray['objectname'] . '_delete'; $msgtitle = strtoupper($msgtitle); $msgflag = constant($msgtitle); $msgAr = explode(' ', $msgflag); $msgdta = implode('@#$', $msgAr); if (isset($dataArray['formgrid']) && $dataArray['formgrid'] == 'true') { $urlString = $_SERVER['REQUEST_URI']; $urlData = explode('/', $urlString); $con = ''; if (isset($dataArray['unitId'])) { $con = '/unitId/' . $dataArray['unitId']; } else { if (isset($params['id'])) { $con = '/unitId/' . $params['id']; } } $formgridVal = $dataArray['formgrid']; if ($dataArray['objectname'] == 'departments') { $viewaction = 'view'; } else { $viewaction = 'viewpopup'; } $editaction = 'editpopup'; if ($dataArray['menuName'] != '') { $menunamestr = $dataArray['menuName']; } $viewpopup_str = '<a onclick="displaydeptform(\'' . DOMAIN . $dataArray['objectname'] . '/' . $viewaction . '/id/{{id}}' . $con . '/popup/1\',\'' . $menunamestr . '\')" name="{{id}}" class="sprite view" title=\'View\'></a>'; $editpopup_str = '<a onclick="displaydeptform(\'' . DOMAIN . $dataArray['objectname'] . '/' . $editaction . '/id/{{id}}' . $con . '/popup/1\',\'' . $menunamestr . '\')" name="{{id}}" class="sprite edit" title=\'Edit\' ></a>'; $deletepopup_str = '<a name="{{id}}" onclick= changeEmployeestatus(\'' . $dataArray['objectname'] . '\',\'{{id}}\',\'' . $msgdta . '\',\'' . $dataArray['userid'] . '\') href= javascript:void(0) title=\'Delete\' class="sprite delete" ></a>'; if (!in_array('view', $actions_arr) && !in_array('edit', $actions_arr) && !in_array('delete', $actions_arr)) { if ($dataArray['objectname'] == 'processes') { $extra['action'] = array('name' => 'edit', 'value' => '<div class="grid-action-align"> <a onclick="displaydeptform(\'' . DOMAIN . $dataArray['objectname'] . '/' . $viewaction . '/id/{{id}}' . $con . '/popup/1\',\'' . $menunamestr . '\')" name="{{id}}" class="sprite view" title=\'View\'></a> <a onclick="displaydeptform(\'' . DOMAIN . $dataArray['objectname'] . '/' . $editaction . '/id/{{id}}' . $con . '/popup/1\',\'' . $menunamestr . '\')" name="{{id}}" class="sprite edit" title=\'Edit\' ></a> <a name="{{id}}" onclick= changeEmployeestatus(\'' . $dataArray['objectname'] . '\',\'{{id}}\',\'' . $msgdta . '\',\'' . $dataArray['userid'] . '\') href= javascript:void(0) title=\'Delete\' class="sprite delete" ></a> </div>'); } else { $extra['action'] = array(); } } else { $extra['action'] = array('name' => 'edit', 'value' => '<div class="grid-action-align"> ' . (in_array('view', $actions_arr) ? $viewpopup_str : '') . ' ' . (in_array('edit', $actions_arr) ? $editpopup_str : '') . ' ' . (in_array('delete', $actions_arr) ? $deletepopup_str : '') . ' </div>'); } } else { $formgridVal = ''; $view_str = '<a href= "' . DOMAIN . $dataArray['objectname'] . '/view/id/{{id}}" name="{{id}}" class="sprite view" title=\'View\'></a>'; $edit_str = '<a href= "' . DOMAIN . $dataArray['objectname'] . '/edit/id/{{id}}" name="{{id}}" class="sprite edit" title=\'Edit\'></a>'; if ($dataArray['objectname'] == 'employee') { $delete_str = ''; } else { $delete_str = '<a name="{{id}}" onclick= changeEmployeestatus(\'' . $dataArray['objectname'] . '\',\'{{id}}\',\'' . $msgdta . '\',\'' . $dataArray['userid'] . '\') href= javascript:void(0) title=\'Delete\' class="sprite delete" ></a>'; } if (!in_array('view', $actions_arr) && !in_array('edit', $actions_arr) && !in_array('delete', $actions_arr)) { $extra['action'] = array(); } else { $extra['action'] = array('name' => 'edit', 'value' => '<div class="grid-action-align"> ' . (in_array('view', $actions_arr) ? $view_str : '') . ' ' . (in_array('edit', $actions_arr) ? $edit_str : '') . ' ' . (in_array('delete', $actions_arr) ? $delete_str : '') . ' </div>'); } } $extra['options'] = array(); $addaction = ''; if (isset($dataArray['add']) && $dataArray['add'] != '') { $addaction = $dataArray['add']; } else { $addaction = ''; } $unitId = ''; if (in_array('add', $actions_arr)) { if ($ViewOnly == 1) { $addpermission = "false"; } else { $addpermission = "true"; } } else { $addpermission = "false"; } if (isset($dataArray['unitId'])) { $unitId = $dataArray['unitId']; } return $this->generateGrid($dataArray['objectname'], $dataArray['tableheader'], $paginator, $extra, true, $dataArray['jsGridFnName'], $dataArray['perPage'], $dataArray['pageNo'], $dataArray['jsFillFnName'], $dataArray['searchArray'], $formgridVal, $addaction, $menuName, $unitId, $addpermission, $menunamestr, isset($dataArray['call']) ? $dataArray['call'] : "", $sortStr, $context, isset($dataArray['search_filters']) ? $dataArray['search_filters'] : "", isset($dataArray['dashboardcall']) ? $dataArray['dashboardcall'] : "No", $actnArr, isset($dataArray['sort']) ? $dataArray['sort'] : "", isset($dataArray['by']) ? $dataArray['by'] : "", $ViewOnly); }
public function fetchmenunameAction() { $auth = Zend_Auth::getInstance(); $role_id = 1; if ($auth->hasIdentity()) { $role_id = $auth->getStorage()->read()->emprole; } $menuid = $this->_request->getParam('menuid'); $tabFlag = $this->_request->getParam('tabFlag'); $successmessage['result'] = ''; $idCsv = 0; $privilege_model = new Default_Model_Privileges(); $settingsmodel = new Default_Model_Settings(); if (is_numeric($menuid)) { $privilegesofObj = $privilege_model->getObjPrivileges($menuid, "", $role_id, $idCsv); $getmenuname = $settingsmodel->fetchMenuName($menuid); if ($privilegesofObj['isactive'] == 1) { if (!empty($getmenuname)) { $data = array('menuname' => $getmenuname[0]['menuName'], 'menuicon' => $getmenuname[0]['iconPath'], 'menuurl' => $getmenuname[0]['url'], 'message' => 'success'); } else { $data = array('message' => 'error'); } } else { $data = array('message' => 'error'); } /** * Added By : Sapplica. * Date of Modification : 30/08/2013 * Purpose : Some of the menus should not be draggable for widgets * Modified By : MAINAK. **/ // Only for Widgets, Organisation Info,Organisation structure,Organisation hierarchy, Site Preferences,leave request,My details,Identity codes and some menus should not be draggable .... if ($tabFlag != "" && $tabFlag == "widgets") { $menusNotdraggable = array(REPORTS, ORGANISATIONINFO, STRUCTURE, HEIRARCHY, MYDETAILS, LEAVEREQUEST, SITEPREFERENCE, IDENTITYCODES, IDENTITYDOCUMENTS, EMPLOYEETABS, MANAGEMODULE); if (in_array($menuid, $menusNotdraggable)) { $data = array('message' => 'error'); } } } else { $data = array('message' => 'error'); } $this->_helper->json($data); }
/** * This function is used to check privileges of a menu item of a particular login. * @param Integer $objectId = id of the menu item. * @param Integer $groupId = group id * @param Integer $roleId = role id * @return string Returns Yes/No */ public static function _check_menu_access($objectId, $groupId = '', $roleId) { $privilege_model = new Default_Model_Privileges(); $privilegesofObj = $privilege_model->getObjPrivileges($objectId, $groupId, $roleId); $result = "No"; if (!empty($privilegesofObj) && count($privilegesofObj) > 0) { $result = "Yes"; } return $result; }
public function shortcuticons($userId) { $role_id = ""; $privilegedmenuIdsArr = array(); $privilegedmenuIdsCsv = ""; $settingsModel = new Default_Model_Settings(); $session = new Zend_Auth_Storage_Session(); $data = $session->read(); //echo "Session Data : <pre>";print_r($data);die; if (!empty($data)) { $role_id = $data['emprole']; } $iconidcount = $settingsModel->getActiveiconCount($userId); $shortcutsStr = '<ul>'; if ($iconidcount[0]['count'] > 0) { $menuIdsArr = $settingsModel->getMenuIds($userId, 2); if (!empty($menuIdsArr) === true) { $menuIdsStr = $menuIdsArr[0]['menuid']; /* Modified By: Yamini Purpose: Checking the privileges for shortcut icons for logged in role... Modified Date: 26/09/2013. */ $idCsv = 1; //Flag $privilege_model = new Default_Model_Privileges(); $privilegesofObj = $privilege_model->getObjPrivileges($menuIdsStr, "", $role_id, $idCsv); $menuwithaddprivilegeArr = array(SITEPREFERENCE, LEAVEREQUEST, IDENTITYCODES, IDENTITYDOCUMENTS); /* This condition is to check whether the menu is active. If active then only the shortcut will be displayed.*/ if (!empty($privilegesofObj) && isset($privilegesofObj)) { for ($i = 0; $i < sizeof($privilegesofObj); $i++) { //if($privilegesofObj[$i]['viewpermission'] == "Yes" || (in_array($privilegesofObj[$i]['object'],$menuwithaddprivilegeArr) && $privilegesofObj[$i]['addpermission'] == "Yes" )) if ($privilegesofObj[$i]['isactive'] == 1) { array_push($privilegedmenuIdsArr, $privilegesofObj[$i]['object']); } } $privilegedmenuIdsCsv = implode(",", $privilegedmenuIdsArr); } if ($privilegedmenuIdsCsv != "") { $menuIdsStr = $privilegedmenuIdsCsv; } $menuDetailsArr = $settingsModel->getMenuName($menuIdsStr, 1); $betaFlag = 0; if (!empty($menuDetailsArr)) { for ($s = 0; $s < sizeof($menuDetailsArr); $s++) { $menuName = $menuDetailsArr[$s]['menuName']; $tmpMenuUrl = $menuDetailsArr[$s]['url']; //echo $s." >> ".(strpos($tmpMenuUrl,'http://') === false)."<br/>"; if ($tmpMenuUrl && (strpos($tmpMenuUrl, 'http://') === false || strpos($tmpMenuUrl, 'http://') === false || strpos($tmpMenuUrl, 'http://') === false)) { $menuUrl = BASE_URL . substr($tmpMenuUrl, 1, strlen($tmpMenuUrl)); } else { if (strpos($tmpMenuUrl, 'http://') === true || strpos($tmpMenuUrl, 'http://') === true || strpos($tmpMenuUrl, 'http://') === true) { $menuUrl = $tmpMenuUrl; } else { $menuUrl = 'javascript:void(0);'; } } if ($menuDetailsArr[$s]['iconPath'] != '') { $menuIcon = 'images/menuIcons/shortcuts/' . $menuDetailsArr[$s]['iconPath']; } else { $menuIcon = 'images/sampleimg.png'; } //$shortcutsStr.='<li><a href="'.$menuUrl.'"><img src="'.MEDIA_PATH.'images/'.$menuIcon.'" onerror=this.src="'.MEDIA_PATH.'images/sampleimg.png"; height="33" width="33" border="0" /></a></li>'; $shortcutsStr .= '<li><a href="' . $menuUrl . '" title="' . $menuName . '" ><img src="' . MEDIA_PATH . '' . $menuIcon . '" onerror=this.src="' . MEDIA_PATH . 'images/sampleimg.png"; height="33" width="33" border="0" /></a></li>'; if ($menuDetailsArr[$s]['id'] > 148 && $menuDetailsArr[$s]['id'] < 175) { $betaFlag = 1; } } echo $shortcutsStr .= '</ul></div>'; if ($betaFlag == 1) { echo '<div class="beta_info" title="beta version">Beta</div>'; } } else { echo "No active shortcut icons. " . '<a href="' . BASE_URL . 'viewsettings/2">' . "Click here" . '</a> ' . "to configure."; } } else { echo "You have not configured your shortcut icons. " . '<a href="' . BASE_URL . 'viewsettings/2">' . "Click here" . '</a> ' . "to configure."; } } else { echo "You have not configured your shortcut icons. " . ' <a href="' . BASE_URL . 'viewsettings/2">' . "Click here" . '</a> ' . "to configure"; } }