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

« back to all changes in this revision

Viewing changes to modules/netpbm/AdminNetPbm.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:
3
3
 * $RCSfile: AdminNetPbm.inc,v $
4
4
 *
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
7
7
 *
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.
21
21
 */
22
22
/**
23
 
 * @version $Revision: 1.47 $ $Date: 2005/08/23 03:49:47 $
 
23
 * @version $Revision: 1.49 $ $Date: 2006/01/17 01:52:02 $
24
24
 * @package NetPbm
25
25
 * @author Bharat Mediratta <bharat@menalto.com>
26
26
 */
27
27
 
28
 
/**
29
 
 * Required class
30
 
 */
31
 
GalleryCoreApi::relativeRequireOnce('modules/netpbm/classes/NetPbmToolkitHelper.class');
 
28
GalleryCoreApi::requireOnce('modules/netpbm/classes/NetPbmToolkitHelper.class');
32
29
 
33
30
/**
34
31
 * @package NetPbm
43
40
        global $gallery;
44
41
 
45
42
        $ret = GalleryCoreApi::assertUserIsSiteAdministrator();
46
 
        if ($ret->isError()) {
 
43
        if ($ret) {
47
44
            return array($ret->wrap(__FILE__, __LINE__), null);
48
45
        }
49
46
 
50
 
        $status = array();
51
 
        $error = array();
 
47
        $status = $error = array();
52
48
        if (isset($form['action']['save'])) {
53
49
 
54
50
            if (empty($form['path'])) {
56
52
            } else {
57
53
 
58
54
                /* Set the path.  Guarantee that it's got a trailing slash. */
59
 
                $platform = $gallery->getPlatform();
 
55
                $platform =& $gallery->getPlatform();
60
56
                $slash = $platform->getDirectorySeparator();
61
57
                $form['path'] = trim($form['path']);
62
58
                if (!empty($form['path'])) {
67
63
 
68
64
                list ($ret, $testResults, $mimeTypes) =
69
65
                    NetPbmToolkitHelper::testBinaries($form['path']);
70
 
                if ($ret->isError()) {
 
66
                if ($ret) {
71
67
                    if ($ret->getErrorCode() & ERROR_BAD_PATH) {
72
68
                        $error[] = 'form[error][path][badPath]';
73
69
                    } else {
82
78
            if (!empty($form['jheadPath'])) {
83
79
                list ($ret, $jheadTests, $jheadMimeTypes) =
84
80
                    NetPbmToolkitHelper::testJhead($form['jheadPath']);
85
 
                if ($ret->isError()) {
 
81
                if ($ret) {
86
82
                    if ($ret->getErrorCode() & ERROR_BAD_PATH) {
87
83
                        $error[] = 'form[error][jheadPath][badPath]';
88
84
                    } else {
102
98
            if (empty($error)) {
103
99
                $ret = GalleryCoreApi::setPluginParameter(
104
100
                    'module', 'netpbm', 'path', $form['path']);
105
 
                if ($ret->isError()) {
 
101
                if ($ret) {
106
102
                    return array($ret->wrap(__FILE__, __LINE__), null);
107
103
                }
108
104
 
109
105
                /* Set the image quality */
110
106
                $ret = GalleryCoreApi::setPluginParameter(
111
107
                    'module', 'netpbm', 'jpegQuality', $form['jpegQuality']);
112
 
                if ($ret->isError()) {
 
108
                if ($ret) {
113
109
                    return array($ret->wrap(__FILE__, __LINE__), null);
114
110
                }
115
111
 
117
113
                $jheadPath = isset($form['jheadPath']) ? $form['jheadPath'] : '';
118
114
                $ret = GalleryCoreApi::setPluginParameter(
119
115
                    'module', 'netpbm', 'jheadPath', $jheadPath);
120
 
                if ($ret->isError()) {
 
116
                if ($ret) {
121
117
                    return array($ret->wrap(__FILE__, __LINE__), null);
122
118
                }
123
119
 
124
120
                /* Save binaries to use for this netpbm path */
125
121
                $ret = NetPbmToolkitHelper::saveParameters($testResults);
126
 
                if ($ret->isError()) {
 
122
                if ($ret) {
127
123
                    return array($ret->wrap(__FILE__, __LINE__), null);
128
124
                }
129
125
 
130
126
                list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'netpbm');
131
 
                if ($ret->isError()) {
 
127
                if ($ret) {
132
128
                    return array($ret->wrap(__FILE__, __LINE__), null);
133
129
                }
134
130
                list ($ret, $isActive) = $module->isActive();
135
 
                if ($ret->isError()) {
 
131
                if ($ret) {
136
132
                    return array($ret->wrap(__FILE__, __LINE__), null);
137
133
                }
138
134
 
162
158
        $results['status'] = $status;
163
159
        $results['error'] = $error;
164
160
 
165
 
        return array(GalleryStatus::success(), $results);
 
161
        return array(null, $results);
166
162
    }
167
163
}
168
164
 
177
173
     */
178
174
    function loadTemplate(&$template, &$form) {
179
175
        global $gallery;
180
 
        $platform = $gallery->getPlatform();
 
176
        $platform =& $gallery->getPlatform();
 
177
 
 
178
        $ret = GalleryCoreApi::assertUserIsSiteAdministrator();
 
179
        if ($ret) {
 
180
            return array($ret->wrap(__FILE__, __LINE__), null);
 
181
        }
181
182
 
182
183
        /* Load our default values if we didn't just come from this form. */
183
184
        if ($form['formName'] != 'AdminNetPbm') {
184
185
            foreach (array('path', 'jpegQuality', 'jheadPath') as $key) {
185
186
                list ($ret, $form[$key]) =
186
187
                    GalleryCoreApi::getPluginParameter('module', 'netpbm', $key);
187
 
                if ($ret->isError()) {
 
188
                if ($ret) {
188
189
                    return array($ret->wrap(__FILE__, __LINE__), null);
189
190
                }
190
191
            }
192
193
        }
193
194
 
194
195
        /* Guarantee that the path and jheadPath have a trailing slash. */
195
 
        $platform = $gallery->getPlatform();
196
196
        $slash = $platform->getDirectorySeparator();
197
197
        foreach (array('path', 'jheadPath') as $key) {
198
198
            $form[$key] = trim($form[$key]);
219
219
                list ($ret, $tests, $mimeTypes) = NetPbmToolkitHelper::testBinaries($form['path']);
220
220
                $debugSnippet = $gallery->stopRecordingDebugSnippet();
221
221
 
222
 
                if ($ret->isError()) {
 
222
                if ($ret) {
223
223
                    if ($ret->getErrorCode() & ERROR_BAD_PATH) {
224
224
                        $form['error']['path']['badPath'] = 1;
225
225
                    } else {
239
239
                list ($ret, $jheadTests, $jheadMimeTypes) =
240
240
                    NetPbmToolkitHelper::testJhead($form['jheadPath']);
241
241
                $debugSnippet .= $gallery->stopRecordingDebugSnippet();
242
 
                if ($ret->isError()) {
 
242
                if ($ret) {
243
243
                    if ($ret->getErrorCode() & ERROR_BAD_PATH) {
244
244
                        $form['error']['jheadPath']['badPath'] = 1;
245
245
                    } else {
255
255
        }
256
256
 
257
257
        list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'netpbm');
258
 
        if ($ret->isError()) {
 
258
        if ($ret) {
259
259
            return array($ret->wrap(__FILE__, __LINE__), null);
260
260
        }
261
261
        list ($ret, $isActive) = $module->isActive();
262
 
        if ($ret->isError()) {
 
262
        if ($ret) {
263
263
            return array($ret->wrap(__FILE__, __LINE__), null);
264
264
        }
265
265
 
277
277
 
278
278
        $template->setVariable('AdminNetPbm', $AdminNetPbm);
279
279
        $template->setVariable('controller', 'netpbm.AdminNetPbm');
280
 
        return array(GalleryStatus::success(),
 
280
        return array(null,
281
281
                     array('body' => 'modules/netpbm/templates/AdminNetPbm.tpl'));
282
282
    }
283
283
}