Thread: New Posting Features - LAM - Dispute Resolution
View Single Post
  #77  
Old 07-18-2011, 06:21 PM
CheeSie's Avatar
CheeSie CheeSie is offline
 
Join Date: Sep 2006
Location: Denmark
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Further improvements..

Plugin: LAM - Save Edited Dispute Resolution Data
What has changed: You just saved the list of disputees everytime, but when quick editing the post the list was empty, this has been fixed as it no longer updates if the request was made via ajax. Now it also only sends out PM notifications if the user has been added to the list and not if they were already on the list (otherwise all tagged members would receive loooots of pm if some noob was editing the thread massively).
New code
Code:
if (!$vbulletin->GPC['ajax'] && ($threadinfo['postuserid'] == $vbulletin->userinfo['userid'] || can_moderate($threadinfo['forumid'], 'caneditthreads'))) {
	$vbulletin->input->clean_gpc('p', 'LAM_DisputeResolution_UserNames', TYPE_STR);
	$vbulletin->GPC['LAM_DisputeResolution_UserNames'] = trim($vbulletin->GPC['LAM_DisputeResolution_UserNames']);

	if(!empty($vbulletin->GPC['LAM_DisputeResolution_UserNames'])) {
		$LAM_DisputeResolution_Names = explode(";", $vbulletin->GPC['LAM_DisputeResolution_UserNames']);
		unset($LAM_DisputeResolution_SQL, $LAM_DisputeResolution_UIDs);
		
		foreach ($LAM_DisputeResolution_Names AS $LAM_DisputeResolution_Name) {
			$LAM_DisputeResolution_Name = $db->escape_string(trim($LAM_DisputeResolution_Name));
			if (!empty($LAM_DisputeResolution_Name)) {
				$LAM_DisputeResolution_SQL .= ",'$LAM_DisputeResolution_Name'";
			}
		}
		
		$LAM_PreDisputees = explode(',', $threadinfo['LAM_DisputeResolution']);
		$LAM_DisputeResolution_UserInfo = fetch_userinfo($vbulletin->options['LAM_DisputeResolution_FromUserID']);
		$LAM_DisputeResolution_SQL = substr($LAM_DisputeResolution_SQL, 1);
		$LAM_DisputeResolution_Query = $db->query_read("SELECT userid, username FROM " . TABLE_PREFIX ."user AS user WHERE username IN ($LAM_DisputeResolution_SQL)");
		
		while ($LAM_DisputeResolution_Row = $db->fetch_array($LAM_DisputeResolution_Query)) {
			$LAM_DisputeResolution_UIDs .= "," . $LAM_DisputeResolution_Row['userid'];
			
			if(!in_array($LAM_DisputeResolution_Row['userid'], $LAM_PreDisputees)){
				$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
				if (empty($vbulletin->options['LAM_DisputeResolution_FromUserID'])) {
					$pmdm->set('fromuserid', $vbulletin->userinfo['userid']);
					$pmdm->set('fromusername', $vbulletin->userinfo['username']);
				} else {
					$pmdm->set('fromuserid', $LAM_DisputeResolution_UserInfo['userid']);
					$pmdm->set('fromusername', $LAM_DisputeResolution_UserInfo['username']);
				}
				$pmdm->set('title', $vbphrase['LAM_DisputeResolution_Title']);
				$pmdm->set('message', construct_phrase($vbphrase['LAM_DisputeResolution_PMText'], $vbulletin->options['bburl'] . "/showthread.php?" . $vbulletin->session->vars['sessionurl'] . $threadinfo['threadid'] . ""));
				$pmdm->set_recipients($LAM_DisputeResolution_Row['username'], $permissions);
				$pmdm->set('dateline', TIMENOW);
				$pmdm->pre_save();
				if (empty($pmdm->errors)) {
					$pmdm->save();
				}
			}
		}
		
		$LAM_DisputeResolution_UIDs = substr($LAM_DisputeResolution_UIDs, 1);
		$db->free_result($LAM_DisputeResolution_Query);

		$db->query_write("UPDATE " . TABLE_PREFIX . "thread SET LAM_DisputeResolution = '" . $LAM_DisputeResolution_UIDs . "' WHERE threadid = " . $threadinfo['threadid'] . "");
	}elseif($vbulletin->options['LAM_DisputeResolution_OptionalDisputes']){
		$db->query_write("UPDATE " . TABLE_PREFIX . "thread SET LAM_DisputeResolution = '' WHERE threadid = " . $threadinfo['threadid'] . "");
	}
		
	unset($LAM_DisputeResolution_Query, $LAM_DisputeResolution_SQL, $LAM_DisputeResolution_Names, $LAM_DisputeResolution_UIDs, $LAM_DisputeResolution_UserInfo, $LAM_PreDisputees);
}

Plugin: LAM - Check Edit Usernames Have Been Given
What has changed: Commented out something you didn't use that was really dumb to include (sorry), but there's no point in it and I had to comment it out to add that "only notify new recipients feature".
New code
Code:
if (!$vbulletin->GPC['ajax'] AND !$vbulletin->GPC['quickeditnoajax'] AND !$vbulletin->GPC['advanced'] AND ($threadinfo['postuserid'] == $vbulletin->userinfo['userid'] || can_moderate($threadinfo['forumid'], 'caneditthreads'))) {
	$vbulletin->input->clean_gpc('p', 'LAM_DisputeResolution_UserNames', TYPE_STR);

	if ($vbulletin->options['LAM_DisputeResolution_GlobalEnable'] || in_array($foruminfo['forumid'], explode(',', $vbulletin->options['LAM_DisputeResolution_DisputeForumIDs']))) {
		if (empty($vbulletin->GPC['LAM_DisputeResolution_UserNames'])) {
		
			if (!$vbulletin->options['LAM_DisputeResolution_OptionalDisputes']) {
				eval(standard_error(fetch_error('LAM_DisputeResolution_MissingUserNames')));
			}
			
		} else {
		
			$LAM_DisputeResolution_Names = explode(";", $vbulletin->GPC['LAM_DisputeResolution_UserNames']);

			foreach ($LAM_DisputeResolution_Names AS $LAM_DisputeResolution_Name) {
				$LAM_DisputeResolution_Name = $db->escape_string(htmlspecialchars_uni(trim($LAM_DisputeResolution_Name)));
				
				if (!empty($LAM_DisputeResolution_Name)) {
					$LAM_DisputeResolution_Query = $db->query_first("SELECT userid FROM " . TABLE_PREFIX ."user AS user WHERE username = '$LAM_DisputeResolution_Name'");

					if ($LAM_DisputeResolution_Query) {
						$LAM_DisputeResolution_UIDs .= "," . $LAM_DisputeResolution_Query['userid'];
						$db->free_result($LAM_DisputeResolution_Query);
					} else {
						eval(standard_error(fetch_error('LAM_DisputeResolution_UnknownUserName', $LAM_DisputeResolution_Name)));
					}
				}
			}
		}
		
		//Could delete if you want to, just kept it commented to show you what I meant
		//$threadinfo[LAM_DisputeResolution] = $vbulletin->GPC['LAM_DisputeResolution_UserNames'];
		unset($LAM_DisputeResolution_Query, $LAM_DisputeResolution_Names, $LAM_DisputeResolution_UIDs);
	}
}
You could do the above change to the "LAM - Check Usernames Have Been Given" plugin as well
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01927 seconds
  • Memory Usage 1,794KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete