home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / forums / do_watch_forum.php < prev    next >
Encoding:
PHP Script  |  2003-04-04  |  838 b   |  28 lines

  1. <?php /* FORUMS $Id: do_watch_forum.php,v 1.2 2003/04/04 05:02:40 eddieajau Exp $ */
  2. ##
  3. ## Change forum watches
  4. ##
  5. $watch = isset( $_POST['watch'] ) ? $_POST['watch'] : 0;
  6.  
  7. if ($watch) {
  8.     // clear existing watches
  9.     $sql = "DELETE FROM forum_watch WHERE watch_user = $AppUI->user_id AND watch_$watch IS NOT NULL";
  10.     if (!db_exec($sql)) {
  11.         $AppUI->setMsg( db_error(), UI_MSG_ERROR );
  12.     } else {
  13.         $sql = '';
  14.         foreach ($_POST as $k => $v) {
  15.             if (strpos($k, 'forum_') !== FALSE) {
  16.                 $sql = "INSERT INTO forum_watch (watch_user,watch_$watch) VALUES ($AppUI->user_id,".substr( $k, 6 ).")";
  17.                 if (!db_exec($sql)) {
  18.                     $AppUI->setMsg( db_error(), UI_MSG_ERROR );
  19.                 } else {
  20.                     $AppUI->setMsg( "Watch updated", UI_MSG_OK );
  21.                 }
  22.             }
  23.         }
  24.     }
  25. } else {
  26.     $AppUI->setMsg( 'Incorrect watch type passed to sql handler.', UI_MSG_ERROR );
  27. }
  28. ?>