Beispiel #1
0
 /**
  * Load object from an id
  *
  * @param int $id
  * @return vB_Legacy_Forum
  */
 public static function create_from_id($id)
 {
     //this is cached for the page load and we rely upon that.  It also loads way more
     //data than just the base record, some of which depends on the current user/options
     //we should try to provide some getters for stuff that depends on those fields
     // (either derived data or related objects) so that we can rework stuff here
     // without massive case statements in get_field
     $record = fetch_socialgroupinfo($id);
     if ($record) {
         $group = new vB_Legacy_SocialGroup();
         $group->set_record($record);
         return $group;
     } else {
         return null;
     }
 }
Beispiel #2
0
    $messagecount = count($messagearray);
    $groupcount = count($grouplist);
    $url =& $vbulletin->url;
    $navbits = array('' => $vbphrase['delete_messages']);
    $navbits = construct_navbits($navbits);
    eval('$navbar = "' . fetch_template('navbar') . '";');
    ($hook = vBulletinHook::fetch_hook('group_inlinemod_delete')) ? eval($hook) : false;
    eval('print_output("' . fetch_template('socialgroups_deletemessages') . '");');
}
if ($_POST['do'] == 'doinlinedelete') {
    $vbulletin->input->clean_array_gpc('p', array('deletetype' => TYPE_UINT, 'deletereason' => TYPE_NOHTMLCOND));
    $physicaldel = $vbulletin->GPC['deletetype'] == 2 ? true : false;
    // Validate Messages
    $messages = $db->query_read_slave("\n\t\tSELECT gm.gmid, gm.state, gm.groupid, gm.dateline, gm.postuserid, gm.postusername\n\t\tFROM " . TABLE_PREFIX . "groupmessage AS gm\n\t\tWHERE gmid IN (" . implode(',', $messageids) . ")\n\t");
    while ($message = $db->fetch_array($messages)) {
        $group = fetch_socialgroupinfo($message['groupid']);
        $message['is_group_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid'];
        $canmoderatemessages = fetch_socialgroup_modperm('canmoderategroupmessages', $group);
        $candeletemessages = (fetch_socialgroup_modperm('candeletegroupmessages', $group) or $message['state'] == 'visible' and $message['postuserid'] == $vbulletin->userinfo['userid'] and $vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canmanagemessages']);
        $canremovemessages = can_moderate(0, 'canremovegroupmessages');
        if ($message['state'] == 'moderation' and !$canmoderatemessages) {
            standard_error(fetch_error('you_do_not_have_permission_to_manage_moderated_messages'));
        } else {
            if ($message['state'] == 'deleted' and !$candeletemessages) {
                standard_error(fetch_error('you_do_not_have_permission_to_manage_deleted_messages'));
            } else {
                if ($physicaldel and !$canremovemessages or !$physicaldel and !$candeletemessages) {
                    standard_error(fetch_error('you_do_not_have_permission_to_delete_messages'));
                }
            }
        }
Beispiel #3
0
     exec_header_redirect('album.php?' . $vbulletin->session->vars['sessionurl'] . 'albumid=' . $albuminfo['albumid'] . ($vbulletin->GPC['pagenumber'] > 1 ? '&page=' . $vbulletin->GPC['pagenumber'] : ''));
 }
 if (empty($albuminfo)) {
     standard_error(fetch_error('invalidid', $vbphrase['album'], $vbulletin->options['contactuslink']));
 }
 if ($userinfo['userid'] != $vbulletin->userinfo['userid'] or !($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_groups']) or !$vbulletin->options['socnet_groups_albums_enabled'] or !($vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canviewgroups'])) {
     print_no_permission();
 }
 if (!$vbulletin->GPC['groupid']) {
     standard_error(fetch_error('must_select_valid_group_add_pictures'));
 }
 if (empty($vbulletin->GPC['pictureids'])) {
     standard_error(fetch_error('must_select_valid_pictures_add_group'));
 }
 require_once DIR . '/includes/functions_socialgroup.php';
 $group = fetch_socialgroupinfo($vbulletin->GPC['groupid']);
 if (!$group or $group['membertype'] != 'member' or !($group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'])) {
     print_no_permission();
 }
 if ($vbulletin->GPC['pictureids']) {
     $picture_sql = $db->query_read("\n\t\t\tSELECT albumpicture.pictureid\n\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture ON\n\t\t\t\t(socialgrouppicture.pictureid = albumpicture.pictureid AND socialgrouppicture.groupid = {$group['groupid']})\n\t\t\tWHERE albumpicture.albumid = {$albuminfo['albumid']}\n\t\t\t\tAND albumpicture.pictureid IN (" . implode(',', $vbulletin->GPC['pictureids']) . ")\n\t\t\t\tAND picture.state = 'visible'\n\t\t");
     $pictures = array();
     while ($picture = $db->fetch_array($picture_sql)) {
         $pictures[] = "({$group['groupid']}, {$picture['pictureid']}, " . TIMENOW . ")";
     }
     ($hook = vBulletinHook::fetch_hook('album_picture_doaddgroups_multiple')) ? eval($hook) : false;
     if ($pictures) {
         $db->query_write("\n\t\t\t\tINSERT IGNORE " . TABLE_PREFIX . "socialgrouppicture\n\t\t\t\t\t(groupid, pictureid, dateline)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(',', $pictures));
         $groupdm =& datamanager_init('SocialGroup', $vbulletin, ERRTYPE_STANDARD);
         $groupdm->set_existing($group);
         $groupdm->rebuild_picturecount();
/**
 * 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();
}
Beispiel #5
0
 /**
  * Any code to run after deleting
  *
  * @param	Boolean Do the query?
  */
 function post_delete($doquery = true)
 {
     $this->dbobject->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "post SET\n\t\t\t\tusername = '******'username']) . "',\n\t\t\t\tuserid = 0\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "groupmessage SET\n\t\t\t\tpostusername = '******'username']) . "',\n\t\t\t\tpostuserid = 0\n\t\t\tWHERE postuserid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "visitormessage SET\n\t\t\t\tpostusername = '******'username']) . "',\n\t\t\t\tpostuserid = 0\n\t\t\tWHERE postuserid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "visitormessage\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "usernote SET\n\t\t\t\tusername = '******'username']) . "',\n\t\t\t\tposterid = 0\n\t\t\tWHERE posterid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "usernote\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "access\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "event\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "customavatar\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     @unlink($this->registry->options['avatarpath'] . '/avatar' . $this->existing['userid'] . '_' . $this->existing['avatarrevision'] . '.gif');
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "customprofilepic\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     @unlink($this->registry->options['profilepicpath'] . '/profilepic' . $this->existing['userid'] . '_' . $this->existing['profilepicrevision'] . '.gif');
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "sigpic\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     @unlink($this->registry->options['sigpicpath'] . '/sigpic' . $this->existing['userid'] . '_' . $this->existing['sigpicrevision'] . '.gif');
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "moderator\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "reputation\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribeforum\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribethread\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribeevent\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "subscriptionlog\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "session\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "userban\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "usergrouprequest\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "announcementread\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "infraction\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t");
     $pendingfriends = array();
     $currentfriends = array();
     $friendlist = $this->dbobject->query_read("\n\t\t\tSELECT relationid, friend\n\t\t\tFROM " . TABLE_PREFIX . "userlist\n\t\t\tWHERE userid = " . $this->existing['userid'] . "\n\t\t\t\tAND type = 'buddy'\n\t\t\t\tAND friend IN('pending','yes')\n\t\t");
     while ($friend = $this->dbobject->fetch_array($friendlist)) {
         if ($friend['friend'] == 'yes') {
             $currentfriends[] = $friend['relationid'];
         } else {
             $pendingfriends[] = $friend['relationid'];
         }
     }
     if (!empty($pendingfriends)) {
         $this->dbobject->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\t\tSET friendreqcount = IF(friendreqcount > 0, friendreqcount - 1, 0)\n\t\t\t\tWHERE userid IN (" . implode(", ", $pendingfriends) . ")\n\t\t\t");
     }
     if (!empty($currentfriends)) {
         $this->dbobject->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\t\tSET friendcount = IF(friendcount > 0, friendcount - 1, 0)\n\t\t\t\tWHERE userid IN (" . implode(", ", $currentfriends) . ")\n\t\t\t");
     }
     $this->dbobject->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "userlist\n\t\t\tWHERE userid = " . $this->existing['userid'] . " OR relationid = " . $this->existing['userid']);
     $admindm =& datamanager_init('Admin', $this->registry, ERRTYPE_SILENT);
     $admindm->set_existing($this->existing);
     $admindm->delete();
     unset($admindm);
     $groups = $this->registry->db->query_read("\n\t\t\tSELECT *\n\t\t\tFROM " . TABLE_PREFIX . "socialgroup\n\t\t\tWHERE creatoruserid = " . $this->existing['userid']);
     $groupsowned = array();
     while ($group = $this->registry->db->fetch_array($groups)) {
         $groupsowned[] = $group['groupid'];
     }
     $this->registry->db->free_result($groups);
     if (!empty($groupsowned)) {
         require_once DIR . '/includes/functions_socialgroup.php';
         foreach ($groupsowned as $groupowned) {
             $group = fetch_socialgroupinfo($groupowned);
             if (!empty($group)) {
                 // dm will have problem if the group is invalid, and in all honesty, at this situation,
                 // if the group is no longer present, then we don't need to worry about it anymore.
                 $socialgroupdm = datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT);
                 $socialgroupdm->set_existing($group);
                 $socialgroupdm->delete();
             }
         }
     }
     $groupmemberships = $this->registry->db->query_read("\n\t\t\tSELECT socialgroup.*\n\t\t\tFROM " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON\n\t\t\t\t(socialgroup.groupid = socialgroupmember.groupid)\n\t\t\tWHERE socialgroupmember.userid = " . $this->existing['userid']);
     $socialgroups = array();
     while ($groupmembership = $this->registry->db->fetch_array($groupmemberships)) {
         $socialgroups["{$groupmembership['groupid']}"] = $groupmembership;
     }
     $grouppicture_sql = $this->registry->db->query_read("\n\t\t\tSELECT socialgrouppicture.groupid, socialgrouppicture.pictureid\n\t\t\tFROM " . TABLE_PREFIX . "picture AS picture\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture ON\n\t\t\t\t(socialgrouppicture.pictureid = picture.pictureid)\n\t\t\tWHERE picture.userid = " . $this->existing['userid'] . "\n\t\t");
     $grouppictures = array();
     while ($grouppicture = $this->registry->db->fetch_array($grouppicture_sql)) {
         $grouppictures[] = $grouppicture['pictureid'];
     }
     if (!empty($grouppictures)) {
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "socialgrouppicture\n\t\t\t\tWHERE pictureid IN (" . implode(',', $grouppictures) . ")\n\t\t\t");
     }
     if (!empty($socialgroups)) {
         $this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "socialgroupmember WHERE userid = " . $this->existing['userid']);
         foreach ($socialgroups as $group) {
             $groupdm =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_STANDARD);
             $groupdm->set_existing($group);
             $groupdm->rebuild_membercounts();
             $groupdm->rebuild_picturecount();
             $groupdm->save();
             list($pendingcountforowner) = $this->registry->db->query_first("\n\t\t\t\t\tSELECT SUM(moderatedmembers) FROM " . TABLE_PREFIX . "socialgroup\n\t\t\t\t\tWHERE creatoruserid = " . $group['creatoruserid'], DBARRAY_NUM);
             $this->registry->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\t\t\tSET socgroupreqcount = " . intval($pendingcountforowner) . "\n\t\t\t\t\tWHERE userid = " . $group['creatoruserid']);
         }
         unset($groupdm);
     }
     $pictures = array();
     $picture_sql = $this->registry->db->query_read("\n\t\t\tSELECT album.albumid, albumpicture.pictureid\n\t\t\tFROM " . TABLE_PREFIX . "album AS album\n\t\t\tINNER JOIN " . TABLE_PREFIX . "albumpicture AS albumpicture ON (albumpicture.albumid = album.albumid)\n\t\t\tWHERE album.userid = " . $this->existing['userid']);
     while ($picture = $this->registry->db->fetch_array($picture_sql)) {
         $pictures[] = $picture['pictureid'];
     }
     if ($pictures) {
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "albumpicture\n\t\t\t\tWHERE pictureid IN (" . implode(',', $pictures) . ")\n\t\t\t");
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\tWHERE pictureid IN (" . implode(',', $pictures) . ")\n\t\t\t");
     }
     $this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "album WHERE userid = " . $this->existing['userid']);
     $this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "picture WHERE userid = " . $this->existing['userid']);
     $this->registry->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "picturecomment SET\n\t\t\t\tpostusername = '******'username']) . "',\n\t\t\t\tpostuserid = 0\n\t\t\tWHERE postuserid = " . $this->existing['userid'] . "\n\t\t");
     require_once DIR . '/includes/adminfunctions.php';
     delete_user_pms($this->existing['userid'], false);
     require_once DIR . '/includes/functions_databuild.php';
     ($hook = vBulletinHook::fetch_hook('userdata_delete')) ? eval($hook) : false;
     build_user_statistics();
     build_birthdays();
 }
Beispiel #6
0
 } else {
     if ($type != 'new') {
         $show['undelete'] = false;
         $show['unapprove'] = false;
     }
 }
 // Create bit factory
 $bitfactory = new vB_Group_Bit_Factory($vbulletin, $itemtype);
 // Build message bits for all items
 $messagebits = '';
 while ($item = $collection->fetch_item()) {
     if (!$do_discussions) {
         $discussion = fetch_socialdiscussioninfo($item['discussionid']);
         $group = fetch_socialgroupinfo($discussion['groupid']);
     } else {
         $group = fetch_socialgroupinfo($item['groupid']);
     }
     // add group name to message
     $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
     // force items to be visible
     if ('new' != $type) {
         $item['state'] = 'visible';
     }
     $bit =& $bitfactory->create($item, $group);
     $messagebits .= $bit->construct();
 }
 unset($bitfactory, $bit);
 // Set counts for view
 list($first, $last, $messageshown, $messagetotal) = array_values($collection->fetch_counts());
 // Legacy for templates
 $show['havemessages'] = (bool) $messagetotal;
 /**
  * Any code to run after deleting
  *
  * @access protected
  * 
  * @param boolean $doquery					Do the query?
  */
 function post_delete($doquery = true)
 {
     if (empty($this->info['group'])) {
         $this->info['group'] = fetch_socialgroupinfo($this->fetch_field('groupid'));
     }
     if ($this->info['hard_delete']) {
         // prepare table names for MySQL 4.0.x
         $discussionid = intval($this->existing['discussionid']);
         $groupmessage_table = TABLE_PREFIX . 'groupmessage';
         $deletionlog_table = TABLE_PREFIX . 'deletionlog';
         $moderation_table = TABLE_PREFIX . 'moderation';
         // delete all messages and their deletion logs and moderation
         $this->registry->db->query_write("DELETE {$groupmessage_table}, {$deletionlog_table}, {$moderation_table} \n\t\t\t\t FROM {$groupmessage_table}   \n\t\t\t\t LEFT JOIN {$deletionlog_table}  \n\t\t\t\t  ON {$deletionlog_table}.primaryid = {$groupmessage_table}.gmid \n\t\t\t\t  AND {$deletionlog_table}.type = 'groupmessage' \n\t\t\t\t LEFT JOIN {$moderation_table} \n\t\t\t\t  ON {$moderation_table}.primaryid = {$groupmessage_table}.gmid \n\t\t\t\t  AND {$moderation_table}.type = 'groupmessage' \n\t\t\t\t WHERE {$groupmessage_table}.discussionid = {$discussionid}");
         if (!$this->info['skip_build_counters']) {
             require_once DIR . '/includes/functions_socialgroup.php';
             build_group_counters($this->existing['groupid']);
         }
         // delete read marking
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "discussionread \n\t\t\t\tWHERE " . TABLE_PREFIX . "discussionread.discussionid = {$discussionid}\n\t\t\t");
         // delete subscriptions
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribediscussion \n\t\t\t\tWHERE " . TABLE_PREFIX . "subscribediscussion.discussionid = {$discussionid}\n\t\t\t");
         // update moderation count for owner
         update_owner_pending_gm_count($this->info['group']['creatoruserid']);
         ($hook = vBulletinHook::fetch_hook('discussiondata_delete')) ? eval($hook) : false;
     }
 }
/**
 * Rebuilds Group Counter information
 *
 * @param	integer	Group ID
 *
 */
function build_group_counters($groupid)
{
    global $vbulletin;
    if (!($groupid = intval($groupid))) {
        return;
    }
    $messages = $vbulletin->db->query_first("\n\t\tSELECT\n\t\t\tSUM(IF(state = 'visible', 1, 0)) AS visible,\n\t\t\tSUM(IF(state = 'deleted', 1, 0)) AS deleted,\n\t\t\tSUM(IF(state = 'moderation', 1, 0)) AS moderation\n\t\tFROM " . TABLE_PREFIX . "groupmessage\n\t\tWHERE groupid = {$groupid}\n\t");
    $lastpost = $vbulletin->db->query_first("\n\t\tSELECT user.username, gm.postuserid, gm.dateline, gm.gmid\n\t\tFROM " . TABLE_PREFIX . "groupmessage AS gm\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = gm.postuserid)\n\t\tWHERE gm.groupid = {$groupid} AND gm.state = 'visible'\n\t\tORDER BY gm.dateline DESC\n\t\tLIMIT 1\n\t");
    $groupinfo = fetch_socialgroupinfo($groupid);
    $dataman =& datamanager_init('SocialGroup', $vbulletin, ERRTYPE_SILENT);
    $dataman->set_existing($groupinfo);
    $dataman->set('lastpost', $lastpost['dateline']);
    $dataman->set('lastposter', $lastpost['username']);
    $dataman->set('lastposterid', $lastpost['postuserid']);
    $dataman->set('lastgmid', $lastpost['gmid']);
    $dataman->set('visible', $messages['visible']);
    $dataman->set('deleted', $messages['deleted']);
    $dataman->set('moderation', $messages['moderation']);
    ($hook = vBulletinHook::fetch_hook('group_build_counters')) ? eval($hook) : false;
    $dataman->save();
    list($pendingcountforowner) = $vbulletin->db->query_first("\n\t\tSELECT SUM(moderation) FROM " . TABLE_PREFIX . "socialgroup\n\t\tWHERE creatoruserid = " . $groupinfo['creatoruserid'], DBARRAY_NUM);
    $vbulletin->db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "user\n\t\tSET gmmoderatedcount = " . intval($pendingcountforowner) . "\n\t\tWHERE userid = " . $groupinfo['creatoruserid']);
}
Beispiel #9
0
	/**
	* Verifies permissions to attach content to groups
	*
	* @return	boolean
	*/
	public function verify_permissions()
	{
		global $show;

		$this->values['groupid'] = intval($this->values['groupid']);
		if (
			!($group = fetch_socialgroupinfo($this->values['groupid']))
				OR
			$group['membertype'] != 'member'
				OR
			!($group['options'] & $this->registry->bf_misc_socialgroupoptions['enable_group_albums'])
				OR
			!($this->registry->options['socnet'] & $this->registry->bf_misc_socnet['enable_groups'])
				OR
			!($this->registry->userinfo['permissions']['socialgrouppermissions'] & $this->registry->bf_ugp_socialgrouppermissions['canviewgroups'])
				OR
			!($this->registry->options['socnet_groups_pictures_enabled'])
		)
		{
			return false;
		}

		return true;
	}
Beispiel #10
0
            }
        }
    }
    ($hook = vBulletinHook::fetch_hook('group_inlinemod_dodelete')) ? eval($hook) : false;
    $redirect_message = $inline_discussion ? 'redirect_inline_deleteddiscussions' : 'redirect_inline_deletedmessages';
    print_standard_redirect($redirect_message, true, $forceredirect);
}
// #######################################################################
if ($_POST['do'] == 'inlineundelete') {
    // Validate Messages
    $messages = $inline_discussion ? verify_discussions($messageids, false, false, true) : verify_messages($messageids, false, false, true);
    require_once DIR . '/vb/search/indexcontroller/queue.php';
    if ($messages) {
        while ($message = $db->fetch_array($messages)) {
            $discussion = fetch_socialdiscussioninfo($message['discussionid']);
            $group = fetch_socialgroupinfo($discussion['groupid']);
            $message['is_group_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid'];
            if ($message['gmid'] == $discussion['firstpostid']) {
                if (!fetch_socialgroup_modperm('canundeletediscussions')) {
                    standard_error(fetch_error('you_do_not_have_permission_to_manage_deleted_discussions'));
                }
                $message['firstpost'] = true;
            } else {
                if (!fetch_socialgroup_modperm('canundeletegroupmessages', $group)) {
                    standard_error(fetch_error('you_do_not_have_permission_to_manage_deleted_messages'));
                }
                $message['firstpost'] = false;
            }
            $message['group_name'] = $group['name'];
            $message['discussion_name'] = $discussion['title'];
            $messagearray["{$message['gmid']}"] = $message;
Beispiel #11
0
 /**
  * Sets up different display variables for the Group Message
  *
  * @access protected
  */
 function process_display()
 {
     global $show;
     $this->discussion = fetch_socialdiscussioninfo($this->item['discussionid']);
     $this->group = fetch_socialgroupinfo($this->discussion['groupid']);
     $this->item['is_discussion'] = $this->item['gmid'] == $this->discussion['firstpostid'];
     $show['moderation'] = $this->item['state'] == 'moderation';
     if ($this->show_moderation_tools and !$this->force_inline_selection) {
         if ($this->item['is_discussion']) {
             $this->item['inlinemod'] = (($this->item['state'] != 'moderation' or fetch_socialgroup_modperm('canmoderatediscussions', $this->group)) and ($this->item['state'] != 'deleted' or fetch_socialgroup_modperm('canundeletediscussions', $this->group)) and (fetch_socialgroup_modperm('canmoderatediscussions') or fetch_socialgroup_modperm('candeletediscussions', $this->group) or fetch_socialgroup_modperm('canremovediscussions', $this->group)));
         } else {
             $this->item['inlinemod'] = (($this->item['state'] != 'deleted' or fetch_socialgroup_modperm('canundeletegroupmessages', $this->group)) and ($this->item['state'] != 'moderated' or fetch_socialgroup_modperm('canmoderategroupmessages', $this->group)) and (fetch_socialgroup_modperm('canmoderategroupmessages', $this->group) or fetch_socialgroup_modperm('canundeletegroupmessages', $this->group) or fetch_socialgroup_modperm('canremovegroupmessages', $this->group)));
         }
     } else {
         $this->item['inlinemod'] = $this->force_inline_selection;
     }
     if ($this->show_moderation_tools) {
         if ($this->item['is_discussion']) {
             $this->item['edit'] = (can_edit_group_discussion($this->discussion) or can_edit_group_message($this->item, $this->group));
         } else {
             $this->item['edit'] = can_edit_group_message($this->item, $this->group);
         }
     } else {
         $show['edit'] = $this->item['edit'] = false;
     }
     // legacy
     $show['inlinemod'] = $this->item['inlinemod'];
     $show['edit'] = $this->item['edit'];
 }
Beispiel #12
0
 /**
  * Any code to run after deleting
  *
  * @access protected
  * 
  * @param boolean $doquery					Do the query?
  */
 function post_delete($doquery = true)
 {
     if (empty($this->info['group'])) {
         $this->info['group'] = fetch_socialgroupinfo($this->fetch_field('groupid'));
     }
     if ($this->info['hard_delete']) {
         // prepare table names for MySQL 4.0.x
         $discussionid = intval($this->existing['discussionid']);
         $groupmessage_table = TABLE_PREFIX . 'groupmessage';
         $deletionlog_table = TABLE_PREFIX . 'deletionlog';
         $moderation_table = TABLE_PREFIX . 'moderation';
         $activity = new vB_ActivityStream_Manage('socialgroup', 'discussion');
         $activity->set('contentid', $this->existing['discussionid']);
         $activity->delete();
         $idlist = array();
         $ids = $this->registry->db->query_read("\n\t\t\t\tSELECT gmid\n\t\t\t\tFROM " . TABLE_PREFIX . "groupmessage\n\t\t\t\tWHERE discussionid = {$this->existing['discussionid']}\n\t\t\t");
         while ($id = $this->registry->db->fetch_array($ids)) {
             $idlist[] = $id['gmid'];
         }
         if ($idlist) {
             $activity = new vB_ActivityStream_Manage('socialgroup', 'groupmessage');
             $activity->set('contentid', $idlist);
             $activity->delete();
         }
         /*
          
         KEVIN :  Need to add SocialGroup ? So this can all be done in one ?
          
         // Search index maintenance - Remove for a hard delete.
         require_once(DIR . '/vb/search/core.php');
         $indexer = vB_Search_Core::get_instance()->get_index_controller('vBForum', 'SocialGroup');			
         $indexer->delete($discussionid);		
         */
         require_once DIR . '/vb/search/core.php';
         $indexer = vB_Search_Core::get_instance()->get_index_controller('vBForum', 'SocialGroupMessage');
         $result = $this->registry->db->query("SELECT gmid FROM " . TABLE_PREFIX . "groupmessage WHERE discussionid={$discussionid}");
         while ($row = $this->registry->db->fetch_row($result)) {
             $indexer->delete($row[0]);
         }
         // delete all messages and their deletion logs and moderation
         $this->registry->db->query_write("DELETE {$groupmessage_table}, {$deletionlog_table}, {$moderation_table} \n\t\t\t\t FROM {$groupmessage_table}   \n\t\t\t\t LEFT JOIN {$deletionlog_table}  \n\t\t\t\t  ON {$deletionlog_table}.primaryid = {$groupmessage_table}.gmid \n\t\t\t\t  AND {$deletionlog_table}.type = 'groupmessage' \n\t\t\t\t LEFT JOIN {$moderation_table} \n\t\t\t\t  ON {$moderation_table}.primaryid = {$groupmessage_table}.gmid \n\t\t\t\t  AND {$moderation_table}.type = 'groupmessage' \n\t\t\t\t WHERE {$groupmessage_table}.discussionid = {$discussionid}");
         if (!$this->info['skip_build_counters']) {
             require_once DIR . '/includes/functions_socialgroup.php';
             build_group_counters($this->existing['groupid']);
         }
         // delete read marking
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "discussionread \n\t\t\t\tWHERE " . TABLE_PREFIX . "discussionread.discussionid = {$discussionid}\n\t\t\t");
         // delete subscriptions
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribediscussion \n\t\t\t\tWHERE " . TABLE_PREFIX . "subscribediscussion.discussionid = {$discussionid}\n\t\t\t");
         // update moderation count for owner
         update_owner_pending_gm_count($this->info['group']['creatoruserid']);
         ($hook = vBulletinHook::fetch_hook('discussiondata_delete')) ? eval($hook) : false;
     }
 }
 public function report_item($reason)
 {
     require_once DIR . '/includes/functions_socialgroup.php';
     $discussion = fetch_socialdiscussioninfo($this->item['discussionid']);
     $group = fetch_socialgroupinfo($discussion['groupid']);
     require_once DIR . '/includes/class_reportitem.php';
     $reportobj = new vB_ReportItem_GroupMessage($vbulletin);
     $reportobj->set_extrainfo('group', $group);
     $reportobj->set_extrainfo('discussion', $discussion);
     $reportobj->do_report($reason, $this->item);
 }
Beispiel #14
0
	/**
	* Any code to run after deleting
	*
	* @access protected
	* 
	* @param boolean $doquery					Do the query?
	*/
	function post_delete($doquery = true)
	{
		if (empty($this->info['group']))
		{
			$this->info['group'] = fetch_socialgroupinfo($this->fetch_field('groupid'));
		}
		
		if ($this->info['hard_delete'])
		{
			// prepare table names for MySQL 4.0.x
			$discussionid = intval($this->existing['discussionid']);
			$groupmessage_table = TABLE_PREFIX . 'groupmessage';
			$deletionlog_table = TABLE_PREFIX . 'deletionlog';
			$moderation_table = TABLE_PREFIX . 'moderation';

			/*
			 
			KEVIN :  Need to add SocialGroup ? So this can all be done in one ?
			 
			// Search index maintenance - Remove for a hard delete.
			require_once(DIR . '/vb/search/core.php');
			$indexer = vB_Search_Core::get_instance()->get_index_controller('vBForum', 'SocialGroup');			
			$indexer->delete($discussionid);		
			*/
			
			require_once(DIR . '/vb/search/core.php');
			$indexer = vB_Search_Core::get_instance()->get_index_controller('vBForum', 'SocialGroupMessage');
			
			$result = $this->registry->db->query("SELECT gmid FROM " . TABLE_PREFIX . "groupmessage WHERE discussionid={$discussionid}");
			 
			while ($row = $this->registry->db->fetch_row($result))
			{
				$indexer->delete($row[0]);
			}
			
			// delete all messages and their deletion logs and moderation
			$this->registry->db->query_write(
				"DELETE $groupmessage_table, $deletionlog_table, $moderation_table 
				 FROM $groupmessage_table   
				 LEFT JOIN $deletionlog_table  
				  ON $deletionlog_table.primaryid = $groupmessage_table.gmid 
				  AND $deletionlog_table.type = 'groupmessage' 
				 LEFT JOIN $moderation_table 
				  ON $moderation_table.primaryid = $groupmessage_table.gmid 
				  AND $moderation_table.type = 'groupmessage' 
				 WHERE $groupmessage_table.discussionid = $discussionid"
			);
			
			if (!$this->info['skip_build_counters'])
			{
				require_once(DIR . '/includes/functions_socialgroup.php');
				build_group_counters($this->existing['groupid']);
			}

			// delete read marking
			$this->registry->db->query_write("
				DELETE FROM " . TABLE_PREFIX . "discussionread 
				WHERE " . TABLE_PREFIX . "discussionread.discussionid = $discussionid
			");
			
			// delete subscriptions
			$this->registry->db->query_write("
				DELETE FROM " . TABLE_PREFIX . "subscribediscussion 
				WHERE " . TABLE_PREFIX . "subscribediscussion.discussionid = $discussionid
			");
			
			// update moderation count for owner
			update_owner_pending_gm_count($this->info['group']['creatoruserid']);
		
 			($hook = vBulletinHook::fetch_hook('discussiondata_delete')) ? eval($hook) : false;
		}
	}
Beispiel #15
0
	/**
	* Any code to run after deleting
	*
	* @param	Boolean Do the query?
	*/
	function post_delete($doquery = true)
	{
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "post SET
				username = '******'username']) . "',
				userid = 0
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "groupmessage SET
				postusername = '******'username']) . "',
				postuserid = 0
			WHERE postuserid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "discussion SET
				lastposter = '" . $this->dbobject->escape_string($this->existing['username']) . "',
				lastposterid = 0
			WHERE lastposterid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "visitormessage SET
				postusername = '******'username']) . "',
				postuserid = 0
			WHERE postuserid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "visitormessage
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "usernote SET
				username = '******'username']) . "',
				posterid = 0
			WHERE posterid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "usernote
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "access
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "event
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "customavatar
			WHERE userid = " . $this->existing['userid'] . "
		");
		@unlink($this->registry->options['avatarpath'] . '/avatar' . $this->existing['userid'] . '_' . $this->existing['avatarrevision'] . '.gif');

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "customprofilepic
			WHERE userid = " . $this->existing['userid'] . "
		");
		@unlink($this->registry->options['profilepicpath'] . '/profilepic' . $this->existing['userid'] . '_' . $this->existing['profilepicrevision'] . '.gif');

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "sigpic
			WHERE userid = " . $this->existing['userid'] . "
		");
		@unlink($this->registry->options['sigpicpath'] . '/sigpic' . $this->existing['userid'] . '_' . $this->existing['sigpicrevision'] . '.gif');

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "moderator
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "reputation
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribeforum
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribethread
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribeevent
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscriptionlog
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "session
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "userban
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "usergrouprequest
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "announcementread
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "infraction
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "groupread
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "discussionread
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribediscussion
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribegroup
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "profileblockprivacy
			WHERE userid = " . $this->existing['userid'] . "
		");

		$pendingfriends = array();
		$currentfriends = array();

		$friendlist = $this->dbobject->query_read("
			SELECT relationid, friend
			FROM " . TABLE_PREFIX . "userlist
			WHERE userid = " . $this->existing['userid'] . "
				AND type = 'buddy'
				AND friend IN('pending','yes')
		");

		while ($friend = $this->dbobject->fetch_array($friendlist))
		{
			if ($friend['friend'] == 'yes')
			{
				$currentfriends[] = $friend['relationid'];
			}
			else
			{
				$pendingfriends[] = $friend['relationid'];
			}
		}

		if (!empty($pendingfriends))
		{
			$this->dbobject->query_write("
				UPDATE " . TABLE_PREFIX . "user
				SET friendreqcount = IF(friendreqcount > 0, friendreqcount - 1, 0)
				WHERE userid IN (" . implode(", ", $pendingfriends) . ")
			");
		}

		if (!empty($currentfriends))
		{
			$this->dbobject->query_write("
				UPDATE " . TABLE_PREFIX . "user
				SET friendcount = IF(friendcount > 0, friendcount - 1, 0)
				WHERE userid IN (" . implode(", ", $currentfriends) . ")
			");
		}

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "userlist
			WHERE userid = " . $this->existing['userid'] . " OR relationid = " . $this->existing['userid']
		);

		$admindm =& datamanager_init('Admin', $this->registry, ERRTYPE_SILENT);
		$admindm->set_existing($this->existing);
		$admindm->delete();
		unset($admindm);

		$groups = $this->registry->db->query_read("
			SELECT *
			FROM " . TABLE_PREFIX . "socialgroup
			WHERE creatoruserid = " . $this->existing['userid']
		);

		$groupsowned = array();

		while ($group = $this->registry->db->fetch_array($groups))
		{
			$groupsowned[] = $group['groupid'];
		}
		$this->registry->db->free_result($groups);

		if (!empty($groupsowned))
		{
			require_once(DIR . '/includes/functions_socialgroup.php');
			foreach($groupsowned AS $groupowned)
			{
				$group = fetch_socialgroupinfo($groupowned);
				if (!empty($group))
				{
					// dm will have problem if the group is invalid, and in all honesty, at this situation,
					// if the group is no longer present, then we don't need to worry about it anymore.
					$socialgroupdm = datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT);
					$socialgroupdm->set_existing($group);
					$socialgroupdm->delete();
				}
			}
		}

		$groupmemberships = $this->registry->db->query_read("
			SELECT socialgroup.*
			FROM " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember
			INNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON
				(socialgroup.groupid = socialgroupmember.groupid)
			WHERE socialgroupmember.userid = " . $this->existing['userid']
		);

		$socialgroups = array();
		while ($groupmembership = $this->registry->db->fetch_array($groupmemberships))
		{
			$socialgroups["$groupmembership[groupid]"] = $groupmembership;
		}

		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();

		$picture_sql = $this->registry->db->query_read("
			SELECT a.attachmentid, a.filedataid, a.userid
			FROM " . TABLE_PREFIX . "attachment AS a
			WHERE
				a.userid = " . $this->existing['userid'] . "
					AND
				a.contenttypeid IN (" . intval($types->getContentTypeID('vBForum_SocialGroup')) . "," . intval($types->getContentTypeID('vBForum_Album')) . ")
		");
		$pictures = array();

		$attachdm =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment');
		while ($picture = $this->registry->db->fetch_array($picture_sql))
		{
			$attachdm->set_existing($picture);
			$attachdm->delete();
		}

		if (!empty($socialgroups))
		{
			$this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "socialgroupmember WHERE userid = "  . $this->existing['userid']);

			foreach ($socialgroups AS $group)
			{
				$groupdm =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_STANDARD);
				$groupdm->set_existing($group);
				$groupdm->rebuild_membercounts();
				$groupdm->rebuild_picturecount();
				$groupdm->save();

				list($pendingcountforowner) = $this->registry->db->query_first("
					SELECT SUM(moderatedmembers) FROM " . TABLE_PREFIX . "socialgroup
					WHERE creatoruserid = " . $group['creatoruserid']
				, DBARRAY_NUM);

				$this->registry->db->query_write("
					UPDATE " . TABLE_PREFIX . "user
					SET socgroupreqcount = " . intval($pendingcountforowner) . "
					WHERE userid = " . $group['creatoruserid']
				);
			}

			unset($groupdm);
		}

		$this->registry->db->query_write("
			UPDATE " . TABLE_PREFIX . "socialgroup
			SET transferowner = 0
			WHERE transferowner = " . $this->existing['userid']
		);

		$this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "album WHERE userid = " . $this->existing['userid']);


		$this->registry->db->query_write("
			UPDATE " . TABLE_PREFIX . "picturecomment SET
				postusername = '******'username']) . "',
				postuserid = 0
			WHERE postuserid = " . $this->existing['userid'] . "
		");

		require_once(DIR . '/includes/adminfunctions.php');
		delete_user_pms($this->existing['userid'], false);

		require_once(DIR . '/includes/functions_databuild.php');

		($hook = vBulletinHook::fetch_hook('userdata_delete')) ? eval($hook) : false;

		build_user_statistics();
		build_birthdays();
	}