~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to modules/fotokasten/FotokastenSiteAdmin.inc

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: FotokastenSiteAdmin.inc,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2006 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.1 $ $Date: 2006/02/06 18:09:40 $
 
24
 * @package Fotokasten
 
25
 * @author Alan Harder <alan.harder@sun.com>
 
26
 */
 
27
 
 
28
/**
 
29
 * @package Fotokasten
 
30
 * @subpackage UserInterface
 
31
 */
 
32
class FotokastenSiteAdminController extends GalleryController {
 
33
 
 
34
    /**
 
35
     * @see GalleryController::handleRequest
 
36
     */
 
37
    function handleRequest($form) {
 
38
        $ret = GalleryCoreApi::assertUserIsSiteAdministrator();
 
39
        if ($ret) {
 
40
            return array($ret->wrap(__FILE__, __LINE__), null);
 
41
        }
 
42
 
 
43
        $status = $error = array();
 
44
        if (isset($form['action']['save'])) {
 
45
            if (empty($form['affiliateId']) || !is_numeric($form['affiliateId'])) {
 
46
                $error[] = 'form[error][affiliateId]';
 
47
            }
 
48
            if (empty($form['affiliateIdPass'])) {
 
49
                $error[] = 'form[error][affiliateIdPass]';
 
50
            }
 
51
            if (empty($error)) {
 
52
                foreach (array('affiliateId', 'affiliateIdPass') as $key) {
 
53
                    $ret = GalleryCoreApi::setPluginParameter(
 
54
                            'module', 'fotokasten', $key, $form[$key]);
 
55
                    if ($ret) {
 
56
                        return array($ret->wrap(__FILE__, __LINE__), null);
 
57
                    }
 
58
                }
 
59
                $status['saved'] = 1;
 
60
            }
 
61
        }
 
62
 
 
63
        $method = empty($error) ? 'redirect' : 'delegate';
 
64
        $results[$method]['view'] = 'core.SiteAdmin';
 
65
        $results[$method]['subView'] = 'fotokasten.FotokastenSiteAdmin';
 
66
        $results['status'] = $status;
 
67
        $results['error'] = $error;
 
68
 
 
69
        return array(null, $results);
 
70
    }
 
71
}
 
72
 
 
73
/**
 
74
 * @package Fotokasten
 
75
 * @subpackage UserInterface
 
76
 */
 
77
class FotokastenSiteAdminView extends GalleryView {
 
78
 
 
79
    /**
 
80
     * @see GalleryView::loadTemplate
 
81
     */
 
82
    function loadTemplate(&$template, &$form) {
 
83
        $ret = GalleryCoreApi::assertUserIsSiteAdministrator();
 
84
        if ($ret) {
 
85
            return array($ret->wrap(__FILE__, __LINE__), null);
 
86
        }
 
87
 
 
88
        if ($form['formName'] != 'FotokastenSiteAdmin') {
 
89
            $form['formName'] = 'FotokastenSiteAdmin';
 
90
            foreach (array('affiliateId', 'affiliateIdPass') as $key) {
 
91
                list ($ret, $form[$key]) =
 
92
                    GalleryCoreApi::getPluginParameter('module', 'fotokasten', $key);
 
93
                if ($ret) {
 
94
                    return array($ret->wrap(__FILE__, __LINE__), null);
 
95
                }
 
96
            }
 
97
        }
 
98
 
 
99
        $template->setVariable('controller', 'fotokasten.FotokastenSiteAdmin');
 
100
        return array(null,
 
101
                     array('body' => 'modules/fotokasten/templates/FotokastenSiteAdmin.tpl'));
 
102
    }
 
103
}
 
104
?>