Beispiel #1
0
 public function savemenuAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $date = new Zend_Date();
     $wizard_model = new Default_Model_Wizard();
     $wizardData = $wizard_model->getWizardData();
     $trDb = Zend_Db_Table::getDefaultAdapter();
     // starting transaction
     $trDb->beginTransaction();
     try {
         if ($this->_request->getPost()) {
             $defined_menus = array(TIMEMANAGEMENT, RESOURCEREQUISITION, BGCHECKS, STAFFING, COMPLIANCES, REPORTS, BENEFITS, SERVICEDESK);
             $chk_menu = $this->_request->getParam('chk_menu');
             // menus to be activate
             $chk_menu = trim($chk_menu, ',');
             $logmenus = $chk_menu;
             if ($chk_menu != '' && $chk_menu != ',' && !is_array($chk_menu)) {
                 $chk_menu = explode(',', $chk_menu);
             } else {
                 $chk_menu = array();
             }
             $disable_menus = array_diff($defined_menus, $chk_menu);
             //menus to be deactivated
             if (!empty($chk_menu)) {
                 foreach ($chk_menu as $menu) {
                     $this->save_helper(1, $menu);
                 }
             }
             if (!empty($disable_menus)) {
                 foreach ($disable_menus as $menu) {
                     $this->save_helper(0, $menu);
                 }
             }
             // Code to Update Logmanager table with comma separated menuids
             $menumodel = new Default_Model_Menu();
             $menuNames = $menumodel->getMenusNamesByIds($logmenus);
             $logarr = array('userid' => $loginUserId, 'recordid' => $logmenus, 'childrecordid' => $menuNames, 'date' => $date->get('yyyy-MM-dd HH:mm:ss'));
             $jsonlogarr = json_encode($logarr);
             $menuID = MANAGEMODULE;
             $actionflag = 2;
             if (!empty($logmenus)) {
                 //only activated records are logged in log manager.
                 $menumodel->addOrUpdateMenuLogManager($menuID, $actionflag, $jsonlogarr, $loginUserId, $menuNames);
             }
             $wizardarray = array('manage_modules' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($wizardData['site_config'] == 2 && $wizardData['org_details'] == 2) {
                 $wizardarray['iscomplete'] = 2;
             }
             $wizard_model->SaveorUpdateWizardData($wizardarray, '');
             $trDb->commit();
             sapp_Global::generateAccessControl();
             $this->_helper->getHelper("FlashMessenger")->addMessage("Modules updated successfully.");
             $this->_redirect('wizard/managemenu');
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage("No Menus were added.");
             $this->_redirect('wizard/managemenu');
         }
     } catch (Exception $e) {
         $trDb->rollBack();
         $msg = $e->getMessage();
         $this->_helper->getHelper("FlashMessenger")->addMessage($msg);
         $this->_redirect('managemenu');
     }
 }
 public function saveAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $date = new Zend_Date();
     $trDb = Zend_Db_Table::getDefaultAdapter();
     // starting transaction
     $trDb->beginTransaction();
     try {
         if ($this->_request->getPost()) {
             $defined_menus = unserialize(MANAGE_MODULE_ARRAY);
             $chk_menu = $this->_request->getParam('chk_menu');
             // menus to be activate
             $chk_menu = trim($chk_menu, ',');
             $logmenus = $chk_menu;
             if ($chk_menu != '' && $chk_menu != ',' && !is_array($chk_menu)) {
                 $chk_menu = explode(',', $chk_menu);
             } else {
                 $chk_menu = array();
             }
             $disable_menus = array_diff($defined_menus, $chk_menu);
             //menus to be deactivated
             if (!empty($chk_menu)) {
                 foreach ($chk_menu as $menu) {
                     $this->save_helper(1, $menu);
                 }
             }
             if (!empty($disable_menus)) {
                 foreach ($disable_menus as $menu) {
                     $this->save_helper(0, $menu);
                 }
             }
             // Code to Update Logmanager table with comma separated menuids
             $menumodel = new Default_Model_Menu();
             $menuNames = $menumodel->getMenusNamesByIds($logmenus);
             $logarr = array('userid' => $loginUserId, 'recordid' => $logmenus, 'childrecordid' => $menuNames, 'date' => $date->get('yyyy-MM-dd HH:mm:ss'));
             $jsonlogarr = json_encode($logarr);
             $menuID = MANAGEMODULE;
             $actionflag = 2;
             if (!empty($logmenus)) {
                 //only activated records are logged in log manager.
                 $menumodel->addOrUpdateMenuLogManager($menuID, $actionflag, $jsonlogarr, $loginUserId, $menuNames);
             }
             $this->_helper->getHelper("FlashMessenger")->addMessage("Modules updated successfully.");
             $trDb->commit();
             sapp_Global::generateAccessControl();
             $this->_redirect('managemenus');
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage("No Menus were added.");
             $this->_redirect('managemenus');
         }
     } catch (Exception $e) {
         $trDb->rollBack();
         $msg = $e->getMessage();
         //echo $msg; die;
         $this->_helper->getHelper("FlashMessenger")->addMessage($msg);
         $this->_redirect('managemenus');
     }
 }