/** * This action is used for adding/updating data. * @parameters * @param id = id of role (optional) * * @return Zend_Form. */ public function editAction() { $groups_model = new Default_Model_Groups(); $role_model = new Default_Model_Roles(); $group_arr = $groups_model->getGroupsListForRoles(); $id = $this->getRequest()->getParam('id', null); $display_grp = "1"; $total_role_cnt = 0; $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $form = new Default_Form_Roles(); $data = array(); if ($id && is_numeric($id) && $id > 1) { try { $id = (int) $id; $id = abs($id); $form->submit->setLabel('Update'); $data = $role_model->getRoleDataById($id); if (count($data) > 0) { foreach ($data as $key => $val) { $data[$key] = htmlentities(addslashes($val), ENT_QUOTES, "UTF-8"); } $form->populate($data); } } catch (Exception $e) { $this->view->nodata = "nodata"; } } else { if ($id == '') { $total_role_cnt = $role_model->getTotalRolecnt(); foreach ($group_arr as $gid => $gdata) { if ($gdata['cnt'] < 5) { $display_grp = $gid; break; } } } else { $this->view->nodata = "nodata"; } } $this->view->form = $form; $this->view->group_arr = $group_arr; $this->view->data = $data; $this->view->display_grp = $display_grp; $this->view->total_role_cnt = $total_role_cnt; }