3
3
* $RCSfile: GalleryPendingUserHelper.class,v $
5
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2005 Bharat Mediratta
6
* Copyright (C) 2000-2006 Bharat Mediratta
8
8
* This program is free software; you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
20
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23
* @version $Revision: 1.15 $ $Date: 2005/08/23 03:49:52 $
23
* @version $Revision: 1.19 $ $Date: 2006/02/05 10:44:36 $
24
24
* @package SelfRegistration
25
25
* @author Sebastian Eichner <mailsp@sebastian-eichner.de>
51
51
WHERE [GalleryPendingUser::userName] = ?
53
53
list ($ret, $searchResults) = $gallery->search($query, array($userName));
54
if ($ret->isError()) {
55
55
return array($ret->wrap(__FILE__, __LINE__), null);
58
58
if ($searchResults->resultCount() == 0) {
59
return array(GalleryStatus::error(ERROR_MISSING_OBJECT, __FILE__, __LINE__), null);
59
return array(GalleryCoreApi::error(ERROR_MISSING_OBJECT, __FILE__, __LINE__), null);
61
61
$result = $searchResults->nextResult();
62
$id = (int)$result[0];
63
63
list ($ret, $user) = GalleryCoreApi::loadEntitiesById($id);
64
if ($ret->isError()) {
65
65
return array($ret->wrap(__FILE__, __LINE__), null);
68
return array(GalleryStatus::success(), $user);
68
return array(null, $user);
91
91
list ($ret, $searchResults) = $gallery->search($query, $data);
92
if ($ret->isError()) {
93
93
return array($ret->wrap(__FILE__, __LINE__), null);
96
96
$result = $searchResults->nextResult();
97
return array(GalleryStatus::success(), (int)$result[0]);
97
return array(null, (int)$result[0]);
129
129
$query .= ' ORDER BY [GalleryPendingUser::userName] ASC';
131
131
list ($ret, $searchResults) = $gallery->search($query, $data,
132
array('limit' => array('count' => $count, 'offset' => $offset)));
133
if ($ret->isError()) {
132
array('limit' => array('count' => (int)$count, 'offset' => (int)$offset)));
134
134
return array($ret->wrap(__FILE__, __LINE__), null);
158
158
list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'register');
159
if ($ret->isError()) {
160
160
return $ret->wrap(__FILE__, __LINE__);
162
162
list($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'register');
163
if ($ret->isError()) {
164
164
return $ret->wrap(__FILE__, __LINE__);
167
167
$generator =& $gallery->getUrlGenerator();
168
168
$confirmationUrl = $generator->generateUrl(
169
array( 'controller' => 'register.ConfirmRegistration',
170
/* Incoming url params will get sanitized, so decode here */
172
GalleryUtilities::htmlEntityDecode($pendingUser->getUserName()),
173
'key' => $pendingUser->getRegistrationKey() ));
174
$confirmationUrl = str_replace('&', '&', $confirmationUrl);
175
$baseUrl = str_replace('&', '&', $generator->generateUrl());
169
array('controller' => 'register.ConfirmRegistration',
170
/* Incoming url params will get sanitized, so decode here */
171
'username' => GalleryUtilities::htmlEntityDecode($pendingUser->getUserName()),
172
'key' => $pendingUser->getRegistrationKey()),
173
array('forceFullUrl' => true, 'htmlEntities' => false));
174
$baseUrl = $generator->generateUrl(
175
array(), array('forceFullUrl' => true, 'htmlEntities' => false));
177
177
$ret = GalleryCoreApi::sendTemplatedEmail(
178
178
'modules/register/templates/ConfirmationEmail.tpl',
186
186
$pendingUser->getEmail(),
187
187
$module->translate($params['subject']));
188
if ($ret->isError()) {
189
189
return $ret->wrap(__FILE__, __LINE__);
192
return GalleryStatus::success();
202
202
function sendAdminEmail(&$pendingUser) {
203
203
list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'register');
204
if ($ret->isError()) {
205
205
return $ret->wrap(__FILE__, __LINE__);
207
207
list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'register');
208
if ($ret->isError()) {
209
209
return $ret->wrap(__FILE__, __LINE__);
211
211
list ($ret, $adminGroupId) =
212
212
GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
213
if ($ret->isError()) {
214
214
return $ret->wrap(__FILE__, __LINE__);
216
216
list ($ret, $adminUserIds) = GalleryCoreApi::fetchUsersForGroup($adminGroupId);
217
if ($ret->isError()) {
218
218
return $ret->wrap(__FILE__, __LINE__);
220
220
list ($ret, $adminUsers) = GalleryCoreApi::loadEntitiesById(array_keys($adminUserIds));
221
if ($ret->isError()) {
222
222
return $ret->wrap(__FILE__, __LINE__);
224
224
$toList = array();
259
259
function createGalleryUser(&$pendingUser, $delete=true) {
260
260
list ($ret, $user) = GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryUser');
261
if ($ret->isError()) {
262
262
return $ret->wrap(__FILE__, __LINE__);
265
265
if (!isset($user)) {
266
return GalleryStatus::error(ERROR_MISSING_OBJECT, __FILE__, __LINE__);
266
return GalleryCoreApi::error(ERROR_MISSING_OBJECT, __FILE__, __LINE__);
269
269
$ret = $user->create($pendingUser->getUserName());
270
if ($ret->isError()) {
271
271
return $ret->wrap(__FILE__, __LINE__);
287
287
$event = GalleryCoreApi::newEvent($eventName);
288
288
$event->setEntity($pendingUser);
289
289
list ($ret) = GalleryCoreApi::postEvent($event);
290
if ($ret->isError()) {
291
291
return $ret->wrap(__FILE__, __LINE__);
295
295
list($ret, $lock) = GalleryCoreApi::acquireWriteLock(array($pendingUser->getId()));
296
if ($ret->isError()) {
297
297
return $ret->wrap(__FILE__, __LINE__);
300
300
$ret = $pendingUser->delete();
301
if ($ret->isError()) {
302
302
return $ret->wrap(__FILE__, __LINE__);
305
305
$ret = GalleryCoreApi::releaseLocks($lock);
306
if ($ret->isError()) {
307
307
return $ret->wrap(__FILE__, __LINE__);
311
return GalleryStatus::success();