1<?php 2/* 3 * Gallery - a web based photo album viewer and editor 4 * Copyright (C) 2000-2008 Bharat Mediratta 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or (at 9 * your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21/** 22 * This controller will handle a user logging out of Gallery 23 * @package GalleryCore 24 * @subpackage UserInterface 25 * @author Bharat Mediratta <bharat@menalto.com> 26 * @version $Revision: 17580 $ 27 */ 28class LogoutController extends GalleryController { 29 30 /** 31 * @see GalleryController::isAllowedInMaintenance 32 */ 33 function isAllowedInMaintenance() { 34 return true; 35 } 36 37 /** 38 * @see GalleryController::handleRequest 39 */ 40 function handleRequest($form) { 41 global $gallery; 42 43 $event = GalleryCoreApi::newEvent('Gallery::Logout'); 44 $activeUser = $gallery->getActiveUser(); 45 $event->setEntity($activeUser); 46 list ($ret, $eventResults) = GalleryCoreApi::postEvent($event); 47 if ($ret) { 48 return array($ret, null); 49 } 50 51 $results = array(); 52 foreach ($eventResults as $key => $value) { 53 if (!empty($value['delegate'])) { 54 $results['delegate'] = $value['delegate']; 55 } 56 } 57 58 $session =& $gallery->getSession(); 59 $ret = $session->reset(); 60 if ($ret) { 61 return array($ret, null); 62 } 63 64 list ($ret, $anonymousId) = GalleryCoreApi::getAnonymousUserId(); 65 if ($ret) { 66 return array($ret, null); 67 } 68 list ($ret, $guestUser) = GalleryCoreApi::loadEntitiesById($anonymousId, 'GalleryUser'); 69 if ($ret) { 70 return array($ret, null); 71 } 72 73 $gallery->setActiveUser($guestUser); 74 75 if (!isset($results['status'])) { 76 $results['status'] = array(); 77 } 78 if (!isset($results['error'])) { 79 $results['error'] = array(); 80 } 81 82 /* 83 * Force return to core.ShowItem, as we don't know if the guest user has necessary 84 * permissions for the return page 85 */ 86 if (!isset($results['return']) 87 && !isset($results['redirect']) 88 && !isset($results['delegate'])) { 89 $results['redirect']['view'] = GALLERY_DEFAULT_VIEW; 90 } 91 92 return array(null, $results); 93 } 94} 95?> 96