Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/xmlrpc/xmlrpcserver.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: xmlrpcserver.php 6304 2001-07-29 23:31:17Z kaid $
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 ob_end_clean();
28 ob_start();
29
30 // site information
31 // include_once( "classes/INIFile.php" );
32 $ini =& eZINI::instance( 'site.ini' );
33 $GlobalSiteIni =& $ini;
34
35
36 // include_once( "classes/ezlocale.php" );
37
38
39 // eZ user
40 // include_once( "ezuser/classes/ezuser.php" );
41 // include_once( "ezuser/classes/ezpermission.php" );
42
43 // eZ article classes
44 // include_once( "ezarticle/classes/ezarticlecategory.php" );
45 // include_once( "ezarticle/classes/ezarticle.php" );
46 // include_once( "ezarticle/classes/ezarticlegenerator.php" );
47 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
48
49
50 // include the server
51 // include_once( "ezxmlrpc/classes/ezxmlrpcserver.php" );
52
53 // include the datatype(s) we need
54 // include_once( "ezxmlrpc/classes/ezxmlrpcstring.php" );
55 // include_once( "ezxmlrpc/classes/ezxmlrpcint.php" );
56 // include_once( "ezxmlrpc/classes/ezxmlrpcdouble.php" );
57 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
58 // include_once( "ezxmlrpc/classes/ezxmlrpcresponse.php" );
59
60 // for payment information
61 // include_once( "eztrade/classes/ezcheckout.php" );
62
63 $server = new eZXMLRPCServer( );
64
65 $server->registerFunction( "newArticle",
66 array( new eZXMLRPCString(),
67 new eZXMLRPCString(),
68 new eZXMLRPCString() ) );
69
70 $server->registerFunction( "login",
71 array( new eZXMLRPCString(),
72 new eZXMLRPCString() ) );
73
74 $server->registerFunction( "articleCategoryTree",
75 array( new eZXMLRPCString(),
76 new eZXMLRPCString() ) );
77
78
79
80 // process the server requests
81 $server->processRequest();
82
83 //
84 // Will add a new article to the archive.
85 // The ID of the article will be returned.
86 //
87 function &newArticle( $args )
88 {
89 // $user = new eZUser();
90 // $user = $user->validateUser( $args[0]->value(), $args[1]->value() );
91
92 $title = $args[0]->value();
93 $contents = $args[1]->value();
94 $readMore = $args[2]->value();
95
96 print( $title );
97 print( $body );
98 print( $readMore );
99
100
101 $generator = new eZArticleGenerator();
102
103 $user = new eZUser( 2 );
104 $article = new eZArticle( );
105 $article->setAuthor( $user );
106
107 $article->setName( $title );
108 $article->setContents( $contents );
109
110 // only one page
111 $article->setPageCount( 1 );
112
113 $article->setAuthorText( "XML-RPC imported article" );
114 $article->setLinkText( $readMore );
115
116 $article->store(); // to get the ID
117
118 $WriteGroupArray[0] = 0;
119 if( isset( $WriteGroupArray ) )
120 {
121 if( $WriteGroupArray[0] == 0 )
122 {
123 eZObjectPermission::setPermission( -1, $article->id(), "article_article", 'w' );
124 }
125 else
126 {
127 eZObjectPermission::removePermissions( $article->id(), "article_article", 'w' );
128 foreach ( $WriteGroupArray as $groupID )
129 {
130 eZObjectPermission::setPermission( $groupID, $article->id(), "article_article", 'w' );
131 }
132 }
133 }
134 else
135 {
136 eZObjectPermission::removePermissions( $article->id(), "article_article", 'w' );
137 }
138
139 $GroupArray[0] = 0;
140 /* read access thingy */
141 if ( isset( $GroupArray ) )
142 {
143 if( $GroupArray[0] == 0 )
144 {
145 eZObjectPermission::setPermission( -1, $article->id(), "article_article", 'r' );
146 }
147 else // some groups are selected.
148 {
149 eZObjectPermission::removePermissions( $article->id(), "article_article", 'r' );
150 foreach ( $GroupArray as $groupID )
151 {
152 eZObjectPermission::setPermission( $groupID, $article->id(), "article_article", 'r' );
153 }
154 }
155 }
156 else
157 {
158 eZObjectPermission::removePermissions( $article->id(), "article_article", 'r' );
159 }
160
161
162 $article->setIsPublished( true );
163
164 // no keywords..
165 $article->setKeywords( "" );
166 $article->store();
167
168 // add to categories
169 $category = new eZArticleCategory( 1 );
170 $category->addArticle( $article );
171
172 $article->setCategoryDefinition( $category );
173
174 $articleID = $article->id();
175
176 $tmp = new eZXMLRPCInt( $articleID );
177
178 return $tmp;
179 }
180
181 function &login( $args )
182 {
183 $user = new eZUser();
184 $user = $user->validateUser( $args[0]->value(), $args[1]->value() );
185
186 if ( is_a( $user, "eZUser" ) and eZPermission::checkPermission( $user, "eZUser", "AdminLogin" ) )
187 {
188
189 $ret = new eZXMLRPCString( "Login success" );
190 }
191 else
192 {
193 $ret = new eZXMLRPCResponse( );
194 $ret->setError( 100, "Authorization failed." );
195 }
196
197 return $ret;
198 }
199
200 function &articleCategoryTree( $args )
201 {
202 $user = new eZUser();
203 $user = $user->validateUser( $args[0]->value(), $args[1]->value() );
204
205 if ( is_a( $user, "eZUser" ) and eZPermission::checkPermission( $user, "eZUser", "AdminLogin" ) )
206 {
207 $category = new eZArticleCategory();
208 $categoryTree =& $category->getTree();
209
210 $cat = array();
211 foreach ( $categoryTree as $catItem )
212 {
213 $cat[] = new eZXMLRPCStruct( array( "ID" => new eZXMLRPCInt( $catItem[0]->id() ),
214 "ParentID" => new eZXMLRPCInt( $catItem[0]->parent( false ) ),
215 "Name" => new eZXMLRPCString( $catItem[0]->name() ),
216 "Level" => new eZXMLRPCInt( $catItem[1] ) ) );
217
218 }
219
220 $ret = new eZXMLRPCArray( $cat );
221
222 }
223 else
224 {
225 $ret = new eZXMLRPCResponse( );
226 $ret->setError( 100, "Authorization failed." );
227 }
228
229 return $ret;
230 }
231
232
233
234 ob_end_flush();
235 exit();
236 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$article
$article
Definition: articlelog.php:45
$tmp
$tmp
Definition: bugview.php:99
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleGenerator
Definition: ezarticlegenerator.php:40
eZArticle
Definition: ezarticle.php:82
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZObjectPermission\removePermissions
static removePermissions( $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:320
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZUser
Definition: ezuser.php:76
eZXMLRPCArray
Definition: ezxmlrpcarray.php:37
eZXMLRPCInt
Definition: ezxmlrpcint.php:37
eZXMLRPCResponse
Definition: ezxmlrpcresponse.php:50
eZXMLRPCServer
Definition: ezxmlrpcserver.php:82
eZXMLRPCString
Definition: ezxmlrpcstring.php:37
eZXMLRPCStruct
Definition: ezxmlrpcstruct.php:37
$args
$args
Definition: companytypelist.php:125
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
articleCategoryTree
& articleCategoryTree( $args)
Definition: ezarticle/xmlrpc/xmlrpcserver.php:200
$ini
$ini
Definition: ezarticle/xmlrpc/xmlrpcserver.php:32
newArticle
& newArticle( $args)
Definition: ezarticle/xmlrpc/xmlrpcserver.php:87
$server
$server
Definition: ezarticle/xmlrpc/xmlrpcserver.php:63
login
& login( $args)
Definition: ezarticle/xmlrpc/xmlrpcserver.php:181
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$groupID
$groupID
Definition: ezgroupeventcalendar/user/dayview.php:90
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
exit
exit
Definition: folder.php:81
$user
$user
Definition: user/adlist.php:39
$articleID
if( $Action=="New") $articleID
Definition: user/articleedit.php:269
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.