~ubuntu-branches/ubuntu/quantal/gallery2/quantal

« back to all changes in this revision

Viewing changes to modules/register/module.inc

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2005-11-29 15:50:12 UTC
  • Revision ID: james.westby@ubuntu.com-20051129155012-wtophp03lu01kdgl
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: module.inc,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2005 Bharat Mediratta
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or (at
 
11
 * your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 
21
 */
 
22
/**
 
23
 * @version $Revision: 1.30 $ $Date: 2005/09/10 20:28:14 $
 
24
 * @package SelfRegistration
 
25
 * @author Sebastian Eichner <mailsp@sebastian-eichner.de>
 
26
 */
 
27
 
 
28
/**
 
29
 * The self-registration module
 
30
 *
 
31
 * @package SelfRegistration
 
32
 */
 
33
class RegisterModule extends GalleryModule {
 
34
 
 
35
    function RegisterModule() {
 
36
        global $gallery;
 
37
 
 
38
        $this->setId('register');
 
39
        $this->setName($gallery->i18n('Registration'));
 
40
        $this->setDescription($gallery->i18n('New User Registration'));
 
41
        $this->setVersion('1.0.0');
 
42
        $this->setGroup('gallery', $this->translate('Gallery'));
 
43
        $this->setCallbacks('getSystemLinks|getUserAdminViews|getSiteAdminViews');
 
44
        $this->setRequiredCoreApi(array(6, 0));
 
45
        $this->setRequiredModuleApi(array(2, 0));
 
46
    }
 
47
 
 
48
    /**
 
49
     * @see GalleryModule::upgrade()
 
50
     */
 
51
    function upgrade($currentVersion) {
 
52
        if (!isset($currentVersion)) {
 
53
            foreach (array('confirmation' => 'admin',
 
54
                           'emailadmins' => 1,
 
55
                           'subject' => $this->translate('Account activation'),
 
56
                           'adminsubject' => $this->translate('New user registration'),
 
57
                           'from' => 'webmaster@' . GalleryUtilities::getServerVar('SERVER_NAME'))
 
58
                         as $key => $value) {
 
59
                $ret = $this->setParameter($key, $value);
 
60
                if ($ret->isError()) {
 
61
                    return $ret->wrap(__FILE__, __LINE__);
 
62
                }
 
63
            }
 
64
        }
 
65
 
 
66
        return GalleryStatus::success();
 
67
    }
 
68
 
 
69
    /**
 
70
     * @see GalleryModule::performFactoryRegistrations()
 
71
     */
 
72
    function performFactoryRegistrations() {
 
73
        $ret = GalleryCoreApi::registerFactoryImplementation(
 
74
            'GalleryEntity', 'GalleryPendingUser', 'GalleryPendingUser',
 
75
            'modules/register/classes/GalleryPendingUser.class', 'register', null);
 
76
        if ($ret->isError()) {
 
77
            return $ret->wrap(__FILE__, __LINE__);
 
78
        }
 
79
 
 
80
        return GalleryStatus::success();
 
81
    }
 
82
 
 
83
    /**
 
84
     * @see GalleryModule::autoConfigure
 
85
     */
 
86
    function autoConfigure() {
 
87
        /* We don't require any special configuration */
 
88
        return array(GalleryStatus::success(), true);
 
89
    }
 
90
 
 
91
 
 
92
    /**
 
93
     * @see GalleryModule::getSystemLinks
 
94
     */
 
95
    function getSystemLinks() {
 
96
        global $gallery;
 
97
        $links = array();
 
98
 
 
99
        list ($ret, $anonymousUserId) =
 
100
            GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
 
101
        if ($ret->isError()) {
 
102
            return array($ret->wrap(__FILE__, __LINE__), null);
 
103
        }
 
104
 
 
105
        /* Only anonymous users will see the register link */
 
106
        if ($gallery->getActiveUserId() == $anonymousUserId) {
 
107
            $links['Register'] = array(
 
108
                'text' => $this->translate('Register'),
 
109
                'params' => array('view' => 'core.UserAdmin',
 
110
                                  'subView' => 'register.UserSelfRegistration',
 
111
                                  'return' => 1));
 
112
        }
 
113
 
 
114
        return array(GalleryStatus::success(), $links);
 
115
    }
 
116
 
 
117
    /**
 
118
     * @see GalleryModule::getUserAdminViews();
 
119
     */
 
120
    function getUserAdminViews($user) {
 
121
        global $gallery;
 
122
        $views = array();
 
123
 
 
124
        list ($ret, $anonymousUserId) =
 
125
            GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
 
126
        if ($ret->isError()) {
 
127
            return array($ret->wrap(__FILE__, __LINE__), null);
 
128
        }
 
129
 
 
130
        /* Only anonymous users will see the register link */
 
131
        if ($gallery->getActiveUserId() == $anonymousUserId) {
 
132
            $views[] = array('name' => $this->translate('Register'),
 
133
                             'view' => 'register.UserSelfRegistration');
 
134
        }
 
135
 
 
136
        return array(GalleryStatus::success(), $views);
 
137
    }
 
138
 
 
139
    /**
 
140
     * @see GalleryModule::getSiteAdminViews
 
141
     */
 
142
    function getSiteAdminViews() {
 
143
        return array(GalleryStatus::success(),
 
144
                     array(array('name' => $this->translate('Registration'),
 
145
                                 'view' => 'register.AdminSelfRegistration')));
 
146
    }
 
147
}
 
148
?>