| 2 |
* |
* |
| 3 |
* $Revision$ |
* $Revision$ |
| 4 |
* $Log$ |
* $Log$ |
| 5 |
|
* Revision 1.57 2005/02/03 12:04:58 youi |
| 6 |
|
* getOwnPublicItemIDを定義. |
| 7 |
|
* binder_item_linkのテーブル名を修正. |
| 8 |
|
* |
| 9 |
* Revision 1.56 2005/01/29 09:49:22 youi |
* Revision 1.56 2005/01/29 09:49:22 youi |
| 10 |
* syslog_printf: デバッグメッセージ出力関数を定義した. |
* syslog_printf: デバッグメッセージ出力関数を定義した. |
| 11 |
* getCertifyPermission: チェック用のsqlを定義した. |
* getCertifyPermission: チェック用のsqlを定義した. |
| 2420 |
SQLUINTEGER uid = 0; |
SQLUINTEGER uid = 0; |
| 2421 |
SQLLEN len = 0; |
SQLLEN len = 0; |
| 2422 |
SQLBindCol( hstmt2, 1, SQL_C_ULONG, &uid, 0, &len ); |
SQLBindCol( hstmt2, 1, SQL_C_ULONG, &uid, 0, &len ); |
| 2423 |
for( int i = 0; ( sqlcode = SQLFetch( hstmt2 ) ) == SQL_SUCCESS && i < count ; i++ ){ |
for( SQLUINTEGER i = 0; ( sqlcode = SQLFetch( hstmt2 ) ) == SQL_SUCCESS && i < count ; i++ ){ |
| 2424 |
dst[ i ] = uid; |
dst[ i ] = uid; |
| 2425 |
} |
} |
| 2426 |
ret = RES_OK; |
ret = RES_OK; |
| 3057 |
ret = queryGetUnsignedInt( "createSession", sql, &count ); |
ret = queryGetUnsignedInt( "createSession", sql, &count ); |
| 3058 |
if ( ret != RES_OK ) |
if ( ret != RES_OK ) |
| 3059 |
return ret; |
return ret; |
| 3060 |
if ( count = 0 ) |
if ( count == 0 ) |
| 3061 |
return RES_NO_SUCH_USER; // bad uid or activate=0 |
return RES_NO_SUCH_USER; // bad uid or activate=0 |
| 3062 |
|
|
| 3063 |
string escSess_id = addSlashes(sess_id); |
string escSess_id = addSlashes(sess_id); |
| 3645 |
if( certify_item_val != 0 ) freeString( certify_item_val ); |
if( certify_item_val != 0 ) freeString( certify_item_val ); |
| 3646 |
certify_item_val = 0; |
certify_item_val = 0; |
| 3647 |
}else{ |
}else{ |
| 3648 |
string s( "getXoopsModuleConfigValue in updateItem(key=" ); |
string s( "getConfigValue in updateItem(key=" ); |
| 3649 |
s += XNP_CONFIG_CERTIFY_ITEM_KEY; |
s += XNP_CONFIG_CERTIFY_ITEM_KEY; |
| 3650 |
s += "), "; |
s += "), "; |
| 3651 |
s += getLastErrorString( ); |
s += getLastErrorString( ); |
| 3677 |
setLastErrorString( s.c_str( ) ); |
setLastErrorString( s.c_str( ) ); |
| 3678 |
ret = RES_ERROR; |
ret = RES_ERROR; |
| 3679 |
} |
} |
|
setLastErrorString( "updateItem succeed" ); |
|
| 3680 |
return ret; |
return ret; |
| 3681 |
} |
} |
| 3682 |
|
|
| 3819 |
notin += unsignedIntToString( iid ); |
notin += unsignedIntToString( iid ); |
| 3820 |
} |
} |
| 3821 |
if( i > 0 ) sql += " AND item_id NOT IN ( " + notin + " )"; |
if( i > 0 ) sql += " AND item_id NOT IN ( " + notin + " )"; |
|
/* |
|
|
else{ |
|
|
dst = new itemid_t[ 0 ]; |
|
|
*iids = dst; |
|
|
*iidsLen = 0; |
|
|
return RES_OK; |
|
|
} |
|
|
*/ |
|
| 3822 |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
| 3823 |
|
|
| 3824 |
if( countResultRows( sql.c_str(), &count ) == RES_OK ){ |
if( countResultRows( sql.c_str(), &count ) == RES_OK ){ |
| 3992 |
SQLINTEGER count = 0; |
SQLINTEGER count = 0; |
| 3993 |
|
|
| 3994 |
sql = "SELECT t1.item_id FROM " + dbprefix + "_xnpaccount_item_basic as t1, " |
sql = "SELECT t1.item_id FROM " + dbprefix + "_xnpaccount_item_basic as t1, " |
| 3995 |
+ dbprefix + "_xnpaccount_binder_item_link as t2 "; |
+ dbprefix + "_xnpbinder_binder_item_link as t2 "; |
| 3996 |
sql += " WHERE t1.item_id = t2.item_id"; |
sql += " WHERE t1.item_id = t2.item_id"; |
| 3997 |
sql += " AND t2.binder_id=" + unsignedIntToString( binderid ); |
sql += " AND t2.binder_id=" + unsignedIntToString( binderid ); |
| 3998 |
sql += criteria2str( cri ); |
sql += criteria2str( cri ); |
| 4098 |
if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED; |
if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED; |
| 4099 |
if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION; |
if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION; |
| 4100 |
|
|
|
int i = 0; |
|
|
SQLHANDLE hstmt = NULL; |
|
| 4101 |
result_t ret = RES_ERROR; |
result_t ret = RES_ERROR; |
|
itemid_t* dst_iids = 0; |
|
|
indexid_t* dst_xids = 0; |
|
| 4102 |
string sql; |
string sql; |
|
SQLRETURN sqlcode; |
|
| 4103 |
SQLINTEGER count = 0; |
SQLINTEGER count = 0; |
| 4104 |
userid_t sess_uid; |
userid_t sess_uid; |
| 4105 |
|
|
| 4266 |
if( !getItemPermission( sid, binderid, item::OP_MODIFY ) ) return RES_NO_WRITE_ACCESS_RIGHT; |
if( !getItemPermission( sid, binderid, item::OP_MODIFY ) ) return RES_NO_WRITE_ACCESS_RIGHT; |
| 4267 |
|
|
| 4268 |
// register the item. |
// register the item. |
| 4269 |
sql = "INSERT INTO " + dbprefix + "_xnpaccount_binder_item_link (binder_id, item_id) values (" |
sql = "INSERT INTO " + dbprefix + "_xnpbinder_binder_item_link (binder_id, item_id) values (" |
| 4270 |
+ unsignedIntToString(binderid) + "," |
+ unsignedIntToString(binderid) + "," |
| 4271 |
+ unsignedIntToString(iid) + ")"; |
+ unsignedIntToString(iid) + ")"; |
| 4272 |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
| 4306 |
if( !getItemPermission( sid, binderid, item::OP_MODIFY ) ) return RES_NO_WRITE_ACCESS_RIGHT; |
if( !getItemPermission( sid, binderid, item::OP_MODIFY ) ) return RES_NO_WRITE_ACCESS_RIGHT; |
| 4307 |
|
|
| 4308 |
// unregister the item. |
// unregister the item. |
| 4309 |
sql = "DELETE FROM " + dbprefix + "_xnpaccount_binder_item_link"; |
sql = "DELETE FROM " + dbprefix + "_xnpbinder_binder_item_link"; |
| 4310 |
sql += " WHERE binder_id=" + unsignedIntToString(binderid); |
sql += " WHERE binder_id=" + unsignedIntToString(binderid); |
| 4311 |
sql += " AND item_id=" + unsignedIntToString(iid); |
sql += " AND item_id=" + unsignedIntToString(iid); |
| 4312 |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
| 6463 |
} |
} |
| 6464 |
return ret; |
return ret; |
| 6465 |
} |
} |
| 6466 |
|
|
| 6467 |
|
/** |
| 6468 |
|
* |
| 6469 |
|
* 指定ユーザの作成アイテムで,一般公開されているアイテムのIDを取得します. |
| 6470 |
|
* 一般ユーザは自分以外のアイテムを取得できない. |
| 6471 |
|
* |
| 6472 |
|
* @param sid セッションID |
| 6473 |
|
* @param uid 対象ユーザのID |
| 6474 |
|
* @param iids 登録されたアイテムIDを受け取る引数 |
| 6475 |
|
* @param iidsLen iidsに格納された個数を受け取る引数 |
| 6476 |
|
* @return RES_OK |
| 6477 |
|
* @return RES_DB_NOT_INITIALIZED |
| 6478 |
|
* @return RES_NO_SUCH_SESSION |
| 6479 |
|
* @return RES_DB_QUERY_ERROR |
| 6480 |
|
* @return RES_ERROR |
| 6481 |
|
* |
| 6482 |
|
*/ |
| 6483 |
|
result_t getOwnPublicItemID( sessionid_t sid, userid_t uid, const itemid_t** iids, int* iidsLen ) |
| 6484 |
|
{ |
| 6485 |
|
if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED; |
| 6486 |
|
if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION; |
| 6487 |
|
|
| 6488 |
|
int i = 0; |
| 6489 |
|
SQLHANDLE hstmt = NULL, hstmt2 = NULL; |
| 6490 |
|
result_t ret = RES_ERROR; |
| 6491 |
|
itemid_t* dst = 0; |
| 6492 |
|
string sql; |
| 6493 |
|
SQLRETURN sqlcode; |
| 6494 |
|
SQLINTEGER count = 0; |
| 6495 |
|
userid_t sess_uid; |
| 6496 |
|
|
| 6497 |
|
if( ( ret = sessionID2UID( sid, &sess_uid ) ) != RES_OK ) return ret; |
| 6498 |
|
if( sess_uid != uid && !isModeratorBySession( sid ) ) |
| 6499 |
|
return RES_NO_READ_ACCESS_RIGHT;//no permissions to access these items |
| 6500 |
|
|
| 6501 |
|
sql = "SELECT DISTINCT tlink.item_id"; |
| 6502 |
|
sql += " FROM " + dbprefix + "_xnpaccount_index_item_link AS tlink"; |
| 6503 |
|
sql += " LEFT JOIN " + dbprefix + "_xnpaccount_index AS tx ON tlink.index_id=tx.index_id"; |
| 6504 |
|
sql += " LEFT JOIN " + dbprefix + "_xnpaccount_item_basic AS ti ON tlink.item_id=ti.item_id"; |
| 6505 |
|
sql += " LEFT JOIN " + dbprefix + "_xnpaccount_groups_users_link AS tgulink ON tgulink.gid = tx.gid AND tx.open_level=" + unsignedIntToString( index::OL_GROUP_ONLY ); |
| 6506 |
|
sql += " WHERE open_level=" + unsignedIntToString( index::OL_PUBLIC ); |
| 6507 |
|
sql += " AND certify_state=" + unsignedIntToString( index::CERTIFIED ); |
| 6508 |
|
sql += " AND item_type_id !=" + unsignedIntToString( item::ITID_INDEX ); |
| 6509 |
|
sql += " AND item_type_id !=" + unsignedIntToString( item::ITID_BINDER ); |
| 6510 |
|
sql += " AND ( ti.uid=" + unsignedIntToString( sess_uid ); |
| 6511 |
|
sql += " OR is_admin=1 AND tgulink.uid=" + unsignedIntToString( sess_uid ); |
| 6512 |
|
sql += ")"; |
| 6513 |
|
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
| 6514 |
|
if( countResultRows( sql.c_str(), &count ) == RES_OK ){ |
| 6515 |
|
dst = new itemid_t[ count ]; |
| 6516 |
|
*iids = dst; |
| 6517 |
|
}else{ |
| 6518 |
|
return RES_ERROR; |
| 6519 |
|
} |
| 6520 |
|
if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) { |
| 6521 |
|
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
| 6522 |
|
itemid_t iid = 0; |
| 6523 |
|
SQLLEN cbIid = 0; |
| 6524 |
|
SQLBindCol( hstmt, 1, SQL_C_ULONG, &iid, 0, &cbIid ); |
| 6525 |
|
|
| 6526 |
|
*iidsLen = 0; |
| 6527 |
|
for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < count ; i++ ){ |
| 6528 |
|
dst[ i ] = iid; |
| 6529 |
|
(*iidsLen)++; |
| 6530 |
|
} |
| 6531 |
|
ret = RES_OK; |
| 6532 |
|
}else{ |
| 6533 |
|
string s( "SQLExecDirect in getOwnPublicItemID " ); |
| 6534 |
|
s += odbcDiagString( SQL_HANDLE_STMT, hstmt2, sqlcode ); |
| 6535 |
|
s += "sql="; |
| 6536 |
|
s += string( sql ); |
| 6537 |
|
setLastErrorString( s.c_str( ) ); |
| 6538 |
|
ret = RES_DB_QUERY_ERROR; |
| 6539 |
|
} |
| 6540 |
|
SQLFreeHandle( SQL_HANDLE_STMT, hstmt ); |
| 6541 |
|
}else{ |
| 6542 |
|
string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in getOwnPublicItemID" ); |
| 6543 |
|
s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode ); |
| 6544 |
|
setLastErrorString( s.c_str( ) ); |
| 6545 |
|
ret = RES_ERROR; |
| 6546 |
|
} |
| 6547 |
|
|
| 6548 |
|
return ret; |
| 6549 |
|
} |
| 6550 |
|
|
| 6551 |
|
|
| 6552 |
|
/** |
| 6553 |
|
* |
| 6554 |
|
* |
| 6555 |
|
* |
| 6556 |
|
*/ |
| 6557 |
|
/* |
| 6558 |
|
result_t zipCreate( char* zippath, char** files, int filesLen ) |
| 6559 |
|
{ |
| 6560 |
|
char** argv = new char*[filesLen+1]; |
| 6561 |
|
argv[ 0 ] = zippath; |
| 6562 |
|
for( int i = 0; i < filesLen; i++ ){ |
| 6563 |
|
argv[ i + 1 ] = files[ i ]; |
| 6564 |
|
} |
| 6565 |
|
if( !zip_main( argc, argv ) ){ |
| 6566 |
|
return RES_OK; |
| 6567 |
|
} |
| 6568 |
|
return RES_ERROR; |
| 6569 |
|
} |
| 6570 |
|
*/ |