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

« back to all changes in this revision

Viewing changes to modules/core/ItemDeleteSingle.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: ItemDeleteSingle.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
21
21
 */
22
22
 
23
23
/**
24
 
 * @version $Revision: 1.8 $ $Date: 2005/08/23 03:49:02 $
 
24
 * @version $Revision: 1.10 $ $Date: 2006/01/13 03:39:31 $
25
25
 * @package GalleryCore
26
26
 * @subpackage UserInterface
27
27
 * @author Bharat Mediratta <bharat@menalto.com>
47
47
        $error = array();
48
48
        if (isset($form['action']['delete'])) {
49
49
            /* Get the root album id, so we don't try to delete it */
50
 
            list ($ret, $rootId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.rootAlbum');
51
 
            if ($ret->isError()) {
 
50
            list ($ret, $rootId) =
 
51
                GalleryCoreApi::getPluginParameter('module', 'core', 'id.rootAlbum');
 
52
            if ($ret) {
52
53
                return array($ret->wrap(__FILE__, __LINE__), null);
53
54
            }
54
55
 
55
56
            /* The view shouldn't let us get this far if we don't have delete permission */
56
57
            $ret = GalleryCoreApi::assertHasItemPermission($itemId, 'core.delete');
57
 
            if ($ret->isError()) {
 
58
            if ($ret) {
58
59
                return array($ret->wrap(__FILE__, __LINE__), null);
59
60
            }
60
61
 
61
62
            list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);
62
 
            if ($ret->isError()) {
 
63
            if ($ret) {
63
64
                return array($ret->wrap(__FILE__, __LINE__), null);
64
65
            }
65
66
 
66
67
            /* The view shouldn't let us try to delete the root album, either */
67
68
            if ($itemId == $rootId) {
68
 
                return array(GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__,
 
69
                return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__,
69
70
                                                  "Can't delete the root album"), null);
70
71
            }
71
72
 
72
73
            $ret = GalleryCoreApi::deleteEntityById($itemId);
73
 
            if ($ret->isError()) {
 
74
            if ($ret) {
74
75
                return array($ret->wrap(__FILE__, __LINE__), null);
75
76
            }
76
77
 
77
 
            list ($ret, $success) = GalleryCoreApi::guaranteeAlbumHasThumbnail($item->getParentId());
78
 
            if ($ret->isError()) {
 
78
            list ($ret, $success) =
 
79
                GalleryCoreApi::guaranteeAlbumHasThumbnail($item->getParentId());
 
80
            if ($ret) {
79
81
                return array($ret->wrap(__FILE__, __LINE__), null);
80
82
            }
81
83
            /* What do we do if we weren't successful?  No thumbnail, I guess */
97
99
        $results['status'] = $status;
98
100
        $results['error'] = $error;
99
101
 
100
 
        return array(GalleryStatus::success(), $results);
 
102
        return array(null, $results);
101
103
    }
102
104
}
103
105
 
123
125
        }
124
126
 
125
127
        list($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);
126
 
        if ($ret->isError()) {
 
128
        if ($ret) {
127
129
            return array($ret->wrap(__FILE__, __LINE__), null);
128
130
        }
129
131
 
130
132
        /* Get child counts */
131
133
        list ($ret, $childCountTable) = GalleryCoreApi::fetchDescendentCounts(array($itemId));
132
 
        if ($ret->isError()) {
 
134
        if ($ret) {
133
135
            return array($ret->wrap(__FILE__, __LINE__), null);
134
136
        }
135
137
        $childCount = isset($childCountTable[$itemId]) ? $childCountTable[$itemId] : 0;
141
143
        $template->setVariable('controller', 'core.ItemDeleteSingle');
142
144
        $template->setVariable('ItemDeleteSingle', $ItemDeleteSingle);
143
145
 
144
 
        return array(GalleryStatus::success(),
 
146
        return array(null,
145
147
                     array('body' => 'modules/core/templates/ItemDeleteSingle.tpl'));
146
148
 
147
149
    }
151
153
     */
152
154
    function getViewDescription() {
153
155
        list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core');
154
 
        if ($ret->isError()) {
 
156
        if ($ret) {
155
157
            return array($ret->wrap(__FILE__, __LINE__), null);
156
158
        }
157
159
 
158
160
        list ($ret, $item) = $this->_getItem();
159
 
        if ($ret->isError()) {
 
161
        if ($ret) {
160
162
            return array($ret->wrap(__FILE__, __LINE__), null);
161
163
        }
162
164
 
163
165
        $itemTypeNames = $item->itemTypeName(true);
164
166
 
165
 
        return array(GalleryStatus::success(), $core->translate(array('text' => 'delete %s',
166
 
                                                                      'arg1' => $itemTypeNames[1])));
 
167
        return array(null, $core->translate(array('text' => 'delete %s',
 
168
                                                  'arg1' => $itemTypeNames[1])));
167
169
    }
168
170
}
169
171
?>