| 22 |
* |
* |
| 23 |
* $Revision$ |
* $Revision$ |
| 24 |
* $Log$ |
* $Log$ |
| 25 |
|
* Revision 1.100 2005/07/21 01:47:57 tani |
| 26 |
|
* getEventsForRSSを定義した. |
| 27 |
|
* |
| 28 |
* Revision 1.99 2005/07/15 04:42:33 aga4096 |
* Revision 1.99 2005/07/15 04:42:33 aga4096 |
| 29 |
* ・getItemTypesで、DBにNULLが書かれているとおかしくなるのを修正. |
* ・getItemTypesで、DBにNULLが書かれているとおかしくなるのを修正. |
| 30 |
* |
* |
| 465 |
static void setLastErrorString( const char* str ); |
static void setLastErrorString( const char* str ); |
| 466 |
static 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 ); |
| 467 |
static result_t _insertItem( sessionid_t sid, const item_t* item, itemid_t* itemid, bool direct ); |
static result_t _insertItem( sessionid_t sid, const item_t* item, itemid_t* itemid, bool direct ); |
| 468 |
|
static result_t getEvents(sessionid_t sid, event_t** events, int* eventsLen, string condition ); |
| 469 |
|
|
| 470 |
static void syslog_printf( char* format, ... ) |
static void syslog_printf( char* format, ... ) |
| 471 |
{ |
{ |
| 6346 |
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 ); |
| 6347 |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key , strlen(key) , &cbKey ); |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key , strlen(key) , &cbKey ); |
| 6348 |
sqlcode = SQLExecute( hstmt ); |
sqlcode = SQLExecute( hstmt ); |
| 6349 |
|
syslog_printf( "\nsqlcode at %d=%d", __LINE__, sqlcode ); |
| 6350 |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6351 |
SQLLEN count = 0; |
SQLLEN count = 0; |
| 6352 |
if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){ |
if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){ |
| 7701 |
if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION; |
if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION; |
| 7702 |
if( !isModeratorBySession( sid ) ) return RES_NO_READ_ACCESS_RIGHT; |
if( !isModeratorBySession( sid ) ) return RES_NO_READ_ACCESS_RIGHT; |
| 7703 |
|
|
|
result_t ret = RES_ERROR; |
|
|
|
|
|
SQLRETURN sqlcode; |
|
|
SQLHANDLE hstmt = NULL; |
|
|
|
|
| 7704 |
// time condition |
// time condition |
| 7705 |
string condition = " where "; |
string condition = " where "; |
| 7706 |
if ( startTime != 0 ) condition += unsignedIntToString(startTime) + " <= timestamp and "; |
if ( startTime != 0 ) condition += unsignedIntToString(startTime) + " <= timestamp and "; |
| 7707 |
if ( endTime != 0 ) condition += " timestamp < " + unsignedIntToString(endTime) + " and "; |
if ( endTime != 0 ) condition += " timestamp < " + unsignedIntToString(endTime) + " and "; |
| 7708 |
condition += "1"; |
condition += "1"; |
| 7709 |
|
condition += " order by timestamp asc"; |
| 7710 |
|
|
| 7711 |
|
return getEvents(sid, events, eventsLen, condition ); |
| 7712 |
|
} |
| 7713 |
|
|
| 7714 |
|
/** |
| 7715 |
|
* |
| 7716 |
|
* 最新<max>件のイベント(アイテム承認,グループ作成のみ)を取得する |
| 7717 |
|
* |
| 7718 |
|
* @param sid セッションID |
| 7719 |
|
* @param events イベント情報の配列のアドレスを受け取るポインタ |
| 7720 |
|
* @param eventsLen eventsに記録したイベント情報の数 |
| 7721 |
|
* @param max eventsに記録する最大イベント数 |
| 7722 |
|
* |
| 7723 |
|
* @return RES_OK 成功 |
| 7724 |
|
* @return RES_NO_SUCH_SESSION 不正なセッション |
| 7725 |
|
* @return RES_NO_READ_ACCESS_RIGHT RSS生成のアクセス権が無い(グループ管理者未満) |
| 7726 |
|
* @return それ以外 その他の失敗 |
| 7727 |
|
* |
| 7728 |
|
*/ |
| 7729 |
|
result_t getEventsForRSS(sessionid_t sid, event_t** events, int* eventsLen, int max ) |
| 7730 |
|
{ |
| 7731 |
|
if( hdbc == NULL ) return RES_DB_NOT_INITIALIZED; |
| 7732 |
|
if( !isValidSessionID( sid ) ) return RES_NO_SUCH_SESSION; |
| 7733 |
|
if( isModeratorBySession( sid ) ); |
| 7734 |
|
else{ |
| 7735 |
|
result_t ret = RES_ERROR; |
| 7736 |
|
criteria_t c; |
| 7737 |
|
groupid_t *gids; |
| 7738 |
|
int gidsLen; |
| 7739 |
|
const session_t* session; |
| 7740 |
|
userid_t uid; |
| 7741 |
|
|
| 7742 |
|
//retrieve uid from session |
| 7743 |
|
ret = getSession( sid, &session ); |
| 7744 |
|
if( ret != RES_OK ) return ret; |
| 7745 |
|
uid = session -> getUID( ); |
| 7746 |
|
freeSession( session ); |
| 7747 |
|
|
| 7748 |
|
//retrieve all group id |
| 7749 |
|
c.clearAll(); |
| 7750 |
|
ret = dumpGids( sid, &c, &gids, &gidsLen ); |
| 7751 |
|
if( ret != RES_OK ) return ret; |
| 7752 |
|
|
| 7753 |
|
//is uid a group admin ? |
| 7754 |
|
int i; |
| 7755 |
|
for( i = 0 ; i < gidsLen; i++ ){ |
| 7756 |
|
if( isGroupAdmin( sid, gids[ i ], uid ) ) break; |
| 7757 |
|
} |
| 7758 |
|
freeGID( gids ); |
| 7759 |
|
if( i >= gidsLen ) |
| 7760 |
|
return RES_NO_READ_ACCESS_RIGHT;// uid is not a group admin |
| 7761 |
|
} |
| 7762 |
|
//retrieve events |
| 7763 |
|
string condition = " where event_type_id in ( " ; |
| 7764 |
|
condition += unsignedIntToString(event_t::ETID_CERTIFY_ITEM); |
| 7765 |
|
condition += ", " + unsignedIntToString(event_t::ETID_INSERT_GROUP) + " )"; |
| 7766 |
|
condition += " order by timestamp desc"; |
| 7767 |
|
condition += " limit " + unsignedIntToString(max); |
| 7768 |
|
|
| 7769 |
|
return getEvents(sid, events, eventsLen, condition ); |
| 7770 |
|
} |
| 7771 |
|
|
| 7772 |
|
static result_t getEvents(sessionid_t sid, event_t** events, int* eventsLen, string condition ) |
| 7773 |
|
{ |
| 7774 |
|
result_t ret = RES_ERROR; |
| 7775 |
|
|
| 7776 |
|
SQLRETURN sqlcode; |
| 7777 |
|
SQLHANDLE hstmt = NULL; |
| 7778 |
|
|
| 7779 |
// allocate events[] |
// allocate events[] |
| 7780 |
string sql = "select count(*) from " + dbprefix + "_xoonips_event_log " + condition; |
string sql = "select count(*) from " + dbprefix + "_xoonips_event_log " + condition; |
| 7793 |
|
|
| 7794 |
// get |
// get |
| 7795 |
sql = "select event_id, event_type_id, timestamp, exec_uid, index_id, item_id, " |
sql = "select event_id, event_type_id, timestamp, exec_uid, index_id, item_id, " |
| 7796 |
" file_id, uid, gid, remote_host, search_keyword, additional_info from " + dbprefix + "_xoonips_event_log " + condition; |
" file_id, uid, gid, remote_host, search_keyword, additional_info from " + dbprefix + "_xoonips_event_log " + condition; |
| 7797 |
if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) { |
if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) { |
| 7798 |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
| 7799 |
eventid_t eventID = 0; SQLLEN cbEventID = 0; |
eventid_t eventID = 0; SQLLEN cbEventID = 0; |
| 7849 |
return ret; |
return ret; |
| 7850 |
} |
} |
| 7851 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|