protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (empty($file->error)) {
         $date = new \DateTime();
         $medium = new Medien();
         $medium->me_kollektion = $this->kollektionId;
         $medium->me_titel = $file->name;
         $medium->me_dateiname = $file->name;
         $medium->me_erweiterung = strtolower(substr(strrchr($name, '.'), 1));
         $medium->me_groesse = $file->size;
         $medium->me_valid_until = $date->modify('+ 3 days');
         $medium->me_token = md5(uniqid(mt_rand(), true));
         $medium->save();
         $file->id = $medium->id;
     }
     return $file;
 }
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     // TODO: Refactor!
     if (isset(Application::getCurrentRequest()->target) && Application::getCurrentRequest()->target != '') {
         $name = Application::getCurrentRequest()->target;
     }
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (empty($file->error) && $this->kollektionId > 0) {
         $medium = new Medien();
         $medium->me_kollektion = $this->kollektionId;
         $medium->me_titel = $file->name;
         $medium->me_dateiname = $file->name;
         $medium->me_erweiterung = strtolower(substr(strrchr($name, '.'), 1));
         $medium->me_groesse = $file->size;
         $medium->me_upload_am = date('d.m.Y');
         $medium->me_upload_von = Security::getUserId();
         if (isset(Application::getCurrentRequest()->token) && Application::getCurrentRequest()->token != '') {
             $medium->me_token = Application::getCurrentRequest()->token;
         }
         $medium->save();
         $file->id = $medium->id;
     }
     return $file;
 }