예제 #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)
 {
     $pictures = array();
     $picture_sql = $this->registry->db->query_read("\n\t\t\tSELECT albumpicture.pictureid, picture.idhash, picture.extension\n\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "picture AS picture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\tWHERE albumpicture.albumid = " . $this->fetch_field('albumid'));
     while ($picture = $this->registry->db->fetch_array($picture_sql)) {
         $pictures["{$picture['pictureid']}"] = $picture;
     }
     if ($pictures) {
         if ($this->registry->options['album_dataloc'] != 'db') {
             // remove from fs
             foreach ($pictures as $picture) {
                 @unlink(fetch_picture_fs_path($picture));
                 @unlink(fetch_picture_fs_path($picture, true));
             }
         }
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picture\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t");
         // delete based on picture id as this means that when a picture is deleted,
         // it's removed from all albums automatically
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "albumpicture\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($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(',', array_keys($pictures)) . ")\n\t\t\t");
         require_once DIR . '/includes/functions_picturecomment.php';
         build_picture_comment_counters($this->fetch_field('userid'));
         $groups = array();
         $groups_sql = $this->registry->db->query_read("\n\t\t\t\tSELECT DISTINCT socialgroup.*\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON (socialgroup.groupid = socialgrouppicture.groupid)\n\t\t\t\tWHERE socialgrouppicture.pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t");
         while ($group = $this->registry->db->fetch_array($groups_sql)) {
             $groups[] = $group;
         }
         $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "socialgrouppicture\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t");
         foreach ($groups as $group) {
             $groupdata =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT);
             $groupdata->set_existing($group);
             $groupdata->rebuild_picturecount();
             $groupdata->save();
         }
     }
     $this->remove_usercss_background_image();
     ($hook = vBulletinHook::fetch_hook('albumdata_delete')) ? eval($hook) : false;
     return true;
 }
예제 #2
0
파일: album.php 프로젝트: holandacz/nb4
    // work out the effective picturebit height/width including any borders and paddings; the +4 works around an IE float issue
    $picturebit_height = $vbulletin->options['album_thumbsize'] + (($usercss ? $stylevar['cellspacing'] : 0) + $stylevar['cellpadding']) * 2 + 4;
    $picturebit_width = $vbulletin->options['album_thumbsize'] + (($usercss ? $stylevar['cellspacing'] : 0) + $stylevar['cellpadding']) * 2;
    $picturebits = '';
    $unread_count = 0;
    while ($picture = $db->fetch_array($pictures)) {
        // $comment contains picture and album info
        $picture = prepare_pictureinfo_thumb($picture, $picture);
        $picture['unreadcomments'] = vb_number_format($picture['unreadcomments']);
        ($hook = vBulletinHook::fetch_hook('album_unread_picturebit')) ? eval($hook) : false;
        eval('$picturebits .= "' . fetch_template('album_picturebit_unread') . '";');
    }
    if ($moderated_count != $vbulletin->userinfo['pcunreadcount']) {
        // back counter -- likely tachy based, rebuild all counters
        require_once DIR . '/includes/functions_picturecomment.php';
        build_picture_comment_counters($vbulletin->userinfo['userid']);
    }
    if (!$picturebits) {
        standard_error(fetch_error('no_unread_picture_comments', 'album.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userinfo['userid']}"), '', false);
    }
    ($hook = vBulletinHook::fetch_hook('album_unread_complete')) ? eval($hook) : false;
    // navbar and final output
    $navbits = construct_navbits(array('member.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userinfo['userid']}" => construct_phrase($vbphrase['xs_profile'], $userinfo['username']), 'album.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userinfo['userid']}" => construct_phrase($vbphrase['xs_albums'], $userinfo['username']), '' => $vbphrase['unread_picture_comments']));
    eval('$navbar = "' . fetch_template('navbar') . '";');
    eval('print_output("' . fetch_template('album_unreadcomments') . '");');
}
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 22:41, Fri Oct 10th 2008
|| # CVS: $RCSfile$ - $Revision: 27273 $
|| ####################################################################
예제 #3
0
 /**
  * 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);
 }
예제 #4
0
 /**
  * Code to run to delete a picture comment
  *
  * @param	boolean Do the query?
  *
  * @return	boolean	Whether this code executed correctly
  *
  */
 function delete()
 {
     if ($commentid = $this->existing['commentid']) {
         $db =& $this->registry->db;
         if ($this->info['hard_delete']) {
             $db->query_write("\n\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "deletionlog WHERE primaryid = {$commentid} AND type = 'picturecomment'\n\t\t\t\t");
             $db->query_write("\n\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment WHERE commentid = {$commentid}\n\t\t\t\t");
             $db->query_write("\n\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = {$commentid} AND type = 'picturecomment'\n\t\t\t\t");
             // Logging?
         } else {
             $this->set('state', 'deleted');
             $this->save();
             $deletionman =& datamanager_init('Deletionlog_PictureComment', $this->registry, ERRTYPE_SILENT, 'deletionlog');
             $deletionman->set('primaryid', $commentid);
             $deletionman->set('type', 'picturecomment');
             $deletionman->set('userid', $this->registry->userinfo['userid']);
             $deletionman->set('username', $this->registry->userinfo['username']);
             $deletionman->set('reason', $this->info['reason']);
             $deletionman->save();
             unset($deletionman);
         }
         if (!$this->info['pictureuser']) {
             $this->info['profileuser'] = fetch_userinfo($this->existing['userid']);
         }
         if ($this->info['pictureuser']) {
             build_picture_comment_counters($this->info['picteuser']['userid']);
         }
         $db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = {$commentid} AND type = 'picturecomment'\n\t\t\t");
         return true;
     }
     $this->post_delete();
     return false;
 }
예제 #5
0
	}

	$db->query_write("
		DELETE FROM " . TABLE_PREFIX . "deletionlog
		WHERE type = 'picturecomment' AND
			primaryid IN(" . implode(',', array_keys($messagearray)) . ")
	");
	$db->query_write("
		UPDATE " . TABLE_PREFIX . "picturecomment
		SET state = 'visible'
		WHERE commentid IN(" . implode(',', array_keys($messagearray)) . ")
	");

	foreach(array_keys($userlist) AS $userid)
	{
		build_picture_comment_counters($userid);
	}

	if (can_moderate(0, 'candeletepicturecomments'))
	{
		foreach ($messagearray AS $message)
		{
			log_moderator_action($message, 'pc_by_x_on_y_undeleted',
				array($message['postusername'], fetch_trimmed_title($message['picture_caption'], 50))
			);
		}
	}

	// empty cookie
	setcookie('vbulletin_inlinepicturecomment', '', TIMENOW - 3600, '/');
예제 #6
0
/**
 * Fetches the Picture Comment HTML for a single picture
 *
 * @param	array	Information regarding the picture
 * @param	array	(return) Statistics regarding the messages shown
 * @param	integer	The current page pumber
 * @param	integer	The number of comments per page
 * @param	integer	A specific comment ID to focus on (causes pagenumber to be ignored)
 * @param	boolean	Whether to show ignored messages in their full
 *
 * @return	string	The HTML for the picture comments
 *
 */
function fetch_picturecommentbits($pictureinfo, &$messagestats, &$pagenumber, &$perpage, $commentid = 0, $showignored = false)
{
	global $vbulletin, $vbphrase, $show;

	require_once(DIR . '/includes/class_bbcode.php');
	require_once(DIR . '/includes/class_picturecomment.php');

	if ($vbulletin->options['globalignore'] != '' AND !can_moderate(0, 'candeletepicturecomments') AND !can_moderate(0, 'canremovepicturecomments'))
	{
		require_once(DIR . '/includes/functions_bigthree.php');

		$coventry = fetch_coventry('string');
	}

	$messagestats = array();
	$state = array('visible');
	$state_or = array();
	if (fetch_user_picture_message_perm('canmoderatemessages', $pictureinfo))
	{
		$state[] = 'moderation';
	}
	else if ($vbulletin->userinfo['userid'])
	{
		$state_or[] = "(picturecomment.postuserid = " . $vbulletin->userinfo['userid'] . " AND state = 'moderation')";
	}

	if (can_moderate(0, 'canmoderatepicturecomments') OR ($vbulletin->userinfo['userid'] == $pictureinfo['userid'] AND $vbulletin->userinfo['permissions']['albumpermissions'] & $vbulletin->bf_ugp_albumpermissions['canmanagepiccomment']))
	{
		$state[] = 'deleted';
		$deljoinsql = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (picturecomment.commentid = deletionlog.primaryid AND deletionlog.type = 'picturecomment')";
	}
	else
	{
		$deljoinsql = '';
	}

	$state_or[] = "picturecomment.state IN ('" . implode("','", $state) . "')";

	$perpage = (!$perpage OR $perpage > $vbulletin->options['pc_maxperpage']) ? $vbulletin->options['pc_perpage'] : $perpage;

	if ($commentid AND $commentinfo = fetch_picturecommentinfo($pictureinfo['filedataid'], $pictureinfo['userid'], $commentid))
	{
		$getpagenum = $vbulletin->db->query_first("
			SELECT COUNT(*) AS comments
			FROM " . TABLE_PREFIX . "picturecomment AS picturecomment
			WHERE
				filedataid = $pictureinfo[filedataid]
					AND
				userid = $pictureinfo[userid]
					AND
				(" . implode(" OR ", $state_or) . ")
					AND
				dateline <= $commentinfo[dateline]
			" . ($coventry ? "AND picturecomment.postuserid NOT IN (" . $coventry . ")" : '' ) . "
		");
		$pagenumber = ceil($getpagenum['comments'] / $perpage);
	}

	do
	{
		if (!$pagenumber)
		{
			$pagenumber = 1;
		}
		$start = ($pagenumber - 1) * $perpage;

		$hook_query_fields = $hook_query_joins = $hook_query_where = '';
		($hook = vBulletinHook::fetch_hook('picture_comment_query')) ? eval($hook) : false;

		$messagebits = '';
		$messages = $vbulletin->db->query_read("
			SELECT SQL_CALC_FOUND_ROWS
				picturecomment.*, user.*, picturecomment.ipaddress AS messageipaddress
				" . ($deljoinsql ? ",deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason" : "") . "
				" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, filedata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" : "") . "
				$hook_query_fields
			FROM " . TABLE_PREFIX . "picturecomment AS picturecomment
			LEFT JOIN " . TABLE_PREFIX . "user AS user ON (picturecomment.postuserid = user.userid)
			" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid)
			LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "
			$deljoinsql
			$hook_query_joins
			WHERE
				picturecomment.filedataid = $pictureinfo[filedataid]
					AND
				picturecomment.userid = $pictureinfo[userid]
					AND (" . implode(" OR ", $state_or) . ")
			" . ($coventry ? "AND picturecomment.postuserid NOT IN (" . $coventry . ")" : '' ) . "
				$hook_query_where
			ORDER BY picturecomment.dateline
			LIMIT $start, $perpage
		");

		list($messagestats['total']) = $vbulletin->db->query_first("SELECT FOUND_ROWS()", DBARRAY_NUM);
		if ($start >= $messagestats['total'])
		{
			$pagenumber = ceil($messagestats['total'] / $perpage);
		}
	}
	while ($start >= $messagestats['total'] AND $messagestats['total']);

	$messagestats['start'] = $start + 1;
	$messagestats['end'] = min($start + $perpage, $messagestats['total']);

	$bbcode = new vB_BbCodeParser($vbulletin, fetch_tag_list());
	$factory = new vB_Picture_CommentFactory($vbulletin, $bbcode, $pictureinfo);

	$messagebits = '';

	$firstrecord = array();
	$read_ids = array();

	if ($vbulletin->userinfo['userid'] AND !$showignored)
	{
		$ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
	}
	else
	{
		$ignorelist = array();
	}

	while ($message = $vbulletin->db->fetch_array($messages))
	{
		if (!$firstrecord)
		{
			$firstrecord = $message;
		}

		if ($ignorelist AND in_array($message['postuserid'], $ignorelist))
		{
			$message['ignored'] = true;
		}

		if (!$showignored AND in_coventry($message['postuserid']))
		{
			$message['ignored'] = true;
		}

		$response_handler =& $factory->create($message);
		$response_handler->cachable = false;
		$messagebits .= $response_handler->construct();

		if (!$message['messageread'] AND $message['state'] == 'visible' AND $pictureinfo['userid'] == $vbulletin->userinfo['userid'])
		{
			$read_ids[] = $message['commentid'];
		}

		$messagestats['lastcomment'] = $message['dateline'];
	}

	if ($pictureinfo['userid'] == $vbulletin->userinfo['userid'])
	{
		$readpcs = 0;

		if (!empty($read_ids))
		{
			$readpcs = sizeof($read_ids);
			$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "picturecomment SET messageread = 1 WHERE commentid IN (" . implode(',', $read_ids) . ")");
		}

		if ($vbulletin->userinfo['pcunreadcount'] - $readpcs > 0 AND $vbulletin->options['globalignore'] != '')
		{
			build_picture_comment_counters($vbulletin->userinfo['userid']);
		}
		else if ($readpcs)
		{
			$vbulletin->db->query_write("
				UPDATE " . TABLE_PREFIX . "user
				SET
					 pcunreadcount = IF(pcunreadcount >= $readpcs, pcunreadcount - $readpcs, 0)
				WHERE
					userid = " . $vbulletin->userinfo['userid']
			);
		}
	}
	$messagestats['perpage'] = $perpage;

	$show['delete'] = fetch_user_picture_message_perm('candeletemessages', $pictureinfo);
	$show['undelete'] = fetch_user_picture_message_perm('canundeletemessages', $pictureinfo);
	$show['approve'] = fetch_user_picture_message_perm('canmoderatemessages', $pictureinfo);
	$show['inlinemod'] = ($show['delete'] OR $show['undelete'] OR $show['approve']);

	return $messagebits;
}
예제 #7
0
파일: usertools.php 프로젝트: Kheros/MMOver
        list($invitedgroups) = $vbulletin->db->query_first("\r\n\t\t\tSELECT COUNT(*) FROM " . TABLE_PREFIX . "socialgroupmember WHERE\r\n\t\t\tuserid = " . intval($destinfo['userid']) . "\r\n\t\t\tAND TYPE = 'invited'\r\n\t\t", DBARRAY_NUM);
        $vbulletin->db->query_write("\r\n\t\t\tUPDATE " . TABLE_PREFIX . "user SET\r\n\t\t\tsocgroupinvitecount = " . intval($invitedgroups) . "\r\n\t\t\tWHERE userid = " . intval($destinfo['userid']));
        $groupdm =& datamanager_init("SocialGroup", $vbulletin, ERRTYPE_STANDARD);
        foreach ($groups as $group) {
            $groupdm->set_existing($group);
            $groupdm->rebuild_membercounts();
            $groupdm->rebuild_picturecount();
            $groupdm->save();
            list($pendingcountforowner) = $vbulletin->db->query_first("\r\n\t\t\t\tSELECT SUM(moderatedmembers) FROM " . TABLE_PREFIX . "socialgroup\r\n\t\t\t\tWHERE creatoruserid = " . $group['creatoruserid'], DBARRAY_NUM);
            $vbulletin->db->query_write("\r\n\t\t\t\tUPDATE " . TABLE_PREFIX . "user\r\n\t\t\t\tSET socgroupreqcount = " . intval($pendingcountforowner) . "\r\n\t\t\t\tWHERE userid = " . $group['creatoruserid']);
        }
    }
    $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "album\r\n\t\tSET userid = {$destinfo['userid']}\r\n\t\tWHERE userid = {$sourceinfo['userid']}\r\n\t");
    $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "picturecomment SET\r\n\t\t\tpostuserid = {$destinfo['userid']},\r\n\t\t\tpostusername = '******'username']) . "'\r\n\t\tWHERE postuserid = {$sourceinfo['userid']}\r\n\t");
    require_once DIR . '/includes/functions_picturecomment.php';
    build_picture_comment_counters($destinfo['userid']);
    ($hook = vBulletinHook::fetch_hook('useradmin_merge')) ? eval($hook) : false;
    // Remove remnants of source user
    $userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
    $userdm->set_existing($sourceinfo);
    $userdm->delete();
    unset($userdm);
    define('CP_BACKURL', '');
    print_stop_message('user_accounts_merged', $sourceinfo['username'], $destinfo['username']);
}
// ###################### Start modify Profile Pic ###########
if ($_REQUEST['do'] == 'profilepic') {
    $userinfo = fetch_userinfo($vbulletin->GPC['userid'], FETCH_USERINFO_PROFILEPIC);
    if (!$userinfo) {
        print_stop_message('invalid_user_specified');
    }
예제 #8
0
 /**
  * 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);
 }
예제 #9
0
파일: album.php 프로젝트: hungnv0789/vhtm
	/**
	* post_delete function - extend if the contenttype needs to do anything
	*
	* @return	void
	*/
	public function post_delete(&$attachdm)
	{
		$users = array();
		// Update something in the album table...
		if (!empty($this->lists['albumlist']))
		{
			$del_usercss = array();
			$albums = $this->registry->db->query_read("
				SELECT *
				FROM " . TABLE_PREFIX . "album
				WHERE albumid IN (" . implode(",", array_keys($this->lists['albumlist'])) . ")
			");
			while ($album = $this->registry->db->fetch_array($albums))
			{
				$users["$album[userid]"] = 1;
				$albumdata =& datamanager_init('Album', $this->registry, ERRTYPE_SILENT);
				$albumdata->set_existing($album);
				$albumdata->rebuild_counts();

				if (in_array($album['coverattachmentid'], array_keys($this->lists['albumlist']["$album[albumid]"])))
				{
					if ($album['visible'] - 1 > 0)
					{
						$new_cover = $this->registry->db->query_first("
							SELECT
								attachment.attachmentid
							FROM " . TABLE_PREFIX . "attachment AS attachment
							WHERE
								attachment.contentid = $album[albumid]
									AND
								attachment.state = 'visible'
									AND
								contenttypeid = " . intval($attachdm->fetch_field('contenttypeid')) . "
							ORDER BY
								attachment.dateline ASC
							LIMIT 1
						");
					}
					$albumdata->set('coverattachmentid', ($new_cover['attachmentid'] ? $new_cover['attachmentid']: 0));
				}

				$albumdata->save();
			}

			foreach ($this->lists['albumlist'] AS $albumid => $values)
			{
				foreach ($values AS $attachmentid => $foo)
				{
					$del_usercss[] = "$albumid,$attachmentid";
				}
			}

			$this->registry->db->query_write("
				DELETE FROM " . TABLE_PREFIX . "usercss
				WHERE
					property = 'background_image'
						AND
					value IN ('" . implode('\',\'', $del_usercss) . "')
			");
			$attachdm->set_info('have_updated_usercss', ($this->registry->db->affected_rows() > 0));

			require_once(DIR . '/includes/functions_picturecomment.php');
			foreach ($users AS $userid => $foo)
			{
				build_picture_comment_counters($userid);
				($hook = vBulletinHook::fetch_hook('picturedata_delete')) ? eval($hook) : false;
			}
		}
	}
예제 #10
0
	/**
	* 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);
	}