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

« back to all changes in this revision

Viewing changes to turba-4.1.1/lib/View/DeleteContact.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
 * The Turba_View_DeleteContact:: class provides an API for viewing events.
 
4
 * @TODO: Refactor to a Horde_View
 
5
 *
 
6
 * @author  Chuck Hagenbuch <chuck@horde.org>
 
7
 * @package Turba
 
8
 */
 
9
class Turba_View_DeleteContact
 
10
{
 
11
    /**
 
12
     * @var Turba_Object
 
13
     *
 
14
     */
 
15
    public $contact;
 
16
 
 
17
    /**
 
18
     * @param Turba_Object $contact
 
19
     */
 
20
    public function __construct(Turba_Object $contact)
 
21
    {
 
22
        $this->contact = $contact;
 
23
    }
 
24
 
 
25
    public function getTitle()
 
26
    {
 
27
        return $this->contact
 
28
            ? sprintf($this->contact->isGroup() ? _("Delete Group \"%s\"") : _("Delete \"%s\""), $this->contact->getValue('name'))
 
29
            : _("Not Found");
 
30
    }
 
31
 
 
32
    public function html($active = true)
 
33
    {
 
34
        if (!$this->contact) {
 
35
            echo '<h3>' . _("The requested contact was not found.") . '</h3>';
 
36
            return;
 
37
        }
 
38
 
 
39
        if (!$this->contact->hasPermission(Horde_Perms::DELETE)) {
 
40
            if (!$this->contact->hasPermission(Horde_Perms::READ)) {
 
41
                echo '<h3>' . _("You do not have permission to view this contact.") . '</h3>';
 
42
                return;
 
43
            } else {
 
44
                echo '<h3>' . _("You only have permission to view this contact.") . '</h3>';
 
45
                return;
 
46
            }
 
47
        }
 
48
 
 
49
        echo '<div id="DeleteContact"' . ($active ? '' : ' style="display:none"') . '>';
 
50
        ?>
 
51
        <form action="<?php echo Horde::url('delete.php') ?>" method="post">
 
52
        <?php echo Horde_Util::formInput() ?>
 
53
        <input type="hidden" name="url" value="<?php echo htmlspecialchars(Horde_Util::getFormData('url')) ?>" />
 
54
        <input type="hidden" name="source" value="<?php echo htmlspecialchars($this->contact->driver->getName()) ?>" />
 
55
        <input type="hidden" name="key" value="<?php echo htmlspecialchars($this->contact->getValue('__key')) ?>" />
 
56
        <div class="headerbox" style="padding: 8px">
 
57
         <p><?php echo _("Permanently delete this contact?") ?></p>
 
58
         <input type="submit" class="horde-delete" name="delete" value="<?php echo _("Delete") ?>" />
 
59
        </div>
 
60
        </form>
 
61
        </div>
 
62
        <?php
 
63
        if ($active && $GLOBALS['browser']->hasFeature('dom')) {
 
64
            if ($this->contact->hasPermission(Horde_Perms::READ)) {
 
65
                $view = new Turba_View_Contact($this->contact);
 
66
                $view->html(false);
 
67
            }
 
68
            if ($this->contact->hasPermission(Horde_Perms::EDIT)) {
 
69
                $delete = new Turba_View_EditContact($this->contact);
 
70
                $delete->html(false);
 
71
            }
 
72
        }
 
73
    }
 
74
 
 
75
}