Beispiel #1
0
function group_comment_store(&$pObject, &$pParamHash)
{
    global $gBitSystem, $gLibertySystem, $gBitUser;
    $errors = NULL;
    if ($gBitSystem->isPackageActive('group') && $gBitSystem->isPackageActive('switchboard')) {
        if ($pObject->isValid() && $pObject->isContentType(BITCOMMENT_CONTENT_TYPE_GUID) && $pObject->loadComment() && $pObject->mInfo['content_status_id'] == 50) {
            // load up the root, we need to know a few things
            $root = LibertyBase::getLibertyObject($pParamHash['root_id']);
            // if its a board and it does not have a mailing list in effect then we can send an email
            if ($root->mType['content_type_guid'] == 'bitboard' && !$root->getPreference('boards_mailing_list')) {
                // Get the groups the root is in
                $listHash['mapped_content_id'] = $pParamHash['root_id'];
                $listHash['offset'] = 0;
                $group = new BitGroup();
                $groups = $group->getList($listHash);
                // Get the link
                require_once BOARDS_PKG_PATH . 'BitBoardPost.php';
                $post = new BitBoardPost($pObject->mCommentId);
                $post->load();
                $link = BIT_BASE_URI . $post->getDisplayUrl();
                // some text we need
                $permaLink = BIT_BASE_URI . $pObject->getDisplayUrlFromHash(array('parent_id' => $pParamHash['root_id'], 'content_id' => $pParamHash['content_id']));
                $parseHash = $pParamHash['content_store'];
                $parseHash['uri_mode'] = TRUE;
                $parsedData = $pObject->parseData($parseHash);
                if (!empty($groups)) {
                    foreach ($groups as $group) {
                        // Draft the message body:
                        $body = tra('A new message was posted to the group') . ' ' . $group['title'] . '<br/><br/>' . tra('The message was posted here:') . ' ' . $link . '<br/><br/><br/>' . '/----- ' . tra('Here is the posted text') . ' -----/<br/><br/>' . $parsedData;
                        global $gSwitchboardSystem;
                        $gSwitchboardSystem->sendEvent('group', 'message', $group['content_id'], array('subject' => tra('Group') . ': ' . $group['title'] . ' : ' . $pParamHash['title'], 'message' => $body));
                    }
                }
            }
        }
    }
}