Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezimagecatalogue/xmlrpc/category.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: category.php 9520 2002-05-08 13:05:20Z jb $
5 //
6 // Created on: <23-Oct-2000 17:53:46 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // eZ article complete data
28 // include_once( "ezimagecatalogue/classes/ezimagecategory.php" );
29 // include_once( "ezimagecatalogue/classes/ezimage.php" );
30 // include_once( "ezuser/classes/ezobjectpermission.php" );
31 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
32 // include_once( "ezxmlrpc/classes/ezxmlrpcbool.php" );
33 // include_once( "ezxmlrpc/classes/ezxmlrpcint.php" );
34 // include_once( "classes/ezlocale.php" );
35 // include_once( "ezsitemanager/classes/ezsection.php" );
36
37 if( $Command == "info" )
38 {
39 $category = new eZImageCategory();
40 if ( !$category->get( $ID ) )
41 {
42 $Error = createErrorMessage( EZERROR_NONEXISTING_OBJECT );
43 }
44 else
45 {
46 $ret = array( "Name" => new eZXMLRPCString( $category->name( false ) ) );
47 $ReturnData = new eZXMLRPCStruct( $ret );
48 }
49 }
50 else if ( $Command == "permission" )
51 {
52 $read = eZObjectPermission::hasPermission( $ID, "imagecatalogue_category", "r", $User );
53 $edit = eZObjectPermission::hasPermission( $ID, "imagecatalogue_category", 'w', $User );
54
55 $ret = array( "Read" => new eZXMLRPCBool( $read ),
56 "Edit" => new eZXMLRPCBool( $edit ) );
57 $ReturnData = new eZXMLRPCStruct( $ret );
58 }
59 else if( $Command == "data" ) // Dump category info!
60 {
61 // usleep( 5000000 );
62 $writeGroups = eZObjectPermission::getGroups( $ID, "imagecatalogue_category", 'w', false );
63 $readGroups = eZObjectPermission::getGroups( $ID, "imagecatalogue_category", 'r', false );
64 $uploadGroups = eZObjectPermission::getGroups( $ID, "imagecatalogue_category", 'u', false );
65
66 $rgp = array();
67 $wgp = array();
68 $ugp = array();
69
70 foreach( $readGroups as $group )
71 $rgp[] = new eZXMLRPCInt( $group );
72 foreach( $writeGroups as $group )
73 $wgp[] = new eZXMLRPCInt( $group );
74 foreach( $uploadGroups as $group )
75 $ugp[] = new eZXMLRPCInt( $group );
76
77 $category = new eZImageCategory( $ID );
78 $cat_def_id = $category->parent( false );
79 $section_id = eZImageCategory::sectionIDStatic( $cat_def_id );
80 $section_lang = false;
81 if ( $section_id != 0 )
82 {
83 $section = new eZSection( $section_id );
84 $section_lang = $section->language();
85 }
86
87 $ret = array( "Location" => createURLStruct( "ezimagecatalogue", "category", $category->id() ),
88 "Name" => new eZXMLRPCString( $category->name( false ) ),
89 "ParentID" => new eZXMLRPCInt( $category->parent( false ) ),
90 "Description" => new eZXMLRPCString( $category->description( false ) ),
91 "ReadGroups" => new eZXMLRPCArray( $rgp ),
92 "WriteGroups" => new eZXMLRPCArray( $wgp ),
93 "UploadGroups" => new eZXMLRPCArray( $ugp )
94 );
95
96 if ( $section_lang != false )
97 {
98 $charsetLocale = new eZLocale( $section_lang );
99 $section_charset = $charsetLocale->languageISO();
100 $ret["Section"] = new eZXMLRPCStruct( array( "Language" => $section_lang,
101 "Charset" => $section_charset ) );
102 }
103
104 $ReturnData = new eZXMLRPCStruct( $ret );
105 }
106 else if( $Command == "storedata" ) // save the category data!
107 {
108 if( $ID == 0 )
109 {
110 $category = new eZImageCategory();
111 }
112 else
113 {
114 $category = new eZImageCategory( $ID );
115 $category->setUser( $User );
116 }
117 $category->setName( $Data["Name"]->value() );
118 $category->setDescription( $Data["Description"]->value() );
119
120 $parent = new eZImageCategory();
121 $parentid = $Data["ParentID"]->value();
122 if ( $parentid == 0 or $parent->get( $parentid ) )
123 {
124 $old_category = $category->parent();
125 $old_category_id = is_object( $old_category ) ? $old_category->id() : 0;
126 $category->setParent( $parent );
127 $category->store();
128 $ID = $category->id();
129
130 eZObjectPermission::removePermissions( $ID, "imagecatalogue_category", 'r' );
131 $readGroups = $Data["ReadGroups"]->value();
132 foreach( $readGroups as $readGroup )
133 eZObjectPermission::setPermission( $readGroup->value(), $ID, "imagecatalogue_category", 'r' );
134
135 eZObjectPermission::removePermissions( $ID, "imagecatalogue_category", 'w' );
136 foreach( $Data["WriteGroups"]->value() as $writeGroup )
137 eZObjectPermission::setPermission( $writeGroup->value(), $ID, "imagecatalogue_category", 'w' );
138
139 eZObjectPermission::removePermissions( $ID, "imagecatalogue_category", 'u' );
140 foreach( $Data["UploadGroups"]->value() as $uploadGroup )
141 eZObjectPermission::setPermission( $uploadGroup->value(), $ID, "imagecatalogue_category", 'u' );
142
143 $par =& createPath( $category, "ezimagecatalogue", "category", false );
144
145 $add_categories = array();
146 $cur_categories = array();
147 $remove_categories = array();
148 $add_categories = array_diff( array( $parent->id() ), array( $old_category_id ) );
149 $remove_categories = array_diff( array( $old_category_id ), array( $parent_id ) );
150 $cur_categories = array_intersect( array( $parent->id() ), array( $old_category_id ) );
151
152 $add_locs =& createURLArray( $add_categories, "ezimagecatalogue", "category" );
153 $cur_locs =& createURLArray( $cur_categories, "ezimagecatalogue", "category" );
154 $old_locs =& createURLArray( $remove_categories, "ezimagecatalogue", "category" );
155
156 $ReturnData = new eZXMLRPCStruct( array( "Location" => createURLStruct( "ezimagecatalogue", "category", $ID ),
157 "Name" => new eZXMLRPCString( $category->name( false ) ),
158 "Path" => new eZXMLRPCArray( $par ),
159 "NewLocations" => $add_locs,
160 "ChangedLocations" => $cur_locs,
161 "RemovedLocations" => $old_locs,
162 "UpdateType" => new eZXMLRPCString( $Command )
163 )
164 );
165 $Command = "update";
166 }
167 else
168 {
169 $Error = createErrorMessage( EZERROR_CUSTOM, "Parent ($parentid) of $Module:/$RequestType/$ID is not an existing parent",
170 EZIMAGECATALOGUE_NONEXISTING_PARENT );
171 }
172 }
173 else if( $Command == "delete" )
174 {
175 $category = new eZImageCategory();
176 if ( $category->get( $ID ) )
177 {
178 $par =& createPath( $category, "ezimagecatalogue", "category", false );
179
180 $ReturnData = new eZXMLRPCStruct( array( "Location" => createURLStruct( "ezimagecatalogue", "category", $ID ),
181 "Path" => new eZXMLRPCArray( $par ),
182 "UpdateType" => new eZXMLRPCString( $Command )
183 )
184 );
185 $Command = "update";
186 $category->delete( $ID );
187 }
188 else
189 $Error = createErrorMessage( EZERROR_NONEXISTING_OBJECT );
190 }
191
192 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$group
$group
Definition: admin/articleedit.php:799
eZImageCategory
Definition: ezimagecategory.php:43
eZImageCategory\sectionIDStatic
static sectionIDStatic( $categoryID)
Definition: ezimagecategory.php:835
eZLocale
Definition: ezlocale.php:119
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZObjectPermission\getGroups
static getGroups( $objectID, $moduleTable, $permission, $GroupReturn=true)
Definition: ezobjectpermission.php:365
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZObjectPermission\removePermissions
static removePermissions( $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:320
eZSection
Definition: ezsection.php:45
eZXMLRPCArray
Definition: ezxmlrpcarray.php:37
eZXMLRPCBool
Definition: ezxmlrpcbool.php:37
eZXMLRPCInt
Definition: ezxmlrpcint.php:37
eZXMLRPCString
Definition: ezxmlrpcstring.php:37
eZXMLRPCStruct
Definition: ezxmlrpcstruct.php:37
$Error
if(isset( $EditButton)) if(!empty( $CancelButton)) if(!empty( $PreviewButton)) if( $Action=="preview") switch( $Action) $Error
Definition: ezforum/user/messageedit.php:134
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
EZIMAGECATALOGUE_NONEXISTING_PARENT
const EZIMAGECATALOGUE_NONEXISTING_PARENT
Definition: ezimagecatalogue/xmlrpc/datasupplier.php:31
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$ReturnData
$ReturnData
Definition: tag.php:48
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.