~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to signup.php

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * $Horde: horde/signup.php,v 1.17.10.1 2005/01/03 12:25:28 jan Exp $
 
4
 *
 
5
 * Copyright 2002-2005 Marko Djukic <marko@oblo.com>
 
6
 *
 
7
 * See the enclosed file COPYING for license information (LGPL). If you
 
8
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 
9
 */
 
10
 
 
11
@define('AUTH_HANDLER', true);
 
12
@define('HORDE_BASE', dirname(__FILE__));
 
13
require_once HORDE_BASE . '/lib/base.php';
 
14
require_once 'Horde/Auth/Signup.php';
 
15
require_once 'Horde/Variables.php';
 
16
 
 
17
// Make sure signups are enabled before proceeding
 
18
if ($conf['signup']['allow'] !== true) {
 
19
    $notification->push(_("User Registration has been disabled for this site."), 'horde.error');
 
20
    header('Location: ' . Auth::getLoginScreen());
 
21
    exit;
 
22
}
 
23
 
 
24
$auth = &Auth::singleton($conf['auth']['driver']);
 
25
$signup = &Auth_Signup::singleton();
 
26
 
 
27
$renderer = &new Horde_Form_Renderer();
 
28
 
 
29
$vars = &Variables::getDefaultVariables();
 
30
 
 
31
$formsignup = &Horde_Form::singleton('HordeSignupForm', $vars);
 
32
$formsignup->validate($vars);
 
33
 
 
34
if ($vars->get('formname') != 'hordesignupform') {
 
35
    /* Not yet submitted. */
 
36
    $formsignup->clearValidation();
 
37
}
 
38
 
 
39
if ($formsignup->isValid() && $vars->get('formname') == 'hordesignupform') {
 
40
    $formsignup->getInfo($vars, $info);
 
41
 
 
42
    if ($auth->hasCapability('add')) {
 
43
        if (!$conf['signup']['approve']) {
 
44
            /* User can sign up directly, no intervention necessary. */
 
45
            $success = $signup->addSignup($info);
 
46
            $success_message = sprintf(_("Added '%s' to the system. You can log in now."), $info['user_name']);
 
47
        } elseif ($conf['signup']['approve']) {
 
48
            /* Insert this user into a queue for admin approval. */
 
49
            $success = $signup->queueSignup($info);
 
50
            $success_message = sprintf(_("Submitted request to add '%s' to the system. You can not log in until your request has been approved."), $info['user_name']);
 
51
        }
 
52
    }
 
53
 
 
54
    if (is_a($success, 'PEAR_Error')) {
 
55
        $notification->push(sprintf(_("There was a problem adding '%s' to the system. %s."), $info['user_name'], $success->getMessage()), 'horde.error');
 
56
    } else {
 
57
        $notification->push($success_message, 'horde.success');
 
58
        $url = Auth::getLoginScreen('', $info['url']);
 
59
        header('Location: ' . $url);
 
60
        exit;
 
61
    }
 
62
}
 
63
 
 
64
$title = _("User Registration");
 
65
require HORDE_TEMPLATES . '/common-header.inc';
 
66
$notification->notify(array('listeners' => 'status'));
 
67
$formsignup->renderActive($renderer, $vars, 'signup.php', 'post');
 
68
require HORDE_TEMPLATES . '/common-footer.inc';