示例#1
0
/**
* Fetches information about the selected message with permission checks
*
* @param	integer	The post we want info about
* @param	boolean	Should we throw an error if there is the id is invalid?
* @param	mixed	Should a permission check be performed as well
*
* @return	array	Array of information about the message or prints an error if it doesn't exist / permission problems
*/
function verify_groupmessage($gmid, $alert = true, $perm_check = true)
{
    global $vbulletin, $vbphrase;
    $messageinfo = fetch_groupmessageinfo($gmid);
    if (!$messageinfo) {
        if ($alert) {
            standard_error(fetch_error('invalidid', $vbphrase['social_group'], $vbulletin->options['contactuslink']));
        } else {
            return 0;
        }
    }
    if ($perm_check) {
        if ($messageinfo['state'] == 'deleted') {
            $can_view_deleted = (can_moderate(0, 'canmoderategroupmessages') or $messageinfo['group_ownerid'] == $vbulletin->userinfo['userid'] and $vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canmanageowngroups']);
            if (!$can_view_deleted) {
                standard_error(fetch_error('invalidid', $vbphrase['message'], $vbulletin->options['contactuslink']));
            }
        }
        if ($messageinfo['state'] == 'moderation') {
            $can_view_message = (can_moderate(0, 'canmoderategroupmessages') or $messageinfo['postuserid'] == $vbulletin->userinfo['userid'] or $messageinfo['group_ownerid'] == $vbulletin->userinfo['userid'] and $vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canmanageowngroups']);
            if (!$can_view_message) {
                standard_error(fetch_error('invalidid', $vbphrase['message'], $vbulletin->options['contactuslink']));
            }
        }
        //	 	Need coventry support first
        //		if (in_coventry($userinfo['userid']) AND !can_moderate())
        //		{
        //			standard_error(fetch_error('invalidid', $vbphrase['gmessage'], $vbulletin->options['contactuslink']));
        //		}
    }
    return $messageinfo;
}
 if ($ci_url_queue_status == 'REPLACE' || $ci_url_queue_status == 'FAILED') {
     // Get classname from contenttypeid
     $ci_content_type = $ci_content_types->getContentTypeClass($ci_urls_data[$key]['contenttypeid']);
     // Replace IMG tag to URL
     switch ($ci_content_type) {
         case 'Post':
         case 'Thread':
             $ci_content = fetch_postinfo($ci_urls_data[$key]['contentid']);
             $ci_manager =& datamanager_init($ci_content_type, $vbulletin, ERRTYPE_STANDARD, 'threadpost');
             $ci_manager->set_existing($ci_content);
             $ci_manager->set('pagetext', ci_replace_img_tag($ci_content['pagetext'], $ci_urls_data[$key]['url'], $url_data['size']));
             $ci_manager->save();
             break;
         case 'SocialGroupMessage':
         case 'SocialGroupDiscussion':
             $ci_content = fetch_groupmessageinfo($ci_urls_data[$key]['contentid']);
             $ci_manager =& datamanager_init('GroupMessage', $vbulletin);
             $ci_manager->set_existing($ci_content);
             $ci_manager->set('pagetext', ci_replace_img_tag($ci_content['pagetext'], $ci_urls_data[$key]['url'], $url_data['size']));
             $ci_manager->save();
             break;
         case 'BlogEntry':
         case 'BlogComment':
             $ci_content = fetch_blog_textinfo($ci_urls_data[$key]['contentid']);
             $ci_manager =& datamanager_init('BlogText', $vbulletin, ERRTYPE_STANDARD, 'blog');
             $ci_manager->set_existing($ci_content);
             $ci_manager->set('pagetext', ci_replace_img_tag($ci_content['pagetext'], $ci_urls_data[$key]['url'], $url_data['size']));
             $ci_manager->save();
             break;
     }
 }
/**
 * Sends email notifications for discussions.
 *
 * @param int		$discussion		- The discussion being updated
 * @param int		$messageid		- Id of the message that triggered the update
 * @param string	$postusername	- Optional username displayed on post
 */
function exec_send_sg_notification($discussionid, $gmid = false, $postusername = false)
{
    global $vbulletin;
    if (!$vbulletin->options['enableemail']) {
        return;
    }
    $discussion = fetch_socialdiscussioninfo($discussionid);
    // if there are no subscribers, no need to send notifications
    if (!$discussion['subscribers']) {
        return;
    }
    // if the discussion is moderated or deleted, don't send notification
    if ('deleted' == $discussion['state'] or 'moderation' == $discussion['state']) {
        return;
    }
    $group = fetch_socialgroupinfo($discussion['groupid']);
    if (!$gmid) {
        // get last gmid from discussion
        $gmid = $vbulletin->db->query_first("\n\t\t\tSELECT MAX(gmid) AS gmid\n\t\t\tFROM " . TABLE_PREFIX . "groupmessage AS groupmessage\n\t\t\tWHERE discussionid = {$discussion['discussionid']}\n\t\t\t\tAND state = 'visible'\n\t\t");
        $gmid = $gmid['gmid'];
    }
    // get message details
    $gmessage = fetch_groupmessageinfo($gmid);
    if (!$gmessage) {
        return;
    }
    // get post time of previous message - if a user hasn't been active since then we won't resend a notification
    $lastposttime = ($lastposttime = $vbulletin->db->query_first("\n\t\t\tSELECT MAX(dateline) AS dateline\n\t\t\tFROM " . TABLE_PREFIX . "groupmessage AS groupmessage\n\t\t\tWHERE discussionid = {$discussion['discussionid']}\n\t\t\t\tAND dateline < {$gmessage['dateline']}\n\t\t\t\tAND state = 'visible'\n\t")) ? $lastposttime['dateline'] : $gmessage['dateline'];
    $discussion['title'] = unhtmlspecialchars($discussion['title']);
    $group['name'] = unhtmlspecialchars($group['name']);
    // temporarily use postusername in userinfo
    if (!$postusername) {
        // get current user name if user exists
        if ($gmessage['postuserid'] and $userinfo = fetch_userinfo($gmessage['postuserid'])) {
            $postusername = $userinfo['username'];
        } else {
            $postusername = $gmessage['postusername'];
        }
    }
    $postusername = unhtmlspecialchars($postusername);
    $userid = $gmessage['postuserid'];
    ($hook = vBulletinHook::fetch_hook('newpost_sg_notification_start')) ? eval($hook) : false;
    $useremails = $vbulletin->db->query_read_slave("\n\t\tSELECT user.*, subscribediscussion.emailupdate, subscribediscussion.subscribediscussionid, IF(socialgroupmember.userid IS NOT NULL,1,0) ismember\n\t\tFROM " . TABLE_PREFIX . "subscribediscussion AS subscribediscussion\n\t\tINNER JOIN " . TABLE_PREFIX . "user AS user ON (subscribediscussion.userid = user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON (usergroup.usergroupid = user.usergroupid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid = user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON (socialgroupmember.userid = user.userid AND socialgroupmember.groupid = {$group['groupid']})\n\t\tWHERE subscribediscussion.discussionid = {$discussion['discussionid']}\n\t\t AND subscribediscussion.emailupdate = 1\n\t\t AND " . ($gmessage['postuserid'] ? " CONCAT(' ', IF(usertextfield.ignorelist IS NULL, '', usertextfield.ignorelist), ' ') NOT LIKE ' " . intval($userid) . " '" : '') . "\n\t\t AND user.usergroupid <> 3\n\t\t AND user.userid <> " . intval($userid) . "\n\t\t AND user.lastactivity >= " . intval($lastposttime) . "\n\t\t AND (usergroup.genericoptions & " . $vbulletin->bf_ugp_genericoptions['isnotbannedgroup'] . ")\n\t");
    vbmail_start();
    // parser for plaintexting the message pagetext
    require_once DIR . '/includes/class_bbcode_alt.php';
    $plaintext_parser =& new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list());
    $pagetext_cache = array();
    // used to cache the results per languageid for speed
    $evalemail = array();
    while ($touser = $vbulletin->db->fetch_array($useremails)) {
        // check user can view discussion
        $permissions = cache_permissions($touser, false);
        if (!($vbulletin->usergroupcache["{$touser['usergroupid']}"]['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup']) or !($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) or !($permissions['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canviewgroups']) or $group['options'] & $vbulletin->bf_misc_socialgroupoptions['join_to_view'] and !$touser['ismember'] and !($permissions['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canalwayscreatediscussion']) and !($permissions['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canalwayspostmessage'])) {
            continue;
        }
        $touser['username'] = unhtmlspecialchars($touser['username']);
        $touser['languageid'] = iif($touser['languageid'] == 0, $vbulletin->options['languageid'], $touser['languageid']);
        $touser['auth'] = md5($touser['userid'] . $touser['subscribediscussionid'] . $touser['salt'] . COOKIE_SALT);
        if (empty($evalemail)) {
            $email_texts = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT text, languageid, fieldname\n\t\t\t\tFROM " . TABLE_PREFIX . "phrase\n\t\t\t\tWHERE fieldname IN ('emailsubject', 'emailbody') AND varname = 'notify_discussion'\n\t\t\t");
            while ($email_text = $vbulletin->db->fetch_array($email_texts)) {
                $emails["{$email_text['languageid']}"]["{$email_text['fieldname']}"] = $email_text['text'];
            }
            require_once DIR . '/includes/functions_misc.php';
            foreach ($emails as $languageid => $email_text) {
                // lets cycle through our array of notify phrases
                $text_message = str_replace("\\'", "'", addslashes(iif(empty($email_text['emailbody']), $emails['-1']['emailbody'], $email_text['emailbody'])));
                $text_message = replace_template_variables($text_message);
                $text_subject = str_replace("\\'", "'", addslashes(iif(empty($email_text['emailsubject']), $emails['-1']['emailsubject'], $email_text['emailsubject'])));
                $text_subject = replace_template_variables($text_subject);
                $evalemail["{$languageid}"] = '
					$message = "' . $text_message . '";
					$subject = "' . $text_subject . '";
				';
            }
        }
        // parse the page text into plain text, taking selected language into account
        if (!isset($pagetext_cache["{$touser['languageid']}"])) {
            $plaintext_parser->set_parsing_language($touser['languageid']);
            $pagetext_cache["{$touser['languageid']}"] = $plaintext_parser->parse($gmessage['pagetext']);
        }
        $pagetext = $pagetext_cache["{$touser['languageid']}"];
        ($hook = vBulletinHook::fetch_hook('new_sg_message_notification_message')) ? eval($hook) : false;
        eval(iif(empty($evalemail["{$touser['languageid']}"]), $evalemail["-1"], $evalemail["{$touser['languageid']}"]));
        vbmail($touser['email'], $subject, $message);
    }
    $vbulletin->db->free_result($useremails);
    unset($plaintext_parser, $pagetext_cache);
    vbmail_end();
}
示例#4
0
    $vbulletin->GPC['contenttype'] = 'vBForum_Post';
}
define('VOTE_CONTENT_TYPE', $vbulletin->GPC['contenttype']);
require_once DIR . '/includes/class_votes.php';
$target_id = 0;
$target = array();
$target_id = $vbulletin->GPC['targetid'];
// fetch target
switch (VOTE_CONTENT_TYPE) {
    case 'vBForum_Post':
        $target = fetch_postinfo($target_id);
        break;
    case 'vBForum_SocialGroupMessage':
        if ($vbulletin->options['vbv_enable_sg_votes']) {
            require_once DIR . '/includes/functions_socialgroup.php';
            $target = fetch_groupmessageinfo($target_id);
            break;
        }
    default:
        standard_error(fetch_error('vbv_unsupported_type', $vbulletin->options['contactuslink']));
}
$permitted_actions = array('vote', 'remove');
if (in_array($_REQUEST['do'], $permitted_actions)) {
    // Init vote manager class
    $vote_manager = vtVotes::get_instance(VOTE_CONTENT_TYPE, $target);
    $need_ajax_response = TRUE;
}
if ($_REQUEST['do'] == 'vote') {
    $vbulletin->input->clean_array_gpc('r', array('value' => TYPE_BOOL));
    // check are negative votes forbidden
    if (!$vbulletin->GPC['value'] and !$vbulletin->options['vbv_enable_neg_votes']) {