| 2 |
* |
* |
| 3 |
* $Revision$ |
* $Revision$ |
| 4 |
* $Log$ |
* $Log$ |
| 5 |
|
* Revision 1.76 2005/03/04 06:13:28 aga4096 |
| 6 |
|
* ・updateIndexで、同じ名前の兄弟があるか名前が空であるならエラーにした. |
| 7 |
|
* |
| 8 |
* Revision 1.75 2005/03/03 10:13:00 aga4096 |
* Revision 1.75 2005/03/03 10:13:00 aga4096 |
| 9 |
* ・isValidSessionでtimestampを更新するよう修正. |
* ・isValidSessionでtimestampを更新するよう修正. |
| 10 |
* ・sessionはisValidSessionしない限り1時間でタイムアウトするよう修正. |
* ・sessionはisValidSessionしない限り1時間でタイムアウトするよう修正. |
| 359 |
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 ); |
| 360 |
static result_t getXoopsModuleConfigValue( const char *module, const char *key, char **value ); |
static result_t getXoopsModuleConfigValue( const char *module, const char *key, char **value ); |
| 361 |
static void setLastErrorString( const char* str ); |
static void setLastErrorString( const char* str ); |
| 362 |
|
static result_t checkTitleConflict( sessionid_t sid, indexid_t parentIndexID, const char *title, bool *conflict ); |
| 363 |
|
|
| 364 |
void syslog_printf( char* format, ... ) |
void syslog_printf( char* format, ... ) |
| 365 |
{ |
{ |
| 5392 |
} |
} |
| 5393 |
|
|
| 5394 |
// parentXID のアクセス権を調べる |
// parentXID のアクセス権を調べる |
| 5395 |
SQLRETURN sqlcode; |
const index_t *parentIndex; |
| 5396 |
SQLHANDLE hstmt = NULL; |
result = getIndex( sid, index->getParentIndexID(), &parentIndex ); |
| 5397 |
string sql; |
if ( result == RES_OK ){ |
| 5398 |
|
if ( !isWritableInternal( sid, uid, parentIndex ) ){ |
| 5399 |
SQLLEN cbTitle = SQL_NTS; |
setLastErrorString( "in insertIndex: cannot write to parentindex" ); |
| 5400 |
string indexTable = dbprefix + "_xnpaccount_index"; |
result = RES_ERROR; // エラー: 親インデックスへの書き込み権限が無い。 |
| 5401 |
string itemTable = dbprefix + "_xnpaccount_item_basic"; |
} |
| 5402 |
sql = "SELECT tx_parent.uid, tx_parent.gid, tx_parent.open_level, tx_child.index_id, ti_child.item_id " |
else { |
| 5403 |
" FROM " + indexTable + " AS tx_parent " |
// 同名の子インデックスがあれば、蹴る |
| 5404 |
" LEFT JOIN " + indexTable + " AS tx_child ON tx_child.parent_index_id = tx_parent.index_id " |
bool conflict = false; |
| 5405 |
" LEFT JOIN " + itemTable + " AS ti_child ON tx_child.index_id = ti_child.item_id AND ti_child.title = ? AND ti_child.item_type_id = " + unsignedIntToString( item::ITID_INDEX ) + |
result = checkTitleConflict( sid, index->getParentIndexID(), index->getTitle(), &conflict ); |
| 5406 |
" WHERE tx_parent.index_id = " + unsignedIntToString( index->getParentIndexID() ); |
if ( result != RES_OK ){ |
| 5407 |
if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) { |
; |
| 5408 |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_TITLE_LEN, 0, (SQLCHAR *)index->getTitle(), strlen(index->getTitle()), &cbTitle ); |
} |
| 5409 |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
else if ( conflict ){ |
| 5410 |
SQLUINTEGER parentUID = 0, parentGID = 0, parentOpenLevel = 0, childXID = 0, childItemID = 0; |
setLastErrorString( "in insertIndex: title conflict" ); |
| 5411 |
SQLLEN len1 = 0, len2 = 0, len3 = 0, len4 = 0, len5 = 0; |
result = RES_ERROR; // エラー: 同名の子indexが既に存在する。 |
| 5412 |
SQLBindCol( hstmt, 1, SQL_C_ULONG, &parentUID, 0, &len1 ); |
} |
| 5413 |
SQLBindCol( hstmt, 2, SQL_C_ULONG, &parentGID, 0, &len2 ); |
else if ( index->getTitle()[0] == '\0' ){ |
| 5414 |
SQLBindCol( hstmt, 3, SQL_C_ULONG, &parentOpenLevel, 0, &len3 ); |
// titleを空文字列にできない |
| 5415 |
SQLBindCol( hstmt, 4, SQL_C_ULONG, &childXID, 0, &len4 ); |
setLastErrorString( "in insertIndex: empty title" ); |
| 5416 |
SQLBindCol( hstmt, 5, SQL_C_ULONG, &childItemID, 0, &len5 ); |
result = RES_ERROR; |
| 5417 |
if( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){ |
} |
| 5418 |
if ( len5 != SQL_NULL_DATA ){ |
else { |
| 5419 |
setLastErrorString( "in insertIndex: title conflict" ); |
unsigned int sortNumber; |
| 5420 |
result = RES_ERROR; // エラー: 同名の子indexが既に存在する。 |
result = getNewSortNumber( index->getParentIndexID(), &sortNumber ); |
| 5421 |
} |
if ( result == RES_OK ){ |
| 5422 |
else if ( !isWritableInternal( sid, uid, parentUID, parentGID, parentOpenLevel ) ){ |
index->setOpenLevel( parentIndex->getOpenLevel() ); |
| 5423 |
setLastErrorString( "in insertIndex: cannot write to parentindex" ); |
index->setOwnerGID( parentIndex->getOwnerGID() ); |
| 5424 |
result = RES_ERROR; // エラー: 親インデックスへの書き込み権限が無い。 |
index->setOwnerUID( parentIndex->getOwnerUID() ); |
| 5425 |
} |
index->setSortNumber( sortNumber ); |
| 5426 |
/* else if ( !(parentOpenLevel == index::OL_PUBLIC && index->getOpenLevel() == index::OL_PUBLIC) |
// インデックスを作成する。 |
| 5427 |
&& !(parentOpenLevel == index::OL_GROUP_ONLY && index->getOpenLevel() == index::OL_GROUP_ONLY && parentGID == index->getOwnerGID()) |
result = insertIndexInternal( sid, index, xid ); |
|
&& !(parentOpenLevel == index::OL_PRIVATE && index->getOpenLevel() == index::OL_PRIVATE && parentUID == index->getOwnerUID())) { |
|
|
setLastErrorString( "in insertIndex: bad uid/gid/openlevel" ); |
|
|
result = RES_ERROR; // エラー: 親インデックスとアクセス権限が矛盾する。 |
|
| 5428 |
} |
} |
|
*/ |
|
| 5429 |
else { |
else { |
| 5430 |
unsigned int sortNumber; |
; // error: getNewSortNumber failed. |
|
result = getNewSortNumber( index->getParentIndexID(), &sortNumber ); |
|
|
if ( result == RES_OK ){ |
|
|
index->setOpenLevel( parentOpenLevel ); |
|
|
index->setOwnerGID( parentGID ); |
|
|
index->setOwnerUID( parentUID ); |
|
|
index->setSortNumber( sortNumber ); |
|
|
// インデックスを作成する。 |
|
|
result = insertIndexInternal( sid, index, xid ); |
|
|
} |
|
|
else { |
|
|
; // error: getNewSortNumber failed. |
|
|
} |
|
| 5431 |
} |
} |
|
}else { |
|
|
string s( "SQLFetch in insertIndex sql=" ); |
|
|
s += sql; |
|
|
s += " sqlcode=" + intToString(sqlcode); |
|
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode ); |
|
|
setLastErrorString( s.c_str() ); |
|
|
result = RES_ERROR; |
|
| 5432 |
} |
} |
|
}else{ |
|
|
string s( "in insertIndex: SQLExecDirect failed. sql=" ); |
|
|
s += sql; |
|
|
s += " sqlcode=" + intToString(sqlcode); |
|
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode ); |
|
|
setLastErrorString( s.c_str() ); |
|
|
result = RES_ERROR; |
|
| 5433 |
} |
} |
| 5434 |
SQLFreeHandle( SQL_HANDLE_STMT, hstmt ); |
freeIndex( parentIndex ); |
| 5435 |
} |
} |
| 5436 |
else { |
else { |
| 5437 |
string s( "SQLAllocHandle in insertIndex" ); |
; // getIndex失敗 |
|
s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode ); |
|
|
setLastErrorString( s.c_str( ) ); |
|
|
result = RES_ERROR; |
|
| 5438 |
} |
} |
| 5439 |
return result; |
return result; |
| 5440 |
} |
} |
| 5586 |
} |
} |
| 5587 |
#endif |
#endif |
| 5588 |
|
|
| 5589 |
result_t checkTitleConflict( sessionid_t sid, indexid_t parentIndexID, const char *title, bool *conflict ){ |
static result_t checkTitleConflict( sessionid_t sid, indexid_t parentIndexID, const char *title, bool *conflict ){ |
| 5590 |
SQLRETURN sqlcode; |
SQLRETURN sqlcode; |
| 5591 |
SQLHANDLE hstmt = NULL; |
SQLHANDLE hstmt = NULL; |
| 5592 |
result_t result = RES_ERROR; |
result_t result = RES_ERROR; |