Develop and Download Open Source Software

Browse CVS Repository

Contents of /xoonips/AL/xnpal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download) (as text)
Wed Dec 1 01:39:55 2004 UTC (19 years, 4 months ago) by aga
Branch: MAIN
Changes since 1.7: +52 -21 lines
File MIME type: text/x-c++src
。ヲvp_dump_group_admins()コ?ョ.

1 /*
2 VPAL: Visiome Platform Abstract Layer
3
4 zend_parse_parameters縺ッphp4.1.0縺悟ソ?ヲ?/span>
5 .so繝輔ぃ繧、繝ォ縺ッ螟悶°繧芽ヲ九∴縺ェ縺??エ謇?縺ォ鄂ョ縺上∋縺阪??/span>
6 C++縺ァ縺ッ縲‘xtern "C"{}, BEGIN/END_EXTERN_C()縺悟ソ?ヲ√??/span>
7 */
8
9
10 #include <stdio.h>
11 #include "criteria.h"
12 #include "common.h"
13 #include "commonal.h"
14 #include "session.h"
15 #include "group.h"
16 #include "account.h"
17 #include "vpal.h"
18
19 // for inet_aton
20 #include <sys/socket.h>
21 #include <netinet/in.h>
22 #include <arpa/inet.h>
23
24 // global variables
25 MYSQL *mysql = NULL;
26
27
28 /* declaration of functions to be exported */
29 extern "C" {
30 ZEND_FUNCTION(first_module );
31 ZEND_FUNCTION(vp_initialize_db );
32 ZEND_FUNCTION(vp_login_user );
33 ZEND_FUNCTION(vp_logout_user );
34 ZEND_FUNCTION(vp_create_session );
35 ZEND_FUNCTION(vp_get_session );
36 ZEND_FUNCTION(vp_is_activated );
37 ZEND_FUNCTION(vp_activate );
38 ZEND_FUNCTION(vp_get_account_count );
39 ZEND_FUNCTION(vp_delete_account );
40 ZEND_FUNCTION(vp_get_account );
41 ZEND_FUNCTION(vp_get_accounts );
42 ZEND_FUNCTION(vp_insert_account );
43 ZEND_FUNCTION(vp_update_account );
44 ZEND_FUNCTION(vp_dump_uids );
45 ZEND_FUNCTION(vp_get_group_count );
46 ZEND_FUNCTION(vp_get_groups_by_uid );
47 ZEND_FUNCTION(vp_is_group_admin );
48 ZEND_FUNCTION(vp_dump_gids );
49 ZEND_FUNCTION(vp_dump_group_admins );
50 /*
51 ZEND_FUNCTION(vp_delete_member );
52 ZEND_FUNCTION(vp_insert_member );
53 ZEND_FUNCTION(vp_get_members );
54 ZEND_FUNCTION(vp_delete_group );
55 ZEND_FUNCTION(vp_insert_group );
56 */
57 ZEND_FUNCTION(vp_update_group );
58 ZEND_FUNCTION(vp_get_group );
59 ZEND_FUNCTION(vp_get_groups );
60 ZEND_FUNCTION(vp_is_moderator );
61 ZEND_FUNCTION(vp_get_uid );
62
63 ZEND_FUNCTION(vp_test_criteria );
64 ZEND_FUNCTION(vp_test_uids );
65 };
66 /* compiled function list so Zend knows what's in this module */
67 zend_function_entry vpalmod_functions[] =
68 {
69 ZEND_FE(first_module ,NULL)
70 ZEND_FE(vp_initialize_db ,NULL)
71 ZEND_FE(vp_login_user ,NULL)
72 ZEND_FE(vp_logout_user ,NULL)
73 ZEND_FE(vp_create_session ,NULL)
74 ZEND_FE(vp_get_session ,NULL)
75 ZEND_FE(vp_is_activated ,NULL)
76 ZEND_FE(vp_activate ,NULL)
77 ZEND_FE(vp_get_account_count ,NULL)
78 ZEND_FE(vp_delete_account ,NULL)
79 ZEND_FE(vp_get_account ,NULL)
80 ZEND_FE(vp_get_accounts ,NULL)
81 ZEND_FE(vp_insert_account ,NULL)
82 ZEND_FE(vp_update_account ,NULL)
83 ZEND_FE(vp_dump_uids ,NULL)
84 ZEND_FE(vp_get_group_count ,NULL)
85 ZEND_FE(vp_get_groups_by_uid ,NULL)
86 ZEND_FE(vp_is_group_admin ,NULL)
87 ZEND_FE(vp_dump_gids ,NULL)
88 ZEND_FE(vp_dump_group_admins ,NULL)
89 /*
90 ZEND_FE(vp_delete_member ,NULL)
91 ZEND_FE(vp_insert_member ,NULL)
92 ZEND_FE(vp_get_members ,NULL)
93 ZEND_FE(vp_delete_group ,NULL)
94 ZEND_FE(vp_insert_group ,NULL)
95 */
96 ZEND_FE(vp_update_group ,NULL)
97 ZEND_FE(vp_get_group ,NULL)
98 ZEND_FE(vp_get_groups ,NULL)
99 ZEND_FE(vp_is_moderator ,NULL)
100 ZEND_FE(vp_get_uid ,NULL)
101 ZEND_FE(vp_test_criteria ,NULL)
102 ZEND_FE(vp_test_uids ,NULL)
103 {NULL, NULL, NULL}
104 };
105
106 /* compiled module information */
107 zend_module_entry vpalmod_module_entry =
108 {
109 STANDARD_MODULE_HEADER,
110 "Visiome Platform Abstract Layer",
111 vpalmod_functions,
112 NULL,
113 NULL,
114 NULL,
115 NULL,
116 NULL,
117 NO_VERSION_YET,
118 STANDARD_MODULE_PROPERTIES
119 };
120
121 /* implement standard "stub" routine to introduce ourselves to Zend */
122 #if COMPILE_DL_FIRST_MODULE
123 BEGIN_EXTERN_C()
124 ZEND_GET_MODULE(vpalmod)
125 END_EXTERN_C()
126 #endif
127
128 /* implement function that is meant to be made available to PHP */
129 ZEND_FUNCTION(first_module)
130 {
131 long parameter;
132 // if(ZEND_NUM_ARGS() != 2) WRONG_PARAM_COUNT;
133 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &parameter) == FAILURE) {
134 return;
135 }
136 parameter++;
137 RETURN_LONG(parameter);
138 }
139 /** zval縺九iC縺ョ譁?ュ怜?繧貞セ励k縲?/span>
140 */
141 char *getZvalString( zval **p ){
142 convert_to_string_ex(p);
143 return Z_STRVAL_PP(p); //(**p).value.str.val;
144 }
145
146 /** zval縺九iint繧貞セ励k縲?/span>
147 */
148 int getZvalInt( zval **p ){
149 convert_to_long_ex(p);
150 return Z_LVAL_PP(p); // (int)(**p).value.lval;
151 }
152
153 // keylen縺ッ譛ォ蟆セ縺ョ\0繧貞性繧?縲?/span>
154 static void print_hash_key( int res, const char *key, uint keyLen, ulong index ){
155 zend_printf( "print_hash_key : key=0x%08x keylen=%08d index=%08d<br> ", key, keyLen, index );
156 if ( res == HASH_KEY_IS_STRING ){
157 char *p = new char[keyLen+1];
158 memcpy( p, key, keyLen );
159 p[keyLen] = 0;
160 zend_printf( " key is string[%s]<br>\n", p );
161 }
162 else {
163 zend_printf( " key is integer[%d]<br>\n", index );
164 }
165 }
166
167
168 /** zval**縺九icriteria_t繧堤函謌舌☆繧九◆繧√?繧ッ繝ゥ繧ケ縲ら函謌仙、ア謨励↑繧曳etResult()!=RES_OK
169 * criteria :
170 array( 'start'=>0, 'rows'=>10,
171 'orders'=>array(
172 array('name'=>'id','order'=>'0'),
173 array('name'=>'timestamp','name'=>'1'), ...)
174 ); 縺薙s縺ェ蠖「縺ョ騾」諠ウ驟榊?
175 */
176 class zCriteria_t : public criteria {
177 private:
178 result_t result;
179 public:
180 // pz: array('name'=>'timestamp','name'=>'1')
181 // 縺薙l縺九iorderby繧剃ス懈?縺励※霑ス蜉?縲?/span>
182 void setOrder( zval *pz ){
183 char *column = 0;
184 order_t order = (order_t)0;
185
186 HashPosition pos;
187 zval **ppzTmp = 0;
188 int res2;
189 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
190 while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
191 char *key = 0;
192 uint keyLen = 0;
193 ulong index = 0;
194 int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
195 if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
196 print_hash_key( keyType, key, keyLen, index );
197 if ( strncasecmp( key, "column", keyLen ) == 0 && keyLen == 7 ){
198 SEPARATE_ZVAL(ppzTmp);
199 column = getZvalString(ppzTmp);
200 // zend_printf( "column=%s<br>\n", column );
201 }
202 else if ( strncasecmp( key, "order", keyLen ) == 0 && keyLen == 6 ){
203 SEPARATE_ZVAL(ppzTmp);
204 order = (order_t)getZvalInt(ppzTmp);
205 // zend_printf( "order=%d<br>\n", order );
206 }
207 }
208
209 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
210 }
211 if ( column ){
212 orderby *o = new orderby( column, order );
213 addOrderBy( o );
214 }
215
216 result = RES_OK;
217 }
218
219 // pz: array( array('column'=>'hoge','order'=>'1'), array('column'=>'huga','order'=>'2'), ...)
220 void setOrders( zval *pz ){
221 HashPosition pos;
222
223 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
224
225 zval **ppzTmp = 0;
226 int res2;
227 while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
228 char *key = 0;
229 uint keyLen = 0;
230 ulong index = 0;
231 int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
232 if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
233 print_hash_key( keyType, key, keyLen, index );
234 setOrder( *ppzTmp );
235 }
236 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
237 }
238 result = RES_OK;
239 }
240
241 void initialize( zval *pz ){
242 HashPosition pos;
243 zval **ppzTmp = 0;
244 int res2;
245 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
246 while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
247 char *key = 0;
248 uint keyLen = 0;
249 ulong index = 0;
250 int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
251 if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
252 print_hash_key( keyType, key, keyLen, index );
253 if ( strncasecmp( key, "start", keyLen ) == 0 && keyLen == 6 ){
254 SEPARATE_ZVAL(ppzTmp);
255 int tmp = getZvalInt(ppzTmp);
256 // zend_printf( "start=%d<br>\n", tmp );
257 setLimit( tmp, getLimitRows() );
258 }
259 else if ( strncasecmp( key, "rows", keyLen ) == 0 && keyLen == 5 ){
260 SEPARATE_ZVAL(ppzTmp);
261 int tmp = getZvalInt(ppzTmp);
262 // zend_printf( "rows=%d<br>\n", tmp );
263 setLimit( getLimitStart(), tmp );
264 }
265 else if ( strncasecmp( key, "orders", keyLen ) == 0 && keyLen == 7 ){
266 setOrders( *ppzTmp );
267 }
268 else
269 ; // ignore unknown key
270 }
271 else
272 ; // ignore bad key
273 zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
274 }
275 result = RES_OK;
276 }
277 zCriteria_t() : criteria(){ result = RES_ERROR; }
278 zCriteria_t( zval *pz ) : criteria(){ initialize(pz); }
279 zCriteria_t( zval **ppz ) : criteria() { initialize(*ppz); }
280 result_t getResult(){ return result; };
281
282 void dump(){
283 zend_printf( "dumping zCriteria...<br>\n" );
284 zend_printf( "result=%d<br>\n", (int)result );
285 zend_printf( "start=%d, rows=%d<br>\n", getLimitStart(), getLimitRows() );
286 const orderby *p = headOrderBy();
287 while ( p ){
288 zend_printf( "column=%s, order=%d<br>\n", p->getColumn(), p->getOrder() );
289 p = nextOrderBy();
290 }
291 }
292 };
293
294
295 class zAccount_t : public account {
296 private:
297 result_t result;
298 public:
299 void initialize(zval *pz){
300 ; // todo
301 }
302 zAccount_t() : account(){ result = RES_ERROR; }
303 zAccount_t( zval *pz ) : account(){ initialize(pz); }
304 zAccount_t( zval **ppz ) : account() { initialize(*ppz); }
305 result_t getResult(){ return result; };
306 };
307
308 /** zval**縺九i(userid_t *puid,int uidLen)繧堤函謌舌☆繧九◆繧√?繧ッ繝ゥ繧ケ縲ら函謌仙、ア謨励↑繧曳etResult()!=RES_OK
309 uids : array( '1', '3', '4', '6', ... ); 縺薙s縺ェ蠖「縺ョ驟榊?
310 */
311 class zUIDs_t {
312 private:
313 result_t result;
314 userid_t *pUID;
315 int len;
316 public:
317 zUIDs_t(){
318 pUID = 0;
319 len = 0;
320 result = RES_ERROR;
321 }
322
323 zUIDs_t( zval *pza ){
324 pUID = 0;
325 len = 0;
326 result = RES_ERROR;
327
328 if ( Z_TYPE_P(pza) != IS_ARRAY ){
329 result = RES_ERROR;
330 }
331 else {
332 len = zend_hash_num_elements(Z_ARRVAL_P(pza));
333 if(len == 0) {
334 pUID = new userid_t[1];
335 result = RES_OK;
336 }
337 else {
338 /* php/ext/standard/string.c 縺ョ implode縺ョ縺ゅ◆繧翫r蜿り??↓縲?/span>
339 zend_hash_*縺ョ繝峨く繝・繝。繝ウ繝医▲縺ヲ縺ゅk縺ョ縺?繧阪≧縺具シ?/span>
340 */
341 zval **tmp;
342 HashPosition pos;
343 int i = 0;
344 pUID = new userid_t[len];
345
346 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
347 while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
348 SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html 蜿ら?
349 convert_to_long_ex(tmp);
350 if ( i < len )
351 pUID[i++] = Z_LVAL_PP(tmp);
352 zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
353 }
354 len = i;
355 result = RES_OK;
356 }
357 }
358 }
359
360 ~zUIDs_t(){
361 if ( pUID ) delete[] pUID;
362 }
363 result_t getResult(){ return result; }
364 userid_t *getPUID(){ return pUID; }
365 int getLen(){ return len; }
366 void dump(){
367 zend_printf( "dumping zUIDs...<br>\n" );
368 zend_printf( "result=%d<br>\n", (int)result );
369 zend_printf( "len=%d<br>\n", len );
370 for ( int i = 0; i < len; i++ ){
371 zend_printf( "pUID[%d] = %d<br>\n", i, pUID[i] );
372 }
373 }
374 };
375
376 /**
377 *
378 * uids_t縺ョ驟榊?繧単HP縺ョ驟榊?縺ォ螟画鋤縺吶k
379 *
380 * @param pUID 螟画鋤繧ゅ→縺ョuserid_t縺ョ驟榊?
381 * @param len pUID縺ョ驟榊?縺ョ髟キ縺?/span>
382 * @param pz 螟画鋤邨先棡繧呈嶌縺崎セシ繧?驟榊?(蛻晄悄蛹匁ク医∩縺ァ縺ゅk縺薙→)
383 * @return RES_OK
384 *
385 */
386 result_t uidsToZval( userid_t *pUID, int len, zval **ppz )
387 {
388 zend_hash_clean( Z_ARRVAL_PP(ppz) );
389
390 // add UIDs
391 for ( int i = 0; i < len; i++ ){
392 add_next_index_long(*ppz, (long)(pUID[i]) );
393 }
394
395 return RES_OK;
396 }
397 /** groupid_t 竊 zval
398 */
399 result_t gidsToZval( groupid_t *pGID, int len, zval **ppz )
400 {
401 zend_hash_clean( Z_ARRVAL_PP(ppz) );
402
403 // add GIDs
404 for ( int i = 0; i < len; i++ ){
405 add_next_index_long(*ppz, (long)(pGID[i]) );
406 }
407
408 return RES_OK;
409 }
410
411 result_t accountToZval( const account_t *pAccount, zval *z )
412 {
413 zend_hash_clean( z -> value.ht );
414
415 add_assoc_long( z, "uid", pAccount -> getUID( ) );
416 add_assoc_string( z, "uname", ( char* )pAccount -> getUname( ), 1 );
417 add_assoc_string( z, "name", ( char* )pAccount -> getName( ), 1 );
418 add_assoc_string( z, "email", ( char* )pAccount -> getEmail( ), 1 );
419 add_assoc_string( z, "url", ( char* )pAccount -> getURL( ), 1 );
420 add_assoc_string( z, "user_avatar", ( char* )pAccount -> getUserAvatar( ), 1 );
421 add_assoc_string( z, "user_icq", ( char* )pAccount -> getUserIcq( ), 1 );
422 add_assoc_string( z, "user_from", ( char* )pAccount -> getUserFrom( ), 1 );
423 add_assoc_string( z, "user_sig", ( char* )pAccount -> getUserSig( ), 1 );
424 add_assoc_string( z, "actkey", ( char* )pAccount -> getActkey( ), 1 );
425 add_assoc_string( z, "user_aim", ( char* )pAccount -> getUserAim( ), 1 );
426 add_assoc_string( z, "user_yim", ( char* )pAccount -> getUserYim( ), 1 );
427 add_assoc_string( z, "user_msnm", ( char* )pAccount -> getUserMsnm( ), 1 );
428 add_assoc_string( z, "pass", ( char* )pAccount -> getPass( ), 1 );
429 add_assoc_string( z, "theme", ( char* )pAccount -> getTheme( ), 1 );
430 add_assoc_string( z, "umode", ( char* )pAccount -> getUmode( ), 1 );
431 add_assoc_string( z, "user_occ", ( char* )pAccount -> getUserOcc( ), 1 );
432 add_assoc_string( z, "bio", ( char* )pAccount -> getBio( ), 1 );
433 add_assoc_string( z, "user_intrest", ( char* )pAccount -> getUserIntrest( ), 1 );
434 add_assoc_double( z, "timezone_offset", pAccount -> getTimezoneOffset( ) );
435 add_assoc_long( z, "attachsig", pAccount -> getAttachsig( ) );
436 add_assoc_long( z, "last_login", pAccount -> getLastLogin( ) );
437 add_assoc_long( z, "level", pAccount -> getLevel( ) );
438 add_assoc_long( z, "notify_method", pAccount -> getNotifyMethod( ) );
439 add_assoc_long( z, "notify_mode", pAccount -> getNotifyMode( ) );
440 add_assoc_long( z, "posts", pAccount -> getPosts( ) );
441 add_assoc_long( z, "rank", pAccount -> getRank( ) );
442 add_assoc_long( z, "uorder", pAccount -> getUorder( ) );
443 add_assoc_long( z, "user_mailok", pAccount -> getUserMailok( ) );
444 add_assoc_long( z, "user_regdate", pAccount -> getUserRegdate( ) );
445 add_assoc_long( z, "user_viewemail", pAccount -> getUserViewemail( ) );
446
447 add_assoc_long( z, "activate", pAccount -> getActivate( ) );
448 add_assoc_string( z, "address", ( char* )pAccount -> getAddress( ), 1 );
449 add_assoc_string( z, "institute", ( char* )pAccount -> getInstitute( ), 1 );
450 add_assoc_string( z, "tel", ( char* )pAccount -> getTel( ), 1 );
451 add_assoc_string( z, "organization", ( char* )pAccount -> getOrganization( ), 1 );
452 add_assoc_string( z, "country", ( char* )pAccount -> getCountry( ), 1 );
453 add_assoc_string( z, "zipcode", ( char* )pAccount -> getZipcode( ), 1 );
454 add_assoc_string( z, "fax", ( char* )pAccount -> getFax( ), 1 );
455 add_assoc_string( z, "base_url", ( char* )pAccount -> getBaseURL( ), 1 );
456 add_assoc_long( z, "notice_mail", pAccount -> getNoticeMail( ) );
457 add_assoc_long( z, "notice_mail_since", pAccount -> getNoticeMailSince( ) );
458 return RES_OK;
459 }
460
461 /** accounts 竊 zval
462 * accounts: 縺薙s縺ェ諢溘§縺ョ驟榊?
463 array(
464 array(
465 'uid'=>100,
466 'activate'=>1,
467 'institute'=>'foo',
468 'tel'=>'123-456-789',
469 ...
470 ),
471 ...
472 )
473 */
474 result_t accountsToZval( const account_t *pAccounts, int accountsLen, zval *z )
475 {
476 zend_hash_clean( z -> value.ht );
477 for( int i = 0; i < accountsLen; i++ ){
478 zval *new_array;
479 MAKE_STD_ZVAL(new_array);
480 if(array_init(new_array) != SUCCESS){
481 return RES_ERROR;
482 }
483 add_index_zval( z, i, new_array );
484 accountToZval( &pAccounts[ i ], new_array );
485 }
486 return RES_OK;
487 }
488
489 /** groups 竊 zval
490 */
491 result_t groupsToZval( const group_t *pGroups, int groupsLen, zval *z )
492 {
493 zend_hash_clean( z -> value.ht );
494 for( int i = 0; i < groupsLen; i++ ){
495 zval *new_array;
496 MAKE_STD_ZVAL(new_array);
497 if(array_init(new_array) != SUCCESS){
498 return RES_ERROR;
499 }
500 add_index_zval( z, i, new_array );
501 add_assoc_long( new_array, "gid", pGroups[ i ].getGID( ) );
502 add_assoc_string( new_array, "gname", ( char* )pGroups[ i ].getGname( ), 1 );
503 add_assoc_string( new_array, "gdesc", ( char* )pGroups[ i ].getDesc( ), 1 );
504 }
505 return RES_OK;
506 }
507
508 /**
509 *
510 * group_t縺ョ蜀?ョケ繧単HP縺ョ騾」諠ウ驟榊?縺ォ螟画鋤縺吶k
511 *
512 * @param pGroup 螟画鋤繧ゅ→縺ョ繧ー繝ォ繝シ繝玲ュ蝣ア
513 * @param z 螟画鋤邨先棡繧呈嶌縺崎セシ繧?騾」諠ウ驟榊?(蛻晄悄蛹匁ク医∩縺ァ縺ゅk縺薙→)
514 * @return RES_OK
515 *
516 */
517 result_t groupToZval( const group_t *pGroup, zval *z )
518 {
519 zend_hash_clean( z -> value.ht );
520 add_assoc_long( z, "gid", pGroup -> getGID( ) );
521 add_assoc_string( z, "gname", ( char* )pGroup -> getGname( ), 1 );
522 add_assoc_string( z, "gdesc", ( char* )pGroup -> getDesc( ), 1 );
523 return RES_OK;
524 }
525
526 /** zval 竊 group
527 */
528 result_t zvalToGroup( zval *z, group_t *pGroup )
529 {
530 zval **tmp;
531 HashPosition pos;
532 int i = 0;
533 char* key = 0;
534
535 key = "gid";
536 zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp );
537 convert_to_long_ex( tmp ) ;
538 pGroup -> setGID( (*tmp) -> value.lval );
539
540 key = "gname";
541 zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp );
542 convert_to_string_ex( tmp ) ;
543 pGroup -> setGname( (*tmp) -> value.str.val );
544
545 key = "gdesc";
546 zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp );
547 convert_to_string_ex( tmp ) ;
548 pGroup -> setDesc( (*tmp) -> value.str.val );
549
550 return RES_OK;
551 }
552
553
554 // int vp_get_group( int sid, int gid, array group );
555 ZEND_FUNCTION(vp_get_group)
556 {
557 long sid, gid;
558 zval *zgroup;
559
560 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
561 &sid, &gid, &zgroup) == FAILURE) {
562 return;
563 }
564
565 const group_t *pgroup;
566 result_t result = getGroup( (sessionid_t)sid, (groupid_t)gid, &pgroup );
567 if ( RES_OK == result ){
568 groupToZval( pgroup, zgroup );
569 freeResult( pgroup );
570 }
571
572 RETURN_LONG(result);
573 }
574
575
576 // int vp_get_groups( int sid, array gids, array criteria, array groups );
577 ZEND_FUNCTION(vp_get_groups)
578 {
579 result_t result;
580 long sid, uid;
581 zval *zcriteria;
582 zval *zgids;
583 zval *zgroups;
584 zval **ppzTmp = 0;
585 HashPosition pos;
586 int res2;
587 int gidsLen;
588 const group_t* groups;
589 int groupsLen;
590
591 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
592 &sid, &zgids, &zcriteria, &zgroups) == FAILURE) {
593 return;
594 }
595
596 //gids縺ォ繧ー繝ォ繝シ繝悠D繧偵さ繝斐?縺吶k
597 gidsLen = zend_hash_num_elements(Z_ARRVAL_P(zgids));
598 groupid_t *gids = new groupid_t[ gidsLen ];
599 zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zgids), &pos);
600 for( int i = 0; i < gidsLen; i++ ){
601 if( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(zgids), (void **)&ppzTmp, &pos)) == SUCCESS ){
602 SEPARATE_ZVAL(ppzTmp);
603 convert_to_long_ex(ppzTmp);
604 gids[ i ] = Z_LVAL_PP(ppzTmp);
605 }
606 zend_hash_move_forward_ex(Z_ARRVAL_P(zgids), &pos);
607 }
608
609 zCriteria_t zcri(zcriteria);
610 result = zcri.getResult();
611 if ( RES_OK == result ){
612 result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen );
613 if ( RES_OK == result ){
614 delete[] gids;
615 freeResult( groups );
616 }
617 }
618 groupsToZval( groups, groupsLen, zgroups );
619 RETURN_LONG(result);
620 }
621
622
623 // int vp_is_moderator(string uname)
624 ZEND_FUNCTION(vp_is_moderator)
625 {
626 long vpSessionID;
627 userid_t uid;
628
629 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
630 &vpSessionID, &uid) == FAILURE) {
631 return;
632 }
633
634 bool result = isModerator( (sessionid_t)vpSessionID, uid );
635 RETURN_BOOL(result)
636 }
637
638 // int vp_get_uid(string uname)
639 ZEND_FUNCTION(vp_get_uid)
640 {
641 char *uname;
642 int unameLen;
643 userid_t uid;
644
645 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
646 &uname, &unameLen) == FAILURE) {
647 return;
648 }
649
650 string strUname( uname, unameLen );
651 result_t result = getUid( strUname.c_str(), &uid );
652 if ( result == RES_OK ){
653 RETURN_LONG((long)uid);
654 }
655 else {
656 //zend_printf( "vpal_debug: vp_get_uid(%s): result=%d<br>\n", strUname.c_str(),(int)result );
657 RETURN_FALSE
658 }
659 }
660
661 /** session 竊 zval
662 */
663 result_t sessionToZval( const session_t *pSession, zval *z )
664 {
665 string sessionID(unsignedIntToString(pSession->getSessionID()));
666 add_assoc_string(z, "session_id", (char *)sessionID.c_str(), 1);
667
668 string date(unsignedIntToString((unsigned int)pSession->getDate()));
669 add_assoc_string(z, "date", (char *)date.c_str(), 1);
670
671 string userID(unsignedIntToString((unsigned int)pSession->getUserID()));
672 add_assoc_string(z, "user_id", (char *)userID.c_str(), 1);
673
674 return RES_OK;
675 }
676
677 ZEND_FUNCTION(vp_test_criteria)
678 {
679 zval *z;
680
681 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
682 &z) == FAILURE) {
683 return;
684 }
685 zend_printf("zend_printf...<br>\n");
686 zCriteria_t zcri(z);
687 zcri.dump();
688 RETURN_FALSE
689 }
690
691 ZEND_FUNCTION(vp_test_uids)
692 {
693 zval *z;
694
695 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
696 &z) == FAILURE) {
697 return;
698 }
699 zend_printf("zend_printf...<br>\n");
700 zUIDs_t zuids(z);
701 zuids.dump();
702 RETURN_FALSE
703 }
704
705
706
707 /** DB縺ォ謗・邯壹☆繧九?よ里縺ォ謗・邯壻クュ縺ョ謗・邯壹?髢峨§繧峨l繧九??lt;br>
708 int initialize_db( string host[, string user[, string password[, string dbname[, string prefix]]]] );
709 @param host 謗・邯壼?縲ら怐逡・譎ゅ?NULL
710 @param user DB謗・邯壽凾縺ョ繝ヲ繝シ繧カ蜷阪?ら怐逡・譎ゅ?NULL
711 @param password DB謗・邯壽凾縺ョ繝代せ繝ッ繝シ繝峨?ら怐逡・譎ゅ?NULL
712 @param dbname DB謗・邯壽凾縺ョDB蜷阪?ら怐逡・譎ゅ?""
713 @param prefix XOOPS DB 縺ョprefix縲?/span>
714 @return 0 success <br>
715 */
716 ZEND_FUNCTION(vp_initialize_db)
717 {
718 zval **parameters[5];
719 char *host;
720 char *user;
721 char *password;
722 char *dbname;
723 char *prefix;
724
725 /* get the number of arguments */
726 int argNum = ZEND_NUM_ARGS();
727 if (argNum > 5)
728 WRONG_PARAM_COUNT;
729
730 /* argument count is correct, now retrieve arguments */
731 if(zend_get_parameters_array_ex(argNum, parameters) != SUCCESS)
732 WRONG_PARAM_COUNT;
733
734 if (argNum < 1) host = NULL;
735 else host = getZvalString( parameters[0] );
736
737 if (argNum < 2) user = NULL;
738 else user = getZvalString( parameters[1] );
739
740 if (argNum < 3) password = NULL;
741 else password = getZvalString( parameters[2] );
742
743 if (argNum < 4) dbname = "";
744 else dbname = getZvalString( parameters[3] );
745
746 if (argNum < 5) prefix = "";
747 else prefix = getZvalString( parameters[4] );
748
749 result_t result = initializeDB( host, user, password, dbname, prefix );
750
751 RETURN_LONG(result);
752 }
753
754 /** 繝ュ繧ー繧、繝ウ縺吶k縲?lt;br>
755 int vp_login_user(string uname, string password)
756 @param uname 繝ヲ繝シ繧カ蜷?xoops_users.uname)
757 @param password 繝代せ繝ッ繝シ繝?md5(password)=xoops_users.pass)
758 @return 0 success
759 */
760 ZEND_FUNCTION(vp_login_user)
761 {
762 char *uname;
763 int unameLen;
764 char *passwd;
765 int passwdLen;
766
767 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
768 &uname, &unameLen, &passwd, &passwdLen) == FAILURE) {
769 return;
770 }
771
772 sessionid_t vpSessionID;
773 result_t result = loginUser( uname, passwd, &vpSessionID );
774 if ( result == RES_OK ){
775 RETURN_LONG((long)vpSessionID);
776 }
777 else {
778 //zend_printf( "vpal_debug: vp_login_user(%s, %s): cannot login. result=%d<br>\n", strUname.c_str(), strPasswd.c_str(), (int)result );
779 RETURN_FALSE
780 }
781 }
782
783 /** 繝ュ繧ー繧「繧ヲ繝医☆繧九??lt;br>
784 void vp_logout_user(int vp_session_id)
785 @param vp_session_id vp縺ョsessionid
786 @return 縺ェ縺?/span>
787 */
788 ZEND_FUNCTION(vp_logout_user)
789 {
790 long vpSessionID;
791
792 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &vpSessionID) == FAILURE) {
793 return;
794 }
795 logoutUser( (sessionid_t)vpSessionID );
796
797 RETURN_NULL();
798 }
799
800 /** vp 縺ョ session id 菴懈?<br>
801 int vp_create_session( string xoops_sess_id, int uid, string remote_host )
802 @param xoops_sess_id xoops縺ョsession id
803 @param uid xoops 縺ョ uid (xoops_users.uid)
804 @return FALSE莉・螟? vp 縺ョ session id
805 @return FALSE: 螟ア謨?/span>
806 */
807 ZEND_FUNCTION(vp_create_session)
808 {
809 char *xoopsSessionID;
810 int xoopsSessionIDLen;
811 long uid;
812
813 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl",
814 &xoopsSessionID, &xoopsSessionIDLen, &uid) == FAILURE) {
815 return;
816 }
817
818 sessionid_t vpSessionID = 0;
819 result_t result = createSession( xoopsSessionID, (userid_t)uid, &vpSessionID );
820 if ( result == RES_OK ){
821 RETURN_LONG((long)vpSessionID);
822 }
823 else {
824 RETURN_FALSE;
825 }
826 }
827
828 /** vp 縺ョ session 縺ョ隧ウ邏ー諠??ア繧貞セ励k<br>
829 int vp_get_session( int vp_session_id, array session_info )
830 @param vp_session_id vp 縺ョ session id
831 @param session_info 邨先棡繧貞女縺大叙繧矩?蛻?/span>
832 @return 0 success
833 */
834 ZEND_FUNCTION(vp_get_session)
835 {
836 long vpSessionID;
837 zval *sessionInfo;
838 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
839 &vpSessionID, &sessionInfo) == FAILURE) {
840 return;
841 }
842 const session_t *session = 0;
843 result_t result = getSession( (sessionid_t)vpSessionID, &session );
844 if ( result == RES_OK ){
845 sessionToZval( session, sessionInfo );
846 freeResult( session );
847 }
848
849 RETURN_LONG((long)result);
850 }
851
852 /** activate迥カ諷 蜿門セ?lt;br>
853 bool vp_is_activated( int vp_session_id, int user_id )
854 @param vp_session_id vp 縺ョ session id
855 @param user_id xoops_users.uid
856 @return 0 success
857 */
858 ZEND_FUNCTION(vp_is_activated)
859 {
860 long sid, uid;
861
862 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &sid, &uid) == FAILURE) {
863 return;
864 }
865
866 bool result = isActivated( (sessionid_t)sid, (userid_t)uid );
867
868 RETURN_BOOL(result);
869 }
870
871 /** activate縺吶k縲?lt;br>
872 bool vp_activate( int vp_session_id, bool activated )
873 @param vp_session_id vp 縺ョ session id
874 @param user_id xoops_users.uid
875 @param activated true:activate, false:inactivate
876 @return 0 success
877 */
878 ZEND_FUNCTION(vp_activate)
879 {
880 long sid, uid;
881 bool activated;
882
883 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llb",
884 &sid, &uid, &activated) == FAILURE) {
885 return;
886 }
887
888 result_t result = activate( (sessionid_t)sid, (userid_t)uid, activated );
889
890 RETURN_LONG(result);
891 }
892
893 /** vp縺ョ繧「繧ォ繧ヲ繝ウ繝域焚繧貞セ励k縲?lt;br>
894 int vp_get_account_count( int vp_session_id )
895 @param vp_session_id vp 縺ョ session id
896 @return 0 success
897 */
898 ZEND_FUNCTION(vp_get_account_count)
899 {
900 long sid;
901
902 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
903 &sid) == FAILURE) {
904 return;
905 }
906
907 long count = getAccountCount( (sessionid_t)sid );
908
909 RETURN_LONG(count);
910 }
911
912 /** 繧「繧ォ繧ヲ繝ウ繝医r蜑企勁縺吶k縲?lt;br>
913 bool vp_delete_account( int vp_session_id, int user_id )
914 @param vp_session_id vp 縺ョ session id
915 @param user_id xoops_users.uid
916 @return 0 success
917 */
918 ZEND_FUNCTION(vp_delete_account)
919 {
920 long sid, uid;
921
922 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
923 &sid, &uid) == FAILURE) {
924 return;
925 }
926
927 result_t result = deleteAccount( (sessionid_t)sid, (userid_t)uid );
928
929 RETURN_LONG(result);
930 }
931
932 /** 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア繧貞セ励k縲?lt;br>
933 int vp_get_account( int vp_session_id, int user_id, array account_info )
934 @param vp_session_id vp 縺ョ session id
935 @param user_id xoops_users.uid
936 @param account_info 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア繧貞女縺大叙繧矩?」諠ウ驟榊?
937 @return 0 success
938 */
939 ZEND_FUNCTION(vp_get_account)
940 {
941 long sid, uid;
942 zval *zaccount;
943
944 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
945 &sid, &uid, &zaccount) == FAILURE) {
946 fprintf( stderr, "error occured " );
947 return;
948 }
949
950 const account_t *paccount;
951 result_t result = getAccount( (sessionid_t)sid, (userid_t)uid, &paccount );
952 if ( RES_OK == result ){
953 accountToZval( paccount, zaccount );
954 freeResult( paccount );
955 }
956
957 RETURN_LONG(result);
958 }
959
960 /** 譚。莉カ縺ォ荳?閾エ縺吶k繧「繧ォ繧ヲ繝ウ繝医?諠??ア繧貞セ励k縲?lt;br>
961 int vp_get_accoutns( int sid, array uids, array criteria, array accounts );
962 @param vp_session_id vp 縺ョ session id
963 @param user_id xoops_users.uid
964 @param criteria 蜿門セ礼ッ?峇繝サ繧ス繝シ繝磯??r陦ィ縺咎?蛻?/span>
965 @param account_info 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア繧貞女縺大叙繧矩?」諠ウ驟榊?
966 @return 0 success
967 */
968 ZEND_FUNCTION(vp_get_accounts)
969 {
970 result_t result;
971 long sid;
972 zval *zuids;
973 zval *zcriteria;
974 zval *zaccount;
975
976 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
977 &sid, &zuids, &zcriteria, &zaccount) == FAILURE) {
978 return;
979 }
980
981 zCriteria_t zcri(zcriteria);
982 result = zcri.getResult();
983 if ( RES_OK == result ){
984 zUIDs_t zUIDs(zuids);
985 result = zUIDs.getResult();
986 if ( RES_OK == result ){
987 const account_t *paccounts;
988 int accountLen;
989 result = getAccounts( (sessionid_t)sid,
990 zUIDs.getPUID(), zUIDs.getLen(),
991 &zcri, &paccounts, &accountLen );
992 if ( RES_OK == result ){
993 accountsToZval( paccounts, accountLen, zaccount );
994 freeResult( paccounts );
995 }
996 }
997 }
998
999 RETURN_LONG(result);
1000 }
1001
1002 /** 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア繧貞セ励k縲?lt;br>
1003 int vp_insert_account( int sid, array account_info );
1004 @param vp_session_id vp 縺ョ session id
1005 @param user_id xoops_users.uid
1006 @param account_info 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア繧貞女縺大叙繧矩?」諠ウ驟榊?
1007 @return 0 success
1008 */
1009 ZEND_FUNCTION(vp_insert_account)
1010 {
1011 result_t result;
1012 long sid;
1013 zval *zaccount;
1014
1015 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1016 &sid, &zaccount) == FAILURE) {
1017 return;
1018 }
1019
1020 zAccount_t zacc(zaccount);
1021 result = zacc.getResult();
1022 if ( RES_OK == result ){
1023 result = insertAccount( (sessionid_t)sid, &zacc );
1024 }
1025
1026 RETURN_LONG(result);
1027 }
1028
1029 /** 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア繧呈峩譁ー縺吶k縲?lt;br>
1030 int vp_update_account( int sid, array account );
1031 @param vp_session_id vp 縺ョ session id
1032 @param account_info 譖ク縺崎セシ繧?縺ケ縺阪い繧ォ繧ヲ繝ウ繝域ュ蝣ア繧定。ィ縺咎?」諠ウ驟榊?
1033 @return 0 success
1034 */
1035 ZEND_FUNCTION(vp_update_account)
1036 {
1037 result_t result;
1038 long sid;
1039 zval *zaccount;
1040
1041 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1042 &sid, &zaccount) == FAILURE) {
1043 return;
1044 }
1045
1046 zAccount_t zacc(zaccount);
1047 result = zacc.getResult();
1048 if ( RES_OK == result ){
1049 result = updateAccount( (sessionid_t)sid, &zacc );
1050 }
1051
1052 RETURN_LONG(result);
1053 }
1054
1055 /** 譚。莉カ縺ォ蜷医≧繧「繧ォ繧ヲ繝ウ繝医?uid縺ョ荳?隕ァ繧貞セ励k縲?lt;br>
1056 int vp_dump_uids( int vp_session_id, array criteria, array uids );
1057 @param vp_session_id vp 縺ョ session id
1058 @param criteria 蜿門セ礼ッ?峇繝サ繧ス繝シ繝磯??r陦ィ縺咎?蛻?/span>
1059 @param uids uid繧貞女縺大叙繧矩?蛻?/span>
1060 @return 0 success
1061 */
1062 ZEND_FUNCTION(vp_dump_uids)
1063 {
1064 result_t result;
1065 long sid;
1066 zval *zcriteria;
1067 zval *zuids;
1068
1069 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1070 &sid, &zcriteria, &zuids) == FAILURE) {
1071 return;
1072 }
1073
1074 zCriteria_t zcri(zcriteria);
1075 result = zcri.getResult();
1076 if ( RES_OK == result ){
1077 userid_t *puid;
1078 int uidLen;
1079 result = dumpUids( (sessionid_t)sid, &zcri, &puid, &uidLen );
1080 if ( RES_OK == result ){
1081 uidsToZval( puid, uidLen, &zuids );
1082 freeResult( puid );
1083 }
1084 }
1085
1086 RETURN_LONG(result);
1087 }
1088
1089 /** VP縺ョ繧ー繝ォ繝シ繝励?謨ー繧貞セ励k<br>
1090 int vp_get_group_count( int sid );
1091 @param vp_session_id vp 縺ョ session id
1092 @return 繧ー繝ォ繝シ繝玲焚
1093 */
1094 ZEND_FUNCTION(vp_get_group_count)
1095 {
1096 result_t result;
1097 long sid;
1098
1099 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1100 &sid) == FAILURE) {
1101 return;
1102 }
1103
1104 int count = getGroupCount( (sessionid_t)sid );
1105
1106 RETURN_LONG(count);
1107 }
1108
1109 /** uid縺ァ謖?ョ壹@縺溘Θ繝シ繧カ縺悟ア槭☆繧ー繝ォ繝シ繝励〒縲√°縺、譚。莉カ縺ォ荳?閾エ縺吶k繧ー繝ォ繝シ繝励?gid繧貞セ励k<br>
1110 int vp_get_group_by_uid( int sid, int uid, array criteria, array gids );
1111 @param vp_session_id vp 縺ョ session id
1112 @param user_id xoops_users.uid
1113 @param criteria 蜿門セ礼ッ?峇繝サ繧ス繝シ繝磯??r陦ィ縺咎?蛻?/span>
1114 @param gids gid繧貞女縺大叙繧矩?蛻?/span>
1115 @return 0 success
1116 */
1117 ZEND_FUNCTION(vp_get_groups_by_uid)
1118 {
1119 result_t result;
1120 long sid, uid;
1121 zval *zcriteria;
1122 zval *zgids;
1123
1124 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1125 &sid, &uid, &zcriteria, &zgids) == FAILURE) {
1126 return;
1127 }
1128
1129 zCriteria_t zcri(zcriteria);
1130 result = zcri.getResult();
1131 if ( RES_OK == result ){
1132 groupid_t *pgids;
1133 int gidLen;
1134 result = getGroupsByUid( (sessionid_t)sid, (userid_t)uid, &zcri, &pgids, &gidLen );
1135 if ( RES_OK == result ){
1136 gidsToZval( pgids, gidLen, &zgids );
1137 freeResult( pgids );
1138 }
1139 }
1140
1141 RETURN_LONG(result);
1142 }
1143
1144
1145
1146 /** uid縺ァ謖?ョ壹@縺溘Θ繝シ繧カ縺携id縺ァ謖?ョ壹@縺溘げ繝ォ繝シ繝励?繧ー繝ォ繝シ繝礼ョ。逅???°縺ゥ縺?°繧貞セ励k<br>
1147 int vp_is_group_admin( int sid, int gid, int uid );
1148 @param vp_session_id vp 縺ョ session id
1149 @param group_id VP縺ョ繧ー繝ォ繝シ繝悠D
1150 @param user_id xoops_users.uid
1151 @return true: 繧ー繝ォ繝シ繝礼ョ。逅???〒縺ゅk縲?/span>
1152 @return false: 繧ー繝ォ繝シ繝礼ョ。逅???〒縺ェ縺??ゅ≠繧九>縺ッ繧ィ繝ゥ繝シ縺ァ縺ゅk縲?/span>
1153 */
1154 ZEND_FUNCTION(vp_is_group_admin)
1155 {
1156 result_t result;
1157 long sid, gid, uid;
1158
1159 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1160 &sid, &gid, &uid) == FAILURE) {
1161 return;
1162 }
1163
1164 bool b = isGroupAdmin( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1165
1166 RETURN_BOOL(b);
1167 }
1168
1169 /** 譚。莉カ縺ォ荳?閾エ縺吶k繧ー繝ォ繝シ繝励?gid縺ョ荳?隕ァ繧貞セ励k縲?lt;br>
1170 int vp_dump_gids( int sid, array criteria, array gids );
1171 @param vp_session_id vp 縺ョ session id
1172 @param criteria 蜿門セ礼ッ?峇繝サ繧ス繝シ繝磯??r陦ィ縺咎?蛻?/span>
1173 @param gids gid繧貞女縺大叙繧矩?蛻?/span>
1174 @return 0 success
1175 */
1176 ZEND_FUNCTION(vp_dump_gids)
1177 {
1178 result_t result;
1179 long sid;
1180 zval *zcriteria;
1181 zval *zgids;
1182
1183 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1184 &sid, &zcriteria, &zgids) == FAILURE) {
1185 return;
1186 }
1187
1188 zCriteria_t zcri(zcriteria);
1189 result = zcri.getResult();
1190 if ( RES_OK == result ){
1191 groupid_t *pgid;
1192 int gidLen;
1193 result = dumpGids( (sessionid_t)sid, &zcri, &pgid, &gidLen );
1194 if ( RES_OK == result ){
1195 gidsToZval( pgid, gidLen, &zgids );
1196 freeResult( pgid );
1197 }
1198 }
1199
1200 RETURN_LONG(result);
1201 }
1202
1203 /** gid縺ァ謖?ョ壹@縺溘げ繝ォ繝シ繝励?邂。逅???〒縲√°縺、譚。莉カ縺ォ荳?閾エ縺吶k繧ー繝ォ繝シ繝礼ョ。逅????uid縺ョ荳?隕ァ繧貞セ励k縲?lt;br>
1204 int vp_dump_group_admins(int sid, int group_id, array criteria, array uids )
1205 @param sid 繧サ繝?す繝ァ繝ウID
1206 @param group_id VP繧ー繝ォ繝シ繝悠D
1207 @param criteria 譚。莉カ
1208 @param uids uid縺ョ荳?隕ァ繧貞女縺大叙繧矩?蛻?/span>
1209 @return 0 success
1210 */
1211
1212 ZEND_FUNCTION(vp_dump_group_admins)
1213 {
1214 long sid, gid;
1215 zval *zcriteria;
1216 zval *zuids;
1217
1218 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1219 &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1220 return;
1221 }
1222
1223 zCriteria_t zcri(zcriteria);
1224 result_t result = zcri.getResult();
1225 if ( result == RES_OK ){
1226 userid_t *uids;
1227 int uidsLen;
1228 result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
1229 if ( result == RES_OK ){
1230 uidsToZval( uids, uidsLen, &zuids );
1231 freeResult( uids );
1232 }
1233 }
1234 RETURN_LONG( result );
1235 }
1236
1237
1238 /** 繧ー繝ォ繝シ繝玲ュ蝣ア繧貞、画峩縺吶k縲?lt;br>
1239 int vp_update_group(int sid, array group )
1240 @param sid 繧サ繝?す繝ァ繝ウID
1241 @param group 繧ー繝ォ繝シ繝玲ュ蝣ア縺ョ騾」諠ウ驟榊?
1242 @return 0 success
1243 */
1244 ZEND_FUNCTION(vp_update_group)
1245 {
1246 long sid;
1247 zval *zgroup;
1248 group_t group;
1249
1250 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1251 &sid, &zgroup) == FAILURE) {
1252 return;
1253 }
1254
1255 zvalToGroup( zgroup, &group );
1256 result_t result = updateGroup( sid, &group );
1257 RETURN_LONG( result );
1258 }
1259

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26