boards
[ class tree: boards ] [ index: boards ] [ all elements ]

Source for file mailing_list.php

Documentation is available at mailing_list.php

  1. <?php
  2. /**
  3.  * $Header$
  4.  * Copyright (c) bitweaver Group
  5.  * All Rights Reserved. See below for details and a complete list of authors.
  6.  * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  7.  *
  8.  * @package boards
  9.  * @subpackage functions
  10.  */
  11.  
  12. /**
  13.  * required setup
  14.  */
  15. require_once( '../kernel/setup_inc.php' );
  16. require_once( BOARDS_PKG_PATH.'BitBoardTopic.php' );
  17. require_once( BOARDS_PKG_PATH.'BitBoardPost.php' );
  18. require_once( BOARDS_PKG_PATH.'BitBoard.php' );
  19. require_once( BOARDS_PKG_PATH.'lookup_inc.php' );
  20. require_once( UTIL_PKG_PATH.'mailman_lib.php' );
  21.  
  22. // Is package installed and enabled
  23. $gBitSystem->verifyPackage( 'boards' );
  24.  
  25. // Verify we found a board
  26. if( !$gContent->isValid() ) {
  27.   $gBitSystem->fatalError(tra("Error: No such board."));
  28. }
  29.  
  30. // Now check permissions to access this page
  31. $gContent->verifyViewPermission();
  32.  
  33. if( $boardSyncInbox = BitBoard::getBoardSyncInbox() ) {
  34.     $gBitSmarty->assign( 'boardSyncInbox', $boardSyncInbox );
  35. }
  36.  
  37. if( !empty( $_REQUEST['create_list'] ) ) {
  38.     //------ Email List ------//
  39.     if( !($error = mailman_newlist( array( 'listname' => $_REQUEST['boards_mailing_list'], 'admin-password'=>$_REQUEST['boards_mailing_list_password'], 'listadmin-addr'=>$gBitUser->getField( 'email' ) ) )) ) {
  40.         $gContent->storePreference( 'boards_mailing_list', !empty( $_REQUEST['boards_mailing_list'] ) ? $_REQUEST['boards_mailing_list'] : NULL );
  41.         $gContent->storePreference( 'boards_mailing_list_password', $_REQUEST['boards_mailing_list_password'] );
  42.     } else {
  43.         $gBitSmarty->assign( 'errorMsg', $error );
  44.     }
  45.  
  46. //        if( $gContent->getPreference( 'boards_mailing_list' ) && $_REQUEST['boards_mailing_list'] != $gContent->getPreference( 'boards_mailing_list' ) ) {
  47.             // Name change
  48. //            groups_mailman_rename( $gContent->getPreference( 'boards_mailing_list' ), $_REQUEST['boards_mailing_list'] );
  49. //        }
  50.  
  51. } elseif( !empty( $_REQUEST['delete_list'] ) ) {
  52.     if( $gContent->getPreference( 'boards_mailing_list' ) ) {
  53.         if( empty( $_REQUEST['confirm'] ) ) {
  54.             $formHash['delete_list'] = TRUE;
  55.             $formHash['b'] = $gContent->getField( 'board_id' );
  56.             $gBitSystem->confirmDialog(    $formHash,
  57.                 array(
  58.                     'warning' => tra('Are you sure you want to delete this mailing list?') . ' ' . $gContent->getTitle(),
  59.                     'error' => tra('This cannot be undone!'),
  60.                 )
  61.             );
  62.         } else {
  63.             if( !($error = mailman_rmlist( $gContent->getPreference( 'boards_mailing_list' ) )) ) {
  64.                 $gContent->storePreference( 'boards_mailing_list', NULL );
  65.                 $gContent->storePreference( 'boards_mailing_list_password', NULL );
  66.                 bit_redirect( BOARDS_PKG_URL."mailing_list.php?b=".$gContent->getField( 'board_id' ) );
  67.             } else {
  68.                 $gBitSmarty->assign( 'errorMsg', $error );
  69.             }
  70.         }
  71.     }
  72. } elseif( !empty( $_REQUEST['save_list_address'] ) ) {
  73.     $gContent->storePreference( 'board_sync_list_address', (!empty( $_REQUEST['board_sync_list_address'] ) ? $_REQUEST['board_sync_list_address'] : NULL ) );
  74. } elseif( $gContent->getPreference( 'boards_mailing_list' ) ) {
  75.     // check for submits that need boards_mailing_list
  76.     if( !empty( $_REQUEST['subscribe_boardsync'] ) ) {
  77.       if( $gContent->getPreference('board_sync_list_address') ) {
  78.           mailman_addmember( $gContent->getPreference( 'boards_mailing_list' ), $boardSyncInbox );
  79.         mailman_setmoderator( $gContent->getPreference( 'boards_mailing_list' ), $boardSyncInbox );
  80.       }
  81.     } elseif( !empty( $_REQUEST['unsubscribe_boardsync'] ) ) {
  82.         if( $gContent->getPreference('board_sync_list_address') ) {
  83.             mailman_remove_member( $gContent->getPreference( 'boards_mailing_list' ), $boardSyncInbox );
  84.         }
  85.     } elseif( !empty( $_REQUEST['subscribe'] ) ) {
  86.         mailman_addmember( $gContent->getPreference( 'boards_mailing_list' ), $gBitUser->getField( 'email' ) );
  87.     } elseif( !empty( $_REQUEST['unsubscribe'] ) ) {
  88.         mailman_remove_member( $gContent->getPreference( 'boards_mailing_list' ), $gBitUser->getField( 'email' ) );
  89.     }
  90. }
  91.  
  92. if( $gContent->getBoardMailingList() ) {
  93.     $gBitSmarty->assign( 'boardsMailingList', $gContent->getBoardMailingList() );
  94.     if ( $gContent->hasUserPermission( 'p_boards_boards_members_view' ) ){
  95.         $members = mailman_list_members( $gContent->getPreference( 'boards_mailing_list' ) );
  96.         $gBitSmarty->assign_by_ref( 'listMembers', $members );
  97.     }
  98. } else {
  99.     $gBitSmarty->assign( 'suggestedListName', preg_replace( '/[^a-z0-9]/', '', strtolower( $gContent->getTitle() ) ) );
  100. }
  101.  
  102. // display
  103. $gBitSmarty->assign_by_ref( 'board', $gContent );
  104. $gBitSystem->display( "bitpackage:boards/mailing_list.tpl", $gContent->getTitle() ." ".  tra( 'Message Board Mailing List' ) , array( 'display_mode' => 'list' ));
  105. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:04 +0000 by phpDocumentor 1.5.0-lsces