/**
  * Update, delete and add new handins
  *
  * @access public
  * @param void
  * @return null
  */
 function update_handins()
 {
     $this->setTemplate('add_handins');
     $manager_class = array_var($_GET, 'manager');
     $object_id = get_id('object_id');
     $obj = get_object_by_manager_and_id($object_id, $manager_class);
     if (!$obj instanceof ProjectDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if ($obj->canEdit()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $new_handins = array_var($_POST, 'new_handins');
     $update_handins = array_var($_POST, 'update_handins');
     $delete_handins = array_var($_POST, 'delete_handins');
     if (is_array(array_var($_POST, 'new_handins')) || is_array(array_var($_POST, 'update_handins')) || is_array(array_var($_POST, 'delete_handins'))) {
         try {
             DB::beginWork();
             //add new handins
             foreach ($new_handins as $handin) {
                 $handin = new ObjectHandin();
                 $handin->setFromAttributes($handin);
                 $handin->setRelObjectId($object_id);
                 $handin->setRelObjectManager($manager_class);
                 $handin->save();
             }
             foreach ($update_handins as $handin) {
                 $handin = ObjectHandins::getHandin(array_var($handin, 'id'));
                 $handin->setFromAttributes($handin);
                 $handin->save();
             }
             foreach ($delete_handins as $handin) {
                 $handin = ObjectHandins::getHandin(array_var($handin, 'id'));
                 $handin->delete();
             }
             tpl_assign('handins', ObjectHandins::getAllHandinsByObject($obj));
             ApplicationLogs::createLog($obj, $obj->getWorkspaces(), ApplicationLogs::ACTION_EDIT);
             DB::commit();
             flash_success(lang('success add handins'));
             $this->redirectToReferer($obj->getObjectUrl());
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
         //
     }
     // if
 }