/** * 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; }
function storeUserEmailPref($pPref, $pUser = NULL) { global $gBitSystem, $gBitUser, $gSwitchboardSystem; // if user is NULL get the active one if (!is_object($pUser)) { $pUser =& $gBitUser; } // @TODO add errors if mailman or switchboard updates fail $errors = array(); // if the content is this and its board has a mailing list then act on that if (($board = $this->getBoard()) && $board->getPreference('boards_mailing_list')) { require_once UTIL_PKG_PATH . 'mailman_lib.php'; if ($pPref != 'none') { mailman_addmember($board->getPreference('boards_mailing_list'), $pUser->getField('email'), $pPref); } elseif ($pPref == 'none') { mailman_remove_member($board->getPreference('boards_mailing_list'), $pUser->getField('email')); } // @TODO - this is may be the future - but don't change it until ok from wjames5 or after april 1 2009 $gSwitchboardSystem->storeUserPref($pUser->mUserId, 'group', 'message', $this->mContentId, $pPref); } elseif ($gBitSystem->isPackageActive('switchboard')) { $gSwitchboardSystem->storeUserPref($pUser->mUserId, 'group', 'message', $this->mContentId, $pPref); } return count($errors) == 0; }
} } elseif (!empty($_REQUEST['save_list_address'])) { $gContent->storePreference('board_sync_list_address', !empty($_REQUEST['board_sync_list_address']) ? $_REQUEST['board_sync_list_address'] : NULL); } elseif ($gContent->getPreference('boards_mailing_list')) { // check for submits that need boards_mailing_list if (!empty($_REQUEST['subscribe_boardsync'])) { if ($gContent->getPreference('board_sync_list_address')) { mailman_addmember($gContent->getPreference('boards_mailing_list'), $boardSyncInbox); mailman_setmoderator($gContent->getPreference('boards_mailing_list'), $boardSyncInbox); } } elseif (!empty($_REQUEST['unsubscribe_boardsync'])) { if ($gContent->getPreference('board_sync_list_address')) { mailman_remove_member($gContent->getPreference('boards_mailing_list'), $boardSyncInbox); } } elseif (!empty($_REQUEST['subscribe'])) { mailman_addmember($gContent->getPreference('boards_mailing_list'), $gBitUser->getField('email')); } elseif (!empty($_REQUEST['unsubscribe'])) { mailman_remove_member($gContent->getPreference('boards_mailing_list'), $gBitUser->getField('email')); } } if ($gContent->getBoardMailingList()) { $gBitSmarty->assign('boardsMailingList', $gContent->getBoardMailingList()); if ($gContent->hasUserPermission('p_boards_boards_members_view')) { $members = mailman_list_members($gContent->getPreference('boards_mailing_list')); $gBitSmarty->assignByRef('listMembers', $members); } } else { $gBitSmarty->assign('suggestedListName', preg_replace('/[^a-z0-9]/', '', strtolower($gContent->getTitle()))); } // display $gBitSmarty->assignByRef('board', $gContent);