Esempio n. 1
0
 /**
  * Additional data to update after a delete call (such as denormalized values in other tables).
  *
  * @param	boolean	Do the query?
  */
 function post_delete($doquery = true)
 {
     $types = vB_Types::instance();
     $contenttypeid = intval($types->getContentTypeID('vBForum_Album'));
     $attachmentids = array();
     $attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_STANDARD, 'attachment');
     $picture_sql = $this->registry->db->query_read("\n\t\t\tSELECT\n\t\t\t\ta.attachmentid, a.filedataid, a.userid\n\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\tWHERE\n\t\t\t\ta.contentid = " . $this->fetch_field('albumid') . "\n\t\t\t\t\tAND\n\t\t\t\ta.contenttypeid = {$contenttypeid}\n\t\t");
     while ($picture = $this->registry->db->fetch_array($picture_sql)) {
         $attachdata->set_existing($picture);
         $attachdata->delete(true, false, 'album', 'photo');
         $attachmentids[] = $picture['attachmentid'];
     }
     $this->registry->db->free_result($picture_sql);
     $this->remove_usercss_background_image();
     ($hook = vBulletinHook::fetch_hook('albumdata_delete')) ? eval($hook) : false;
     $activity = new vB_ActivityStream_Manage('album', 'album');
     $activity->set('contentid', $this->fetch_field('albumid'));
     $activity->delete();
     return true;
 }
Esempio n. 2
0
function delete_post($postid, $countposts = true, $threadid = 0, $physicaldel = true, $delinfo = NULL, $dolog = true)
{
    global $vbulletin, $vbphrase, $threadinfo;
    $postid = intval($postid);
    $threadid = intval($threadid);
    if (!is_array($delinfo)) {
        $delinfo = array('userid' => $vbulletin->userinfo['userid'], 'username' => $vbulletin->userinfo['username'], 'reason' => '', 'keepattachments' => false);
    } else {
        if (!$delinfo['userid']) {
            $delinfo['userid'] = $vbulletin->userinfo['userid'];
        }
        if (!$delinfo['username']) {
            $delinfo['username'] = $vbulletin->userinfo['username'];
        }
    }
    if ($postinfo = fetch_postinfo($postid)) {
        $threadinfo = fetch_threadinfo($postinfo['threadid']);
        if (!$physicaldel and $postinfo['visible'] == 2) {
            // post is already soft deleted
            return;
        }
        if ($threadinfo['firstpostid'] == $postid) {
            if (!$physicaldel and $threadinfo['visible'] == 2) {
                // thread is already soft deleted
                return;
            }
            // delete thread
            $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost');
            $threadman->set_existing($threadinfo);
            $threadman->delete($countposts, $physicaldel, $delinfo);
            unset($threadman);
            return;
        }
        if (can_moderate() and $dolog) {
            fetch_phrase_group('threadmanage');
            if (!$physicaldel) {
                $type = 'post_x_by_y_softdeleted';
            } else {
                $type = 'post_x_by_y_removed';
            }
            $postinfo['forumid'] = $threadinfo['forumid'];
            require_once DIR . '/includes/functions_log_error.php';
            log_moderator_action($postinfo, $type, array($postinfo['title'], $postinfo['username']));
        }
        if ($countposts and $postinfo['visible'] == 1 and $threadinfo['visible'] == 1 and $postinfo['userid']) {
            // deleted posts have already been decremented and hidden posts were never incremented (as of 3.5 at least)
            // init user data manager
            $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
            $userdata->set_existing($postinfo);
            $userdata->set('posts', 'IF(posts > 1, posts - 1, 0)', false);
            $userdata->set_ladder_usertitle_relative(-1);
            $userdata->save();
            unset($userdata);
        }
        if ($postinfo['attach']) {
            if ($physicaldel or !$delinfo['keepattachments'] and can_moderate($threadinfo['forumid'], 'canremoveposts')) {
                $types = vB_Types::instance();
                $contenttypeid = intval($types->getContentTypeID('vBForum_Post'));
                $attachdata =& datamanager_init('Attachment', $vbulletin, ERRTYPE_SILENT, 'attachment');
                $attachdata->condition = "a.contentid = " . intval($postinfo['postid']) . " AND a.contenttypeid = " . intval($contenttypeid);
                $attachdata->delete(true, false);
            }
        }
        if (!$physicaldel) {
            $deletionman =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog');
            $deletionman->set('primaryid', $postinfo['postid']);
            $deletionman->set('type', 'post');
            $deletionman->set('userid', $delinfo['userid']);
            $deletionman->set('username', $delinfo['username']);
            $deletionman->set('reason', $delinfo['reason']);
            $deletionman->save();
            unset($deletionman);
            $postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
            $postman->set_existing($postinfo);
            $postman->set('visible', 2);
            $postman->save();
            unset($postman);
            if (!$postinfo['visible']) {
                // only posts that are already moderated need tidied up
                $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = {$postinfo['postid']} AND type = 'reply'");
                $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "spamlog WHERE postid = {$postinfo['postid']}");
            }
            return;
        }
        // Sending the cookie below in rapid fire fashion for 300 posts deleted via inline mod seems to blowup IE but we don't need to set this cookie when using inlinemod
        if (THIS_SCRIPT != 'inlinemod') {
            // Delete any postid entries from the inline moderation cookie
            $vbulletin->input->clean_array_gpc('c', array('vbulletin_inlinepost' => TYPE_STR));
            if (!empty($vbulletin->GPC['vbulletin_inlinepost']) and !headers_sent()) {
                $newcookie = array();
                $found = false;
                $temp = explode('-', $vbulletin->GPC['vbulletin_inlinepost']);
                foreach ($temp as $inlinepostid) {
                    if ($inlinepostid == $postid) {
                        $found = true;
                    } else {
                        $newcookie[] = $inlinepostid;
                    }
                }
                // this post is in the inline post cookie so delete it by rewriting cookie without it
                if ($found) {
                    setcookie('vbulletin_inlinepost', implode('-', $newcookie), TIMENOW + 3600, '/');
                }
            }
        }
        // delete post hash when physically deleting a post - last argument is type
        $dupehash = md5($threadinfo['forumid'] . $postinfo['title'] . $postinfo['pagetext'] . $postinfo['userid'] . 'reply');
        $vbulletin->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "posthash\n\t\t\tWHERE userid = {$postinfo['userid']} AND\n\t\t\tdupehash = '" . $vbulletin->db->escape_string($dupehash) . "' AND\n\t\t\tdateline > " . (TIMENOW - 300));
        // Hook this post's children up to it's parent so they aren't orphaned. Foster parents I guess.
        if ($postinfo['parentid'] == 0) {
            if ($firstchild = $vbulletin->db->query_first("\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . TABLE_PREFIX . "post\n\t\t\t\tWHERE threadid = {$postinfo['threadid']} AND\n\t\t\t\tparentid = {$postid}\n\t\t\t\tORDER BY dateline\n\t\t\t\tLIMIT 1\n\t\t\t")) {
                $postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
                $postman->set_existing($firstchild);
                $postman->set('parentid', 0);
                $postman->save();
                unset($postman);
                $postinfo['parentid'] = $firstchild['postid'];
            }
        }
        $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "post SET\n\t\t\t\tparentid = " . intval($postinfo['parentid']) . "\n\t\t\tWHERE threadid = {$postinfo['threadid']}\n\t\t\t\tAND parentid = {$postid}\n\t\t");
        $deletiondata =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog');
        $deletioninfo = array('type' => 'post', 'primaryid' => $postid);
        $deletiondata->set_existing($deletioninfo);
        $deletiondata->delete();
        unset($deletiondata, $deletioninfo);
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "post WHERE postid = {$postid}");
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "postparsed WHERE postid = {$postid}");
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "editlog WHERE postid = {$postid}");
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "postedithistory WHERE postid = {$postid}");
        //$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "reputation WHERE postid = $postid");
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = {$postid} AND type = 'reply'");
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "spamlog WHERE postid = {$postid}");
        $activity = new vB_ActivityStream_Manage('forum', 'post');
        $activity->set('contentid', $postid);
        $activity->delete();
        $activity = new vB_ActivityStream_Manage('cms', 'comment');
        $activity->set('contentid', $postid);
        $activity->delete();
    }
}
Esempio n. 3
0
 /**
  * Additional data to update after a delete call (such as denormalized values in other tables).
  *
  * @param	boolean	Do the query?
  */
 function post_delete($doquery = true)
 {
     $activity = new vB_ActivityStream_Manage('calendar', 'event');
     $activity->set('contentid', intval($this->fetch_field('eventid')));
     $activity->delete();
     $this->dbobject->query_write("DELETE FROM " . TABLE_PREFIX . "subscribeevent WHERE eventid = " . intval($this->fetch_field('eventid')));
     require_once DIR . '/includes/functions_calendar.php';
     build_events();
     ($hook = vBulletinHook::fetch_hook('eventdata_delete')) ? eval($hook) : false;
     return true;
 }
Esempio n. 4
0
 /**
  * Code to run after Saving a Visitor Message
  *
  * @param	boolean	Do the query?
  */
 function post_save_once($doquery = true)
 {
     $vmid = intval($this->fetch_field('vmid'));
     vB_Search_Indexcontroller_Queue::indexQueue('vBForum', 'VisitorMessage', 'index', $vmid);
     if (!$this->condition) {
         if ($this->fetch_field('userid')) {
             $this->insert_dupehash($this->fetch_field('userid'));
         }
         $activity = new vB_ActivityStream_Manage('forum', 'visitormessage');
         $activity->set('contentid', $this->fetch_field('vmid'));
         $activity->set('userid', $this->fetch_field('postuserid'));
         $activity->set('dateline', $this->fetch_field('dateline'));
         $activity->set('action', 'create');
         $activity->save();
     }
     if (!$this->info['profileuser']) {
         $this->info['profileuser'] = fetch_userinfo($this->fetch_field('userid'));
     }
     if ($this->info['profileuser'] and !in_coventry($this->fetch_field('postuserid'), true)) {
         $userdata =& datamanager_init('User', $this->registry, ERRTYPE_SILENT);
         $userdata->set_existing($this->info['profileuser']);
         if ($this->fetch_field('state') == 'visible') {
             if (!$this->condition and !$this->fetch_field('messageread')) {
                 // new vm, not been read, visible -> increase unread count
                 $userdata->set('vmunreadcount', 'vmunreadcount + 1', false);
             } else {
                 if ($this->condition and $this->fetch_field('messageread') and isset($this->existing['messageread']) and !$this->existing['messageread']) {
                     // existing vm going from unread to read -> decrease unread count
                     // isset() check ensures that messageread info was explicitly passed in
                     $userdata->set('vmunreadcount', 'vmunreadcount - 1', false);
                 }
             }
         }
         if ($this->fetch_field('state') == 'visible' and $this->existing['state'] == 'moderation') {
             // moderated message made visible -> decrease moderated count
             $userdata->set('vmmoderatedcount', 'vmmoderatedcount - 1', false);
         } else {
             if ($this->fetch_field('state') == 'moderation' and $this->fetch_field('state') != $this->existing['state']) {
                 // message is moderated and wasn't moderated before -> increase moderated count
                 $userdata->set('vmmoderatedcount', 'vmmoderatedcount + 1', false);
             }
         }
         $userdata->save();
     }
     if ($this->fetch_field('state') == 'moderation') {
         /*insert query*/
         $this->dbobject->query_write("\n\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "moderation\n\t\t\t\t\t(primaryid, type, dateline)\n\t\t\t\tVALUES\n\t\t\t\t\t({$vmid}, 'visitormessage', " . TIMENOW . ")\n\t\t\t");
     } else {
         if ($this->fetch_field('state') == 'visible' and $this->existing['state'] == 'moderation') {
             // message was made visible, remove the moderation record
             $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation\n\t\t\t\tWHERE primaryid = {$vmid} AND type = 'visitormessage'\n\t\t\t");
         }
     }
     ($hook = vBulletinHook::fetch_hook('visitormessagedata_postsave')) ? eval($hook) : false;
 }
Esempio n. 5
0
 function post_save_each($doquery = true)
 {
     if (!$this->condition and $this->fetch_field('dateline') == TIMENOW) {
         $this->insert_dupehash(0);
     }
     $this->post_save_each_post($doquery);
     if (!$this->condition and $this->fetch_field('dateline') == TIMENOW) {
         $this->insert_postlog_data();
     }
     $threadid = intval($this->fetch_field('threadid'));
     if (!$this->condition and !$this->info['skip_activitystream']) {
         $activity = new vB_ActivityStream_Manage('forum', 'thread');
         $activity->set('contentid', $threadid);
         $activity->set('userid', $this->fetch_field('postuserid'));
         $activity->set('dateline', $this->fetch_field('dateline'));
         $activity->set('action', 'create');
         $activity->save();
     }
     if ($this->thread['visible'] === 0) {
         $postid = intval($this->fetch_field('firstpostid'));
         /*insert query*/
         $this->dbobject->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "moderation (primaryid, type, dateline) VALUES ({$threadid}, 'thread', " . TIMENOW . ")");
     }
     if ($this->info['forum']['podcast'] and $postid = intval($this->fetch_field('firstpostid'))) {
         $this->dbobject->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "podcastitem\n\t\t\t\t\t(postid, url, length, explicit, author, keywords, subtitle)\n\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t{$postid},\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcasturl']) . "',\n\t\t\t\t\t\t" . intval($this->info['podcastsize']) . ",\n\t\t\t\t\t\t" . intval($this->info['podcastexplicit']) . ",\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastauthor']) . "',\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastkeywords']) . "',\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastsubtitle']) . "'\n\t\t\t\t\t)\n\t\t\t");
         // reset rss cache for this forum
         $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "externalcache\n\t\t\t\tWHERE forumid = " . intval($this->info['forum']['forumid']) . "\n\t\t\t");
     }
     if ($this->info['mark_thread_read'] and $this->info['forum'] and $this->registry->options['threadmarking'] and $userid = $this->fetch_field('postuserid')) {
         $threadinfo = fetch_threadinfo($threadid);
         if ($threadinfo) {
             require_once DIR . '/includes/functions_bigthree.php';
             mark_thread_read($threadinfo, $this->info['forum'], $userid, $this->fetch_field('dateline'));
         }
     }
     $this->insert_moderator_log();
     if (!$this->condition) {
         $this->email_moderators(array('newthreademail', 'newpostemail'));
     }
     ($hook = vBulletinHook::fetch_hook('threadfpdata_postsave')) ? eval($hook) : false;
 }
Esempio n. 6
0
 /**
  *
  * @param	boolean	Do the query?
  */
 function post_save_once($doquery = true)
 {
     $gmid = intval($this->fetch_field('gmid'));
     $discussionid = intval($this->fetch_field('discussionid'));
     if (!$this->condition) {
         if ($this->fetch_field('discussionid')) {
             $this->insert_dupehash($this->fetch_field('discussionid'));
         }
         // Update last post info on parent discussion
         if ($this->info['discussion']) {
             $dataman =& datamanager_init('Discussion', $this->registry, ERRTYPE_SILENT);
             $dataman->set_existing($this->info['discussion']);
             // Give group info to discussion
             if ($this->info['group']) {
                 $dataman->setr_info('group', $this->info['group']);
             }
             if ($this->fetch_field('state') == 'visible' and $this->fetch_field('dateline') == TIMENOW) {
                 $dataman->set('lastpost', TIMENOW);
                 $dataman->set('lastposter', $this->fetch_field('postusername'));
                 $dataman->set('lastposterid', $this->fetch_field('postuserid'));
                 $dataman->set('lastpostid', $gmid);
                 $dataman->set_info('lastposttitle', $this->info['discussion']['title']);
             }
             if ($this->fetch_field('state') == 'visible') {
                 $dataman->set('visible', 'visible + 1', false);
             } else {
                 if ($this->fetch_field('state') == 'moderation') {
                     $dataman->set('moderation', 'moderation + 1', false);
                 }
             }
             $dataman->save();
             unset($dataman);
             $activity = new vB_ActivityStream_Manage('socialgroup', 'groupmessage');
             $activity->set('contentid', $gmid);
             $activity->set('userid', $this->fetch_field('postuserid'));
             $activity->set('dateline', $this->fetch_field('dateline'));
             $activity->set('action', 'create');
             $activity->save();
         }
     }
     if ($this->fetch_field('state') == 'moderation') {
         /*insert query*/
         $this->dbobject->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "moderation (primaryid, type, dateline) VALUES ({$gmid}, 'groupmessage', " . TIMENOW . ")");
     } else {
         if ($this->fetch_field('state') == 'visible' and $this->existing['state'] == 'moderation') {
             // message was made visible, remove the moderation record
             $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation\n\t\t\t\tWHERE primaryid = {$gmid} AND type = 'groupmessage'\n\t\t\t");
         }
     }
     if ($this->info['group']) {
         update_owner_pending_gm_count($this->info['group']['creatoruserid']);
     }
     ($hook = vBulletinHook::fetch_hook('groupmessagedata_postsave')) ? eval($hook) : false;
 }
Esempio n. 7
0
 /**
  * Delete from the attachment table
  *
  */
 public function delete($doquery = true, $checkperms = true, $activitysection = '', $activitytype = '')
 {
     if (!$this->pre_delete($doquery, $checkperms) or empty($this->lists['attachmentids'])) {
         return false;
     }
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "attachment\n\t\t\tWHERE attachmentid IN (" . implode(", ", $this->lists['attachmentids']) . ")\n\t\t");
     if ($activitysection and $activitytype) {
         $activity = new vB_ActivityStream_Manage($activitysection, $activitytype);
         $activity->set('contentid', $this->lists['attachmentids']);
         $activity->delete();
     }
     $this->post_delete($doquery);
     return true;
 }
Esempio n. 8
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;
     }
 }
Esempio n. 9
0
 /**
  * Any code to run after deleting
  *
  * @param	Boolean Do the query?
  */
 function post_delete($doquery = true)
 {
     if (!defined('MYSQL_VERSION')) {
         $mysqlversion = $this->registry->db->query_first("SELECT version() AS version");
         define('MYSQL_VERSION', $mysqlversion['version']);
     }
     $enginetype = version_compare(MYSQL_VERSION, '4.0.18', '<') ? 'TYPE' : 'ENGINE';
     $tabletype = version_compare(MYSQL_VERSION, '4.1', '<') ? 'HEAP' : 'MEMORY';
     $aggtable = 'aaggregate_temp_' . $this->registry->userinfo['userid'] . '_' . $this->fetch_field('groupid') . '_' . TIMENOW;
     $this->registry->db->query_write("\n\t\t\tCREATE TABLE IF NOT EXISTS " . TABLE_PREFIX . "{$aggtable} (\n\t\t\t\tuserid INT UNSIGNED NOT NULL DEFAULT '0',\n\t\t\t\tPRIMARY KEY (userid)\n\t\t\t) {$enginetype} = {$tabletype}\n\t\t");
     if ($this->registry->options['usemailqueue'] == 2) {
         $this->registry->db->lock_tables(array($aggtable => 'WRITE', 'socialgroupmember' => 'WRITE'));
     }
     $this->registry->db->query_write("\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "{$aggtable}\n\t\t\tSELECT userid\n\t\t\tFROM " . TABLE_PREFIX . "socialgroupmember\n\t\t\tWHERE groupid = " . $this->fetch_field('groupid') . "\n\t\t\t\tAND type = 'invited'\n\t\t");
     // A user's 'type' doesn't seem to change when a group's type is changed. Why is this?
     // e.g. a 'moderated' user doesn't become a member if a moderated group is made public
     $result = array();
     if ($this->fetch_field('creatoruserid')) {
         $result = $this->registry->db->query_first("\n\t\t\t\tSELECT COUNT(*) AS count\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroupmember\n\t\t\t\tWHERE groupid = " . $this->fetch_field('groupid') . "\n\t\t\t\t\tAND type = 'moderated'\n\t\t\t");
     }
     if ($this->registry->options['usemailqueue'] == 2) {
         $this->registry->db->unlock_tables();
     }
     $this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "socialgroupmember WHERE groupid = " . $this->fetch_field('groupid'));
     $this->registry->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "user AS user," . TABLE_PREFIX . "{$aggtable} AS aggregate\n\t\t\tSET socgroupinvitecount = IF(socgroupinvitecount > 0, socgroupinvitecount - 1, 0)\n\t\t\tWHERE user.userid = aggregate.userid\n\t\t");
     if ($result['count']) {
         $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\t\tSET socgroupreqcount = IF(socgroupreqcount >= {$result['count']}, socgroupreqcount - {$result['count']}, 0)\n\t\t\t\tWHERE userid = " . $this->fetch_field('creatoruserid') . "\n\t\t\t");
     }
     $this->registry->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . $aggtable);
     // delete picture references
     $contenttypeid = vB_Types::instance()->getContentTypeID('vBForum_SocialGroup');
     $attachids = array();
     $ids = $this->registry->db->query_read("\n\t\t\tSELECT attachmentid\n\t\t\tFROM " . TABLE_PREFIX . "attachment\n\t\t\tWHERE contentid = " . intval($this->fetch_field('groupid')) . " AND\n\t\t\t\tcontenttypeid = {$contenttypeid}\t\n\t\t");
     while ($id = $this->registry->db->fetch_array($ids)) {
         $attachids[] = $id['attachmentid'];
     }
     if ($attachids) {
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "attachment\n\t\t\t\tWHERE attachmentid IN (" . implode(",", $attachids) . ")\n\t\t\t");
         $activity = new vB_ActivityStream_Manage('socialgroup', 'photo');
         $activity->set('contentid', $attachids);
         $activity->delete();
     }
     vb_Search_Indexcontroller_Queue::indexQueue('vBForum', 'SocialGroup', 'delete', $this->fetch_field('groupid'));
     $gms_to_delete = array();
     $gmids = $this->registry->db->query_read("SELECT gmid FROM " . TABLE_PREFIX . "discussion AS discussion\n\t\t\t INNER JOIN " . TABLE_PREFIX . "groupmessage AS gm\n\t\t\t  ON (gm.discussionid = discussion.discussionid)\n\t\t\t WHERE discussion.groupid = " . intval($this->fetch_field('groupid')));
     while ($gmid = $this->registry->db->fetch_array($gmids)) {
         $gms_to_delete[] = $gmid['gmid'];
         vb_Search_Indexcontroller_Queue::indexQueue('vBForum', 'SocialGroupMessage', 'delete', $gmid['gmid']);
     }
     $this->registry->db->free_result($gmids);
     if (!empty($gms_to_delete)) {
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation\n\t\t\t\tWHERE type = 'groupmessage'\n\t\t\t\t\tAND primaryid IN (" . implode(', ', $gms_to_delete) . ")\n\t\t\t");
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "deletionlog\n\t\t\t\tWHERE type = 'groupmessage'\n\t\t\t\t\tAND primaryid IN (" . implode(', ', $gms_to_delete) . ")\n\t\t\t");
         $this->registry->db->query_write("\n\t\t\t\tDELETE " . TABLE_PREFIX . "groupmessage\n\t\t\t\tFROM " . TABLE_PREFIX . "groupmessage\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "discussion ON (" . TABLE_PREFIX . "discussion.discussionid = " . TABLE_PREFIX . "groupmessage.discussionid)\n\t\t\t\tWHERE " . TABLE_PREFIX . "discussion.groupid = " . $this->fetch_field('groupid'));
         $activity = new vB_ActivityStream_Manage('socialgroup', 'groupmessage');
         $activity->set('contentid', $gms_to_delete);
         $activity->delete();
     }
     // delete subscribed discussions
     $this->registry->db->query_write("\n\t\t\tDELETE " . TABLE_PREFIX . "subscribediscussion\n\t\t\tFROM " . TABLE_PREFIX . "subscribediscussion\n\t\t\tINNER JOIN " . TABLE_PREFIX . "discussion ON (" . TABLE_PREFIX . "discussion.discussionid = " . TABLE_PREFIX . "subscribediscussion.discussionid)\n\t\t\t AND " . TABLE_PREFIX . "discussion.groupid = " . intval($this->fetch_field('groupid')) . "\n\t\t");
     // delete discussion readmarking
     $this->registry->db->query_write("\n\t\t\tDELETE " . TABLE_PREFIX . "discussionread\n\t\t\tFROM " . TABLE_PREFIX . "discussionread\n\t\t\tINNER JOIN " . TABLE_PREFIX . "discussion\n\t\t\t ON (" . TABLE_PREFIX . "discussion.discussionid = " . TABLE_PREFIX . "discussionread.discussionid)\n\t\t\t AND " . TABLE_PREFIX . "discussion.groupid = " . intval($this->fetch_field('groupid')) . "\n\t\t");
     $idlist = array();
     $ids = $this->registry->db->query_read("\n\t\t\tSELECT discussionid\n\t\t\tFROM " . TABLE_PREFIX . "discussion\n\t\t\tWHERE groupid = " . intval($this->fetch_field('groupid')));
     while ($id = $this->registry->db->fetch_array($ids)) {
         $idlist[] = $id['discussionid'];
     }
     if ($idlist) {
         $activity = new vB_ActivityStream_Manage('socialgroup', 'discussion');
         $activity->set('contentid', $idlist);
         $activity->delete();
     }
     // delete discussions
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "discussion\n\t\t\tWHERE groupid = " . intval($this->fetch_field('groupid')));
     // delete group subscriptions
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribegroup\n\t\t\tWHERE " . TABLE_PREFIX . "subscribegroup.groupid = " . intval($this->fetch_field('groupid')) . "\n\t\t");
     // delete readmarking
     $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "groupread\n\t\t\tWHERE " . TABLE_PREFIX . "groupread.groupid = " . intval($this->fetch_field('groupid')) . "\n\t\t");
     // delete group icon
     $groupicon =& datamanager_init('SocialGroupIcon', $this->registry, ERRTYPE_STANDARD);
     $groupicon->condition = "groupid = " . intval($this->fetch_field('groupid'));
     $groupicon->delete();
     unset($groupicon);
     // update moderation count for owner
     update_owner_pending_gm_count($this->fetch_field('creatoruserid'));
     // update category cloud
     fetch_socialgroup_category_cloud(true);
     // update newest groups
     fetch_socialgroup_newest_groups(true, false, !$this->registry->options['sg_enablesocialgroupicons']);
     $activity = new vB_ActivityStream_Manage('socialgroup', 'group');
     $activity->set('contentid', $this->fetch_field('groupid'));
     $activity->delete();
     ($hook = vBulletinHook::fetch_hook('socgroupdata_delete')) ? eval($hook) : false;
 }
Esempio n. 10
0
 }
 if ($vbulletin->GPC['groupsshown']) {
     $delete = array();
     $insert = array();
     $changed_groups = array();
     $groups_sql = $db->query_read("\n\t\t\tSELECT\n\t\t\t\tsocialgroup.*, IF(attachment.filedataid IS NULL, 0, 1) AS picingroup,\n\t\t\t\tattachment.filedataid, attachment.filename\n\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON\n\t\t\t\t(\n\t\t\t\t\tsocialgroupmember.groupid = socialgroup.groupid\n\t\t\t\t\t\tAND\n\t\t\t\t\tsocialgroupmember.userid = {$userinfo['userid']}\n\t\t\t\t)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "attachment AS attachment ON\n\t\t\t\t(\n\t\t\t\t\tattachment.contenttypeid = " . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tsocialgroup.groupid = attachment.contentid\n\t\t\t\t\t\tAND\n\t\t\t\t\tattachment.filedataid = {$pictureinfo['filedataid']}\n\t\t\t\t\t\tAND\n\t\t\t\t\tattachment.userid = {$userinfo['userid']}\n\t\t\t\t)\n\t\t\tWHERE\n\t\t\t\tsocialgroup.groupid IN (" . implode(',', $vbulletin->GPC['groupsshown']) . ")\n\t\t\t\t\tAND\n\t\t\t\tsocialgroupmember.type = 'member'\n\t\t\t\t\tAND\n\t\t\t\tsocialgroup.options & " . $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'] . "\n\t\t");
     while ($group = $db->fetch_array($groups_sql)) {
         if (!empty($vbulletin->GPC['groupids']["{$group['groupid']}"]) and !$group['picingroup']) {
             // Yes this does single inserts on purpose
             // An atomic check since we can't put an unique key on the attachment table but we don't want the same attachment getting into the group more than once.
             if (!$db->query_first("\n\t\t\t\t\tSELECT attachmentid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tcontenttypeid = " . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tuserid = {$userinfo['userid']}\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tcontentid = {$group['groupid']}\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tfiledataid = {$pictureinfo['filedataid']}\n\t\t\t\t")) {
                 $db->query_write("\n\t\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "attachment\n\t\t\t\t\t\t\t(contenttypeid, contentid, userid, dateline, filedataid, filename, caption)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(" . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . ", {$group['groupid']}, {$userinfo['userid']}, " . TIMENOW . ", {$pictureinfo['filedataid']}, '" . $db->escape_string($pictureinfo['filename']) . "', '" . $db->escape_string($pictureinfo['caption']) . "')\n\t\t\t\t\t");
                 $changed_groups["{$group['groupid']}"] = $group;
                 $attachmentid = $db->insert_id();
                 $activity = new vB_ActivityStream_Manage('socialgroup', 'photo');
                 $activity->set('contentid', $attachmentid);
                 $activity->set('userid', $userinfo[userid]);
                 $activity->set('dateline', TIMENOW);
                 $activity->set('action', 'create');
                 $activity->save();
             }
         } else {
             if (empty($vbulletin->GPC['groupids']["{$group['groupid']}"]) and $group['picingroup']) {
                 $delete[] = $group['groupid'];
                 $changed_groups["{$group['groupid']}"] = $group;
             }
         }
     }
     ($hook = vBulletinHook::fetch_hook('album_picture_doaddgroups')) ? eval($hook) : false;
     if ($delete) {
         $db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "attachment\n\t\t\t\tWHERE\n\t\t\t\t\tfiledataid = {$pictureinfo['filedataid']}\n\t\t\t\t\t\tAND\n\t\t\t\t\tcontentid IN (" . implode(',', $delete) . ")\n\t\t\t\t\t\tAND\n\t\t\t\t\tcontenttypeid = " . intval(vB_Types::instance()->getContentTypeID('vBForum_SocialGroup')) . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tuserid = {$userinfo['userid']}\n\t\t\t");
Esempio n. 11
0
             $attachdata->delete(true, true, 'socialgroup', 'photo');
             $deleted_picture = true;
         }
     } else {
         if ($picture['state'] == 'moderation' and can_moderate(0, 'canmoderategrouppicture') and $vbulletin->GPC['pictures']["{$picture['attachmentid']}"]['approve']) {
             // need to increase picture counter
             $attachdata->set('state', 'visible');
             $updatecounter++;
         }
         if ($vbulletin->GPC['posthash']) {
             $attachdata->set('contentid', $group['groupid']);
             $attachdata->set('posthash', '');
         }
         if (!$picture['contentid']) {
             $activity = new vB_ActivityStream_Manage('socialgroup', 'photo');
             $activity->set('contentid', $picture['attachmentid']);
             $activity->set('userid', $picture['userid']);
             $activity->set('dateline', $picture['dateline']);
             $activity->set('action', 'create');
             $activity->save();
         }
         $attachdata->set('caption', $vbulletin->GPC['pictures']["{$picture['attachmentid']}"]['caption']);
         $attachdata->save();
         if ($picture['userid'] != $vbulletin->userinfo['userid'] and $vbulletin->GPC['pictures']["{$picture['attachmentid']}"]['caption'] != $picture['caption'] and can_moderate(0, 'caneditgrouppicture')) {
             require_once DIR . '/includes/functions_log_error.php';
             log_moderator_action($picture, 'picture_x_in_y_by_z_edited', array(fetch_trimmed_title($picture['caption'], 50), $group['name'], $userinfo['username']));
         }
     }
 }
 ($hook = vBulletinHook::fetch_hook('group_picture_update_complete')) ? eval($hook) : false;
 $groupdm = datamanager_init('SocialGroup', $vbulletin);
Esempio n. 12
0
 /**
  * Code to run after saving a picture comment
  *
  * @param	boolean	Do the query?
  */
 function post_save_once($doquery = true)
 {
     $commentid = intval($this->fetch_field('commentid'));
     if (!$this->condition) {
         if ($this->fetch_field('filedataid') and $this->fetch_field('userid')) {
             $this->insert_dupehash($this->fetch_field('filedataid'), $this->fetch_field('userid'));
         }
         if ($this->info['pictureuser'] and !in_coventry($this->fetch_field('postuserid'), true)) {
             $userdata =& datamanager_init('User', $this->registry, ERRTYPE_STANDARD);
             $userdata->set_existing($this->info['pictureuser']);
             if (!$this->fetch_field('messageread') and $this->fetch_field('state') == 'visible') {
                 $userdata->set('pcunreadcount', 'pcunreadcount + 1', false);
             } else {
                 if ($this->fetch_field('state') == 'moderation') {
                     $userdata->set('pcmoderatedcount', 'pcmoderatedcount + 1', false);
                 }
             }
             $userdata->save();
         }
         if ($this->info['pictureinfo']['groupid']) {
             $section = 'socialgroup';
             $type = 'photocomment';
         } else {
             if ($this->info['pictureinfo']['albumid']) {
                 $section = 'album';
                 $type = 'comment';
             } else {
                 ($hook = vBulletinHook::fetch_hook('picturecommentdata_postsave_activitystream')) ? eval($hook) : false;
             }
         }
         if ($section and $type) {
             $activity = new vB_ActivityStream_Manage($section, $type);
             $activity->set('contentid', $commentid);
             $activity->set('userid', $this->fetch_field('postuserid'));
             $activity->set('dateline', $this->fetch_field('dateline'));
             $activity->set('action', 'create');
             $activity->save();
         }
     }
     if ($this->fetch_field('state') == 'moderation') {
         /*insert query*/
         $this->dbobject->query_write("\n\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "moderation\n\t\t\t\t\t(primaryid, type, dateline)\n\t\t\t\tVALUES\n\t\t\t\t\t({$commentid}, 'picturecomment', " . TIMENOW . ")\n\t\t\t");
     }
     ($hook = vBulletinHook::fetch_hook('picturecommentdata_postsave')) ? eval($hook) : false;
 }