~ubuntu-branches/ubuntu/vivid/php-horde-nag/vivid

« back to all changes in this revision

Viewing changes to nag-4.1.2/tasklists/edit.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2013-10-29 22:01:43 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131029220143-k16crjhccwr56jxq
Tags: 4.1.3-1
New upstream version 4.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Copyright 2002-2013 Horde LLC (http://www.horde.org/)
4
 
 *
5
 
 * See the enclosed file COPYING for license information (GPL). If you
6
 
 * did not receive this file, see http://www.horde.org/licenses/gpl.
7
 
 */
8
 
 
9
 
require_once __DIR__ . '/../lib/Application.php';
10
 
Horde_Registry::appInit('nag');
11
 
 
12
 
// Exit if this isn't an authenticated user.
13
 
if (!$GLOBALS['registry']->getAuth()) {
14
 
    Horde::url('list.php', true)->redirect();
15
 
}
16
 
 
17
 
$vars = Horde_Variables::getDefaultVariables();
18
 
try {
19
 
    $tasklist = $nag_shares->getShare($vars->get('t'));
20
 
} catch (Horde_Share_Exception $e) {
21
 
    $notification->push($e);
22
 
    Horde::url('list.php', true)->redirect();
23
 
}
24
 
$owner = $tasklist->get('owner') == $GLOBALS['registry']->getAuth() ||
25
 
    (is_null($tasklist->get('owner')) && $GLOBALS['registry']->isAdmin());
26
 
if (!$owner &&
27
 
    !$tasklist->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
28
 
    $notification->push(_("You are not allowed to see this task list."), 'horde.error');
29
 
    Horde::url('list.php', true)->redirect();
30
 
}
31
 
$form = new Nag_Form_EditTaskList($vars, $tasklist);
32
 
 
33
 
// Execute if the form is valid.
34
 
if ($owner && $form->validate($vars)) {
35
 
    $original_name = $tasklist->get('name');
36
 
    try {
37
 
        $form->execute();
38
 
        if ($tasklist->get('name') != $original_name) {
39
 
            $notification->push(sprintf(_("The task list \"%s\" has been renamed to \"%s\"."), $original_name, $tasklist->get('name')), 'horde.success');
40
 
        } else {
41
 
            $notification->push(sprintf(_("The task list \"%s\" has been saved."), $original_name), 'horde.success');
42
 
        }
43
 
        Horde::url('list.php', true)->redirect();
44
 
    } catch (Exception $e) {
45
 
        $notification->push($e);
46
 
    }
47
 
}
48
 
 
49
 
$vars->set('name', $tasklist->get('name'));
50
 
$vars->set('color', $tasklist->get('color'));
51
 
$vars->set('system', is_null($tasklist->get('owner')));
52
 
$vars->set('description', $tasklist->get('desc'));
53
 
 
54
 
$page_output->header(array(
55
 
    'title' => $form->getTitle()
56
 
));
57
 
Nag::status();
58
 
if ($owner) {
59
 
    echo $form->renderActive($form->getRenderer(), $vars,
60
 
                             Horde::url('tasklists/edit.php'), 'post');
61
 
} else {
62
 
    echo $form->renderInactive($form->getRenderer(), $vars);
63
 
}
64
 
$page_output->footer();