public function save($data, $overwrite = false)
 {
     if (isset($data['vo_id']) && isset($data['group_id']) && $data['group_id'] == $data['org_group_id'] && !$overwrite) {
         $vo_id = htmlentities($data['vo_id']);
         $group_id = htmlentities($data['group_id']);
         $groupService = new EngineBlock_Service_VirtualOrganisationGroup();
         $group = $groupService->fetchById($vo_id, $group_id);
     } else {
         $group = new EngineBlock_Model_VirtualOrganisationGroup();
     }
     $group->populate($data);
     $form = new EngineBlock_Form_VirtualOrganisationGroup();
     if (!$form->isValid($group->toArray())) {
         $formErrors = $form->getErrors();
         $modelErrors = array();
         foreach ($formErrors as $fieldName => $fieldErrors) {
             foreach ($fieldErrors as $fieldError) {
                 switch ($fieldError) {
                     case 'isEmpty':
                         $error = 'Field is obligatory, but no input given';
                         break;
                     default:
                         $error = $fieldError;
                 }
                 if (!isset($modelErrors[$fieldName])) {
                     $modelErrors[$fieldName] = array();
                 }
                 $modelErrors[$fieldName][] = $error;
             }
         }
         $group->errors = $modelErrors;
         return $group;
     }
     $mapper = new EngineBlock_Model_Mapper_VirtualOrganisationGroup(new EngineBlock_Model_DbTable_VirtualOrganisationGroup());
     $isNewRecord = isset($data['org_group_id']) && $group->group_id != $data['org_group_id'];
     $mapper->save($group, $isNewRecord);
     // if the PK changes, it is saved as a new record, so the original record should be deleted
     if ($isNewRecord) {
         $this->delete($data['vo_id'], $data['org_group_id']);
     }
     return $group;
 }
 public function groupeditAction()
 {
     $this->view->vo_id = htmlentities($this->_getParam('vo_id'));
     $this->view->group_id = htmlentities($this->_getParam('group_id'));
     $service = new EngineBlock_Service_VirtualOrganisationGroup();
     $this->view->virtualOrganisationGroup = $service->fetchById($this->view->vo_id, $this->view->group_id);
     $this->view->saveUrl = $this->view->url(array('action' => 'groupsave'));
     $this->view->listUrl = $this->view->url(array('action' => 'edit', 'vo_id' => $this->view->vo_id));
 }