| 2 |
* |
* |
| 3 |
* $Revision$ |
* $Revision$ |
| 4 |
* $Log$ |
* $Log$ |
| 5 |
|
* Revision 1.62 2005/02/09 11:11:52 youi |
| 6 |
|
* deleteItemにアイテムに関係するエントリの削除処理を追加. |
| 7 |
|
* |
| 8 |
* Revision 1.61 2005/02/09 07:23:50 aga |
* Revision 1.61 2005/02/09 07:23:50 aga |
| 9 |
* ・URL to My Personal Archive をDB・ALから消した. |
* ・URL to My Personal Archive をDB・ALから消した. |
| 10 |
* |
* |
| 3731 |
3. delete item |
3. delete item |
| 3732 |
*/ |
*/ |
| 3733 |
|
|
| 3734 |
//TODO 1. delete item from index keywords |
//1. delete item from index keywords |
| 3735 |
|
sql = "DELETE FROM " + dbprefix + "_xnpaccount_index_item_link "; |
| 3736 |
|
sql += "WHERE item_id = " + string( unsignedIntToString( itemid ) ); |
| 3737 |
|
if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) { |
| 3738 |
|
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
| 3739 |
|
SQLINTEGER count = 0; |
| 3740 |
|
if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){ |
| 3741 |
|
ret = RES_OK; |
| 3742 |
|
}else{ |
| 3743 |
|
string s( "SQLRowCount in deleteItem" ); |
| 3744 |
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode ); |
| 3745 |
|
s += string( ", sql=" ) + string( sql ); |
| 3746 |
|
setLastErrorString( s.c_str( ) ); |
| 3747 |
|
ret = RES_NO_SUCH_USER; |
| 3748 |
|
} |
| 3749 |
|
}else{ |
| 3750 |
|
string s( "SQLExecDirect in deleteItem" ); |
| 3751 |
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode ); |
| 3752 |
|
s += ", sql="; |
| 3753 |
|
s += string( sql ); |
| 3754 |
|
setLastErrorString( s.c_str( ) ); |
| 3755 |
|
ret = RES_DB_QUERY_ERROR; |
| 3756 |
|
} |
| 3757 |
|
SQLFreeHandle( SQL_HANDLE_STMT, hstmt ); |
| 3758 |
|
}else{ |
| 3759 |
|
string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in deleteItem" ); |
| 3760 |
|
s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode ); |
| 3761 |
|
setLastErrorString( s.c_str( ) ); |
| 3762 |
|
ret = RES_ERROR; |
| 3763 |
|
} |
| 3764 |
|
|
| 3765 |
|
//2. delete item from binders |
| 3766 |
|
sql = "DELETE FROM " + dbprefix + "_xnpbinder_binder_item_link "; |
| 3767 |
|
sql += "WHERE item_id = " + string( unsignedIntToString( itemid ) ); |
| 3768 |
|
if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) { |
| 3769 |
|
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
| 3770 |
|
SQLINTEGER count = 0; |
| 3771 |
|
if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){ |
| 3772 |
|
ret = RES_OK; |
| 3773 |
|
}else{ |
| 3774 |
|
string s( "SQLRowCount in deleteItem" ); |
| 3775 |
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode ); |
| 3776 |
|
s += string( ", sql=" ) + string( sql ); |
| 3777 |
|
setLastErrorString( s.c_str( ) ); |
| 3778 |
|
ret = RES_NO_SUCH_USER; |
| 3779 |
|
} |
| 3780 |
|
}else{ |
| 3781 |
|
string s( "SQLExecDirect in deleteItem" ); |
| 3782 |
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode ); |
| 3783 |
|
s += ", sql="; |
| 3784 |
|
s += string( sql ); |
| 3785 |
|
setLastErrorString( s.c_str( ) ); |
| 3786 |
|
ret = RES_DB_QUERY_ERROR; |
| 3787 |
|
} |
| 3788 |
|
SQLFreeHandle( SQL_HANDLE_STMT, hstmt ); |
| 3789 |
|
}else{ |
| 3790 |
|
string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in deleteItem" ); |
| 3791 |
|
s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode ); |
| 3792 |
|
setLastErrorString( s.c_str( ) ); |
| 3793 |
|
ret = RES_ERROR; |
| 3794 |
|
} |
| 3795 |
|
|
|
//TODO 2. delete item from binders |
|
| 3796 |
|
|
| 3797 |
// 3. delete item |
// 3. delete item |
| 3798 |
sql = "DELETE FROM " + dbprefix + "_xnpaccount_item_basic "; |
sql = "DELETE FROM " + dbprefix + "_xnpaccount_item_basic "; |
| 4504 |
string sql; |
string sql; |
| 4505 |
SQLRETURN sqlcode; |
SQLRETURN sqlcode; |
| 4506 |
SQLHANDLE hstmt = NULL; |
SQLHANDLE hstmt = NULL; |
| 4507 |
|
char* value = 0; |
| 4508 |
|
|
| 4509 |
|
if( sid == session_t::SID_GUEST ){ |
| 4510 |
|
//ゲストにアイテムを公開する設定なら,ゲスト用SIDを承認する |
| 4511 |
|
if( getConfigValue( XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_KEY, &value ) == RES_OK ){ |
| 4512 |
|
bool ret = ( strcmp( value, XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_ALL ) == 0 ); |
| 4513 |
|
freeString( value ); |
| 4514 |
|
return ret; |
| 4515 |
|
} |
| 4516 |
|
} |
| 4517 |
|
|
| 4518 |
#ifdef USE_SYSLOG |
#ifdef USE_SYSLOG |
| 4519 |
openlog( "commonal", LOG_ODELAY, LOG_USER ); |
openlog( "commonal", LOG_ODELAY, LOG_USER ); |
| 6240 |
xmlChar* val = getChildText( reader ); |
xmlChar* val = getChildText( reader ); |
| 6241 |
p -> setJournal( ( char* )val ); |
p -> setJournal( ( char* )val ); |
| 6242 |
if( val != NULL ) xmlFree( val ); |
if( val != NULL ) xmlFree( val ); |
| 6243 |
}else if( strcmp( "Year", ( char* )name ) == 0 ){//TODO |
}else if( strcmp( "Year", ( char* )name ) == 0 ){ |
| 6244 |
xmlChar* val = getChildText( reader ); |
xmlChar* val = getChildText( reader ); |
| 6245 |
p -> setYearOfPublication( atoi( ( char* )val ) ); |
p -> setYearOfPublication( atoi( ( char* )val ) ); |
| 6246 |
if( val != NULL ) xmlFree( val ); |
if( val != NULL ) xmlFree( val ); |