Пример #1
0
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.read.php";
     newbb_setRead("topic", $topic_obj->getVar("topic_id"), $postid);
     if (!$post_obj->getVar("pid")) {
         newbb_setRead("forum", $forum_obj->getVar('forum_id'), $postid);
     }
 }
 $post_obj->loadFilters(empty($isnew) ? "update" : "insert");
 // Define tags for notification message
 if ($approved && !empty($xoopsModuleConfig['notification_enabled']) && !empty($isnew)) {
     $tags = array();
     $tags['THREAD_NAME'] = $_POST['subject'];
     $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/viewtopic.php?post_id=' . $postid;
     $tags['POST_URL'] = $tags['THREAD_URL'];
     // . '#forumpost' . $postid;
     include_once 'include/notification.inc.php';
     $forum_info = newbb_notify_iteminfo('forum', $forum_obj->getVar('forum_id'));
     $tags['FORUM_NAME'] = $forum_info['name'];
     $tags['FORUM_URL'] = $forum_info['url'];
     $notification_handler =& xoops_gethandler('notification');
     if (empty($isreply)) {
         // Notify of new thread
         $notification_handler->triggerEvent('forum', $forum_obj->getVar('forum_id'), 'new_thread', $tags);
     } else {
         // Notify of new post
         $notification_handler->triggerEvent('thread', $topic_id, 'new_post', $tags);
         $_tags["name"] = $tags['THREAD_NAME'];
         $_tags['url'] = $tags['POST_URL'];
         $_tags['uid'] = $uid;
         $notification_handler->triggerEvent('thread', $topic_id, 'post', $_tags);
     }
     $notification_handler->triggerEvent('global', 0, 'new_post', $tags);
Пример #2
0
     include_once XOOPS_ROOT_PATH . '/header.php';
     xoops_error('Could not insert forum post');
     include_once XOOPS_ROOT_PATH . '/footer.php';
     exit;
 }
 if (is_object($xoopsUser) && !empty($isnew)) {
     $xoopsUser->incrementPost();
 }
 // RMV-NOTIFY
 // Define tags for notification message
 $tags = array();
 $tags['THREAD_NAME'] = $HTTP_POST_VARS['subject'];
 $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?forum=' . $forum . '&post_id=' . $postid . '&topic_id=' . $forumpost->topic();
 $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $postid;
 include_once 'include/notification.inc.php';
 $forum_info = newbb_notify_iteminfo('forum', $forum);
 $tags['FORUM_NAME'] = $forum_info['name'];
 $tags['FORUM_URL'] = $forum_info['url'];
 $notification_handler =& xoops_gethandler('notification');
 if (!empty($isnew)) {
     if (empty($isreply)) {
         // Notify of new thread
         $notification_handler->triggerEvent('forum', $forum, 'new_thread', $tags);
     } else {
         // Notify of new post
         $notification_handler->triggerEvent('thread', $topic_id, 'new_post', $tags);
     }
     $notification_handler->triggerEvent('global', 0, 'new_post', $tags);
     $notification_handler->triggerEvent('forum', $forum, 'new_post', $tags);
     $myts =& MyTextSanitizer::getInstance();
     $tags['POST_CONTENT'] = $myts->stripSlashesGPC($HTTP_POST_VARS['message']);
Пример #3
0
function newbb_welcome($user = -1)
{
    global $xoopsModule, $xoopsModuleConfig, $xoopsUser, $xoopsConfig, $myts;
    if (empty($xoopsModuleConfig["welcome_forum"])) {
        return null;
    }
    if ($user == -1) {
        $user =& $xoopsUser;
    }
    if (!is_object($user) || $user->getVar('posts')) {
        return null;
    }
    $forum_handler =& xoops_getmodulehandler('forum', 'newbb');
    $forum =& $forum_handler->get($xoopsModuleConfig["welcome_forum"]);
    if (!$forum_handler->getPermission($forum)) {
        unset($forum);
        return null;
    }
    unset($forum);
    $post_handler =& xoops_getmodulehandler('post', 'newbb');
    $forumpost =& $post_handler->create();
    $forumpost->setVar('poster_ip', newbb_getIP());
    $forumpost->setVar('uid', $user->getVar("uid"));
    $forumpost->setVar('approved', 1);
    $forumpost->setVar('forum_id', $xoopsModuleConfig["welcome_forum"]);
    $subject = sprintf(_MD_WELCOME_SUBJECT, $user->getVar('uname'));
    $forumpost->setVar('subject', $subject);
    $forumpost->setVar('dohtml', 1);
    $forumpost->setVar('dosmiley', 1);
    $forumpost->setVar('doxcode', 0);
    $forumpost->setVar('dobr', 1);
    $forumpost->setVar('icon', "");
    $forumpost->setVar('attachsig', 1);
    $gperm_handler =& xoops_gethandler('groupperm');
    $groups = array(XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS);
    $module_handler =& xoops_gethandler('module');
    $mod = $module_handler->getByDirname('profile');
    if (!defined("_PROFILE_MA_ALLABOUT")) {
        $mod->loadLanguage();
    }
    $groupperm_handler =& xoops_gethandler('groupperm');
    $show_ids =& $groupperm_handler->getItemIds('profile_show', $groups, $mod->getVar('mid'));
    $visible_ids =& $groupperm_handler->getItemIds('profile_visible', $groups, $mod->getVar('mid'));
    unset($mod);
    $fieldids = array_intersect($show_ids, $visible_ids);
    $profile_handler =& xoops_gethandler('profile');
    $fields =& $profile_handler->loadFields();
    $cat_handler =& xoops_getmodulehandler('category', 'profile');
    $categories =& $cat_handler->getObjects(null, true, false);
    $fieldcat_handler =& xoops_getmodulehandler('fieldcategory', 'profile');
    $fieldcats =& $fieldcat_handler->getObjects(null, true, false);
    // Add core fields
    $categories[0]['cat_title'] = sprintf(_PROFILE_MA_ALLABOUT, $user->getVar('name'));
    $avatar = trim($user->getVar('user_avatar'));
    if (!empty($avatar) && $avatar != "blank.gif") {
        $categories[0]['fields'][] = array('title' => _PROFILE_MA_AVATAR, 'value' => "<img src='" . XOOPS_UPLOAD_URL . "/" . $user->getVar('user_avatar') . "' alt='" . $user->getVar('name') . "' />");
        $weights[0][] = 0;
    }
    if ($user->getVar('user_viewemail') == 1) {
        $email = $user->getVar('email', 'E');
        $categories[0]['fields'][] = array('title' => _PROFILE_MA_EMAIL, 'value' => $email);
        $weights[0][] = 0;
    }
    // Add dynamic fields
    foreach (array_keys($fields) as $i) {
        if (in_array($fields[$i]->getVar('fieldid'), $fieldids)) {
            $catid = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? $fieldcats[$fields[$i]->getVar('fieldid')]['catid'] : 0;
            $value = $fields[$i]->getOutputValue($user);
            if (is_array($value)) {
                $value = implode('<br />', array_values($value));
            }
            if (empty($value)) {
                continue;
            }
            $categories[$catid]['fields'][] = array('title' => $fields[$i]->getVar('field_title'), 'value' => $value);
            $weights[$catid][] = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? intval($fieldcats[$fields[$i]->getVar('fieldid')]['field_weight']) : 1;
        }
    }
    foreach (array_keys($categories) as $i) {
        if (isset($categories[$i]['fields'])) {
            array_multisort($weights[$i], SORT_ASC, array_keys($categories[$i]['fields']), SORT_ASC, $categories[$i]['fields']);
        }
    }
    ksort($categories);
    $message = sprintf(_MD_WELCOME_MESSAGE, $user->getVar('uname')) . "\n\n";
    $message .= _PROFILE . ": <a href='" . XOOPS_URL . "/userinfo.php?uid=" . $user->getVar('uid') . "'><strong>" . $user->getVar('uname') . "</strong></a> ";
    $message .= " | <a href='" . XOOPS_URL . "/pmlite.php?send2=1&amp;to_userid=" . $user->getVar('uid') . "'>" . _MD_PM . "</a>\n";
    foreach ($categories as $category) {
        if (isset($category["fields"])) {
            $message .= "\n\n" . $category["cat_title"] . ":\n\n";
            foreach ($category["fields"] as $field) {
                if (empty($field["value"])) {
                    continue;
                }
                $message .= $field["title"] . ": " . $field["value"] . "\n";
            }
        }
    }
    $forumpost->setVar('post_text', $message);
    $postid = $post_handler->insert($forumpost);
    if (!empty($xoopsModuleConfig['notification_enabled'])) {
        $tags = array();
        $tags['THREAD_NAME'] = $subject;
        $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?post_id=' . $postid . '&amp;topic_id=' . $forumpost->getVar('topic_id') . '&amp;forum=' . $xoopsModuleConfig["welcome_forum"];
        $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $postid;
        include_once 'include/notification.inc.php';
        $forum_info = newbb_notify_iteminfo('forum', $xoopsModuleConfig["welcome_forum"]);
        $tags['FORUM_NAME'] = $forum_info['name'];
        $tags['FORUM_URL'] = $forum_info['url'];
        $notification_handler =& xoops_gethandler('notification');
        $notification_handler->triggerEvent('forum', $xoopsModuleConfig["welcome_forum"], 'new_thread', $tags);
        $notification_handler->triggerEvent('global', 0, 'new_post', $tags);
        $notification_handler->triggerEvent('forum', $xoopsModuleConfig["welcome_forum"], 'new_post', $tags);
        $tags['POST_CONTENT'] = $myts->stripSlashesGPC($message);
        $tags['POST_NAME'] = $myts->stripSlashesGPC($subject);
        $notification_handler->triggerEvent('global', 0, 'new_fullpost', $tags);
    }
    return $postid;
}