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 view lets you make very simple callbacks to the framework to get very specific data. 23 * Eventually this will probably get refactored into a much more sophisticated framework. 24 * 25 * @package GalleryCore 26 * @subpackage UserInterface 27 * @author Bharat Mediratta <bharat@menalto.com> 28 * @version $Revision: 17580 $ 29 */ 30class RepositoryCallbackView extends GalleryView { 31 /** 32 * @see GalleryView::isImmediate 33 */ 34 function isImmediate() { 35 return true; 36 } 37 38 /** 39 * @see GalleryView::isControllerLike 40 */ 41 function isControllerLike() { 42 return true; 43 } 44 45 /** 46 * @see GalleryView::renderImmediate 47 */ 48 function renderImmediate($status, $error) { 49 $ret = GalleryCoreApi::assertUserIsSiteAdministrator(); 50 if ($ret) { 51 return $ret; 52 } 53 54 list ($command, $form) = GalleryUtilities::getRequestVariables('command', 'form'); 55 if ($command == 'saveRepositoryList') { 56 /* 57 * Filter the form values through our list of valid keys to avoid exploits 58 * This is duplicated from AdminRepositoryController. Success is assumed here 59 * since the UI is not configured to actually do anything on failure. This probably 60 * isn't the best long term approach. 61 */ 62 $data = array(); 63 foreach (array('released', 'experimental', 'community') as $key) { 64 if ($form['repositories'][$key]) { 65 $data[$key] = 1; 66 } 67 } 68 69 if (empty($data)) { 70 $data['released'] = 1; 71 } 72 73 $ret = GalleryCoreApi::setPluginParameter( 74 'module', 'core', 'core.repositories', serialize($data)); 75 if ($ret) { 76 return $ret; 77 } 78 79 /* Remove the default repositories from the data cache */ 80 GalleryRepository::clearRepositoryCache(); 81 } 82 return null; 83 } 84} 85?> 86