File: signup.php

package info (click to toggle)
horde3 3.3.8%2Bdebian0-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 34,220 kB
  • ctags: 28,224
  • sloc: php: 115,191; xml: 4,247; sql: 2,417; sh: 147; makefile: 140
file content (74 lines) | stat: -rw-r--r-- 2,993 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
65
66
67
68
69
70
71
72
73
74
<?php
/**
 * $Horde: horde/signup.php,v 1.17.10.16 2009/01/06 15:13:50 jan Exp $
 *
 * Copyright 2002-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author Marko Djukic <marko@oblo.com>
 */

@define('AUTH_HANDLER', true);
@define('HORDE_BASE', dirname(__FILE__));
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Auth/Signup.php';
require_once 'Horde/Variables.php';

$auth = &Auth::singleton($conf['auth']['driver']);

// Make sure signups are enabled before proceeding
if ($conf['signup']['allow'] !== true ||
    !$auth->hasCapability('add')) {
    $notification->push(_("User Registration has been disabled for this site."), 'horde.error');
    header('Location: ' . Auth::getLoginScreen());
    exit;
}

$signup = Auth_Signup::factory();
if (is_a($signup, 'PEAR_Error')) {
    Horde::logMessage($signup->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
    $notification->push(_("User Registration is not properly configured for this site."), 'horde.error');
    header('Location: ' . Auth::getLoginScreen());
    exit;
}

$vars = Variables::getDefaultVariables();
$formsignup = new HordeSignupForm($vars);
if ($formsignup->validate()) {
    $formsignup->getInfo($vars, $info);
    $success_message = null;

    if (!$conf['signup']['approve']) {
        /* User can sign up directly, no intervention necessary. */
        $success = $signup->addSignup($info);
        if (!is_a($success, 'PEAR_Error')) {
            $success_message = sprintf(_("Added \"%s\" to the system. You can log in now."), $info['user_name']);
        }
    } elseif ($conf['signup']['approve']) {
        /* Insert this user into a queue for admin approval. */
        $success = $signup->queueSignup($info);
        if (!is_a($success, 'PEAR_Error')) {
            $success_message = sprintf(_("Submitted request to add \"%s\" to the system. You cannot log in until your request has been approved."), $info['user_name']);
        }
    }

    if (is_a($info, 'PEAR_Error')) {
        $notification->push(sprintf(_("There was a problem adding \"%s\" to the system: %s"), $vars->get('user_name'), $info->getMessage()), 'horde.error');
    } elseif (is_a($success, 'PEAR_Error')) {
        $notification->push(sprintf(_("There was a problem adding \"%s\" to the system: %s"), $info['user_name'], $success->getMessage()), 'horde.error');
    } else {
        $notification->push($success_message, 'horde.success');
        $url = Auth::getLoginScreen('', $info['url']);
        header('Location: ' . $url);
        exit;
    }
}

$title = _("User Registration");
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/login/header.inc';
$notification->notify(array('listeners' => 'status'));
$formsignup->renderActive($formsignup->getRenderer(), $vars, 'signup.php', 'post');
require HORDE_TEMPLATES . '/common-footer.inc';