function post_delete($doquery = true) { ($hook = vBulletinHook::fetch_hook('userpicdata_delete')) ? eval($hook) : false; return parent::post_delete($doquery); }
/** * Code to run after deleting * * @param boolean Do the query? * * @return boolean Was this code executed correctly? * */ function post_delete($doquery = true) { $albums = array(); $albums_sql = $this->registry->db->query_read("\n\t\t\tSELECT album.*\n\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\tINNER JOIN " . TABLE_PREFIX . "album AS album ON (album.albumid = albumpicture.albumid)\n\t\t\tWHERE albumpicture.pictureid = " . $this->fetch_field('pictureid')); while ($album = $this->registry->db->fetch_array($albums_sql)) { $albums[] = $album; } $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "albumpicture\n\t\t\tWHERE pictureid = " . $this->fetch_field('pictureid')); if ($this->info['auto_count_update'] and $albums) { foreach ($albums as $album) { $albumdata =& datamanager_init('Album', $this->registry, ERRTYPE_SILENT); $albumdata->set_existing($album); $albumdata->rebuild_counts(); // for a picture to have been set to the cover, it must have been visible if ($albumdata->fetch_field('coverpictureid') == $this->fetch_field('pictureid')) { if ($album['visible'] - 1 > 0) { $new_cover = $this->registry->db->query_first("\n\t\t\t\t\t\t\tSELECT albumpicture.pictureid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\t\t\t\t\tWHERE albumpicture.albumid = {$album['albumid']} AND picture.state = 'visible'\n\t\t\t\t\t\t\tORDER BY albumpicture.dateline ASC\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t"); } $albumdata->set('coverpictureid', $new_cover['pictureid'] ? $new_cover['pictureid'] : 0); } $albumdata->save(); } } $del_usercss = array(); foreach ($albums as $album) { $del_usercss[] = "'{$album['albumid']}," . $this->fetch_field('pictureid') . "'"; } if ($del_usercss) { $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "usercss\n\t\t\t\tWHERE property = 'background_image'\n\t\t\t\t\tAND value IN (" . implode(',', $del_usercss) . ")\n\t\t\t\t\tAND userid = " . intval($this->fetch_field('userid')) . "\n\t\t\t"); $this->info['have_updated_usercss'] = $this->registry->db->affected_rows() > 0; } $groups = array(); $groups_sql = $this->registry->db->query_read("\n\t\t\tSELECT DISTINCT socialgroup.*\n\t\t\tFROM " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture\n\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON (socialgroup.groupid = socialgrouppicture.groupid)\n\t\t\tWHERE socialgrouppicture.pictureid = " . $this->fetch_field('pictureid')); while ($group = $this->registry->db->fetch_array($groups_sql)) { $groups[] = $group; } $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "socialgrouppicture\n\t\t\tWHERE pictureid = " . $this->fetch_field('pictureid')); foreach ($groups as $group) { $groupdata =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT); $groupdata->set_existing($group); $groupdata->rebuild_picturecount(); $groupdata->save(); } $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\tWHERE pictureid = " . $this->fetch_field('pictureid')); require_once DIR . '/includes/functions_picturecomment.php'; build_picture_comment_counters($this->fetch_field('userid')); ($hook = vBulletinHook::fetch_hook('picturedata_delete')) ? eval($hook) : false; return parent::post_delete($doquery); }
/** * Additional data to update after a delete call (such as denormalized values in other tables). * * @access protected * * @param boolean $doquery Do the query? */ function post_delete($doquery = true) { require_once(DIR . '/includes/functions_socialgroup.php'); fetch_socialgroup_newest_groups(true, false, !$this->registry->options['sg_enablesocialgroupicons']); ($hook = vBulletinHook::fetch_hook('socgroupicondata_delete')) ? eval($hook) : false; return parent::post_delete($doquery); }
/** * Any code to run after deleting * * @param Boolean Do the query? */ function post_delete($doquery = true) { foreach ($this->lists['content'] as $contenttypeid => $list) { if (!($attach =& vB_Attachment_Dm_Library::fetch_library($this->registry, $contenttypeid))) { return false; } $attach->post_delete($this); unset($attach); } // Update the refcount in the filedata table if (!empty($this->lists['filedataids'])) { $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "filedata AS fd\n\t\t\t\tSET fd.refcount = (\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\t\t\tWHERE fd.filedataid = a.filedataid\n\t\t\t\t)\n\t\t\t\tWHERE fd.filedataid IN (" . implode(", ", array_keys($this->lists['filedataids'])) . ")\n\t\t\t"); } // Below here only applies to attachments in pictures/groups but I forsee all attachments gaining the ability to have comments if ($this->info['type'] == 'filedata') { if (!empty($this->lists['filedataids'])) { $this->registry->db->query_write("\n\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\t\tWHERE filedataid IN (" . implode(", ", array_keys($this->lists['filedataids'])) . ")\n\t\t\t\t"); } } else { if (!empty($this->lists['picturecomments'])) { foreach ($this->lists['picturecomments'] as $sql) { if (!($results = $this->registry->db->query_first("\n\t\t\t\t\tSELECT a.attachmentid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t{$sql}\n\t\t\t\t"))) { $this->registry->db->query_write("\n\t\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t{$sql}\n\t\t\t\t\t"); } } } } require_once DIR . '/includes/functions_picturecomment.php'; foreach (array_keys($this->lists['userids']) as $userid) { build_picture_comment_counters($userid); } return parent::post_delete($doquery); }
/** * Any code to run after deleting * * @param Boolean Do the query? */ function post_delete($doquery = true) { foreach ($this->lists['content'] AS $contenttypeid => $list) { if (!($attach =& vB_Attachment_Dm_Library::fetch_library($this->registry, $contenttypeid))) { return false; } $attach->post_delete($this); unset($attach); } // Update the refcount in the filedata table if (!empty($this->lists['filedataids'])) { $this->registry->db->query_write(" UPDATE " . TABLE_PREFIX . "filedata AS fd SET fd.refcount = ( SELECT COUNT(*) FROM " . TABLE_PREFIX . "attachment AS a WHERE fd.filedataid = a.filedataid ) WHERE fd.filedataid IN (" . implode(", ", array_keys($this->lists['filedataids'])) . ") "); } // Hourly cron job will clean out the FS where refcount = 0 and dateline > 1 hour // Below here only applies to attachments in pictures/groups but I forsee all attachments gaining the ability to have comments if ($this->info['type'] == 'filedata') { if (!empty($this->lists['filedataids'])) { $this->registry->db->query_write(" DELETE FROM " . TABLE_PREFIX . "picturecomment WHERE filedataid IN (" . implode(", ", array_keys($this->lists['filedataids'])) . ") "); } } else if (!empty($this->lists['picturecomments'])) // deletion type is by attachment { foreach ($this->lists['picturecomments'] AS $sql) { if (!($results = $this->registry->db->query_first(" SELECT a.attachmentid FROM " . TABLE_PREFIX . "attachment AS a WHERE $sql "))) { $this->registry->db->query_write(" DELETE FROM " . TABLE_PREFIX . "picturecomment WHERE $sql "); } } } require_once(DIR . '/includes/functions_picturecomment.php'); foreach (array_keys($this->lists['userids']) AS $userid) { build_picture_comment_counters($userid); } return parent::post_delete($doquery); }
function post_delete($doquery = true) { return parent::post_delete($doquery); }