LOGIN ID Password Auto Login Register Now! Lost Password?
XUGJ Forum

Re: グループメンバー変更→新規モジュールインストールでACL情報破壊の可能性

このトピックの投稿一覧へ

なし Re: グループメンバー変更→新規モジュールインストールでACL情報破壊の可能性

msg# 1.1
depth:
1
前の投稿 - 次の投稿 | 親投稿 - 子投稿.1 | 投稿日時 2008-10-17 15:31
orrisroot  2nd Class 登録日: 2006-9-5   投稿数: 11
とりあえず,既に壊れたグループ権限情報を一括で修正するスクリプトを書いてみました.

function fixXoopsGroupPermissions() {
  global $xoopsDB;
  // get invalid group ids
  $table = $xoopsDB->prefix( 'group_permission' );
  $table2 = $xoopsDB->prefix( 'groups' );
  $sql = sprintf( 'SELECT DISTINCT `gperm_groupid` FROM `%s` LEFT JOIN `%s` ON `%s`.`gperm_groupid`=`%s`.`groupid` WHERE `gperm_modid`=1 AND `groupid` IS NULL', $table, $table2, $table, $table2 );
  $result = $xoopsDB->query( $sql );
  if ( ! $result ) {
    return false;
  }
  $gids = array();
  while ( $myrow = $xoopsDB->fetchArray( $result ) ) {
    $gids[] = $myrow['gperm_groupid'];
  }
  $xoopsDB->freeRecordSet( $result );
  // remove all invalid group id entries
  if ( count( $gids ) != 0 ) {
    $sql = sprintf( 'DELETE FROM `%s` WHERE `gperm_groupid` IN (%s) AND `gperm_modid`=1', $table, implode( ',', $gids ) );
    $result = $xoopsDB->query( $sql );
    if ( ! $result ) {
      return false;
    }
  }
  return true;
}
投票数:0 平均点:0.00

投稿ツリー

  条件検索へ


Back to Page Top
MainMenu
Manuals
Search
XOOPS Official & Dev.
XOOPS Communities