Kaynağa Gözat

Merge pull request #1490 from MissAllSunday/profile_call_func

Profile call func
Jessica González 10 yıl önce
ebeveyn
işleme
f65f0e6075
2 değiştirilmiş dosya ile 20 ekleme ve 3 silme
  1. 17 1
      Sources/Admin.php
  2. 3 2
      Sources/Profile.php

+ 17 - 1
Sources/Admin.php

@@ -484,7 +484,23 @@ function AdminMain()
 	if (isset($admin_include_data['file']))
 		require_once($sourcedir . '/' . $admin_include_data['file']);
 
-	$admin_include_data['function']();
+	// Do we defined a class for this function?
+	if (isset($admin_include_data['class']) && !empty($admin_include_data['class']) && is_string($admin_include_data['class']))
+	{
+		// Is there an instance already? nope? then create it!
+		if (empty($context['instances'][$admin_include_data['class']]) || !($context['instances'][$admin_include_data['class']] instanceof $admin_include_data['class']))
+			$context['instances'][$admin_include_data['class']] = new $admin_include_data['class'];
+
+		$call = array($context['instances'][$admin_include_data['class']], $admin_include_data['function']);
+	}
+
+	// A static one or more likely, a plain good old function.
+	else
+		$call = $admin_include_data['function'];
+
+	// Is it valid?
+	if (is_callable($call))
+		call_user_func($call);
 }
 
 /**

+ 3 - 2
Sources/Profile.php

@@ -724,7 +724,7 @@ function ModifyProfile($post_errors = array())
 		redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
 
 	// Is this a "real" method?
-	if (isset($profile_include_data['class']))
+	if (isset($profile_include_data['class']) && !empty($profile_include_data['class']) && is_string($profile_include_data['class']))
 	{
 		// Is there an instance already? nope? then create it!
 		if (empty($context['instances'][$profile_include_data['class']]) || !($context['instances'][$profile_include_data['class']] instanceof $profile_include_data['class']))
@@ -733,12 +733,13 @@ function ModifyProfile($post_errors = array())
 		$call = array($context['instances'][$profile_include_data['class']], $profile_include_data['function']);
 	}
 
+	// A static one or more likely, a plain good old function.
 	else
 		$call = $profile_include_data['function'];
 
 	// Is it valid?
 	if (is_callable($call))
-		call_user_func_array($call, array($memID));
+		call_user_func($call, $memID);
 
 	// Set the page title if it's not already set...
 	if (!isset($context['page_title']))