~ubuntu-branches/debian/sid/php-horde-turba/sid

« back to all changes in this revision

Viewing changes to turba-4.1.1/deletefile.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2013-08-11 13:16:25 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130811131625-z91stjvq51jr9onv
Tags: 4.1.1-1
New upstream version 4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Turba deletefile.php.
 
4
 *
 
5
 * Copyright 2000-2013 Horde LLC (http://www.horde.org/)
 
6
 *
 
7
 * See the enclosed file LICENSE for license information (ASL).  If you
 
8
 * did not receive this file, see http://www.horde.org/licenses/apache.
 
9
 *
 
10
 * @author Chuck Hagenbuch <chuck@horde.org>
 
11
 */
 
12
 
 
13
require_once __DIR__ . '/lib/Application.php';
 
14
Horde_Registry::appInit('turba');
 
15
 
 
16
$source = Horde_Util::getPost('source');
 
17
if ($source === null || !isset($cfgSources[$source])) {
 
18
    $notification->push(_("Not found"), 'horde.error');
 
19
    Horde::url($prefs->getValue('initial_page'), true)->redirect();
 
20
}
 
21
 
 
22
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 
23
 
 
24
try {
 
25
    $contact = $driver->getObject(Horde_Util::getPost('key'));
 
26
} catch (Horde_Exception $e) {
 
27
    $notification->push($e);
 
28
    Horde::url($prefs->getValue('initial_page'), true)->redirect();
 
29
}
 
30
 
 
31
if (!$contact->isEditable()) {
 
32
    $notification->push(_("Permission denied"), 'horde.error');
 
33
    Horde::url($prefs->getValue('initial_page'), true)->redirect();
 
34
}
 
35
 
 
36
$file = Horde_Util::getPost('file');
 
37
 
 
38
try {
 
39
    $contact->deleteFile($file);
 
40
    $notification->push(sprintf(_("The file \"%s\" has been deleted."), $file), 'horde.success');
 
41
} catch (Turba_Exception $e) {
 
42
    $notification->push($e, 'horde.error');
 
43
}
 
44
 
 
45
$contact->url('Contact', true)->redirect();