Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/commonal.cc

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

revision 1.55 by youi, Fri Jan 28 07:01:38 2005 UTC revision 1.56 by youi, Sat Jan 29 09:49:22 2005 UTC
# Line 2  Line 2 
2   *   *
3   * $Revision$   * $Revision$
4   * $Log$   * $Log$
5     * Revision 1.56  2005/01/29 09:49:22  youi
6     * syslog_printf: デバッグメッセージ出力関数を定義した.
7     * getCertifyPermission: チェック用のsqlを定義した.
8     * SQLINTEGER->SQLLENへ型を変更した.
9     * getItemPermission: モデレータであるか?の判断条件を修正.
10     *
11   * Revision 1.55  2005/01/28 07:01:38  youi   * Revision 1.55  2005/01/28 07:01:38  youi
12   * getItemIDByIndexID: 対象となるアイテムの条件見直し.   * getItemIDByIndexID: 対象となるアイテムの条件見直し.
13   * SQLAllocHandle失敗時のメッセージを追加.   * SQLAllocHandle失敗時のメッセージを追加.
# Line 280  static int streamPubmedFile(const char * Line 286  static int streamPubmedFile(const char *
286  static result_t insertIndexInternal( sessionid_t sid, index_t *index, indexid_t *xid );  static result_t insertIndexInternal( sessionid_t sid, index_t *index, indexid_t *xid );
287  static string odbcDiagString( SQLSMALLINT HandleType, SQLHANDLE hstmt, SQLRETURN sqlcode );  static string odbcDiagString( SQLSMALLINT HandleType, SQLHANDLE hstmt, SQLRETURN sqlcode );
288  static result_t deleteMemberNoLimit( sessionid_t sid, groupid_t gid, userid_t uid );  static result_t deleteMemberNoLimit( sessionid_t sid, groupid_t gid, userid_t uid );
289    static result_t getXoopsModuleConfigValue( const char *module, const char *key, char **value );
290  static void setLastErrorString( const char* str );  static void setLastErrorString( const char* str );
291    
292  static result_t countResultRows( const char* sql, SQLINTEGER* count )  void syslog_printf( char* format, ... )
293    {
294    #ifdef USE_SYSLOG
295        va_list ap;
296        va_start(ap, format);
297        openlog( "commonal", LOG_ODELAY, LOG_USER );
298        vsyslog( LOG_DEBUG, format, ap );
299        closelog( );
300    #endif
301    }
302    
303    static result_t countResultRows( const char* sql, SQLLEN* count )
304  {  {
305      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
306      SQLRETURN sqlcode;      SQLRETURN sqlcode;
# Line 419  static result_t queryGetUnsignedInt( con Line 437  static result_t queryGetUnsignedInt( con
437      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
438          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){
439              SQLUINTEGER sInt = 0;              SQLUINTEGER sInt = 0;
440              SQLINTEGER len = 0;              SQLLEN len = 0;
441              SQLBindCol( hstmt, 1, SQL_C_ULONG, &sInt, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &sInt, 0, &len );
442              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
443                  if ( len == SQL_NULL_DATA )                  if ( len == SQL_NULL_DATA )
# Line 464  static char* strncpy2( char* dst, const Line 482  static char* strncpy2( char* dst, const
482  {  {
483      strncpy( dst, src, len );      strncpy( dst, src, len );
484      dst[ len ] = '\0';      dst[ len ] = '\0';
485      //fprintf( stderr, "\nstrncpy2 '%s'\n", dst );      syslog_printf( "\nstrncpy2 '%s'\n", dst );
486      return dst;      return dst;
487  }  }
488    
# Line 483  static string odbcDiagString( SQLSMALLIN Line 501  static string odbcDiagString( SQLSMALLIN
501          SQLCHAR SQLState[6];          SQLCHAR SQLState[6];
502          SQLINTEGER NativeError;          SQLINTEGER NativeError;
503          SQLCHAR MessageText[ 1024 ];          SQLCHAR MessageText[ 1024 ];
         SQLSMALLINT BufferLength;  
504          SQLSMALLINT TextLength;          SQLSMALLINT TextLength;
505          SQLGetDiagRec( HandleType, hstmt, 1, SQLState, &NativeError, MessageText, 1024, &TextLength );          SQLGetDiagRec( HandleType, hstmt, 1, SQLState, &NativeError, MessageText, 1024, &TextLength );
506                    
# Line 507  string getResultCol( SQLHANDLE hstmt, in Line 524  string getResultCol( SQLHANDLE hstmt, in
524      string s;      string s;
525      SQLRETURN sqlcode;      SQLRETURN sqlcode;
526      SQLCHAR       BinaryPtr[5000];      SQLCHAR       BinaryPtr[5000];
527      SQLUINTEGER   PartID;      SQLINTEGER    BinaryLenOrInd, NumBytes;
     SQLINTEGER    PartIDInd, BinaryLenOrInd, NumBytes;  
     SQLRETURN     rc;  
528            
529      while ( ( sqlcode = SQLGetData(hstmt, col, SQL_C_CHAR, BinaryPtr, sizeof(BinaryPtr),      while ( ( sqlcode = SQLGetData(hstmt, col, SQL_C_CHAR, BinaryPtr, sizeof(BinaryPtr),
530                                     &BinaryLenOrInd)) != SQL_NO_DATA) {                                     &BinaryLenOrInd)) != SQL_NO_DATA) {
# Line 581  static result_t getXoopsModuleConfigValu Line 596  static result_t getXoopsModuleConfigValu
596              " from " + dbprefix + "_config as tc, " + dbprefix  + "_modules as tm "              " from " + dbprefix + "_config as tc, " + dbprefix  + "_modules as tm "
597              " where tm.mid=tc.conf_modid and tm.dirname = ? and tc.conf_name = ? ";              " where tm.mid=tc.conf_modid and tm.dirname = ? and tc.conf_name = ? ";
598          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
599          SQLINTEGER cbModule = SQL_NTS, cbKey = SQL_NTS;          SQLLEN cbModule = SQL_NTS, cbKey = SQL_NTS;
600          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(module), 0, (SQLCHAR *)module, 0, &cbModule );          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(module), 0, (SQLCHAR *)module, 0, &cbModule );
601          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(key),    0, (SQLCHAR *)key,    0, &cbKey );          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(key),    0, (SQLCHAR *)key,    0, &cbKey );
602          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){
# Line 647  static bool isGuestEnabled(){ Line 662  static bool isGuestEnabled(){
662  static result_t sessionID2UID( sessionid_t sid, userid_t *uid ){  static result_t sessionID2UID( sessionid_t sid, userid_t *uid ){
663      if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED;      if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED;
664            
     SQLRETURN sqlcode;  
     SQLHANDLE hstmt = NULL;      
       
665      if ( sid == session::SID_GUEST ){      if ( sid == session::SID_GUEST ){
666          if ( isGuestEnabled() ){          if ( isGuestEnabled() ){
667              *uid = account::UID_GUEST;              *uid = account::UID_GUEST;
# Line 722  static bool uidExists( userid_t uid ) Line 734  static bool uidExists( userid_t uid )
734      bool ret = false;      bool ret = false;
735      string sql;      string sql;
736      SQLRETURN sqlcode;      SQLRETURN sqlcode;
     SQLINTEGER count = 0;  
737            
738      sql = "SELECT * FROM " + dbprefix + "_xnpaccount_users ";      sql = "SELECT * FROM " + dbprefix + "_xnpaccount_users ";
739      sql += "WHERE uid=" + string( unsignedIntToString( uid ) );      sql += "WHERE uid=" + string( unsignedIntToString( uid ) );
# Line 812  result_t initializeDB( const char* dsn, Line 823  result_t initializeDB( const char* dsn,
823            
824      // 初期化と接続      // 初期化と接続
825  //    if( SQLAllocEnv( &henv ) != SQL_SUCCESS ) {  //    if( SQLAllocEnv( &henv ) != SQL_SUCCESS ) {
826      if( SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv ) != SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv ) ) != SQL_SUCCESS ) {
827          string s( "SQLAllocHandle(SQL_HANDLE_ENV,...) in initializeDB" );          string s( "SQLAllocHandle(SQL_HANDLE_ENV,...) in initializeDB" );
828          s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode );          s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode );
829          setLastErrorString( s.c_str( ) );          setLastErrorString( s.c_str( ) );
# Line 997  int getAccountCount( sessionid_t sid ) Line 1008  int getAccountCount( sessionid_t sid )
1008      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
1009          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
1010              SQLUINTEGER count = 0;              SQLUINTEGER count = 0;
1011              SQLINTEGER len = 0;              SQLLEN len = 0;
1012              SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );
1013              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
1014                  ret = count;                  ret = count;
# Line 1214  result_t getAccounts( sessionid_t sid, c Line 1225  result_t getAccounts( sessionid_t sid, c
1225            
1226      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
1227          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
1228              SQLINTEGER len = 0;              SQLLEN len = 0;
1229              userid_t uid = 0;              userid_t uid = 0;
1230              SQLBindCol( hstmt, 1, SQL_C_ULONG, &uid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &uid, 0, &len );
1231              *accountsLen=0;              *accountsLen=0;
# Line 1321  result_t insertAccount( sessionid_t sid, Line 1332  result_t insertAccount( sessionid_t sid,
1332            
1333      string sql;      string sql;
1334      string tmp;      string tmp;
     char buf[ 12 ];  
1335      SQLRETURN sqlcode;      SQLRETURN sqlcode;
1336      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
1337            
# Line 1338  result_t insertAccount( sessionid_t sid, Line 1348  result_t insertAccount( sessionid_t sid,
1348      SQLINTEGER user_regdate, user_viewemail, posts, attachsig, rank, level, last_login, uorder, notify_method, notify_mode, user_mailok;      SQLINTEGER user_regdate, user_viewemail, posts, attachsig, rank, level, last_login, uorder, notify_method, notify_mode, user_mailok;
1349      SQLDOUBLE timezone_offset;      SQLDOUBLE timezone_offset;
1350            
1351      SQLINTEGER cbUname = SQL_NTS, cbName = SQL_NTS, cbEmail = SQL_NTS, cbUrl = SQL_NTS, cbUser_avatar = SQL_NTS, cbUser_icq = SQL_NTS, cbUser_from = SQL_NTS, cbUser_sig = SQL_NTS, cbActkey = SQL_NTS, cbUser_aim = SQL_NTS, cbUser_yim = SQL_NTS, cbUser_msnm = SQL_NTS, cbPass = SQL_NTS, cbTheme = SQL_NTS, cbUmode = SQL_NTS, cbUser_occ = SQL_NTS, cbBio = SQL_NTS, cbUser_intrest = SQL_NTS;      SQLLEN cbUname = SQL_NTS, cbName = SQL_NTS, cbEmail = SQL_NTS, cbUrl = SQL_NTS, cbUser_avatar = SQL_NTS, cbUser_icq = SQL_NTS, cbUser_from = SQL_NTS, cbUser_sig = SQL_NTS, cbActkey = SQL_NTS, cbUser_aim = SQL_NTS, cbUser_yim = SQL_NTS, cbUser_msnm = SQL_NTS, cbPass = SQL_NTS, cbTheme = SQL_NTS, cbUmode = SQL_NTS, cbUser_occ = SQL_NTS, cbBio = SQL_NTS, cbUser_intrest = SQL_NTS;
1352      SQLINTEGER cbUser_regdate = 0, cbUser_viewemail = 0, cbPosts = 0, cbAttachsig = 0, cbRank = 0, cbLevel = 0, cbLast_login = 0, cbUorder = 0, cbNotify_method = 0, cbNotify_mode = 0, cbUser_mailok = 0, cbTimezone_offset = 0;      SQLLEN cbUser_regdate = 0, cbUser_viewemail = 0, cbPosts = 0, cbAttachsig = 0, cbRank = 0, cbLevel = 0, cbLast_login = 0, cbUorder = 0, cbNotify_method = 0, cbNotify_mode = 0, cbUser_mailok = 0, cbTimezone_offset = 0;
1353    
1354      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
1355          string sql;          string sql;
# Line 1451  result_t insertAccount( sessionid_t sid, Line 1461  result_t insertAccount( sessionid_t sid,
1461          SQLCHAR zipcode[XNP_ACCOUNT_ZIPCODE_LEN+1];          SQLCHAR zipcode[XNP_ACCOUNT_ZIPCODE_LEN+1];
1462          SQLCHAR fax[XNP_ACCOUNT_FAX_LEN+1];          SQLCHAR fax[XNP_ACCOUNT_FAX_LEN+1];
1463          SQLCHAR base_url[XNP_ACCOUNT_BASE_URL_LEN+1];          SQLCHAR base_url[XNP_ACCOUNT_BASE_URL_LEN+1];
1464          SQLINTEGER cbAddress = SQL_NTS, cbDivision = SQL_NTS, cbTel = SQL_NTS, cbCompany_name = SQL_NTS, cbCountry = SQL_NTS, cbZipcode = SQL_NTS, cbFax = SQL_NTS, cbBase_url = SQL_NTS;          SQLLEN cbAddress = SQL_NTS, cbDivision = SQL_NTS, cbTel = SQL_NTS, cbCompany_name = SQL_NTS, cbCountry = SQL_NTS, cbZipcode = SQL_NTS, cbFax = SQL_NTS, cbBase_url = SQL_NTS;
1465          SQLINTEGER cbUid = 0, cbActivate = 0, cbNotice_mail = 0, cbNotice_mail_since = 0;          SQLLEN cbUid = 0, cbActivate = 0, cbNotice_mail = 0, cbNotice_mail_since = 0;
1466          SQLUINTEGER notice_mail;          SQLUINTEGER notice_mail;
1467          SQLUINTEGER notice_mail_since;          SQLUINTEGER notice_mail_since;
1468          if( ret == RES_OK && ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {          if( ret == RES_OK && ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
# Line 1604  result_t updateAccount( sessionid_t sid, Line 1614  result_t updateAccount( sessionid_t sid,
1614      SQLINTEGER uid, user_regdate, user_viewemail, posts, attachsig, rank, level, last_login, uorder, notify_method, notify_mode, user_mailok;      SQLINTEGER uid, user_regdate, user_viewemail, posts, attachsig, rank, level, last_login, uorder, notify_method, notify_mode, user_mailok;
1615      SQLDOUBLE timezone_offset;      SQLDOUBLE timezone_offset;
1616            
1617      SQLINTEGER cbUname = SQL_NTS, cbName = SQL_NTS, cbEmail = SQL_NTS, cbUrl = SQL_NTS, cbUser_avatar = SQL_NTS, cbUser_icq = SQL_NTS, cbUser_from = SQL_NTS, cbUser_sig = SQL_NTS, cbActkey = SQL_NTS, cbUser_aim = SQL_NTS, cbUser_yim = SQL_NTS, cbUser_msnm = SQL_NTS, cbPass = SQL_NTS, cbTheme = SQL_NTS, cbUmode = SQL_NTS, cbUser_occ = SQL_NTS, cbBio = SQL_NTS, cbUser_intrest = SQL_NTS;      SQLLEN cbUname = SQL_NTS, cbName = SQL_NTS, cbEmail = SQL_NTS, cbUrl = SQL_NTS, cbUser_avatar = SQL_NTS, cbUser_icq = SQL_NTS, cbUser_from = SQL_NTS, cbUser_sig = SQL_NTS, cbActkey = SQL_NTS, cbUser_aim = SQL_NTS, cbUser_yim = SQL_NTS, cbUser_msnm = SQL_NTS, cbPass = SQL_NTS, cbTheme = SQL_NTS, cbUmode = SQL_NTS, cbUser_occ = SQL_NTS, cbBio = SQL_NTS, cbUser_intrest = SQL_NTS;
1618      SQLINTEGER cbUid = 0, cbUser_regdate = 0, cbUser_viewemail = 0, cbPosts = 0, cbAttachsig = 0, cbRank = 0, cbLevel = 0, cbLast_login = 0, cbUorder = 0, cbNotify_method = 0, cbNotify_mode = 0, cbUser_mailok = 0, cbTimezone_offset = 0;      SQLLEN cbUid = 0, cbUser_regdate = 0, cbUser_viewemail = 0, cbPosts = 0, cbAttachsig = 0, cbRank = 0, cbLevel = 0, cbLast_login = 0, cbUorder = 0, cbNotify_method = 0, cbNotify_mode = 0, cbUser_mailok = 0, cbTimezone_offset = 0;
1619    
1620      SQLUINTEGER activate;      SQLUINTEGER activate;
1621      SQLCHAR address[XNP_ACCOUNT_ADDRESS_LEN+1];      SQLCHAR address[XNP_ACCOUNT_ADDRESS_LEN+1];
# Line 1616  result_t updateAccount( sessionid_t sid, Line 1626  result_t updateAccount( sessionid_t sid,
1626      SQLCHAR zipcode[XNP_ACCOUNT_ZIPCODE_LEN+1];      SQLCHAR zipcode[XNP_ACCOUNT_ZIPCODE_LEN+1];
1627      SQLCHAR fax[XNP_ACCOUNT_FAX_LEN+1];      SQLCHAR fax[XNP_ACCOUNT_FAX_LEN+1];
1628      SQLCHAR base_url[XNP_ACCOUNT_BASE_URL_LEN+1];      SQLCHAR base_url[XNP_ACCOUNT_BASE_URL_LEN+1];
1629      SQLINTEGER cbActivate = 0, cbAddress = SQL_NTS, cbDivision = SQL_NTS, cbTel = SQL_NTS, cbCompany_name = SQL_NTS, cbCountry = SQL_NTS, cbZipcode = SQL_NTS, cbFax = SQL_NTS, cbBase_url = SQL_NTS;      SQLLEN cbActivate = 0, cbAddress = SQL_NTS, cbDivision = SQL_NTS, cbTel = SQL_NTS, cbCompany_name = SQL_NTS, cbCountry = SQL_NTS, cbZipcode = SQL_NTS, cbFax = SQL_NTS, cbBase_url = SQL_NTS;
1630      SQLUINTEGER notice_mail, notice_mail_since;      SQLUINTEGER notice_mail, notice_mail_since;
1631      SQLINTEGER cbNotice_mail = 0, cbNotice_mail_since = 0;      SQLLEN cbNotice_mail = 0, cbNotice_mail_since = 0;
1632    
1633      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
1634          string sql;          string sql;
# Line 1875  result_t dumpUids( sessionid_t sid, crit Line 1885  result_t dumpUids( sessionid_t sid, crit
1885      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
1886          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
1887              userid_t uid = 0;              userid_t uid = 0;
1888              SQLINTEGER len = 0;              SQLLEN len = 0;
1889              SQLBindCol( hstmt, 1, SQL_C_ULONG, &uid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &uid, 0, &len );
1890    
1891              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *uidsLen ; i++ ){              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *uidsLen ; i++ ){
# Line 1934  int getGroupCount( sessionid_t sid ) Line 1944  int getGroupCount( sessionid_t sid )
1944      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
1945          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
1946              SQLUINTEGER count = 0;              SQLUINTEGER count = 0;
1947              SQLINTEGER len = 0;              SQLLEN len = 0;
1948              SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );
1949              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
1950                  ret = count;                  ret = count;
# Line 1987  result_t getGroupsByUid( sessionid_t sid Line 1997  result_t getGroupsByUid( sessionid_t sid
1997      SQLHANDLE hstmt = NULL;          SQLHANDLE hstmt = NULL;    
1998      SQLINTEGER count = 0;      SQLINTEGER count = 0;
1999      groupid_t* dst = 0;      groupid_t* dst = 0;
     int len = 0;  
2000            
2001      sql = "SELECT gid FROM " + dbprefix + "_xnpaccount_groups_users_link";      sql = "SELECT gid FROM " + dbprefix + "_xnpaccount_groups_users_link";
2002      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );
# Line 2010  result_t getGroupsByUid( sessionid_t sid Line 2019  result_t getGroupsByUid( sessionid_t sid
2019                      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );                      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );
2020                      sql += criteria2str( cri );                      sql += criteria2str( cri );
2021                      if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                      if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2022                          SQLINTEGER len = 0;                          SQLLEN len = 0;
2023                          groupid_t gid = 0;                          groupid_t gid = 0;
2024                          SQLBindCol( hstmt, 1, SQL_C_ULONG, &gid, 0, &len );                          SQLBindCol( hstmt, 1, SQL_C_ULONG, &gid, 0, &len );
2025                          for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *gidsLen ; i++ ){                          for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *gidsLen ; i++ ){
# Line 2071  bool isGroupAdmin( sessionid_t sid, grou Line 2080  bool isGroupAdmin( sessionid_t sid, grou
2080            
2081      bool ret = false;      bool ret = false;
2082      string sql;      string sql;
     SQLRETURN sqlcode;  
2083      SQLINTEGER count = 0;      SQLINTEGER count = 0;
2084            
2085      sql = "SELECT * FROM " + dbprefix + "_xnpaccount_groups_users_link ";      sql = "SELECT * FROM " + dbprefix + "_xnpaccount_groups_users_link ";
# Line 2129  result_t dumpGids( sessionid_t sid, crit Line 2137  result_t dumpGids( sessionid_t sid, crit
2137      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2138          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2139              groupid_t gid = 0;              groupid_t gid = 0;
2140              SQLINTEGER len = 0;              SQLLEN len = 0;
2141              SQLBindCol( hstmt, 1, SQL_C_ULONG, &gid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &gid, 0, &len );
2142              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *gidsLen ; i++ ){              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *gidsLen ; i++ ){
2143                  dst[ i ] = gid;                  dst[ i ] = gid;
# Line 2172  result_t dumpGroupAdmins( sessionid_t si Line 2180  result_t dumpGroupAdmins( sessionid_t si
2180      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
2181            
2182      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
     groupid_t* dst = 0;  
2183      string sql;      string sql;
2184      SQLRETURN sqlcode;      SQLRETURN sqlcode;
2185      SQLINTEGER count = 0;      SQLINTEGER count = 0;
# Line 2188  result_t dumpGroupAdmins( sessionid_t si Line 2195  result_t dumpGroupAdmins( sessionid_t si
2195      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2196          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2197              userid_t uid;              userid_t uid;
2198              SQLINTEGER len = 0;              SQLLEN len = 0;
2199              SQLBindCol( hstmt, 1, SQL_C_ULONG, &uid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &uid, 0, &len );
2200              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *uidsLen ; i++ ){              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < *uidsLen ; i++ ){
2201                  (*uids)[ i ] = uid;                  (*uids)[ i ] = uid;
# Line 2392  result_t getMembers( sessionid_t sid, gr Line 2399  result_t getMembers( sessionid_t sid, gr
2399      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2400          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2401              SQLUINTEGER count = 0;              SQLUINTEGER count = 0;
2402              SQLINTEGER len = 0;              SQLLEN len = 0;
2403              SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );
2404              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
2405                  dst = new userid_t[ count ];                  dst = new userid_t[ count ];
# Line 2407  result_t getMembers( sessionid_t sid, gr Line 2414  result_t getMembers( sessionid_t sid, gr
2414                          sql += " " + string( criteria2str( cri ) );                          sql += " " + string( criteria2str( cri ) );
2415                          if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                          if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2416                              SQLUINTEGER uid = 0;                              SQLUINTEGER uid = 0;
2417                              SQLINTEGER len = 0;                              SQLLEN len = 0;
2418                              SQLBindCol( hstmt2, 1, SQL_C_ULONG, &uid, 0, &len );                              SQLBindCol( hstmt2, 1, SQL_C_ULONG, &uid, 0, &len );
2419                              for( int i = 0; ( sqlcode = SQLFetch( hstmt2 ) ) == SQL_SUCCESS && i < count ; i++ ){                              for( int i = 0; ( sqlcode = SQLFetch( hstmt2 ) ) == SQL_SUCCESS && i < count ; i++ ){
2420                                  dst[ i ] = uid;                                  dst[ i ] = uid;
# Line 2525  result_t insertGroup( sessionid_t sid, c Line 2532  result_t insertGroup( sessionid_t sid, c
2532      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
2533      string sql;      string sql;
2534      SQLCHAR gname[XNP_GROUP_GNAME_LEN+1], gdesc[XNP_GROUP_GDESC_LEN+1];      SQLCHAR gname[XNP_GROUP_GNAME_LEN+1], gdesc[XNP_GROUP_GDESC_LEN+1];
2535      SQLINTEGER cbGname = SQL_NTS, cbGdesc = SQL_NTS;      SQLLEN cbGname = SQL_NTS, cbGdesc = SQL_NTS;
2536      SQLRETURN sqlcode;      SQLRETURN sqlcode;
2537            
2538      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
# Line 2632  result_t updateGroup( sessionid_t sid, c Line 2639  result_t updateGroup( sessionid_t sid, c
2639      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
2640      string sql;      string sql;
2641      SQLCHAR gname[XNP_GROUP_GNAME_LEN+1], gdesc[XNP_GROUP_GDESC_LEN+1];      SQLCHAR gname[XNP_GROUP_GNAME_LEN+1], gdesc[XNP_GROUP_GDESC_LEN+1];
2642      SQLINTEGER cbGname = SQL_NTS, cbGdesc = SQL_NTS;      SQLLEN cbGname = SQL_NTS, cbGdesc = SQL_NTS;
2643      SQLRETURN sqlcode;      SQLRETURN sqlcode;
2644            
2645      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
# Line 2739  result_t getGroups( sessionid_t sid, gro Line 2746  result_t getGroups( sessionid_t sid, gro
2746            
2747      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2748          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2749              SQLINTEGER len = 0;              SQLLEN len = 0;
2750              groupid_t gid = 0;              groupid_t gid = 0;
2751              SQLBindCol( hstmt, 1, SQL_C_ULONG, &gid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &gid, 0, &len );
2752              *groupsLen=0;              *groupsLen=0;
# Line 2808  bool isModerator( sessionid_t sid, useri Line 2815  bool isModerator( sessionid_t sid, useri
2815          sql = "SELECT value FROM " + dbprefix + "_xnpaccount_config";          sql = "SELECT value FROM " + dbprefix + "_xnpaccount_config";
2816          sql += " WHERE name='moderator_gid'";          sql += " WHERE name='moderator_gid'";
2817          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2818              SQLINTEGER len = 0;              SQLLEN len = 0;
2819              SQLBindCol( hstmt, 1, SQL_C_ULONG, &moderator_gid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &moderator_gid, 0, &len );
2820              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
2821                  sql = "SELECT * from " + dbprefix + "_groups_users_link ";                  sql = "SELECT * from " + dbprefix + "_groups_users_link ";
# Line 2870  result_t getUid( const char* uname, user Line 2877  result_t getUid( const char* uname, user
2877      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2878          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2879              userid_t _uid = 0;              userid_t _uid = 0;
2880              SQLINTEGER len = 0;              SQLLEN len = 0;
2881              SQLBindCol( hstmt, 1, SQL_C_ULONG, &_uid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &_uid, 0, &len );
2882              sqlcode = SQLFetch( hstmt );              sqlcode = SQLFetch( hstmt );
2883              if( sqlcode == SQL_SUCCESS ){              if( sqlcode == SQL_SUCCESS ){
# Line 2944  result_t loginUser(const char* uname, co Line 2951  result_t loginUser(const char* uname, co
2951      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2952          sql = "SELECT uid FROM " + dbprefix + "_users WHERE uname = ? and pass = ? ";          sql = "SELECT uid FROM " + dbprefix + "_users WHERE uname = ? and pass = ? ";
2953          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
2954          SQLINTEGER cbUname = SQL_NTS, cbPasswd = SQL_NTS;          SQLLEN cbUname = SQL_NTS, cbPasswd = SQL_NTS;
2955          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(uname), 0, (SQLCHAR *)uname, 0, &cbUname );          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(uname), 0, (SQLCHAR *)uname, 0, &cbUname );
2956          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(passwd),0, (SQLCHAR *)passwd,0, &cbPasswd );          SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(passwd),0, (SQLCHAR *)passwd,0, &cbPasswd );
2957          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){
2958              SQLUINTEGER sUID = 0;              SQLUINTEGER sUID = 0;
2959              SQLINTEGER len = 0;              SQLLEN len = 0;
2960              SQLBindCol( hstmt, 1, SQL_C_ULONG, &sUID, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &sUID, 0, &len );
2961              if ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
2962                  ret = addSession( (userid_t)sUID, session );                  ret = addSession( (userid_t)sUID, session );
# Line 2996  void logoutUser( sessionid_t sid ) Line 3003  void logoutUser( sessionid_t sid )
3003  {  {
3004      if( hdbc == NULL ) return; // RES_DB_NOT_INITIALIZED;      if( hdbc == NULL ) return; // RES_DB_NOT_INITIALIZED;
3005            
     result_t ret;  
3006      string sql;      string sql;
3007      SQLRETURN sqlcode;      SQLRETURN sqlcode;
3008      SQLHANDLE hstmt = NULL;          SQLHANDLE hstmt = NULL;    
# Line 3055  result_t createSession( const char* sess Line 3061  result_t createSession( const char* sess
3061          sql = "SELECT sess_id from " + dbprefix + "_session where sess_id=?";          sql = "SELECT sess_id from " + dbprefix + "_session where sess_id=?";
3062          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
3063          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
3064              SQLINTEGER cbSess_id = SQL_NTS;              SQLLEN cbSess_id = SQL_NTS;
3065              SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(sess_id), 0, (SQLCHAR*)sess_id, 0, &cbSess_id );              SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(sess_id), 0, (SQLCHAR*)sess_id, 0, &cbSess_id );
3066              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){
3067                  if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){                  if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
# Line 3100  result_t getSession( sessionid_t sid, co Line 3106  result_t getSession( sessionid_t sid, co
3106      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
3107          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3108              userid_t uid = 0;              userid_t uid = 0;
3109              SQLINTEGER cbUid = 0;              SQLLEN cbUid = 0;
3110              unsigned long date = 0;              unsigned long date = 0;
3111              SQLINTEGER cbDate = 0;              SQLLEN cbDate = 0;
3112              SQLBindCol( hstmt, 2, SQL_C_ULONG, &uid, 0, &cbUid );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &uid, 0, &cbUid );
3113              SQLBindCol( hstmt, 3, SQL_C_ULONG, &date, 0, &cbDate );              SQLBindCol( hstmt, 3, SQL_C_ULONG, &date, 0, &cbDate );
3114              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
# Line 3188  result_t insertItem( sessionid_t sid, co Line 3194  result_t insertItem( sessionid_t sid, co
3194      if( !isActivatedBySession( sid ) ) return RES_NO_WRITE_ACCESS_RIGHT;      if( !isActivatedBySession( sid ) ) return RES_NO_WRITE_ACCESS_RIGHT;
3195            
3196      string sql;      string sql;
3197      SQLHANDLE hstmt = NULL, hstmt2 = NULL;      SQLHANDLE hstmt = NULL;
3198      SQLRETURN sqlcode;      SQLRETURN sqlcode;
3199      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
3200      SQLINTEGER uid, item_type_id, creation_date, last_update_date;      SQLINTEGER uid, item_type_id, creation_date, last_update_date;
3201      SQLINTEGER cbUid = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0;      SQLLEN cbUid = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0;
3202      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],
3203          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],
3204          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],
3205          doi[ XNP_ITEM_DOI_LEN + 1 ];          doi[ XNP_ITEM_DOI_LEN + 1 ];
3206      SQLINTEGER cbTitle = SQL_NTS,      SQLLEN cbTitle = SQL_NTS,
3207          cbKeywords = SQL_NTS,          cbKeywords = SQL_NTS,
3208          cbDescription = SQL_NTS,          cbDescription = SQL_NTS,
3209          cbDOI = SQL_NTS;          cbDOI = SQL_NTS;
# Line 3241  result_t insertItem( sessionid_t sid, co Line 3247  result_t insertItem( sessionid_t sid, co
3247                              //insert into private index                              //insert into private index
3248                              sql = "SELECT private_index_id FROM " + dbprefix + "_xnpaccount_users ";                              sql = "SELECT private_index_id FROM " + dbprefix + "_xnpaccount_users ";
3249                              sql += " WHERE uid=" + unsignedIntToString( uid );                              sql += " WHERE uid=" + unsignedIntToString( uid );
3250                              //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );                              syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3251                              if( ( ret = queryGetUnsignedInt( "insertItem", sql, (unsigned int*)&private_xid ) ) == RES_OK ){                              if( ( ret = queryGetUnsignedInt( "insertItem", sql, (unsigned int*)&private_xid ) ) == RES_OK ){
3252                                  ret = registerItem( sid, private_xid, *itemid );                                  ret = registerItem( sid, private_xid, *itemid );
3253                              }                              }
# Line 3384  result_t getItems( sessionid_t sid, cons Line 3390  result_t getItems( sessionid_t sid, cons
3390  */  */
3391      sql += criteria2str( cri );      sql += criteria2str( cri );
3392            
3393      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3394      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
3395          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3396              userid_t uid = 0;              userid_t uid = 0;
# Line 3392  result_t getItems( sessionid_t sid, cons Line 3398  result_t getItems( sessionid_t sid, cons
3398              itemtypeid_t item_type_id = 0;              itemtypeid_t item_type_id = 0;
3399              time_t creation_date = 0;              time_t creation_date = 0;
3400              time_t last_update_date = 0;              time_t last_update_date = 0;
3401              SQLINTEGER cbUid = 0, cbItem_id = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0;              SQLLEN cbUid = 0, cbItem_id = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0;
3402              SQLBindCol( hstmt, 1, SQL_C_ULONG, &item_id, 0, &cbItem_id );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &item_id, 0, &cbItem_id );
3403              SQLBindCol( hstmt, 2, SQL_C_ULONG, &item_type_id, 0, &cbItem_type_id );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &item_type_id, 0, &cbItem_type_id );
3404              SQLBindCol( hstmt, 7, SQL_C_ULONG, &uid, 0, &cbUid );              SQLBindCol( hstmt, 7, SQL_C_ULONG, &uid, 0, &cbUid );
# Line 3480  result_t dumpItemID(sessionid_t sid, cri Line 3486  result_t dumpItemID(sessionid_t sid, cri
3486            
3487      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
3488          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3489              SQLINTEGER len = 0;              SQLLEN len = 0;
3490              SQLUINTEGER itemid = 0;              SQLUINTEGER itemid = 0;
3491              SQLBindCol( hstmt, 1, SQL_C_ULONG, &itemid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &itemid, 0, &len );
3492              *iidsLen = 0;              *iidsLen = 0;
# Line 3539  result_t updateItem( sessionid_t sid, co Line 3545  result_t updateItem( sessionid_t sid, co
3545          return RES_ERROR;          return RES_ERROR;
3546      }      }
3547            
3548      SQLINTEGER uid, item_type_id, creation_date, last_update_date, item_id;      SQLINTEGER uid, item_type_id, last_update_date, item_id;
3549      SQLINTEGER cbUid = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0, cbItem_id = 0;      SQLLEN cbUid = 0, cbItem_type_id = 0, cbLast_update_date = 0, cbItem_id = 0;
3550      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],
3551          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],
3552          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],
3553          doi[ XNP_ITEM_DOI_LEN + 1 ];          doi[ XNP_ITEM_DOI_LEN + 1 ];
3554      SQLINTEGER cbTitle = SQL_NTS,      SQLLEN cbTitle = SQL_NTS,
3555          cbKeywords = SQL_NTS,          cbKeywords = SQL_NTS,
3556          cbDescription = SQL_NTS,          cbDescription = SQL_NTS,
3557          cbDOI = SQL_NTS;          cbDOI = SQL_NTS;
# Line 3585  result_t updateItem( sessionid_t sid, co Line 3591  result_t updateItem( sessionid_t sid, co
3591                  SQLINTEGER count = 0;                  SQLINTEGER count = 0;
3592                  if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){                  if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){
3593                      char* certify_item_val;                      char* certify_item_val;
3594                      if( getXoopsModuleConfigValue( "xnpaccount", XNP_CONFIG_CERTIFY_ITEM_KEY, &certify_item_val ) == RES_OK ){                      if( getConfigValue( XNP_CONFIG_CERTIFY_ITEM_KEY, &certify_item_val ) == RES_OK ){
                         //if( getConfigValue( XNP_CONFIG_CERTIFY_ITEM_KEY, &certify_item_val ) == RES_OK ){  
3595                          SQLHANDLE hstmt2 = NULL;                          SQLHANDLE hstmt2 = NULL;
3596                          certify_t cerity_state = index::NOT_CERTIFIED;                          certify_t cerity_state = index::NOT_CERTIFIED;
3597                          if( strcmp( certify_item_val, XNP_CONFIG_CERTIFY_ITEM_AUTO ) == 0 ){                          if( strcmp( certify_item_val, XNP_CONFIG_CERTIFY_ITEM_AUTO ) == 0 ){
# Line 3605  result_t updateItem( sessionid_t sid, co Line 3610  result_t updateItem( sessionid_t sid, co
3610                              sql += " OR tx.open_level=" + unsignedIntToString( index::OL_GROUP_ONLY );                              sql += " OR tx.open_level=" + unsignedIntToString( index::OL_GROUP_ONLY );
3611                              sql += ") AND ti.item_type_id!=" + unsignedIntToString( item::ITID_BINDER );                              sql += ") AND ti.item_type_id!=" + unsignedIntToString( item::ITID_BINDER );
3612                              sql += " AND tlink.item_id=" + unsignedIntToString( item_id );                              sql += " AND tlink.item_id=" + unsignedIntToString( item_id );
3613                              //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );                              syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3614                              if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                              if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3615                                  SQLINTEGER len = 0;                                  SQLLEN len = 0;
3616                                  SQLUINTEGER registered_index_id = 0;                                  SQLUINTEGER registered_index_id = 0;
3617                                  SQLBindCol( hstmt2,1, SQL_C_ULONG, &registered_index_id, 0, &len );                                  SQLBindCol( hstmt2,1, SQL_C_ULONG, &registered_index_id, 0, &len );
3618                                  certify_t certify_state = getInitialCertifyStateFromConfig( );                                  certify_t certify_state = getInitialCertifyStateFromConfig( );
# Line 3615  result_t updateItem( sessionid_t sid, co Line 3620  result_t updateItem( sessionid_t sid, co
3620                                      string sql = "UPDATE " + dbprefix + "_xnpaccount_index_item_link";                                      string sql = "UPDATE " + dbprefix + "_xnpaccount_index_item_link";
3621                                      sql += " SET certify_state=" + unsignedIntToString( certify_state );                                      sql += " SET certify_state=" + unsignedIntToString( certify_state );
3622                                      sql += " WHERE index_item_link_id=" + unsignedIntToString( registered_index_id );                                      sql += " WHERE index_item_link_id=" + unsignedIntToString( registered_index_id );
3623                                      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );                                      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3624                                      querySimple( "updateItem", sql );                                      querySimple( "updateItem", sql );
3625                                  }                                  }
3626                                  ret = RES_OK;                                  ret = RES_OK;
# Line 3632  result_t updateItem( sessionid_t sid, co Line 3637  result_t updateItem( sessionid_t sid, co
3637                              setLastErrorString( s.c_str( ) );                              setLastErrorString( s.c_str( ) );
3638                              ret = RES_ERROR;                              ret = RES_ERROR;
3639                          }                          }
3640                          //fprintf( stderr, "\n%08lx '%s'", certify_item_val, certify_item_val );                          syslog_printf( "\n%08lx '%s'", certify_item_val, certify_item_val );
3641                          if( certify_item_val != 0 ) freeString( certify_item_val );                          if( certify_item_val != 0 ) freeString( certify_item_val );
3642                          certify_item_val = 0;                          certify_item_val = 0;
3643                      }else{                      }else{
# Line 3694  result_t deleteItem( sessionid_t sid, it Line 3699  result_t deleteItem( sessionid_t sid, it
3699      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
3700      criteria_t c;      criteria_t c;
3701      string sql;      string sql;
     groupid_t* gids;  
     int gidsLen;  
3702      SQLRETURN sqlcode;      SQLRETURN sqlcode;
3703      SQLHANDLE hstmt = NULL;      SQLHANDLE hstmt = NULL;
3704      const item_t* pitem;      const item_t* pitem;
3705      userid_t item_uid;      userid_t item_uid;
     const session_t* psess;  
3706            
3707      // retrieve an item's owner uid      // retrieve an item's owner uid
3708      if( getItem( sid, itemid, &pitem ) != RES_OK )      if( getItem( sid, itemid, &pitem ) != RES_OK )
# Line 3797  result_t getPrivateItemID( sessionid_t s Line 3799  result_t getPrivateItemID( sessionid_t s
3799      sql += " AND ( ti.uid=" + unsignedIntToString( sess_uid );      sql += " AND ( ti.uid=" + unsignedIntToString( sess_uid );
3800      sql +=       " OR is_admin=1 AND tgulink.uid=" + unsignedIntToString( sess_uid );      sql +=       " OR is_admin=1 AND tgulink.uid=" + unsignedIntToString( sess_uid );
3801      sql += ")";      sql += ")";
3802      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3803      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
3804          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3805              itemid_t iid = 0;              itemid_t iid = 0;
3806              SQLINTEGER cbIid = 0;              SQLLEN cbIid = 0;
3807              SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &cbIid );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &cbIid );
3808                            
3809              string notin;              string notin;
# Line 3822  result_t getPrivateItemID( sessionid_t s Line 3824  result_t getPrivateItemID( sessionid_t s
3824                  return RES_OK;                  return RES_OK;
3825              }              }
3826  */  */
3827              //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );              syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3828                            
3829              if( countResultRows( sql.c_str(), &count ) == RES_OK ){              if( countResultRows( sql.c_str(), &count ) == RES_OK ){
3830                  dst = new itemid_t[ count ];                  dst = new itemid_t[ count ];
# Line 3834  result_t getPrivateItemID( sessionid_t s Line 3836  result_t getPrivateItemID( sessionid_t s
3836              if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt2 ) ) == SQL_SUCCESS ) {              if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt2 ) ) == SQL_SUCCESS ) {
3837                  if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                  if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3838                      itemid_t iid;                      itemid_t iid;
3839                      SQLINTEGER len = 0;                      SQLLEN len = 0;
3840                      SQLBindCol( hstmt2, 1, SQL_C_ULONG, &iid, 0, &len );                      SQLBindCol( hstmt2, 1, SQL_C_ULONG, &iid, 0, &len );
3841                      *iidsLen = 0;                      *iidsLen = 0;
3842                      for( int i = 0; ( sqlcode = SQLFetch( hstmt2 ) ) == SQL_SUCCESS && i < count ; i++ ){                      for( int i = 0; ( sqlcode = SQLFetch( hstmt2 ) ) == SQL_SUCCESS && i < count ; i++ ){
# Line 3931  result_t getItemIDByIndexID( sessionid_t Line 3933  result_t getItemIDByIndexID( sessionid_t
3933      sql+=    ") AND ti.item_type_id!=" + unsignedIntToString( item::ITID_INDEX );      sql+=    ") AND ti.item_type_id!=" + unsignedIntToString( item::ITID_INDEX );
3934      sql += " AND tx.index_id=" + unsignedIntToString( xid );      sql += " AND tx.index_id=" + unsignedIntToString( xid );
3935      sql += criteria2str( cri );      sql += criteria2str( cri );
3936      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
3937      if( countResultRows( sql.c_str(), &count ) == RES_OK ){      if( countResultRows( sql.c_str(), &count ) == RES_OK ){
3938          dst = new itemid_t[ count ];          dst = new itemid_t[ count ];
3939          *iids = dst;          *iids = dst;
# Line 3942  result_t getItemIDByIndexID( sessionid_t Line 3944  result_t getItemIDByIndexID( sessionid_t
3944      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
3945          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
3946              itemid_t iid;              itemid_t iid;
3947              SQLINTEGER len = 0;              SQLLEN len = 0;
3948              SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &len );
3949              *iidsLen = 0;              *iidsLen = 0;
3950              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < count ; i++ ){              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < count ; i++ ){
# Line 4009  result_t getItemIDByBinderID( sessionid_ Line 4011  result_t getItemIDByBinderID( sessionid_
4011      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
4012          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
4013              itemid_t iid;              itemid_t iid;
4014              SQLINTEGER len = 0;              SQLLEN len = 0;
4015              SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &len );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &len );
4016              *iidsLen = 0;              *iidsLen = 0;
4017              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < count ; i++ ){              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < count ; i++ ){
# Line 4057  result_t getCertifyState( sessionid_t si Line 4059  result_t getCertifyState( sessionid_t si
4059      sql += " FROM " + dbprefix + "_xnpaccount_index_item_link";      sql += " FROM " + dbprefix + "_xnpaccount_index_item_link";
4060      sql += " WHERE item_id = " + unsignedIntToString( iid );      sql += " WHERE item_id = " + unsignedIntToString( iid );
4061      sql += " AND index_id = " + unsignedIntToString( xid );      sql += " AND index_id = " + unsignedIntToString( xid );
4062      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4063      return queryGetUnsignedInt( "getCertifyState", sql, (unsigned int*)certify );      return queryGetUnsignedInt( "getCertifyState", sql, (unsigned int*)certify );
4064  }  }
4065    
# Line 4098  result_t setCertifyState( sessionid_t si Line 4100  result_t setCertifyState( sessionid_t si
4100   */   */
4101  bool getCertifyPermission( sessionid_t sid, indexid_t xid, itemid_t iid, certify_t state )  bool getCertifyPermission( sessionid_t sid, indexid_t xid, itemid_t iid, certify_t state )
4102  {  {
4103        if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED;
4104        if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
4105        
4106        int i = 0;
4107        SQLHANDLE hstmt = NULL;
4108        result_t ret = RES_ERROR;
4109        itemid_t* dst_iids = 0;
4110        indexid_t* dst_xids = 0;
4111        string sql;
4112        SQLRETURN sqlcode;
4113        SQLINTEGER count = 0;
4114        userid_t sess_uid;
4115        
4116        if( ( ret = sessionID2UID( sid, &sess_uid ) ) != RES_OK ) return ret;
4117        
4118            sql = "SELECT DISTINCT tlink.index_id, tlink.item_id";
4119            sql += " FROM " + dbprefix + "_xnpaccount_index_item_link AS tlink";
4120            sql += " LEFT JOIN " + dbprefix + "_xnpaccount_index AS tx ON tlink.index_id = tx.index_id";
4121            sql += " LEFT JOIN " + dbprefix + "_xnpaccount_item_basic AS ti ON tlink.item_id = ti.item_id";
4122            sql += " LEFT JOIN " + dbprefix + "_xnpaccount_groups_users_link AS tgulink ON tgulink.gid = tx.gid AND tx.open_level =" + unsignedIntToString( index::OL_GROUP_ONLY );;
4123            sql += " WHERE open_level<=" + unsignedIntToString( index::OL_GROUP_ONLY );
4124        sql += " AND item_type_id !=" + unsignedIntToString( item::ITID_INDEX );
4125            sql += " AND ti.item_id=" + unsignedIntToString( iid );
4126            sql += " AND tx.index_id=" + unsignedIntToString( xid );
4127            sql += " AND ( is_admin=1 AND tgulink.uid=" + unsignedIntToString( sess_uid );
4128        sql += " OR item_type_id =" + unsignedIntToString( item::ITID_BINDER ); //すべてのバインダーを承認
4129        sql += string( isModerator( sid, sess_uid ) ? " OR 1)" : " OR 0)" ); //モデレータならOR 1,それ以外は OR 0
4130        syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4131    
4132        if( countResultRows( sql.c_str(), &count ) != RES_OK ){
4133            return false;
4134        }
4135        return count > 0;
4136    
4137    #if 0
4138      //available if moderator      //available if moderator
4139      if( isModeratorBySession( sid ) ) return true;      if( isModeratorBySession( sid ) ) return true;
4140            
# Line 4109  bool getCertifyPermission( sessionid_t s Line 4146  bool getCertifyPermission( sessionid_t s
4146              return true;              return true;
4147          }          }
4148          //          //
         indexid_t index_uid = index -> getOwnerUID( );  
4149          freeIndex( index );          freeIndex( index );
4150          userid_t sess_uid;          userid_t sess_uid;
4151          if( sessionID2UID( sid, &sess_uid ) == RES_OK ){          if( sessionID2UID( sid, &sess_uid ) == RES_OK ){
# Line 4129  bool getCertifyPermission( sessionid_t s Line 4165  bool getCertifyPermission( sessionid_t s
4165          }          }
4166      }      }
4167      return false;      return false;
4168    #endif
4169  }  }
4170    
4171  result_t getOverlappedItems( sessionid_t sid, indexid_t xid, item_t* item, itemid_t** iids, int* iidsLen ){ return RES_ERROR; }  result_t getOverlappedItems( sessionid_t sid, indexid_t xid, item_t* item, itemid_t** iids, int* iidsLen ){ return RES_ERROR; }
# Line 4152  result_t registerItem( sessionid_t sid, Line 4189  result_t registerItem( sessionid_t sid,
4189  {  {
4190      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
4191            
     userid_t uid;  
     const index_t* index;  
     unsigned int tmp;  
     char* certify_item_val;  
4192      string sql;      string sql;
4193      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
4194            
# Line 4166  result_t registerItem( sessionid_t sid, Line 4199  result_t registerItem( sessionid_t sid,
4199          + unsignedIntToString(xid) + ","          + unsignedIntToString(xid) + ","
4200          + unsignedIntToString(iid) + ","          + unsignedIntToString(iid) + ","
4201          + unsignedIntToString( getInitialCertifyStateFromConfig( ) ) + ")";          + unsignedIntToString( getInitialCertifyStateFromConfig( ) ) + ")";
4202      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4203      ret = querySimple( "registerItem", sql );      ret = querySimple( "registerItem", sql );
4204      if( ret == RES_OK ){      if( ret == RES_OK ){
4205          // update last update date          // update last update date
4206          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="
4207              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="
4208              + unsignedIntToString( xid );              + unsignedIntToString( xid );
4209          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4210          ret = querySimple( "registerItem", sql );          ret = querySimple( "registerItem", sql );
4211      }      }
4212      return ret;      return ret;
# Line 4197  result_t unregisterItem( sessionid_t sid Line 4230  result_t unregisterItem( sessionid_t sid
4230  {  {
4231      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
4232            
     userid_t uid;  
     const index_t* index;  
     unsigned int tmp;  
4233      string sql;      string sql;
4234      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
4235            
# Line 4209  result_t unregisterItem( sessionid_t sid Line 4239  result_t unregisterItem( sessionid_t sid
4239      sql = "DELETE FROM " + dbprefix + "_xnpaccount_index_item_link";      sql = "DELETE FROM " + dbprefix + "_xnpaccount_index_item_link";
4240      sql += " WHERE index_id=" + unsignedIntToString(xid);      sql += " WHERE index_id=" + unsignedIntToString(xid);
4241      sql += " AND item_id=" + unsignedIntToString(iid);      sql += " AND item_id=" + unsignedIntToString(iid);
4242      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4243      ret = querySimple( "unregisterItem", sql );      ret = querySimple( "unregisterItem", sql );
4244      if( ret == RES_OK ){      if( ret == RES_OK ){
4245          // update last update date          // update last update date
4246          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="
4247              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="
4248              + unsignedIntToString( xid );              + unsignedIntToString( xid );
4249          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4250          ret = querySimple( "unregisterItem", sql );          ret = querySimple( "unregisterItem", sql );
4251      }      }
4252      return ret;      return ret;
# Line 4240  result_t registerBinderItem( sessionid_t Line 4270  result_t registerBinderItem( sessionid_t
4270  {  {
4271      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
4272            
     userid_t uid;  
     const index_t* index;  
     unsigned int tmp;  
     char* certify_item_val;  
4273      string sql;      string sql;
4274      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
4275            
# Line 4253  result_t registerBinderItem( sessionid_t Line 4279  result_t registerBinderItem( sessionid_t
4279      sql = "INSERT INTO " + dbprefix + "_xnpaccount_binder_item_link (binder_id, item_id) values ("      sql = "INSERT INTO " + dbprefix + "_xnpaccount_binder_item_link (binder_id, item_id) values ("
4280          + unsignedIntToString(binderid) + ","          + unsignedIntToString(binderid) + ","
4281          + unsignedIntToString(iid) + ")";          + unsignedIntToString(iid) + ")";
4282      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4283      ret = querySimple( "registerBinderItem", sql );      ret = querySimple( "registerBinderItem", sql );
4284      if( ret == RES_OK ){      if( ret == RES_OK ){
4285          // update binder's last update date          // update binder's last update date
4286          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="
4287              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="
4288              + unsignedIntToString( binderid );              + unsignedIntToString( binderid );
4289          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4290          ret = querySimple( "registerBinderItem", sql );          ret = querySimple( "registerBinderItem", sql );
4291      }      }
4292      return ret;      return ret;
# Line 4284  result_t unregisterBinderItem( sessionid Line 4310  result_t unregisterBinderItem( sessionid
4310  {  {
4311      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
4312            
     userid_t uid;  
     const index_t* index;  
     unsigned int tmp;  
4313      string sql;      string sql;
4314      result_t ret = RES_OK;      result_t ret = RES_OK;
4315            
# Line 4296  result_t unregisterBinderItem( sessionid Line 4319  result_t unregisterBinderItem( sessionid
4319      sql = "DELETE FROM " + dbprefix + "_xnpaccount_binder_item_link";      sql = "DELETE FROM " + dbprefix + "_xnpaccount_binder_item_link";
4320      sql += " WHERE binder_id=" + unsignedIntToString(binderid);      sql += " WHERE binder_id=" + unsignedIntToString(binderid);
4321      sql += " AND item_id=" + unsignedIntToString(iid);      sql += " AND item_id=" + unsignedIntToString(iid);
4322      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4323      ret = querySimple( "unregisterBinderItem", sql );      ret = querySimple( "unregisterBinderItem", sql );
4324      if( ret == RES_OK ){      if( ret == RES_OK ){
4325          // update binder's last update date          // update binder's last update date
4326          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="          sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="
4327              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="              + unsignedIntToString( time( NULL ) ) + " WHERE item_id="
4328              + unsignedIntToString( binderid );              + unsignedIntToString( binderid );
4329          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4330          ret = querySimple( "unregisterBinderItem", sql );          ret = querySimple( "unregisterBinderItem", sql );
4331      }      }
4332      return ret;      return ret;
# Line 4332  bool getItemPermission( sessionid_t sid, Line 4355  bool getItemPermission( sessionid_t sid,
4355          sql = "SELECT DISTINCT tlink.item_id FROM " + dbprefix + "_xnpaccount_index_item_link AS tlink";          sql = "SELECT DISTINCT tlink.item_id FROM " + dbprefix + "_xnpaccount_index_item_link AS tlink";
4356          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_index AS tx ON tlink.index_id = tx.index_id";          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_index AS tx ON tlink.index_id = tx.index_id";
4357          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_item_basic AS ti ON tlink.item_id = ti.item_id";          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_item_basic AS ti ON tlink.item_id = ti.item_id";
4358          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_groups_users_link as tgulink ON tx.gid=tgulink.gid AND (ti.uid=";          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_groups_users_link as tgulink ON tx.gid=tgulink.gid";
4359          sql+= unsignedIntToString( uid ) + " OR ";          sql+= " LEFT JOIN " + dbprefix + "_xnpaccount_config AS tc ON tc.name=\"" XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_KEY "\" LEFT JOIN ";
         sql+= string( isModerator( sid, uid ) ? "1" : "0" ) + ") LEFT JOIN ";  
         sql+= dbprefix + "_xnpaccount_config AS tc ON tc.name=\"" XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_KEY "\" LEFT JOIN ";  
4360          sql+= dbprefix + "_xnpaccount_session AS tsess ON tsess.uid=" + unsignedIntToString( uid );          sql+= dbprefix + "_xnpaccount_session AS tsess ON tsess.uid=" + unsignedIntToString( uid );
4361          sql+= " WHERE ( tc.value=\"" XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_ALL "\"";          sql+= " WHERE ( tc.value=\"" XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_ALL "\"";
4362          sql+=       " AND tx.open_level=" + unsignedIntToString( index::OL_PUBLIC ) + " AND tsess.uid IS NULL";          sql+=       " AND tx.open_level=" + unsignedIntToString( index::OL_PUBLIC ) + " AND tsess.uid IS NULL";
# Line 4347  bool getItemPermission( sessionid_t sid, Line 4368  bool getItemPermission( sessionid_t sid,
4368          sql+=    " OR " + string( isModerator( sid, uid ) ? "1" : "0" );          sql+=    " OR " + string( isModerator( sid, uid ) ? "1" : "0" );
4369          sql+=    " OR tx.uid IS NULL ";          sql+=    " OR tx.uid IS NULL ";
4370          sql+=    " AND tx.open_level=" + unsignedIntToString( index::OL_PUBLIC );          sql+=    " AND tx.open_level=" + unsignedIntToString( index::OL_PUBLIC );
4371            sql += string( isModerator( sid, uid ) ? " OR 1" : " OR 0" ); //モデレータならOR 1,それ以外は OR 0
4372          sql+=    ") AND tlink.item_id=" + unsignedIntToString( iid );          sql+=    ") AND tlink.item_id=" + unsignedIntToString( iid );
4373          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4374          if( queryGetUnsignedInt( "getItemPermission", sql, (unsigned int*)&itemid ) == RES_OK ){          if( queryGetUnsignedInt( "getItemPermission", sql, (unsigned int*)&itemid ) == RES_OK ){
4375              return itemid == iid;              return itemid == iid;
4376          }          }
# Line 4357  bool getItemPermission( sessionid_t sid, Line 4379  bool getItemPermission( sessionid_t sid,
4379          sql = "SELECT item_id FROM " + dbprefix + "_xnpaccount_item_basic";          sql = "SELECT item_id FROM " + dbprefix + "_xnpaccount_item_basic";
4380          sql += " WHERE uid=" + unsignedIntToString( uid );          sql += " WHERE uid=" + unsignedIntToString( uid );
4381          sql += " AND item_id=" + unsignedIntToString( iid );          sql += " AND item_id=" + unsignedIntToString( iid );
4382          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4383          if( queryGetUnsignedInt( "getItemPermission", sql, (unsigned int*)&itemid ) == RES_OK ){          if( queryGetUnsignedInt( "getItemPermission", sql, (unsigned int*)&itemid ) == RES_OK ){
4384              return itemid == iid;              return itemid == iid;
4385          }          }
# Line 4382  bool getIndexPermission( sessionid_t sid Line 4404  bool getIndexPermission( sessionid_t sid
4404      userid_t uid;      userid_t uid;
4405      unsigned int tmp;      unsigned int tmp;
4406      string sql;      string sql;
4407      if( xid == index::IID_ROOT ) return RES_NO_WRITE_ACCESS_RIGHT;      if( xid == index::IID_ROOT ) return false;
4408            
4409      if( isModeratorBySession( sid ) );      if( isModeratorBySession( sid ) );
4410      else if( xid == item::IID_BINDERS );      else if( xid == item::IID_BINDERS );
# Line 4395  bool getIndexPermission( sessionid_t sid Line 4417  bool getIndexPermission( sessionid_t sid
4417          sql += " OR tx.open_level=2 AND tlink.uid=" + unsignedIntToString( uid );          sql += " OR tx.open_level=2 AND tlink.uid=" + unsignedIntToString( uid );
4418          sql += " OR tx.open_level=3 AND tx.uid=" + unsignedIntToString( uid ) + " )";          sql += " OR tx.open_level=3 AND tx.uid=" + unsignedIntToString( uid ) + " )";
4419          sql += " AND index_id=" + unsignedIntToString( xid );          sql += " AND index_id=" + unsignedIntToString( xid );
4420          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
4421          if( queryGetUnsignedInt( "getIndexPermission", sql, &tmp ) == RES_OK          if( queryGetUnsignedInt( "getIndexPermission", sql, &tmp ) == RES_OK
4422              && tmp == xid );              && tmp == xid );
4423          else return false;          else return false;
# Line 4522  static result_t getIndexesInternal( sess Line 4544  static result_t getIndexesInternal( sess
4544          " LEFT JOIN " + itemTable + " AS ti on tx.index_id = ti.item_id "          " LEFT JOIN " + itemTable + " AS ti on tx.index_id = ti.item_id "
4545          " LEFT JOIN " + groupUserLinkTable + " AS tlink on tlink.gid = tx.gid and tlink.uid = " + uidString +          " LEFT JOIN " + groupUserLinkTable + " AS tlink on tlink.gid = tx.gid and tlink.uid = " + uidString +
4546          " WHERE " + accessRightCond + " AND " + cond;          " WHERE " + accessRightCond + " AND " + cond;
4547      SQLINTEGER len = 0;      SQLLEN len = 0;
4548      result = countResultRows( sql.c_str(), &len );      result = countResultRows( sql.c_str(), &len );
4549      if ( result != RES_OK )      if ( result != RES_OK )
4550          return result;          return result;
# Line 4538  static result_t getIndexesInternal( sess Line 4560  static result_t getIndexesInternal( sess
4560          " LEFT JOIN " + itemTable + " AS ti on tx.index_id = ti.item_id "          " LEFT JOIN " + itemTable + " AS ti on tx.index_id = ti.item_id "
4561          " LEFT JOIN " + groupUserLinkTable + " AS tlink on tlink.gid = tx.gid and tlink.uid = " + uidString +          " LEFT JOIN " + groupUserLinkTable + " AS tlink on tlink.gid = tx.gid and tlink.uid = " + uidString +
4562          " WHERE " + accessRightCond + " AND " + cond + criteriaString;          " WHERE " + accessRightCond + " AND " + cond + criteriaString;
4563      SQLCHAR subtype[XNP_ITEM_SUBTYPE_LEN+1], title[XNP_ITEM_TITLE_LEN+1],      SQLCHAR title[XNP_ITEM_TITLE_LEN+1],
4564        keywords[XNP_ITEM_KEYWORDS_LEN+1], description[XNP_ITEM_DESCRIPTION_LEN+1];        keywords[XNP_ITEM_KEYWORDS_LEN+1], description[XNP_ITEM_DESCRIPTION_LEN+1];
4565      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
4566          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
4567              SQLUINTEGER xid = 0, parentXID = 0, ownerUID = 0, ownerGID = 0, openLevel = 0,              SQLUINTEGER xid = 0, parentXID = 0, ownerUID = 0, ownerGID = 0, openLevel = 0,
4568               sortNumber = 0, itemTypeID = 0, contributorUID = 0, lastUpdateDate = 0, creationDate = 0;               sortNumber = 0, itemTypeID = 0, contributorUID = 0, lastUpdateDate = 0, creationDate = 0;
4569              SQLINTEGER lens[14];              SQLLEN lens[14];
4570              memset( lens, 0, sizeof( SQLINTEGER ) * 14 );              memset( lens, 0, sizeof( SQLINTEGER ) * 14 );
4571              SQLBindCol( hstmt, 1, SQL_C_ULONG, &xid, 0, lens+0 );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &xid, 0, lens+0 );
4572              SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentXID, 0, lens+1 );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentXID, 0, lens+1 );
# Line 4659  bool isGroupMemberInternal( sessionid_t Line 4681  bool isGroupMemberInternal( sessionid_t
4681            
4682      bool ret = false;      bool ret = false;
4683      string sql;      string sql;
     SQLRETURN sqlcode;  
4684      SQLINTEGER count = 0;      SQLINTEGER count = 0;
4685            
4686      sql = "SELECT * FROM " + dbprefix + "_xnpaccount_groups_users_link ";      sql = "SELECT * FROM " + dbprefix + "_xnpaccount_groups_users_link ";
# Line 4953  result_t insertIndex( sessionid_t sid, i Line 4974  result_t insertIndex( sessionid_t sid, i
4974      SQLHANDLE hstmt = NULL;          SQLHANDLE hstmt = NULL;    
4975      string sql;      string sql;
4976            
4977      SQLINTEGER cbTitle = SQL_NTS;      SQLLEN cbTitle = SQL_NTS;
4978      string indexTable = dbprefix + "_xnpaccount_index";      string indexTable = dbprefix + "_xnpaccount_index";
4979      string itemTable = dbprefix + "_xnpaccount_item_basic";      string itemTable = dbprefix + "_xnpaccount_item_basic";
4980      sql = "SELECT tx_parent.uid, tx_parent.gid, tx_parent.open_level, tx_child.index_id, ti_child.item_id "      sql = "SELECT tx_parent.uid, tx_parent.gid, tx_parent.open_level, tx_child.index_id, ti_child.item_id "
# Line 4965  result_t insertIndex( sessionid_t sid, i Line 4986  result_t insertIndex( sessionid_t sid, i
4986          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_TITLE_LEN, 0, (SQLCHAR *)index->getTitle(), strlen(index->getTitle()), &cbTitle );          SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_TITLE_LEN, 0, (SQLCHAR *)index->getTitle(), strlen(index->getTitle()), &cbTitle );
4987          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
4988              SQLUINTEGER parentUID = 0, parentGID = 0, parentOpenLevel = 0, childXID = 0, childItemID = 0;              SQLUINTEGER parentUID = 0, parentGID = 0, parentOpenLevel = 0, childXID = 0, childItemID = 0;
4989              SQLINTEGER len1 = 0, len2 = 0, len3 = 0, len4 = 0, len5 = 0;              SQLLEN len1 = 0, len2 = 0, len3 = 0, len4 = 0, len5 = 0;
4990              SQLBindCol( hstmt, 1, SQL_C_ULONG, &parentUID, 0, &len1 );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &parentUID, 0, &len1 );
4991              SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentGID, 0, &len2 );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentGID, 0, &len2 );
4992              SQLBindCol( hstmt, 3, SQL_C_ULONG, &parentOpenLevel, 0, &len3 );              SQLBindCol( hstmt, 3, SQL_C_ULONG, &parentOpenLevel, 0, &len3 );
# Line 5075  result_t getDescendantIndexID( int xid, Line 5096  result_t getDescendantIndexID( int xid,
5096              string sql = "SELECT index_id FROM " + dbprefix + "_xnpaccount_index WHERE parent_index_id=" + unsignedIntToString(xid);              string sql = "SELECT index_id FROM " + dbprefix + "_xnpaccount_index WHERE parent_index_id=" + unsignedIntToString(xid);
5097              if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
5098                  SQLUINTEGER sXID = 0;                  SQLUINTEGER sXID = 0;
5099                  SQLINTEGER len = 0;                  SQLLEN len = 0;
5100                  SQLBindCol( hstmt, 1, SQL_C_ULONG, &sXID, 0, &len );                  SQLBindCol( hstmt, 1, SQL_C_ULONG, &sXID, 0, &len );
5101                  while ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){                  while ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
5102                      *pFill++ = sXID;                      *pFill++ = sXID;
# Line 5137  static result_t getAllIndexLink( indexLi Line 5158  static result_t getAllIndexLink( indexLi
5158          string sql("SELECT index_id, parent_index_id FROM " + dbprefix + "_xnpaccount_index ORDER BY index_id");          string sql("SELECT index_id, parent_index_id FROM " + dbprefix + "_xnpaccount_index ORDER BY index_id");
5159          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
5160              SQLUINTEGER xid = 0, parentXID = 0;              SQLUINTEGER xid = 0, parentXID = 0;
5161              SQLINTEGER len1 = 0, len2 = 0;              SQLLEN len1 = 0, len2 = 0;
5162              SQLBindCol( hstmt, 1, SQL_C_ULONG, &xid, 0, &len1 );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &xid, 0, &len1 );
5163              SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentXID, 0, &len2 );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentXID, 0, &len2 );
5164                            
# Line 5188  result_t checkTitleConflict( sessionid_t Line 5209  result_t checkTitleConflict( sessionid_t
5209      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
5210          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
5211          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
5212              SQLINTEGER cbTitle = SQL_NTS;              SQLLEN cbTitle = SQL_NTS;
5213              SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, strlen(title), 0, (SQLCHAR *)title, 0, &cbTitle );              SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, strlen(title), 0, (SQLCHAR *)title, 0, &cbTitle );
5214              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){
5215                  SQLUINTEGER count = 0;                  SQLUINTEGER count = 0;
5216                  SQLINTEGER len;                  SQLLEN len = 0;
5217                  SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );                  SQLBindCol( hstmt, 1, SQL_C_ULONG, &count, 0, &len );
5218                  if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){                  if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
5219                      if ( count == 0 ){                      if ( count == 0 ){
# Line 5357  result_t updateIndexInternal( sessionid_ Line 5378  result_t updateIndexInternal( sessionid_
5378                  " where item_id = " + unsignedIntToString(newIndex->getIndexID()) );                  " where item_id = " + unsignedIntToString(newIndex->getIndexID()) );
5379              sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);              sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
5380              if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){              if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
5381                  SQLINTEGER cb1 = SQL_NTS, cb2 = SQL_NTS, cb3 = SQL_NTS;                  SQLLEN cb1 = SQL_NTS, cb2 = SQL_NTS, cb3 = SQL_NTS;
5382                  SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_DESCRIPTION_LEN, 0, (SQLCHAR *)newIndex->getDescription(), 0, &cb1 );                  SQLBindParameter(hstmt,  1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_DESCRIPTION_LEN, 0, (SQLCHAR *)newIndex->getDescription(), 0, &cb1 );
5383                  SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_TITLE_LEN, 0, (SQLCHAR *)newIndex->getTitle(), 0, &cb2 );                  SQLBindParameter(hstmt,  2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_TITLE_LEN, 0, (SQLCHAR *)newIndex->getTitle(), 0, &cb2 );
5384                  SQLBindParameter(hstmt,  3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_KEYWORDS_LEN, 0, (SQLCHAR *)newIndex->getKeywords(), 0, &cb3 );                  SQLBindParameter(hstmt,  3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_KEYWORDS_LEN, 0, (SQLCHAR *)newIndex->getKeywords(), 0, &cb3 );
# Line 5550  result_t deleteIndex( sessionid_t sid, Line 5571  result_t deleteIndex( sessionid_t sid,
5571                          " WHERE t1.index_id=" + strXID + " and t2.item_id is NULL" );                          " WHERE t1.index_id=" + strXID + " and t2.item_id is NULL" );
5572                      if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                      if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
5573                          SQLUINTEGER sLinkID = 0;                          SQLUINTEGER sLinkID = 0;
5574                          SQLINTEGER len = 0;                          SQLLEN len = 0;
5575                          SQLBindCol( hstmt, 1, SQL_C_ULONG, &sLinkID, 0, &len );                          SQLBindCol( hstmt, 1, SQL_C_ULONG, &sLinkID, 0, &len );
5576                          while ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){                          while ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){
5577                              string sql2( "UPDATE " + linkTable + " set index_id= " + strParentXID + " where index_item_link_id = " + unsignedIntToString(sLinkID) );                              string sql2( "UPDATE " + linkTable + " set index_id= " + strParentXID + " where index_item_link_id = " + unsignedIntToString(sLinkID) );
# Line 5688  result_t setConfigValue( const char* key Line 5709  result_t setConfigValue( const char* key
5709      SQLRETURN sqlcode;      SQLRETURN sqlcode;
5710      SQLHANDLE hstmt = NULL;          SQLHANDLE hstmt = NULL;    
5711      SQLHANDLE hstmt2 = NULL;          SQLHANDLE hstmt2 = NULL;    
5712      SQLINTEGER cbKey = SQL_NTS, cbValue = SQL_NTS;      SQLLEN cbKey = SQL_NTS, cbValue = SQL_NTS;
5713      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
5714            
5715      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
5716          string sql( "UPDATE " + dbprefix + "_xnpaccount_config SET value=? WHERE name=?");          string sql( "UPDATE " + dbprefix + "_xnpaccount_config SET value=? WHERE name=?");
5717          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
5718          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
5719          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
5720              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue );              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue );
# Line 5704  result_t setConfigValue( const char* key Line 5725  result_t setConfigValue( const char* key
5725                      ret = RES_OK;                      ret = RES_OK;
5726                  }else if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt2 ) ) == SQL_SUCCESS ) {                  }else if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt2 ) ) == SQL_SUCCESS ) {
5727                      string sql( "INSERT INTO " + dbprefix + "_xnpaccount_config (name,value) VALUES (?,?)");                      string sql( "INSERT INTO " + dbprefix + "_xnpaccount_config (name,value) VALUES (?,?)");
5728                      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );                      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
5729                      sqlcode = SQLPrepare(hstmt2, (SQLCHAR*)sql.c_str(), SQL_NTS);                      sqlcode = SQLPrepare(hstmt2, (SQLCHAR*)sql.c_str(), SQL_NTS);
5730                      if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){                      if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
5731                          SQLBindParameter(hstmt2, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key  , strlen(key)  , &cbKey );                          SQLBindParameter(hstmt2, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key  , strlen(key)  , &cbKey );
# Line 5769  result_t getConfigValue( const char* key Line 5790  result_t getConfigValue( const char* key
5790  {  {
5791      SQLRETURN sqlcode;      SQLRETURN sqlcode;
5792      SQLHANDLE hstmt = NULL;          SQLHANDLE hstmt = NULL;    
5793      SQLINTEGER cbKey = SQL_NTS;      SQLLEN cbKey = SQL_NTS;
5794      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
5795            
5796      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
# Line 5780  result_t getConfigValue( const char* key Line 5801  result_t getConfigValue( const char* key
5801              if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
5802                  while( SQLFetch( hstmt ) == SQL_SUCCESS ){                  while( SQLFetch( hstmt ) == SQL_SUCCESS ){
5803                      string valuestr;                      string valuestr;
5804                      SQLINTEGER length;                      SQLINTEGER length = 0;
5805                      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );                      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
5806                      // get amount of data                      // get amount of data
5807                      if( SQLGetData(hstmt, 1, SQL_C_BINARY, *value, 0, &length)                      if( SQLGetData(hstmt, 1, SQL_C_BINARY, *value, 0, &length)
5808                          == SQL_SUCCESS_WITH_INFO ){                          == SQL_SUCCESS_WITH_INFO ){
# Line 5862  result_t getChangeLogs( sessionid_t sid, Line 5883  result_t getChangeLogs( sessionid_t sid,
5883      SQLHANDLE hstmt = NULL;      SQLHANDLE hstmt = NULL;
5884      SQLINTEGER count = 0;      SQLINTEGER count = 0;
5885      string sql;      string sql;
5886      SQLINTEGER len = 0;      SQLLEN len = 0;
5887      time_t log_date = 0;      time_t log_date = 0;
5888            
5889      sql = "SELECT log_date, log FROM " +  dbprefix + "_xnpaccount_changelog"      sql = "SELECT log_date, log FROM " +  dbprefix + "_xnpaccount_changelog"
# Line 5927  result_t insertChangeLog( sessionid_t si Line 5948  result_t insertChangeLog( sessionid_t si
5948      time( &now );      time( &now );
5949      // insert change log      // insert change log
5950      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
5951          SQLINTEGER cbLog = SQL_NTS;          SQLLEN cbLog = SQL_NTS;
5952          string sql;          string sql;
5953          sql = "INSERT INTO " + dbprefix + "_xnpaccount_changelog (item_id, log_date, log) VALUES (";          sql = "INSERT INTO " + dbprefix + "_xnpaccount_changelog (item_id, log_date, log) VALUES (";
5954          sql += unsignedIntToString( itemid ) + ", ";          sql += unsignedIntToString( itemid ) + ", ";
5955          sql += unsignedIntToString( now ) + ", ?)";          sql += unsignedIntToString( now ) + ", ?)";
5956          //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );          syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
5957          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
5958          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
5959              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CHANGELOG_LOG_LEN, 0,              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CHANGELOG_LOG_LEN, 0,
# Line 5942  result_t insertChangeLog( sessionid_t si Line 5963  result_t insertChangeLog( sessionid_t si
5963                  sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="                  sql = "UPDATE " + dbprefix + "_xnpaccount_item_basic SET last_update_date="
5964                      + unsignedIntToString( now ) + " WHERE item_id="                      + unsignedIntToString( now ) + " WHERE item_id="
5965                      + unsignedIntToString( itemid );                      + unsignedIntToString( itemid );
5966                  //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );                  syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
5967                  querySimple( "insertChangeLog", sql );                  querySimple( "insertChangeLog", sql );
5968                  ret = RES_OK;                  ret = RES_OK;
5969              }else{              }else{
# Line 6010  void setLastErrorString( const char* str Line 6031  void setLastErrorString( const char* str
6031      syslog( LOG_DEBUG, "%s", str );      syslog( LOG_DEBUG, "%s", str );
6032      closelog( );      closelog( );
6033  #endif  #endif
6034      //fprintf( stderr, "\nsetLastErrorString( '%s' );", str );      syslog_printf( "\nsetLastErrorString( '%s' );", str );
6035  }  }
6036    
6037    
# Line 6030  static xmlChar* getChildText(xmlTextRead Line 6051  static xmlChar* getChildText(xmlTextRead
6051  static int streamPubmedFile(const char *filename, pubmed_t* p)  static int streamPubmedFile(const char *filename, pubmed_t* p)
6052  {  {
6053      xmlTextReaderPtr reader;      xmlTextReaderPtr reader;
6054      int ret;      int ret = 0;
6055            
6056      reader = xmlNewTextReaderFilename(filename);      reader = xmlNewTextReaderFilename(filename);
6057      if( reader != NULL ){      if( reader != NULL ){
# Line 6283  result_t getUncertifiedLink( sessionid_t Line 6304  result_t getUncertifiedLink( sessionid_t
6304      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;      if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION;
6305            
6306      int i = 0;      int i = 0;
6307      SQLHANDLE hstmt = NULL, hstmt2 = NULL;      SQLHANDLE hstmt = NULL;
6308      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
6309      itemid_t* dst_iids = 0;      itemid_t* dst_iids = 0;
6310      indexid_t* dst_xids = 0;      indexid_t* dst_xids = 0;
# Line 6305  result_t getUncertifiedLink( sessionid_t Line 6326  result_t getUncertifiedLink( sessionid_t
6326      sql += " AND item_type_id !=" + unsignedIntToString( item::ITID_BINDER );      sql += " AND item_type_id !=" + unsignedIntToString( item::ITID_BINDER );
6327          sql += " AND ( is_admin=1 AND tgulink.uid=" + unsignedIntToString( sess_uid );          sql += " AND ( is_admin=1 AND tgulink.uid=" + unsignedIntToString( sess_uid );
6328      sql += string( isModerator( sid, sess_uid ) ? " OR 1)" : " OR 0)" ); //モデレータならOR 1,それ以外は OR 0      sql += string( isModerator( sid, sess_uid ) ? " OR 1)" : " OR 0)" ); //モデレータならOR 1,それ以外は OR 0
6329      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
6330    
6331      if( countResultRows( sql.c_str(), &count ) == RES_OK ){      if( countResultRows( sql.c_str(), &count ) == RES_OK ){
6332          dst_xids = new indexid_t[ count ];          dst_xids = new indexid_t[ count ];
# Line 6320  result_t getUncertifiedLink( sessionid_t Line 6341  result_t getUncertifiedLink( sessionid_t
6341      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
6342          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
6343              indexid_t xid = 0;              indexid_t xid = 0;
6344              SQLINTEGER cbXid = 0;              SQLLEN cbXid = 0;
6345              itemid_t iid = 0;              itemid_t iid = 0;
6346              SQLINTEGER cbIid = 0;              SQLLEN cbIid = 0;
6347              SQLBindCol( hstmt, 1, SQL_C_ULONG, &xid, 0, &cbXid );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &xid, 0, &cbXid );
6348              SQLBindCol( hstmt, 2, SQL_C_ULONG, &iid, 0, &cbIid );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &iid, 0, &cbIid );
6349              for( i = 0 ; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ; i++ ){              for( i = 0 ; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ; i++ ){
6350                  //fprintf( stderr, "\nxid=%d, iid=%d", xid, iid );                  syslog_printf( "\nxid=%d, iid=%d", xid, iid );
6351                  dst_xids[ i ] = xid;                  dst_xids[ i ] = xid;
6352                  dst_iids[ i ] = iid;                  dst_iids[ i ] = iid;
6353                  ( *len )++;                  ( *len )++;
# Line 6363  result_t getItemTypes( const itemtype_t* Line 6384  result_t getItemTypes( const itemtype_t*
6384            
6385          sql = "SELECT item_type_id, name, mid, display_name ";          sql = "SELECT item_type_id, name, mid, display_name ";
6386          sql += " FROM " + dbprefix + "_xnpaccount_item_type order by item_type_id";          sql += " FROM " + dbprefix + "_xnpaccount_item_type order by item_type_id";
6387      //fprintf( stderr, "\nsql at %d=%s", __LINE__, sql.c_str() );      syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() );
6388      if( countResultRows( sql.c_str(), &count ) == RES_OK ){      if( countResultRows( sql.c_str(), &count ) == RES_OK ){
6389          dst = new itemtype_t[ count ];          dst = new itemtype_t[ count ];
6390          *types = dst;          *types = dst;
# Line 6378  result_t getItemTypes( const itemtype_t* Line 6399  result_t getItemTypes( const itemtype_t*
6399              SQLINTEGER mid = 0;              SQLINTEGER mid = 0;
6400              SQLCHAR name[XNP_ITEMTYPE_NAME_LEN+1];              SQLCHAR name[XNP_ITEMTYPE_NAME_LEN+1];
6401              SQLCHAR display_name[XNP_ITEMTYPE_DISPLAY_NAME_LEN+1];              SQLCHAR display_name[XNP_ITEMTYPE_DISPLAY_NAME_LEN+1];
6402              SQLINTEGER cbItid = 0, cbMid = 0, cbName=SQL_NTS, cbDisplayName=SQL_NTS;              SQLLEN cbItid = 0, cbMid = 0, cbName=SQL_NTS, cbDisplayName=SQL_NTS;
6403              SQLBindCol( hstmt, 1, SQL_C_ULONG, &itid, 0, &cbItid );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &itid, 0, &cbItid );
6404              SQLBindCol( hstmt, 2, SQL_C_CHAR , &name, XNP_ITEMTYPE_NAME_LEN+1, &cbName );              SQLBindCol( hstmt, 2, SQL_C_CHAR , &name, XNP_ITEMTYPE_NAME_LEN+1, &cbName );
6405              SQLBindCol( hstmt, 3, SQL_C_ULONG, &mid, 0, &cbMid );              SQLBindCol( hstmt, 3, SQL_C_ULONG, &mid, 0, &cbMid );
6406              SQLBindCol( hstmt, 4, SQL_C_CHAR , &display_name, XNP_ITEMTYPE_DISPLAY_NAME_LEN+1, &cbDisplayName );              SQLBindCol( hstmt, 4, SQL_C_CHAR , &display_name, XNP_ITEMTYPE_DISPLAY_NAME_LEN+1, &cbDisplayName );
6407              for( i = 0 ; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ; i++ ){              for( i = 0 ; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ; i++ ){
6408                  //fprintf( stderr, "\nitid=%d, mid=%d, name='%s', display_name='%s'", itid, mid, name, display_name );                  syslog_printf( "\nitid=%d, mid=%d, name='%s', display_name='%s'", itid, mid, name, display_name );
6409                  dst[ i ].setItemTypeID( itid );                  dst[ i ].setItemTypeID( itid );
6410                  dst[ i ].setModuleID( itid );                  dst[ i ].setModuleID( itid );
6411                  dst[ i ].setName( ( char* )name );                  dst[ i ].setName( ( char* )name );
# Line 6422  result_t getIndexIDByItemID( sessionid_t Line 6443  result_t getIndexIDByItemID( sessionid_t
6443      SQLINTEGER count = 0;      SQLINTEGER count = 0;
6444      string sql;      string sql;
6445      indexid_t xid = 0;      indexid_t xid = 0;
6446      SQLINTEGER len = 0;      SQLLEN len = 0;
6447            
6448      sql = "SELECT index_id FROM " +  dbprefix + "_xnpaccount_index_item_link"      sql = "SELECT index_id FROM " +  dbprefix + "_xnpaccount_index_item_link"
6449          + " WHERE item_id=" + unsignedIntToString( itemid );          + " WHERE item_id=" + unsignedIntToString( itemid );

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.56

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