File: CreateAddressBook.php

package info (click to toggle)
turba2 2.3.4%2Bdebian0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,844 kB
  • ctags: 2,910
  • sloc: php: 12,341; xml: 1,851; sql: 520; makefile: 101; sh: 27; perl: 17
file content (64 lines) | stat: -rw-r--r-- 1,820 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
 * Horde_Form for creating address books.
 *
 * $Horde: turba/lib/Forms/CreateAddressBook.php,v 1.1.2.3 2009/12/15 11:12:33 jan Exp $
 *
 * See the enclosed file LICENSE for license information (ASL). If you
 * did not receive this file, see http://www.horde.org/licenses/asl.php.
 *
 * @package Turba
 */

/** Variables */
require_once 'Horde/Variables.php';

/** Horde_Form */
require_once 'Horde/Form.php';

/** Horde_Form_Renderer */
require_once 'Horde/Form/Renderer.php';

/**
 * The Turba_CreateAddressBookForm class provides the form for
 * creating an address book.
 *
 * @author  Chuck Hagenbuch <chuck@horde.org>
 * @since   Turba 2.2
 * @package Turba
 */
class Turba_CreateAddressBookForm extends Horde_Form {

    function Turba_CreateAddressBookForm(&$vars)
    {
        parent::Horde_Form($vars, _("Create Address Book"));

        $this->addVariable(_("Name"), 'name', 'text', true);
        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));

        $this->setButtons(array(_("Create")));
    }

    function execute()
    {
        // This global is necessary for BC with old groupware configuration
        // files that don't use $GLOBALS['conf'] yet.
        global $conf;

        // Need a clean cfgSources array
        include TURBA_BASE . '/config/sources.php';

        $driver = &Turba_Driver::singleton($cfgSources[$GLOBALS['conf']['shares']['source']]);
        if (is_a($driver, 'PEAR_Error')) {
            return $driver;
        }

        $params = array(
            'params' => array('source' => $GLOBALS['conf']['shares']['source']),
            'name' => $this->_vars->get('name'),
            'desc' => $this->_vars->get('description'),
        );
        return $driver->createShare(md5(mt_rand()), $params);
    }

}