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.91 by tani, Tue Jun 7 01:10:33 2005 UTC revision 1.92 by tani, Wed Jun 8 04:27:08 2005 UTC
# Line 22  Line 22 
22   *   *
23   * $Revision$   * $Revision$
24   * $Log$   * $Log$
25     * Revision 1.92  2005/06/08 04:27:08  tani
26     * defaultグループの存在を秘匿した.
27     *
28   * Revision 1.91  2005/06/07 01:10:33  tani   * Revision 1.91  2005/06/07 01:10:33  tani
29   * SQLGetDataの引数を修正.   * SQLGetDataの引数を修正.
30   * SQLExecDirectの代わりにSQLExecuteの利用.   * SQLExecDirectの代わりにSQLExecuteの利用.
# Line 2064  result_t dumpUids( sessionid_t sid, crit Line 2067  result_t dumpUids( sessionid_t sid, crit
2067    
2068  /**  /**
2069   *   *
2070   * グループ数を返す.   * グループ数を返す(defaultグループを除く).
2071   * 不正なセッションIDなら0を返す.   * 不正なセッションIDなら0を返す.
2072   *   *
2073   * @param sid セッションID   * @param sid セッションID
# Line 2083  int getGroupCount( sessionid_t sid ) Line 2086  int getGroupCount( sessionid_t sid )
2086            
2087      //グループ数を求める      //グループ数を求める
2088      sql = "SELECT COUNT(*) FROM " + dbprefix + "_xoonips_groups";      sql = "SELECT COUNT(*) FROM " + dbprefix + "_xoonips_groups";
2089        sql += " WHERE gid != " + unsignedIntToString( group::GID_DEFAULT );
2090      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2091          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){          if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2092              SQLUINTEGER count = 0;              SQLUINTEGER count = 0;
# Line 2113  int getGroupCount( sessionid_t sid ) Line 2117  int getGroupCount( sessionid_t sid )
2117  /**  /**
2118   *   *
2119   * 所属グループ一覧取得.   * 所属グループ一覧取得.
2120   * ユーザが所属しているグループのIDを取得する   * ユーザが所属しているグループのIDを取得する(defaultグループを除く).
2121   *   *
2122   * @param sid セッションID   * @param sid セッションID
2123   * @param uid ユーザのUID   * @param uid ユーザのUID
# Line 2142  result_t getGroupsByUid( sessionid_t sid Line 2146  result_t getGroupsByUid( sessionid_t sid
2146            
2147      sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups_users_link";      sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups_users_link";
2148      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );
2149        sql += " AND gid != " + unsignedIntToString( group::GID_DEFAULT );
2150      sql += criteria2str( cri );      sql += criteria2str( cri );
2151      if( countResultRows( sql.c_str(), &count ) == RES_OK ){      if( countResultRows( sql.c_str(), &count ) == RES_OK ){
2152          *gidsLen = count;          *gidsLen = count;
# Line 2159  result_t getGroupsByUid( sessionid_t sid Line 2164  result_t getGroupsByUid( sessionid_t sid
2164                  if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt2 ) ) == SQL_SUCCESS ) {                  if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt2 ) ) == SQL_SUCCESS ) {
2165                      sql = "SELECT gid, uid, is_admin FROM " + dbprefix + "_xoonips_groups_users_link";                      sql = "SELECT gid, uid, is_admin FROM " + dbprefix + "_xoonips_groups_users_link";
2166                      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );                      sql += " WHERE uid=" + string( unsignedIntToString( uid ) );
2167                        sql += " AND gid != " + unsignedIntToString( group::GID_DEFAULT );
2168                      sql += criteria2str( cri );                      sql += criteria2str( cri );
2169                      if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){                      if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){
2170                          SQLLEN len = 0;                          SQLLEN len = 0;
# Line 2267  result_t dumpGids( sessionid_t sid, crit Line 2273  result_t dumpGids( sessionid_t sid, crit
2273      SQLLEN count = 0;      SQLLEN count = 0;
2274                            
2275      sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups ";      sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups ";
2276        sql += " WHERE gid != " + unsignedIntToString( group::GID_DEFAULT );
2277      sql += criteria2str( cri );      sql += criteria2str( cri );
2278      if( countResultRows( sql.c_str(), &count ) == RES_OK ){      if( countResultRows( sql.c_str(), &count ) == RES_OK ){
2279          *gidsLen = count;          *gidsLen = count;
# Line 2683  result_t insertGroup( sessionid_t sid, c Line 2690  result_t insertGroup( sessionid_t sid, c
2690            
2691      // examine whether there is already a group name      // examine whether there is already a group name
2692      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2693          string sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups WHERE gname=?";          string sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups WHERE gname=? AND gid!=" + unsignedIntToString(group -> getGID() ) + " AND gid != " + unsignedIntToString( group::GID_DEFAULT );
2694          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
2695          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
2696              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_GROUP_GNAME_LEN, 0, gname, 0, &cbGname );              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_GROUP_GNAME_LEN, 0, gname, 0, &cbGname );
# Line 2838  result_t updateGroup( sessionid_t sid, c Line 2845  result_t updateGroup( sessionid_t sid, c
2845            
2846      // examine whether there is already a group name      // examine whether there is already a group name
2847      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
2848          string sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups WHERE gname=? AND gid!=" + unsignedIntToString(group -> getGID() );          string sql = "SELECT gid FROM " + dbprefix + "_xoonips_groups WHERE gname=? AND gid!=" + unsignedIntToString(group -> getGID() ) + " AND gid != " + unsignedIntToString( group::GID_DEFAULT );
2849          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
2850          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
2851              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_GROUP_GNAME_LEN, 0, gname, 0, &cbGname );              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_GROUP_GNAME_LEN, 0, gname, 0, &cbGname );
# Line 2853  result_t updateGroup( sessionid_t sid, c Line 2860  result_t updateGroup( sessionid_t sid, c
2860                          return ret;                          return ret;
2861                      }                      }
2862                  }else{                  }else{
2863                      string s( "SQLRowCount in insertGroup sql=" );                      string s( "SQLRowCount in updateGroup sql=" );
2864                      s += string( sql );                      s += string( sql );
2865                      setLastErrorString( s.c_str( ) );                      setLastErrorString( s.c_str( ) );
2866                      ret = RES_DB_QUERY_ERROR;                      ret = RES_DB_QUERY_ERROR;
2867                      return ret;                      return ret;
2868                  }                  }
2869              }else{              }else{
2870                  string s( "SQLExecute in insertGroup " );                  string s( "SQLExecute in updateGroup " );
2871                  s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode );                  s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode );
2872                  setLastErrorString( s.c_str( ) );                  setLastErrorString( s.c_str( ) );
2873                  ret = RES_DB_QUERY_ERROR;                  ret = RES_DB_QUERY_ERROR;
2874              }              }
2875          }else{          }else{
2876              string s( "SQLPrepare in insertGroup " );              string s( "SQLPrepare in updateGroup " );
2877              s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode );              s += odbcDiagString( SQL_HANDLE_STMT, hstmt, sqlcode );
2878              setLastErrorString( s.c_str( ) );              setLastErrorString( s.c_str( ) );
2879              ret = RES_ERROR;              ret = RES_ERROR;
# Line 3017  result_t getGroups( sessionid_t sid, gro Line 3024  result_t getGroups( sessionid_t sid, gro
3024      group_t* dst = new group_t[ gidsLen ];      group_t* dst = new group_t[ gidsLen ];
3025            
3026      sql += "SELECT gid, gname, gdesc, group_index_id, group_item_number_limit, group_index_number_limit, group_item_storage_limit ";      sql += "SELECT gid, gname, gdesc, group_index_id, group_item_number_limit, group_index_number_limit, group_item_storage_limit ";
3027      sql += "FROM " + dbprefix + "_xoonips_groups ";      sql += " FROM " + dbprefix + "_xoonips_groups ";
3028      if( gidsLen > 0 ){      if( gidsLen > 0 ){
3029          sql += "WHERE gid=" + string( unsignedIntToString( gids[ 0 ] ) );          sql += " WHERE gid in ( ";
3030          for( int i = 1; i < gidsLen; i++ ){          int i = 0;
3031              sql += " OR gid=" + string( unsignedIntToString( gids[ i ] ) );          for( ; i < gidsLen; i++ ){
3032                if( gids[ i ] == group::GID_DEFAULT ) continue;
3033                sql += string( unsignedIntToString( gids[ i ] ) );
3034                break;
3035            }
3036            for( ; i < gidsLen; i++ ){
3037                if( gids[ i ] == group::GID_DEFAULT ) continue;
3038                sql += ", " + string( unsignedIntToString( gids[ i ] ) );
3039          }          }
3040            sql += " )";
3041      }      }
3042      sql += criteria2str( cri );      sql += criteria2str( cri );
3043            
# Line 5105  static result_t getIndexesInternal( sess Line 5120  static result_t getIndexesInternal( sess
5120      if ( !isModerator( sid, uid ) )      if ( !isModerator( sid, uid ) )
5121          accessRightCond =          accessRightCond =
5122              " (  tx.open_level=1 "              " (  tx.open_level=1 "
5123              " OR tx.open_level=2 AND tlink.uid is not NULL "              " OR tx.open_level=2 AND tlink.uid is not NULL AND tx.gid != " + unsignedIntToString( group::GID_DEFAULT ) +
5124              " OR tx.open_level=3 AND tx.uid = " + uidString + ")"; // アクセス権を表すSQL              " OR tx.open_level=3 AND tx.uid = " + uidString + ")"; // アクセス権を表すSQL
5125      string sql = "SELECT tx.index_id "      string sql = "SELECT tx.index_id "
5126          " FROM " + indexTable + " AS tx " +          " FROM " + indexTable + " AS tx " +

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.92

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