/** * 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("UPDATE " . 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 $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "socialgrouppicture\n\t\t\tWHERE groupid = " . intval($this->fetch_field('groupid')) . "\n\t\t"); $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']; } $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("DELETE " . TABLE_PREFIX . "groupmessage\n\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "groupmessage\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "discussion\n\t\t\t\t\t\t\t\t\t\t\t ON (" . TABLE_PREFIX . "discussion.discussionid = " . TABLE_PREFIX . "groupmessage.discussionid)\n\t\t\t\t\t\t\t\t\t\t\tWHERE " . TABLE_PREFIX . "discussion.groupid = " . $this->fetch_field('groupid')); } // 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\n\t\t\t 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"); // 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']); ($hook = vBulletinHook::fetch_hook('socgroupdata_delete')) ? eval($hook) : false; }
/** * Fetches newest groups from datastore or rebuilds the cache. * * @param boolean $force_rebuild Force the cache to be rebuilt * @param boolean $without_icons Fetch groups that have no icon * @return array Array of groupinfos */ function fetch_socialgroup_newest_groups($force_rebuild = false, $without_icons = false, $listview = false) { global $vbulletin; if ($listview) { $without_icons = true; } $groups = $vbulletin->sg_newest_groups; $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('group_fetch_newest')) ? eval($hook) : false; if ($force_rebuild or !is_array($groups)) { $sql = "SELECT " . ($listview ? "socialgroup.*, socialgroup.dateline AS createdate, sgc.title AS categoryname, sgc.socialgroupcategoryid AS categoryid," : "socialgroup.groupid, socialgroup.name, socialgroup.description, socialgroup.dateline, sgicon.dateline AS icondateline,") . "\n\t\t\t\t\tsgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height\n\t\t\t\t{$hook_query_fields}\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup " . ($without_icons ? 'LEFT' : 'INNER') . ' JOIN ' . TABLE_PREFIX . 'socialgroupicon AS sgicon ON (sgicon.groupid = socialgroup.groupid) ' . ($listview ? 'INNER JOIN ' . TABLE_PREFIX . 'socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)' : '') . "\n\t\t\t\t{$hook_query_joins}\n\t\t\t\t{$hook_query_where}\n\t\t\t\tORDER BY socialgroup.dateline DESC\n\t\t\t\tLIMIT 0, " . ($vbulletin->options['sg_newgroups_count'] ? intval($vbulletin->options['sg_newgroups_count']) : ($listview ? 20 : 15)) . "\n\t\t"; $newgroups = $vbulletin->db->query_read_slave($sql); $groups = array(); while ($group = $vbulletin->db->fetch_array($newgroups)) { $groups[] = $group; } $vbulletin->db->free_result($newgroups); build_datastore('sg_newest_groups', serialize($groups), 1); } if (sizeof($groups) < 4 and !$without_icons) { return fetch_socialgroup_newest_groups(true, true); } return $groups; }
vbflush(); $startat = $vbulletin->GPC['startat'] + $vbulletin->GPC['perpage']; if ($checkmore) { if ($vbulletin->GPC['autoredirect'] == 1) { print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=rebuildsgicons&startat=$startat&pp=" . $vbulletin->GPC['perpage'] . "&quality=" . $vbulletin->GPC['quality'] . "&autoredirect=1"); } echo "<p><a href=\"misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=rebuildsgicons&startat=$startat&pp=" . $vbulletin->GPC['perpage'] . '&quality=' . $vbulletin->GPC['quality'] . '>' . $vbphrase['click_here_to_continue_processing'] . '</a></p>'; } else { // rebuild newest groups cache fetch_socialgroup_newest_groups(true, false, !$vbulletin->options['sg_enablesocialgroupicons']); define('CP_REDIRECT', 'misc.php'); print_stop_message('rebuilt_sgicon_thumbnails_successfully'); } } // ###################### Start rebuilding post cache ####################### if ($_POST['do'] == 'rebuildalbumupdates') { if (!$vbulletin->options['album_recentalbumdays']) { define('CP_REDIRECT', 'misc.php'); print_stop_message('recent_album_updates_disabled'); }
/** * Any code to run after deleting * * @access protected * * @param boolean $doquery Do the query? */ function post_delete($doquery = true) { // remove image files if (is_array($this->info['remove_icons'])) { foreach ($this->info['remove_icons'] AS $group) { @unlink($this->fetch_path($group['groupid'], $group['icondateline'])); @unlink($this->fetch_path($group['groupid'], $group['icondateline'], 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; }
if ($_REQUEST['do'] == 'overview') { $show['sgicons'] = $vbulletin->options['sg_enablesocialgroupicons']; ($hook = vBulletinHook::fetch_hook('group_prepareinfo')) ? eval($hook) : false; $vbulletin->input->clean_array_gpc('r', array('owngrouppage' => TYPE_UINT)); $show['messageinfo'] = $vbulletin->options['socnet_groups_msg_enabled'] ? true : false; $show['pictureinfo'] = $vbulletin->options['socnet_groups_pictures_enabled']; // Get categories $categories = fetch_socialgroup_category_cloud(); $categorybits = ''; foreach ($categories as $category) { $templater = vB_Template::create('socialgroups_category_cloud_bit'); $templater->register('category', $category); $categorybits .= $templater->render(); } // Get newest groups $newgroups = fetch_socialgroup_newest_groups(true, true, false); $newgroupbits = ''; foreach ($newgroups as $group) { $group = prepare_socialgroup($group); $group['canjoin'] = can_join_group($group); $group['canleave'] = can_leave_group($group); ($hook = vBulletinHook::fetch_hook('group_newgroup_bit')) ? eval($hook) : false; $templater = vB_Template::create('socialgroups_newgroup_bit'); $templater->register('group', $group); $templater->register('template_hook', $template_hook); $newgroupbits .= $templater->render(); } unset($newgroups); // Get recently updated groups $updatedgroups = fetch_socialgroups_updatedgroups(); if ($vbulletin->userinfo['userid']) {
/** * Saves the image data with the supploed DataManager * * @access protected * * @return boolean Success */ function save_upload() { $ext_pos = strrpos($this->upload['filename'], '.'); $this->data->setr_info('group', $this->groupinfo); $this->data->set('groupid', $this->groupinfo['groupid']); $this->data->set('userid', $this->userinfo['userid']); $this->data->set('dateline', TIMENOW); $this->data->set('width', $this->imginfo[0]); $this->data->set('height', $this->imginfo[1]); $this->data->set('extension', substr($this->upload['filename'], $ext_pos + 1)); $this->data->setr('filedata', $this->upload['filestuff']); $this->data->setr('thumbnail_filedata', $this->upload['thumbnail']['filedata']); $this->data->set('thumbnail_width', $this->upload['thumbnail']['width']); $this->data->set('thumbnail_height', $this->upload['thumbnail']['height']); if (!($result = $this->data->save())) { if (empty($this->data->errors[0]) or !($this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel'])) { $this->set_error('upload_file_failed'); } else { $this->error =& $this->data->errors[0]; } } else { if ($this->registry->options['sg_enablesocialgroupicons']) { fetch_socialgroup_newest_groups(true); } } unset($this->upload); return $result; }