Example #1
0
 /**
  * Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an bitboard!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  *
  * @param array pParams hash of values that will be used to store the page
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "boards";
         $this->StartTrans();
         if ($this->mBitBoardId) {
             $locId = array("board_id" => $pParamHash['board_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['board_store'], $locId);
         } else {
             $pParamHash['board_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['board_id'])) {
                 // if pParamHash['board_id'] is set, some is requesting a particular board_id. Use with caution!
                 $pParamHash['board_store']['board_id'] = $pParamHash['board_id'];
             } else {
                 $pParamHash['board_store']['board_id'] = $this->mDb->GenID('boards_board_id_seq');
             }
             $this->mBitBoardId = $pParamHash['board_store']['board_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['board_store']);
             $result = $this->mDb->associateInsert(BIT_DB_PREFIX . "boards_map", array('board_content_id' => $pParamHash['board_store']['content_id'], 'topic_content_id' => $pParamHash['board_store']['content_id']));
             if (!empty($pParamHash['boards_mailing_list'])) {
                 global $gBitSystem, $gBitUser;
                 require_once UTIL_PKG_PATH . 'mailman_lib.php';
                 if ($gBitSystem->getConfig('boards_sync_mail_server')) {
                     if (!($error = mailman_newlist(array('listname' => $pParamHash['boards_mailing_list'], 'listhost' => $gBitSystem->getConfig('boards_email_host', $gBitSystem->getConfig('kernel_server_name')), 'admin-password' => $pParamHash['boards_mailing_list_password'], 'listadmin-addr' => $gBitUser->getField('email'))))) {
                         $this->storePreference('boards_mailing_list', !empty($pParamHash['boards_mailing_list']) ? $pParamHash['boards_mailing_list'] : NULL);
                         $this->storePreference('boards_mailing_list_password', $pParamHash['boards_mailing_list_password']);
                         // Subscribe the owner
                         mailman_addmember($this->getPreference('boards_mailing_list'), $gBitUser->getField('email'));
                         // If we have an inbox then subscribe it as a moderator
                         if ($this->getBoardSyncInbox()) {
                             mailman_addmember($this->getPreference('boards_mailing_list'), $this->getBoardSyncInbox());
                             mailman_setmoderator($this->getPreference('boards_mailing_list'), $this->getBoardSyncInbox());
                         }
                         $this->storePreference('board_sync_list_address', $this->getBoardMailingList());
                     } else {
                         $this->mErrors['mailing_list'] = $error;
                     }
                 }
             }
         }
         if (count($this->mErrors) == 0) {
             $this->CompleteTrans();
             $this->load();
         } else {
             $this->mDb->RollbackTrans();
             $this->mContentId = NULL;
             $this->mBitBoardId = NULL;
         }
     }
     return count($this->mErrors) == 0;
 }
Example #2
0
require_once BOARDS_PKG_PATH . 'lookup_inc.php';
require_once UTIL_PKG_PATH . 'mailman_lib.php';
// Is package installed and enabled
$gBitSystem->verifyPackage('boards');
// Verify we found a board
if (!$gContent->isValid()) {
    $gBitSystem->fatalError(tra("Error: No such board."));
}
// Now check permissions to access this page
$gContent->verifyViewPermission();
if ($boardSyncInbox = BitBoard::getBoardSyncInbox()) {
    $gBitSmarty->assign('boardSyncInbox', $boardSyncInbox);
}
if (!empty($_REQUEST['create_list'])) {
    //------ Email List ------//
    if (!($error = mailman_newlist(array('listname' => $_REQUEST['boards_mailing_list'], 'admin-password' => $_REQUEST['boards_mailing_list_password'], 'listadmin-addr' => $gBitUser->getField('email'))))) {
        $gContent->storePreference('boards_mailing_list', !empty($_REQUEST['boards_mailing_list']) ? $_REQUEST['boards_mailing_list'] : NULL);
        $gContent->storePreference('boards_mailing_list_password', $_REQUEST['boards_mailing_list_password']);
    } else {
        $gBitSmarty->assign('errorMsg', $error);
    }
    //		if( $gContent->getPreference( 'boards_mailing_list' ) && $_REQUEST['boards_mailing_list'] != $gContent->getPreference( 'boards_mailing_list' ) ) {
    // Name change
    //			groups_mailman_rename( $gContent->getPreference( 'boards_mailing_list' ), $_REQUEST['boards_mailing_list'] );
    //		}
} elseif (!empty($_REQUEST['delete_list'])) {
    if ($gContent->getPreference('boards_mailing_list')) {
        if (empty($_REQUEST['confirm'])) {
            $formHash['delete_list'] = TRUE;
            $formHash['b'] = $gContent->getField('board_id');
            $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete this mailing list?') . ' ' . $gContent->getTitle(), 'error' => tra('This cannot be undone!')));