3
* $RCSfile: module.inc,v $
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2005 Bharat Mediratta
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.
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.
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.
23
* @version $Revision: 1.30 $ $Date: 2005/09/10 20:28:14 $
24
* @package SelfRegistration
25
* @author Sebastian Eichner <mailsp@sebastian-eichner.de>
29
* The self-registration module
31
* @package SelfRegistration
33
class RegisterModule extends GalleryModule {
35
function RegisterModule() {
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));
49
* @see GalleryModule::upgrade()
51
function upgrade($currentVersion) {
52
if (!isset($currentVersion)) {
53
foreach (array('confirmation' => 'admin',
55
'subject' => $this->translate('Account activation'),
56
'adminsubject' => $this->translate('New user registration'),
57
'from' => 'webmaster@' . GalleryUtilities::getServerVar('SERVER_NAME'))
59
$ret = $this->setParameter($key, $value);
60
if ($ret->isError()) {
61
return $ret->wrap(__FILE__, __LINE__);
66
return GalleryStatus::success();
70
* @see GalleryModule::performFactoryRegistrations()
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__);
80
return GalleryStatus::success();
84
* @see GalleryModule::autoConfigure
86
function autoConfigure() {
87
/* We don't require any special configuration */
88
return array(GalleryStatus::success(), true);
93
* @see GalleryModule::getSystemLinks
95
function getSystemLinks() {
99
list ($ret, $anonymousUserId) =
100
GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
101
if ($ret->isError()) {
102
return array($ret->wrap(__FILE__, __LINE__), null);
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',
114
return array(GalleryStatus::success(), $links);
118
* @see GalleryModule::getUserAdminViews();
120
function getUserAdminViews($user) {
124
list ($ret, $anonymousUserId) =
125
GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
126
if ($ret->isError()) {
127
return array($ret->wrap(__FILE__, __LINE__), null);
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');
136
return array(GalleryStatus::success(), $views);
140
* @see GalleryModule::getSiteAdminViews
142
function getSiteAdminViews() {
143
return array(GalleryStatus::success(),
144
array(array('name' => $this->translate('Registration'),
145
'view' => 'register.AdminSelfRegistration')));