Преглед изворни кода

Add user_exists function

Pulled from 4.4 pull request that was accepted. 4.5.
FusionPBX пре 4 година
родитељ
комит
3f92e1794f
1 измењених фајлова са 26 додато и 0 уклоњено
  1. 26 0
      resources/functions.php

+ 26 - 0
resources/functions.php

@@ -2236,4 +2236,30 @@ function number_pad($number,$n) {
 		}
 	}
 
+// User exists
+        if (!function_exists('user_exists')) {
+                function user_exists($login, $domain_name = null) {
+                	//connect to freeswitch
+                        $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
+                        if (!$fp) {
+                                return false;
+                        }
+
+               		//send the user_exists command to freeswitch
+                        if ($fp) {
+                                //build and send the mkdir command to freeswitch
+				if (is_null($domain_name)){
+					$domain_name = $_SESSION['domain_name'];
+				}
+				$switch_cmd = "user_exists id '$login' '$domain_name'";
+				$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
+				fclose($fp);
+				return ($switch_result == 'true'?true:false);
+                        }
+
+			//can not create directory
+                        return null;
+                }
+        }
+
 ?>