From 3f71a7727d6914af79b0734a193aeb473d26d824 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 4 Oct 2001 23:34:30 +0000 Subject: [PATCH] deleting of attached files --- infolog/inc/class.uiinfolog.inc.php | 59 ++++++++++++++++++++-------- infolog/setup/phpgw_de.lang | 1 + infolog/setup/phpgw_en.lang | 1 + infolog/templates/default/delete.tpl | 10 +++-- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/infolog/inc/class.uiinfolog.inc.php b/infolog/inc/class.uiinfolog.inc.php index f9961359db..1df474c3b7 100644 --- a/infolog/inc/class.uiinfolog.inc.php +++ b/infolog/inc/class.uiinfolog.inc.php @@ -975,7 +975,7 @@ function delete( ) { - global $info_id,$confirm; + global $info_id,$confirm,$to_del; $t = $this->template; $html = $this->html; @@ -989,20 +989,25 @@ } if ($confirm) { - $this->bo->delete($info_id); + $file = $this->basedir.'/'.$info_id; // whole dir - Header('Location: ' . $html->link($referer,array( 'cd' => 16 ))); - - /* - ** Also remove the attached files for that entry - */ - $dir=$this->basedir.'/'.$info_id; - if ($this->vfs->file_exists($dir,array(RELATIVE_ROOT))) + if (!isset($to_del) || $to_del == '.') { - $this->vfs->override_acl = 1; - $this->vfs->delete($dir,array(RELATIVE_ROOT)); - $this->vfs->override_acl = 0; + $this->bo->delete($info_id); + + $file = $this->basedir.'/'.$info_id; // whole dir } + else + { + $file .= '/'.$to_del; + } + if ($this->vfs->file_exists($file,array(RELATIVE_ROOT))) + { + $this->vfs->override_acl = 1; + $this->vfs->delete($file,array(RELATIVE_ROOT)); + $this->vfs->override_acl = 0; + } + Header('Location: ' . $html->link($referer,array( 'cd' => 16 ))); } else { @@ -1010,18 +1015,38 @@ echo parse_navbar(); $t->set_file(array( 'info_delete' => 'delete.tpl' )); + + // add the links to the files which corrospond to this entry + $attachments = $this->vfs->ls($this->basedir.'/'.$info_id.'/',array(REALTIVE_NONE)); + if (count($attachments) && $attachments[0]['name']) + { + $to_del = array('.' => lang('entry and all files')); + + while (list($keys,$fileinfo) = each($attachments)) + { + $to_del[$fileinfo['name']] = $fileinfo['name'] . + ($fileinfo['comment'] ? ' ('.$fileinfo['comment'].')' : ''); + } + $sbox2 = CreateObject('phpgwapi.sbox2'); + $t->set_var('to_del',$sbox2->getArrayItem('to_del','.',$to_del,True)); + } + else + { + $t->set_var('to_del',''); + } $t->set_var( $this->setStyleSheet( )); $t->set_var( $this->infoHeaders( )); $t->set_var( $this->formatInfo( $info_id )); $t->set_var('lang_info_action',lang('InfoLog - Delete')); - $t->set_var('deleteheader', - lang('Are you sure you want to delete this entry')); + $t->set_var('deleteheader',lang('Are you sure you want to delete this entry')); $t->set_var('no_button',$html->form_1button('no_button', 'No - Cancel','',$referer)); - $t->set_var('yes_button',$html->form_1button('yes_button', - 'Yes - Delete',array('referer' => $referer),'/index.php',$this->menuaction('delete')+ - array('info_id' => $info_id,'confirm' => 'True'))); + + $t->set_var('yes_form',$html->form('',array('referer' => $referer),'/index.php', + $this->menuaction('delete') + array('info_id' => $info_id,'confirm' => 'True'))); + $t->set_var('yes_button',$html->submit_button('yes_button','Yes - Delete')); + $t->pfp('out','info_delete'); } } diff --git a/infolog/setup/phpgw_de.lang b/infolog/setup/phpgw_de.lang index 526dbaa8dc..ec0f554428 100644 --- a/infolog/setup/phpgw_de.lang +++ b/infolog/setup/phpgw_de.lang @@ -30,6 +30,7 @@ download infolog de Datei laden duration infolog de Dauer enddate infolog de Enddatum enddate can not be before startdate infolog de Das Enddatum kann nicht vor dem Startdatum liegen +entry and all files infolog de Eintrag und alle Dateien fax infolog de Fax fieldseparator infolog de Feldbegrenzer finish infolog de wenn erledigt diff --git a/infolog/setup/phpgw_en.lang b/infolog/setup/phpgw_en.lang index e7743aba7b..6adca80898 100644 --- a/infolog/setup/phpgw_en.lang +++ b/infolog/setup/phpgw_en.lang @@ -30,6 +30,7 @@ download infolog en Download duration infolog en Duration enddate infolog en Enddate enddate can not be before startdate infolog en Enddate can not be before startdate +entry and all files infolog en Entry and all files fax infolog en Fax fieldseparator infolog en Fieldseparator finish infolog en finish diff --git a/infolog/templates/default/delete.tpl b/infolog/templates/default/delete.tpl index dd71eb8a79..5ecf8cf001 100644 --- a/infolog/templates/default/delete.tpl +++ b/infolog/templates/default/delete.tpl @@ -22,16 +22,18 @@ {responsible}

- +{yes_form} - - + +
- {deleteheader} + {deleteheader}

+{to_del}

{yes_button}{no_button}{yes_button}{no_button}
+