File: delete.php

package info (click to toggle)
turba2 2.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,332 kB
  • ctags: 2,927
  • sloc: php: 11,046; xml: 1,690; sql: 507; makefile: 62; perl: 17; sh: 1
file content (43 lines) | stat: -rw-r--r-- 1,576 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
 * $Horde: turba/delete.php,v 1.29.4.7 2008/01/02 11:32:38 jan Exp $
 *
 * Copyright 2000-2008 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/asl.php.
 *
 * @author Chuck Hagenbuch <chuck@horde.org>
 */

@define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';

$source = Util::getFormData('source');
$key = Util::getFormData('key');
$driver = &Turba_Driver::singleton($source);

if ($conf['documents']['type'] != 'none') {
    $object = $driver->getObject($key);
    if (is_a($object, 'PEAR_Error')) {
        $notification->push($object->getMessage(), 'horde.error');
        header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
        exit;
    }
    if (is_a($deleted = $object->deleteFiles(), 'PEAR_Error')) {
        $notification->push($deleted, 'horde.error');
        header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
        exit;
    }
}

if (!is_a($result = $driver->delete($key), 'PEAR_Error')) {
    header('Location: ' . Util::getFormData('url', Horde::url($prefs->getValue('initial_page'), true)));
    exit;
}

$notification->push(sprintf(_("There was an error deleting this contact: %s"), $result->getMessage()), 'horde.error');
$title = _("Deletion failed");
require TURBA_TEMPLATES . '/common-header.inc';
require TURBA_TEMPLATES . '/menu.inc';
require $registry->get('templates', 'horde') . '/common-footer.inc';