[ PHPXref.com ] [ Generated: Sun Jul 20 18:53:27 2008 ] [ myPHPNuke 1.8.8_8 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/classes/ -> core_LIB_ForumMaint.subclass.php (source)

   1  <?php
   2  
   3  @( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );
   4  error_reporting( _E_VALUE );
   5  
   6  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   7  
   8  // ***** BEGIN LICENSE BLOCK ( DO NOT REMOVE ) *****
   9  
  10  // +----------------------------------------------------------------------+
  11  // | WSCL -> Forum Content Maintenance                                    |
  12  // |                                                                      |
  13  // | -> Maintains A Forums Database Entires                               |
  14  // +----------------------------------------------------------------------+
  15  // | VERSION: 0.1 Alpha                                                   |
  16  // +----------------------------------------------------------------------+
  17  // | LICENSE: LGPL 2.1 (see ./docs/LICENSE_LGPL)                          |
  18  // +----------------------------------------------------------------------+
  19  // | AUTHOR(s):                                                           |
  20  // |                                                                      |
  21  // | The Original Code is the WebSanitizer For MPN 188_8.                 |
  22  // | The Initial Developer of the Original Code is Eric Haddix.           |
  23  // |                                                                      |
  24  // | Portions created by Eric Haddix or Kiril Threndor                    |
  25  // | <support@websanitizer.illearth.net> are                              |
  26  // | Copyright (C) 2003 Eric Haddix.  All Rights Reserved.                |
  27  // |                                                                      |
  28  // | Portions created by Arjan van Waay or avw                            |
  29  // | <arjan@vanwaay.net> are                                              |
  30  // | Copyright (C) 2004 Arjan van Waay.  All Rights Reserved.             |
  31  // +----------------------------------------------------------------------+
  32  // | CONTRIBUTOR(s):                                                      |
  33  // |                                                                      |
  34  // |                                                                      |
  35  // +----------------------------------------------------------------------+
  36  // | MODIFICATIONS:                                                       |
  37  // |                                                                      |
  38  // |                                                                      |
  39  // +----------------------------------------------------------------------+
  40  // | REQUIRED FILES:                                                      |
  41  // |                                                                      |
  42  // +----------------------------------------------------------------------+
  43  // | NOTES:                                                               |
  44  // |   This Class is Currently Being Built.                               |
  45  // |   The only use in this alpha version is maint. of forum database     |
  46  // |   tables when users have been deleted.                               |
  47  // +----------------------------------------------------------------------+
  48  // | SUPPORT:                                                             |
  49  // |   WEB:   http://myphpnuke.com/                                       |
  50  // |   EMAIL: support@websanitizer.illearth.net                           |
  51  // +----------------------------------------------------------------------+
  52  
  53  /**
  54   * MPN_188_8_Classes
  55   *
  56   * @package MPN_188_8_Classes
  57   * @subpackage Content_Maintenance
  58   * @category forum_maintenance
  59   * @version $Id: core_LIB_ForumMaint.subclass.php,v 1.1.2.8 2004/08/15 12:58:23 kirilt Exp $
  60   *
  61   * @author Kiril Threndor <support@websanitizer.project-php.com>
  62   * @author avw <arjan@vanwaay.net>
  63   * @copyright Copyright (C) 2003 Eric Haddix and Arjan van Waay
  64   * @license http://www.gnu.org/licenses/lgpl.html LGPL 2.1
  65   * @support http://websanitizer.project-php.com/
  66   *
  67   * @tutorial
  68   * @filesource
  69   */
  70  
  71  // ***** END LICENSE AND DOCUMENTATION BLOCKS ( DO NOT REMOVE ) *****
  72  
  73  /**
  74   * Content Maintenance Base Class
  75   *
  76   * @package MPN_188_8_Classes
  77   * @subpackage Content_Maintenance
  78   * @category forum_maintenance
  79   * @version 0.1 Alpha
  80   */
  81  
  82  class ForumMaint extends ContentMaint
  83  {
  84      var $global_admin_uid = -1;
  85  
  86      var $show_modsonly = TRUE;
  87  
  88  /**
  89   * Constructor.
  90   *
  91   * Class Constructor
  92   *
  93   * @param array ( $dbtables -> db table array )
  94   * @return object
  95   */
  96  
  97  function ForumMaint( $dbtables )
  98      {
  99          $this -> __construct( $dbtables );
 100  
 101          $forum_tables = array
 102          (
 103              'config'    => $this -> dbtables['forumconfig']
 104            , 'forums'    => $this -> dbtables['forums']
 105            , 'topics'    => $this -> dbtables['forumtopics']
 106            , 'posts'     => $this -> dbtables['posts']
 107            , 'users'     => $this -> dbtables['users']
 108            , 'ustatus'   => $this -> dbtables['users_status']
 109            , 'pm'        => $this -> dbtables['priv_msgs']
 110            , 'guestbook' => $this -> dbtables['guestbook']
 111          );
 112  
 113          $this -> cmtbls = array_merge( $this -> cmtbls, $forum_tables );
 114  
 115          return $this;
 116  
 117      } // End Constructor
 118  
 119  /**
 120   * Automatic Forum Tables Fixing When User Has Been Deleted.
 121   *
 122   * This is intended for eventual integration
 123   * with a new content management script.
 124   *
 125   * @param integer ( $uid -> user ID for the post )
 126   * @global array ( $this -> dbtables -> DB table array )
 127   * @return void
 128   */
 129  
 130  function fixAllTables( $uid, $newuid = NULL, $topicid = FALSE, $topic_only = FALSE, $action = 'del' )
 131      {
 132          $this -> checkNewUID( $uid, $newuid );
 133  
 134          $results = array
 135          (
 136              'topics'    => $this -> fixTopics( $topicid, $uid, $newuid, $topic_only )
 137  
 138            , 'pm'        => $this -> fixPMTable( $topicid, $uid, $newuid, $topic_only )
 139  
 140            , 'guestbook' => $this -> fixGuestBookTable( $uid, $newuid, $action )
 141          );
 142  
 143          if ( $this -> checkResults( $results ) )
 144          {
 145              $msg = 'Method fixAllTables -> One Or More Database Queries Failed';
 146              $this -> _ERROR_( $msg, $sql, $results, __FILE__, __LINE__, TRUE );
 147          }
 148  
 149          return (bool)TRUE;
 150  
 151      } // End Method fixForumTables
 152  
 153  /**
 154   * Fix Forum Topic & Posts Table When User Has Been Deleted.
 155   *
 156   * @param integer ( $topicid -> topic ID to fix if not fixing all of them )
 157   * @param integer ( $uid -> user ID for the post )
 158   * @param integer ( $newuid -> user ID to assign )
 159   * @param bool ( $topic_only -> fix just one topic or all of them )
 160   * @return bool
 161   */
 162  
 163  function fixTopics( $topicid, $uid, $newuid = NULL, $topic_only = FALSE )
 164      {
 165          $this -> checkNewUID( $uid, $newuid );
 166          $add_stamp = ( $newuid > 1 || $newuid == $this -> global_admin_uid );
 167  
 168          $sql_1 = 'UPDATE ' . $this -> cmtbls['topics'] . '
 169                    SET topic_poster = "' . $newuid . '"
 170                    WHERE topic_poster = "' . $uid . '"
 171                        && ( ' . $uid . ' + topic_poster ) != 0';
 172  
 173          $sql_2 = 'UPDATE ' . $this -> cmtbls['posts'] . '
 174                    SET poster_id = ' . $newuid;
 175  
 176          if ( $add_stamp )
 177          {
 178              $msg = '<br /><br />&#045;&#045;&#045;&#032;Admin Reclaimed Post&#032;&#045;&#045;&#045;<br /><br />';
 179  
 180              $sql_2 .= ', post_text = CONCAT( post_text, "' . $msg . '" ) WHERE ( INSTR( post_text, "' . $msg . '" ) = 0 ) && ';
 181          }
 182          else
 183          {
 184              $sql_2 .= ' WHERE ';
 185          }
 186  
 187          $sql_2 .= '( ' . $uid . ' + poster_id ) != 0
 188                          && poster_id = ' . $uid;
 189  
 190          if ( $topic_only )
 191          {
 192              $sql_1 .= ' && topic_id = "' . $topicid . '"';
 193              $sql_2 .= ' && topic_id = "' . $topicid . '"';
 194          }
 195  
 196          $results = $this -> execSQLQueries( array( 'topics' => $sql_1, 'posts' => $sql_2 ) );
 197  
 198          if ( $this -> checkResults( $results ) )
 199          {
 200              $msg = 'Method fixTopics -> One Or More Database Queries Failed';
 201              $sql = $sql_1 . '<br />' . $sql_2;
 202              $this -> _ERROR_( $msg, $sql, $results, __FILE__, __LINE__ );
 203          }
 204  
 205          return (bool)TRUE;
 206  
 207      } // End Method fixTopics
 208  
 209  /**
 210   * Fix Forum Topics Table When User Has Been Deleted.
 211   *
 212   * @param integer ( $topicid -> topic ID to fix if not fixing all of them )
 213   * @param integer ( $uid -> user ID for the post )
 214   * @param integer ( $newuid -> user ID to assign )
 215   * @param bool ( $topic_only -> fix just one topic or all of them )
 216   * @return bool
 217   */
 218  
 219  function fixPMTable( $uid, $newuid = NULL, $action = 'del' )
 220      {
 221          $this -> checkNewUID( $uid, $newuid );
 222  
 223          $_EXEC = ( $action == 'del' ) ? ( 'DELETE FROM' ) : ( 'UPDATE' );
 224  
 225          $sql = $_EXEC . $this -> cmtbls['pm'];
 226  
 227          if ( $action != 'del' )
 228          {
 229              $sql .= ' SET to_userid = "' . $newuid . '", from_userid = "' . $newuid . '"';
 230          }
 231  
 232          $sql .= ' WHERE ( to_userid = "' . $uid . '" || from_userid = "' . $uid . '" )
 233                        && ( ( ' . $uid . ' + to_userid ) != 0 || ( ' . $uid . ' + from_userid ) != 0 )';
 234  
 235          $results = $this -> execSQLQuery( $sql );
 236  
 237          if ( $this -> checkResults( $results ) )
 238          {
 239              $msg = 'Method fixPostTable -> Update Or Delete Query Failed';
 240              $this -> _ERROR_( $msg, $sql, $result, __FILE__, __LINE__ );
 241          }
 242  
 243          return (bool)TRUE;
 244  
 245      } // End Method fixTopics
 246  
 247  /**
 248   * Fix Forum Topics Table When User Has Been Deleted.
 249   *
 250   * @param integer ( $topicid -> topic ID to fix if not fixing all of them )
 251   * @param integer ( $uid -> user ID for the post )
 252   * @param integer ( $newuid -> user ID to assign )
 253   * @param bool ( $topic_only -> fix just one topic or all of them )
 254   * @return bool
 255   */
 256  
 257  function fixGuestBookTable( $uid, $newuid = NULL, $action = 'del' )
 258      {
 259          $this -> checkNewUID( $uid, $newuid );
 260  
 261          $_EXEC = ( $action == 'del' ) ? ( 'DELETE FROM' ) : ( 'UPDATE' );
 262  
 263          $sql = $_EXEC . $this -> cmtbls['guestbook'];
 264  
 265          if ( $action != 'del' )
 266          {
 267              $sql .= ' SET guest_poster = "' . $newuid . '"';
 268          }
 269  
 270          $sql .= ' WHERE guest_poster = "' . $uid . '"';
 271  
 272          $results = $this -> execSQLQuery( $sql );
 273  
 274          if ( $this -> checkResults( $results ) )
 275          {
 276              $msg = 'Method fixGuestBookTable -> Update Or Delete Query Failed';
 277              $this -> _ERROR_( $msg, $sql, $result, __FILE__, __LINE__ );
 278          }
 279  
 280          return (bool)TRUE;
 281  
 282      } // End Method fixTopics
 283  
 284  /**
 285   * Generate An Admin Interface
 286   *
 287   * @return $string
 288   */
 289  
 290  function getAdminInterface( $puid, $topicid )
 291      {
 292          if ( ! $this -> cm_admin ) { return ''; }
 293  
 294          $content = '';
 295  
 296          $content .= '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">' . "\n";
 297  
 298          $content .= extractQuery();
 299  
 300          $content .= '<input type="hidden" name="fmaint" value="1">' . "\n";
 301          $content .= '<input type="hidden" name="topicid" value="' . $topicid . '">' . "\n";
 302          $content .= '<input type="hidden" name="puid" value="' . $puid . '">' . "\n";
 303  
 304          $content .= '<label>' . translate( 'Assign To' ) . ' :</label>' . "\n";
 305  
 306          $content .= '<select name="newuid">' . "\n";
 307  
 308              if ( $puid > 1 )
 309              {
 310                  $content .= '<option value="' . $puid . '" selected="1">' . translate( 'Tag For Later Action' ) . '</option>' . "\n";
 311              }
 312  
 313              $content .= '<option value="' . $this -> global_admin_uid . '">' . translate( 'Global Admin User' ) . '</option>' . "\n";
 314  
 315              if ( $this -> show_modsonly )
 316              {
 317                  $sql = 'SELECT t1.uid, t1.uname
 318                          FROM ' . $this -> cmtbls['users'] . ' AS t1,
 319                               ' . $this -> cmtbls['ustatus'] . ' AS t2
 320                          WHERE t1.uid = t2.uid
 321                              && t2.level > 1';
 322              }
 323              else
 324              {
 325                  $sql = 'SELECT uid, uname
 326                          FROM ' . $this -> cmtbls['users'];
 327              }
 328  
 329              $result = $this -> execSQLQuery( $sql );
 330  
 331              $content .= '<option></option>' . "\n";
 332  
 333              if ( $this -> checkResults( $result ) )
 334              {
 335                  for ( $i = 0; $i < @mysql_num_rows( $result ); $i++ )
 336                  {
 337                      if (    ! @mysql_data_seek( $result, $i )
 338                           || ! @( $tmp = mysql_fetch_row( $result ) ) )
 339                      {
 340                          continue;
 341                      }
 342  
 343                     $content .= '<option value="' . $tmp[0] . '">' . $tmp[1] . '</option>' . "\n";
 344                  }
 345  
 346                  @mysql_free_result ( $result );
 347              }
 348  
 349          $content .= '</select>' . "\n";
 350  
 351          $content .= '&nbsp;&nbsp;<label>' . translate( 'Apply To' ) . ' :</label>' . "\n";
 352  
 353          $content .= '<select name="action">' . "\n";
 354  
 355              $content .= '<option value="0" selected="1">' . translate( 'This Topic Only' ) . '</option>' . "\n";
 356  
 357              $content .= '<option value="1">' . translate( 'All Topics' ) . '</option>' . "\n";
 358  
 359              //$content .= '<option value="2" >' . translate( 'All Related Tables' ) . '</option>' . "\n";
 360  
 361          $content .= '</select>' . "\n";
 362  
 363          $content .= '<input class="button" type="submit" value="' . translate( 'Go' ) . '"></input>' . "\n";
 364  
 365          $content .= '</form>' . "\n";
 366  
 367          if ( $puid < - 1 )
 368          {
 369              $content .= '<em class="look">' . translate( 'This Message Has Already Been Tagged For Later Action' ) . '</em><br />';
 370         }
 371  
 372          return $content;
 373  
 374      } // End Method getAdminInterface
 375  
 376  /**
 377   * Check New User ID And Modifies If Necessary
 378   *
 379   * @return void ( $newuid passed by reference )
 380   */
 381  
 382  function checkNewUID( $uid, &$newuid )
 383      {
 384          if ( $uid < - 1 && ( is_null( $newuid ) || $newuid < - 1 ) )
 385          {
 386              $this -> _ERROR_( 'Invalid Arguments. User Already Tagged For Later Action', NULL, NULL, __FILE__, __LINE__ );
 387          }
 388  
 389          if ( is_null( $newuid ) || $newuid == $uid ) { $newuid = - $uid; }
 390  
 391          if ( $newuid == $this -> global_admin_uid )
 392          {
 393              $this -> checkAdminUser( 'users', 'uid' );
 394          }
 395  
 396          return;
 397  
 398      } // End Method checkNewUID
 399  
 400  } // End Class ForumMaint
 401  
 402  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]