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

« back to all changes in this revision

Viewing changes to modules/customfield/classes/interfaces/CustomFieldMap.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: CustomFieldMap.inc,v $
4
 
 *
5
 
 * Gallery - a web based photo album viewer and editor
6
 
 * Copyright (C) 2000-2005 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
 
 * @package CustomField
24
 
 * @subpackage ClassInterfaces
25
 
 * @version $Revision: 1.9 $ $Date: 2005/08/23 03:49:37 $
26
 
 * @author Bharat Mediratta <bharat@menalto.com>
27
 
 */
28
 
 
29
 
/**
30
 
 * Interface class for the CustomFieldMap class.
31
 
 * (Class schema version: 1.0)
32
 
 *
33
 
 * This file is automatically generated from XML embedded in the
34
 
 * class, combined with the ClassCode.xsl file.  You should not modify
35
 
 * it by hand, as your changes will be lost next time this file is
36
 
 * rebuilt.  If you want to add more getters/setters, you should add
37
 
 * them in the core class.  If you want to change the format of this
38
 
 * file, then you should edit the XSL template.
39
 
 *
40
 
 * @package CustomField
41
 
 * @subpackage Classes
42
 
 */
43
 
class CustomFieldMap extends CustomFieldMap_core {
44
 
  
45
 
    /**
46
 
     * Return the name of this class with the proper mix of uppercase and
47
 
     * lowercase (get_class() always returns lowercase)
48
 
     *
49
 
     * @return string class name
50
 
     */
51
 
    function getClassName() {
52
 
        return 'CustomFieldMap';
53
 
    }
54
 
 
55
 
    /** 
56
 
     * Return the path to the PHP file for this class, relative to the gallery2 dir
57
 
     * 
58
 
     * @return string path
59
 
     */ 
60
 
    function getClassFile() { 
61
 
        return 'modules/' .  
62
 
            basename(dirname(dirname(dirname(__FILE__)))) .  
63
 
            '/classes/CustomFieldMap.class'; 
64
 
    }
65
 
    
66
 
    /**
67
 
     * Get meta information about this class' map 
68
 
     *
69
 
     * @return array map member => type
70
 
     */
71
 
    function getMapInfo() {
72
 
        $info = array();
73
 
        $info['members']['itemId'] = STORAGE_TYPE_INTEGER;
74
 
        $info['members']['field'] = STORAGE_TYPE_STRING;
75
 
        $info['members']['value'] = STORAGE_TYPE_STRING;
76
 
        $info['members']['setId'] = STORAGE_TYPE_INTEGER;
77
 
        $info['members']['setType'] = STORAGE_TYPE_INTEGER;
78
 
        return $info; 
79
 
    }
80
 
 
81
 
    /**
82
 
     * Add an entry to this map
83
 
     *
84
 
     * @param array an associative array of the entry data
85
 
     * @return object GalleryStatus a status code
86
 
     * @static
87
 
     */
88
 
    function addMapEntry($data) {
89
 
        global $gallery;
90
 
        foreach (array('itemId', 'field', 'value', 'setId', 'setType', ) as $key) {
91
 
            if (!array_key_exists($key, $data)) {
92
 
                return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__,
93
 
                                            'Missing parameter: ' . $key);
94
 
            }
95
 
        }
96
 
 
97
 
        $storage =& $gallery->getStorage();
98
 
        $ret = $storage->addMapEntry('CustomFieldMap', $data);
99
 
        if ($ret->isError()) {
100
 
            return $ret->wrap(__FILE__, __LINE__);
101
 
        }
102
 
        return GalleryStatus::success();
103
 
    }
104
 
 
105
 
    /**
106
 
     * Remove an entry from this map
107
 
     *
108
 
     * @param array an associative array of the entry data to match and remove
109
 
     * @return object GalleryStatus a status code
110
 
     * @static
111
 
     */
112
 
    function removeMapEntry($data) {
113
 
        global $gallery;
114
 
 
115
 
        if (sizeof($data) == 0) {
116
 
            return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__);
117
 
        }
118
 
 
119
 
        $storage =& $gallery->getStorage();
120
 
        $ret = $storage->removeMapEntry('CustomFieldMap', $data);
121
 
        if ($ret->isError()) {
122
 
            return $ret->wrap(__FILE__, __LINE__);
123
 
        }
124
 
        return GalleryStatus::success();
125
 
    }
126
 
 
127
 
    /**
128
 
     * Remove ALL entries from this map.. use with caution!
129
 
     *
130
 
     * @return object GalleryStatus a status code
131
 
     * @static
132
 
     */
133
 
    function removeAllMapEntries() {
134
 
        global $gallery;
135
 
 
136
 
        $storage =& $gallery->getStorage();
137
 
        $ret = $storage->removeAllMapEntries('CustomFieldMap');
138
 
        if ($ret->isError()) {
139
 
            return $ret->wrap(__FILE__, __LINE__);
140
 
        }
141
 
        return GalleryStatus::success();
142
 
    }
143
 
 
144
 
    /**
145
 
     * Update an entry in this map
146
 
     *
147
 
     * @param array the entry to match
148
 
     * @param array the values to change
149
 
     * @return object GalleryStatus a status code
150
 
     * @static
151
 
     */
152
 
    function updateMapEntry($match, $change) {
153
 
        global $gallery;
154
 
 
155
 
        if (sizeof($match) == 0 || sizeof($change) == 0) {
156
 
            return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__);
157
 
        }
158
 
 
159
 
        $storage =& $gallery->getStorage();
160
 
        $ret = $storage->updateMapEntry('CustomFieldMap', $match, $change);
161
 
        if ($ret->isError()) {
162
 
            return $ret->wrap(__FILE__, __LINE__);
163
 
        }
164
 
        return GalleryStatus::success();
165
 
    }
166
 
  
167
 
}
168
 
?>