Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/xmlrpc/category.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: category.php 9773 2003-02-11 14:16:31Z 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( "ezarticle/classes/ezarticlecategory.php" );
29 // include_once( "ezarticle/classes/ezarticle.php" );
30 // include_once( "ezarticle/classes/ezarticletool.php" );
31 // include_once( "ezuser/classes/ezobjectpermission.php" );
32 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
33 // include_once( "ezxmlrpc/classes/ezxmlrpcbool.php" );
34 // include_once( "ezxmlrpc/classes/ezxmlrpcint.php" );
35 // include_once( "classes/ezlocale.php" );
36 // include_once( "ezsitemanager/classes/ezsection.php" );
37
38 if( $Command == "info" )
39 {
40 $category = new eZArticleCategory();
41 if ( !$category->get( $ID ) )
42 {
43 $Error = createErrorMessage( EZERROR_NONEXISTING_OBJECT );
44 }
45 else
46 {
47 $ret = array( "Name" => new eZXMLRPCString( $category->name( false ) ) );
48 $ReturnData = new eZXMLRPCStruct( $ret );
49 }
50 }
51 else if ( $Command == "permission" )
52 {
53 $read = eZObjectPermission::hasPermission( $ID, "article_category", "r", $User );
54 $edit = eZObjectPermission::hasPermission( $ID, "article_category", 'w', $User );
55
56 $ret = array( "Read" => new eZXMLRPCBool( $read ),
57 "Edit" => new eZXMLRPCBool( $edit ) );
58 $ReturnData = new eZXMLRPCStruct( $ret );
59 }
60 else if( $Command == "data" ) // Dump category info!
61 {
62 // usleep( 5000000 );
63 $writeGroups = eZObjectPermission::getGroups( $ID, "article_category", 'w', false );
64 $readGroups = eZObjectPermission::getGroups( $ID, "article_category", 'r', false );
65
66 foreach( $readGroups as $group )
67 $rgp[] = new eZXMLRPCInt( $group );
68 foreach( $writeGroups as $group )
69 $wgp[] = new eZXMLRPCInt( $group );
70
71 $category = new eZArticleCategory( $ID );
72
73 $cat_def_id = $category->parent( false );
74 $section_id = eZArticleCategory::sectionIDStatic( $cat_def_id );
75 $section_lang = false;
76 if ( $section_id != 0 )
77 {
78 $section = new eZSection( $section_id );
79 $section_lang = $section->language();
80 }
81
82 $ret = array( "Location" => createURLStruct( "ezarticle", "category", $category->id() ),
83 "Name" => new eZXMLRPCString( $category->name( false ) ),
84 "ParentID" => new eZXMLRPCInt( $category->parent( false ) ),
85 "Description" => new eZXMLRPCString( $category->description( false ) ),
86 "ExcludeFromSearch" => new eZXMLRPCBool( $category->excludeFromSearch() ),
87 "SortMode" => new eZXMLRPCInt( $category->sortMode( true ) ),
88 "OwnerID" => new eZXMLRPCInt( $category->owner( false ) ),
89 "SectionID" => new eZXMLRPCInt( $category->sectionIDStatic( $ID ) ),
90 "ImageID" => new eZXMLRPCInt( $category->image( false ) ),
91 "BulkMailID" => new eZXMLRPCInt( $category->bulkMailCategory(false ) ),
92 "ReadGroups" => new eZXMLRPCArray( $rgp ),
93 "WriteGroups" => new eZXMLRPCArray( $wgp )
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 $ReturnData = new eZXMLRPCStruct( $ret );
104 }
105 else if( $Command == "storedata" ) // save the category data!
106 {
107
108 if( $ID == 0 )
109 $category = new eZArticleCategory();
110 else
111 {
112 $category = new eZArticleCategory( $ID );
113 $category->setOwner( $User );
114 }
115 $category->setName( $Data["Name"]->value() );
116 $category->setDescription( $Data["Description"]->value() );
117
118 $parent = new eZArticleCategory();
119 $parentid = $Data["ParentID"]->value();
120 if ( $parentid == 0 or $parent->get( $parentid ) )
121 {
122 $old_category = $category->parent( false );
123 $category->setParent( $parent );
124 $category->setExcludeFromSearch( $Data["ExcludeFromSearch"]->value() );
125
126 $category->setBulkMailCategory( $Data["BulkMailID"]->value() );
127 $category->setSortMode( $Data["SortMode"]->value() );
128 $category->setSectionID( $Data["SectionID"]->value() );
129 $category->setImage( $Data["ImageID"]->value() );
130 $category->store();
131 eZArticleTool::deleteCache( 0, $parentid, 0 );
132 eZArticleTool::deleteCache( 0, $ID, 0 );
133
134 $ID = $category->id();
135 eZObjectPermission::removePermissions( $ID, "article_category", 'r' );
136 $readGroups = $Data["ReadGroups"]->value();
137 foreach( $readGroups as $readGroup )
138 {
139 eZObjectPermission::setPermission( $readGroup->value(), $ID, "article_category", 'r' );
140 }
141
142 eZObjectPermission::removePermissions( $ID, "article_category", 'w' );
143 foreach( $Data["WriteGroups"]->value() as $writeGroup )
144 eZObjectPermission::setPermission( $writeGroup->value(), $ID, "article_category", 'w' );
145
146 $par =& createPath( $category, "ezarticle", "category", false );
147
148 $add_categories = array();
149 $cur_categories = array();
150 $remove_categories = array();
151 $add_categories = array_diff( array( $parent->id() ), array( $old_category ) );
152 $remove_categories = array_diff( array( $old_category ), array( $parent->id() ) );
153 $cur_categories = array_intersect( array( $parent->id() ), array( $old_category ) );
154
155 $add_locs =& createURLArray( $add_categories, "ezarticle", "category" );
156 $cur_locs =& createURLArray( $cur_categories, "ezarticle", "category" );
157 $old_locs =& createURLArray( $remove_categories, "ezarticle", "category" );
158
159 $ReturnData = new eZXMLRPCStruct( array( "Location" => createURLStruct( "ezarticle", "category", $ID ),
160 "Name" => new eZXMLRPCString( $category->name( false ) ),
161 "Path" => new eZXMLRPCArray( $par ),
162 "NewLocations" => $add_locs,
163 "ChangedLocations" => $cur_locs,
164 "RemovedLocations" => $old_locs,
165 "UpdateType" => new eZXMLRPCString( $Command )
166 )
167 );
168 $Command = "update";
169 }
170 else
171 {
172 $Error = createErrorMessage( EZERROR_CUSTOM, "Parent ($parentid) of $Module:/$RequestType/$ID is not an existing parent",
173 EZARTICLE_NONEXISTING_PARENT );
174 }
175 }
176 else if( $Command == "delete" )
177 {
178 // create the path array
179 $category = new eZArticleCategory( $ID );
180 $path =& $category->path();
181 if ( $category->id() != 0 )
182 {
183 $par[] = createURLStruct( "ezarticle", "category", 0 );
184 }
185 else
186 {
187 $par[] = createURLStruct( "ezarticle", "" );
188 }
189 foreach( $path as $item )
190 {
191 if ( $item[0] != $category->id() )
192 $par[] = createURLStruct( "ezarticle", "category", $item[0] );
193 }
194
195 $ReturnData = new eZXMLRPCStruct( array( "Location" => createURLStruct( "ezarticle", "category", $ID ),
196 "Path" => new eZXMLRPCArray( $par ),
197 "UpdateType" => new eZXMLRPCString( $Command )
198 )
199 );
200 $Command = "update";
201 // Delete the cache
202 $parentid = $category->parent( false );
203 eZArticleTool::deleteCache( 0, $parentid, 0 );
204 eZArticleTool::deleteCache( 0, $ID, 0 );
205 eZArticleCategory::delete( $ID ); // finally, delete the articlecategory..
206 }
207
208 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$group
$group
Definition: admin/articleedit.php:799
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleCategory\delete
delete( $catID=-1)
Definition: ezarticlecategory.php:138
eZArticleCategory\sectionIDStatic
static sectionIDStatic($categoryID)
Definition: ezarticlecategory.php:662
eZArticleTool\deleteCache
static deleteCache( $ArticleID, $CategoryID, $CategoryArray)
Definition: ezarticletool.php:52
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
$item
$item
Definition: classes/admin/linklist.php:228
EZARTICLE_NONEXISTING_PARENT
const EZARTICLE_NONEXISTING_PARENT
Definition: ezarticle/xmlrpc/datasupplier.php:29
$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
$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+.