Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/xnpal.cc

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

revision 1.5 by aga, Tue Nov 30 09:49:49 2004 UTC revision 1.6 by youi, Tue Nov 30 11:55:24 2004 UTC
# Line 54  ZEND_FUNCTION(vp_get_members       ); Line 54  ZEND_FUNCTION(vp_get_members       );
54  ZEND_FUNCTION(vp_delete_group      );  ZEND_FUNCTION(vp_delete_group      );
55  ZEND_FUNCTION(vp_insert_group      );  ZEND_FUNCTION(vp_insert_group      );
56  ZEND_FUNCTION(vp_update_group      );  ZEND_FUNCTION(vp_update_group      );
57    */
58  ZEND_FUNCTION(vp_get_group         );  ZEND_FUNCTION(vp_get_group         );
59  ZEND_FUNCTION(vp_get_groups        );  ZEND_FUNCTION(vp_get_groups        );
60  ZEND_FUNCTION(vp_is_moderator      );  ZEND_FUNCTION(vp_is_moderator      );
61  ZEND_FUNCTION(vp_get_uid           );  ZEND_FUNCTION(vp_get_uid           );
 */  
62    
63  ZEND_FUNCTION(vp_test_criteria     );  ZEND_FUNCTION(vp_test_criteria     );
64  ZEND_FUNCTION(vp_test_uids         );  ZEND_FUNCTION(vp_test_uids         );
# Line 93  zend_function_entry vpalmod_functions[] Line 93  zend_function_entry vpalmod_functions[]
93      ZEND_FE(vp_delete_group      ,NULL)      ZEND_FE(vp_delete_group      ,NULL)
94      ZEND_FE(vp_insert_group      ,NULL)      ZEND_FE(vp_insert_group      ,NULL)
95      ZEND_FE(vp_update_group      ,NULL)      ZEND_FE(vp_update_group      ,NULL)
96    */    
97      ZEND_FE(vp_get_group         ,NULL)      ZEND_FE(vp_get_group         ,NULL)
98      ZEND_FE(vp_get_groups        ,NULL)      ZEND_FE(vp_get_groups        ,NULL)
99      ZEND_FE(vp_is_moderator      ,NULL)      ZEND_FE(vp_is_moderator      ,NULL)
100      ZEND_FE(vp_get_uid           ,NULL)      ZEND_FE(vp_get_uid           ,NULL)
 */      
101      ZEND_FE(vp_test_criteria     ,NULL)      ZEND_FE(vp_test_criteria     ,NULL)
102      ZEND_FE(vp_test_uids         ,NULL)      ZEND_FE(vp_test_uids         ,NULL)
103      {NULL, NULL, NULL}      {NULL, NULL, NULL}
# Line 412  result_t gidsToZval( groupid_t *pGID, in Line 412  result_t gidsToZval( groupid_t *pGID, in
412          return RES_OK;          return RES_OK;
413  }  }
414    
415    result_t accountToZval( const account_t *pAccount, zval *z )
416    {
417        zend_hash_clean( z -> value.ht );
418        
419        if( add_assoc_long( z, "uid", pAccount -> getUID( ) ) != SUCCESS ){
420            fprintf( stderr, "aaaaaaaaaaaaaaaa" );
421            abort( );
422        }
423        add_assoc_string( z, "uname", ( char* )pAccount -> getUname( ), 1 );
424        add_assoc_string( z, "name", ( char* )pAccount -> getName( ), 1 );
425        add_assoc_string( z, "email", ( char* )pAccount -> getEmail( ), 1 );
426        add_assoc_string( z, "url", ( char* )pAccount -> getURL( ), 1 );
427        add_assoc_string( z, "user_avatar", ( char* )pAccount -> getUserAvatar( ), 1 );
428        add_assoc_string( z, "user_icq", ( char* )pAccount -> getUserIcq( ), 1 );
429        add_assoc_string( z, "user_from", ( char* )pAccount -> getUserFrom( ), 1 );
430        add_assoc_string( z, "user_sig", ( char* )pAccount -> getUserSig( ), 1 );
431        add_assoc_string( z, "actkey", ( char* )pAccount -> getActkey( ), 1 );
432        add_assoc_string( z, "user_aim", ( char* )pAccount -> getUserAim( ), 1 );
433        add_assoc_string( z, "user_yim", ( char* )pAccount -> getUserYim( ), 1 );
434        add_assoc_string( z, "user_msnm", ( char* )pAccount -> getUserMsnm( ), 1 );
435        add_assoc_string( z, "pass", ( char* )pAccount -> getPass( ), 1 );
436        add_assoc_string( z, "theme", ( char* )pAccount -> getTheme( ), 1 );
437        add_assoc_string( z, "umode", ( char* )pAccount -> getUmode( ), 1 );
438        add_assoc_string( z, "user_occ", ( char* )pAccount -> getUserOcc( ), 1 );
439        add_assoc_string( z, "bio", ( char* )pAccount -> getBio( ), 1 );
440        add_assoc_string( z, "user_intrest", ( char* )pAccount -> getUserIntrest( ), 1 );
441        add_assoc_double( z, "timezone_offset", pAccount -> getTimezoneOffset( ) );
442        add_assoc_long( z, "attachsig", pAccount -> getAttachsig( ) );
443        add_assoc_long( z, "last_login", pAccount -> getLastLogin( ) );
444        add_assoc_long( z, "level", pAccount -> getLevel( ) );
445        add_assoc_long( z, "notify_method", pAccount -> getNotifyMethod( ) );
446        add_assoc_long( z, "notify_mode", pAccount -> getNotifyMode( ) );
447        add_assoc_long( z, "posts", pAccount -> getPosts( ) );
448        add_assoc_long( z, "rank", pAccount -> getRank( ) );
449        add_assoc_long( z, "uorder", pAccount -> getUorder( ) );
450        add_assoc_long( z, "user_mailok", pAccount -> getUserMailok( ) );
451        add_assoc_long( z, "user_regdate", pAccount -> getUserRegdate( ) );
452        add_assoc_long( z, "user_viewemail", pAccount -> getUserViewemail( ) );
453        
454        add_assoc_long( z, "activate", pAccount -> getActivate( ) );
455        add_assoc_string( z, "address", ( char* )pAccount -> getAddress( ), 1 );
456        add_assoc_string( z, "institute", ( char* )pAccount -> getInstitute( ), 1 );
457        add_assoc_string( z, "tel", ( char* )pAccount -> getTel( ), 1 );
458        add_assoc_string( z, "organization", ( char* )pAccount -> getOrganization( ), 1 );
459        add_assoc_string( z, "country", ( char* )pAccount -> getCountry( ), 1 );
460        add_assoc_string( z, "zipcode", ( char* )pAccount -> getZipcode( ), 1 );
461        add_assoc_string( z, "fax", ( char* )pAccount -> getFax( ), 1 );
462        add_assoc_string( z, "base_url", ( char* )pAccount -> getBaseURL( ), 1 );
463        add_assoc_long( z, "notice_mail", pAccount -> getNoticeMail( ) );
464        add_assoc_long( z, "notice_mail_since", pAccount -> getNoticeMailSince( ) );
465            return RES_OK;
466    }
467    
468  /** accounts → zval  /** accounts → zval
469    * accounts: こんな感じの配列    * accounts: こんな感じの配列
470      array(      array(
# Line 425  result_t gidsToZval( groupid_t *pGID, in Line 478  result_t gidsToZval( groupid_t *pGID, in
478        ...        ...
479      )      )
480    */    */
481  result_t accountsToZval( const account_t *pAccounts, int accountLen, zval *z )  result_t accountsToZval( const account_t *pAccounts, int accountsLen, zval *z )
482  {  {
483          return RES_ERROR;      zend_hash_clean( z -> value.ht );
484        for( int i = 0; i < accountsLen; i++ ){
485            zval *new_array;
486            MAKE_STD_ZVAL(new_array);
487            if(array_init(new_array) != SUCCESS){
488                return RES_ERROR;
489            }
490            add_index_zval( z, i, new_array );
491            accountToZval( &pAccounts[ i ], new_array );
492        }
493            return RES_OK;
494  }  }
495    
496  result_t accountToZval( const account_t *pAccount, zval *z )  /** groups → zval
497      */
498    result_t groupsToZval( const group_t *pGroups, int groupsLen, zval *z )
499  {  {
500          return RES_ERROR;      zend_hash_clean( z -> value.ht );
501        for( int i = 0; i < groupsLen; i++ ){
502            zval *new_array;
503            MAKE_STD_ZVAL(new_array);
504            if(array_init(new_array) != SUCCESS){
505                return RES_ERROR;
506            }
507            add_index_zval( z, i, new_array );
508            add_assoc_long( new_array, "gid",  pGroups[ i ].getGID( ) );
509            add_assoc_string( new_array, "gname", ( char* )pGroups[ i ].getGname( ), 1 );
510            add_assoc_string( new_array, "gdesc", ( char* )pGroups[ i ].getDesc( ), 1 );
511        }
512            return RES_OK;
513  }  }
514    
515  /** groups → zval  /** group → zval
516    */    */
517  result_t groupsToZval( const group_t *pGroups, int groupLen, zval *z )  result_t groupToZval( const group_t *pGroup, int groupLen, 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    // int vp_get_group( int sid, int gid, array group );
527    ZEND_FUNCTION(vp_get_group)
528  {  {
529            long sid, gid;
530            zval *zgroup;
531            
532            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
533                                  &sid, &gid, &zgroup) == FAILURE) {
534                    return;
535            }
536            
537            const group_t *pgroup;
538            result_t result = getGroup( (sessionid_t)sid, (groupid_t)gid, &pgroup );
539            if ( RES_OK == result ){
540                    //groupToZval( pgroup, zgroup );
541                    freeResult( pgroup );
542            }
543            
544        RETURN_LONG(result);
545    }
546    
547    
548          return RES_ERROR;  // int vp_get_groups( int sid, array gids, array criteria, array groups );
549    ZEND_FUNCTION(vp_get_groups)
550    {
551            result_t result;
552            long sid, uid;
553            zval *zcriteria;
554            zval *zgids;
555            zval *zgroups;
556        zval **ppzTmp = 0;
557        HashPosition pos;
558        int res2;
559        int gidsLen;
560        const group_t* groups;
561        int groupsLen;
562        
563            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
564                                  &sid, &zgids, &zcriteria, &zgroups) == FAILURE) {
565                    return;
566            }
567            
568        //gidsにグループIDをコピーする
569        gidsLen = zend_hash_num_elements(Z_ARRVAL_P(zgids));
570        groupid_t *gids = new groupid_t[ gidsLen ];
571        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zgids), &pos);
572        for( int i = 0; i < gidsLen; i++ ){
573            if( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(zgids), (void **)&ppzTmp, &pos)) == SUCCESS ){
574                SEPARATE_ZVAL(ppzTmp);
575                convert_to_long_ex(ppzTmp);
576                gids[ i ] = Z_LVAL_PP(ppzTmp);
577            }
578            zend_hash_move_forward_ex(Z_ARRVAL_P(zgids), &pos);
579        }
580        
581            zCriteria_t zcri(zcriteria);
582            result = zcri.getResult();
583            if ( RES_OK == result ){
584            result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen );
585            if ( RES_OK == result ){
586                delete[] gids;
587                freeResult( groups );
588            }
589        }
590        groupsToZval( groups, groupsLen, zgroups );
591        RETURN_LONG(result);
592    }
593    
594    
595    // int vp_is_moderator(string uname)
596    ZEND_FUNCTION(vp_is_moderator)
597    {
598            long vpSessionID;
599            userid_t uid;
600            
601            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
602                                  &vpSessionID, &uid) == FAILURE) {
603                    return;
604            }
605            
606            bool result = isModerator( (sessionid_t)vpSessionID, uid );
607        RETURN_BOOL(result)
608    }
609    
610    // int vp_get_uid(string uname)
611    ZEND_FUNCTION(vp_get_uid)
612    {
613            char *uname;
614            int unameLen;
615            userid_t uid;
616        
617            if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
618              &uname, &unameLen) == FAILURE) {
619                    return;
620            }
621            
622            string strUname( uname, unameLen );
623            result_t result = getUid( strUname.c_str(), &uid );
624            if ( result == RES_OK ){
625                RETURN_LONG((long)uid);
626            }
627            else {
628                    //zend_printf( "vpal_debug: vp_get_uid(%s): result=%d<br>\n", strUname.c_str(),(int)result );
629                    RETURN_FALSE
630            }
631  }  }
632    
633  /** session → zval  /** session → zval
# Line 728  ZEND_FUNCTION(vp_get_account) Line 915  ZEND_FUNCTION(vp_get_account)
915                    
916          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
917            &sid, &uid, &zaccount) == FAILURE) {            &sid, &uid, &zaccount) == FAILURE) {
918            fprintf( stderr, "error occured " );
919                  return;                  return;
920          }          }
921                    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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