[Freeswitch-svn] [commit] r12615 - in freeswitch/trunk/scripts/contrib/swk: flex/amf-test1/src php/amfphp

FreeSWITCH SVN silik0n at freeswitch.org
Sun Mar 15 18:12:05 PDT 2009


Author: silik0n
Date: Sun Mar 15 20:12:05 2009
New Revision: 12615

Log:
Looks like we have most of the data retrival done... still needs some work on pushing data updates

Modified:
   freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml
   freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php

Modified: freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml
==============================================================================
--- freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml	(original)
+++ freeswitch/trunk/scripts/contrib/swk/flex/amf-test1/src/main.mxml	Sun Mar 15 20:12:05 2009
@@ -217,14 +217,14 @@
                 			<mx:DataGrid left="10" top="40" bottom="116" width="45%" dataProvider="{freeswitch.getDirDomain.lastResult.params}"
                 				itemEditEnd="dgChangeDomainParam();" editable="true" id="dgDomainParam">
                 				<mx:columns>
-                					<mx:DataGridColumn headerText="Parameter" dataField="name" width="120"/>
+                					<mx:DataGridColumn headerText="Parameter" dataField="name" width="120" editable="false" />
                 					<mx:DataGridColumn headerText="Value" dataField="value"/>
                 				</mx:columns>
                 			</mx:DataGrid>
                 			<mx:DataGrid right="10" top="40" bottom="116" width="45%" dataProvider="{freeswitch.getDirDomain.lastResult.variables}" 
                 				itemEditEnd="dgChangeDomainVars();" editable="true" id="dgDomainVars">
                 				<mx:columns>
-                					<mx:DataGridColumn headerText="Variable" dataField="name" width="120"/>
+                					<mx:DataGridColumn headerText="Variable" dataField="name" width="120" editable="false"/>
                 					<mx:DataGridColumn headerText="Data" dataField="value"/>
                 				</mx:columns>
                 			</mx:DataGrid>
@@ -265,14 +265,14 @@
                 			<mx:DataGrid left="10" top="40" bottom="116" width="45%" dataProvider="{freeswitch.getDirUser.lastResult.params}"
                 				change="dgChangeDomainUserParam();" editable="true" id="dgDomainUserParam">
                 				<mx:columns>
-                					<mx:DataGridColumn headerText="Parameter" dataField="name" width="120"/>
+                					<mx:DataGridColumn headerText="Parameter" dataField="name" width="120" editable="false"/>
                 					<mx:DataGridColumn headerText="Value" dataField="value"/>
                 				</mx:columns>
                 			</mx:DataGrid>
                 			<mx:DataGrid right="10" top="40" bottom="116" width="45%" dataProvider="{freeswitch.getDirUser.lastResult.variables}" 
                 				change="dgChangeDomainVars();" editable="true" id="dgDomainUserVars">
                 				<mx:columns>
-                					<mx:DataGridColumn headerText="Variable" dataField="name" width="120"/>
+                					<mx:DataGridColumn headerText="Variable" dataField="name" width="120" editable="false"/>
                 					<mx:DataGridColumn headerText="Data" dataField="value"/>
                 				</mx:columns>
                 			</mx:DataGrid>
@@ -294,27 +294,30 @@
                 <mx:Canvas label="Groups" width="100%" height="100%">
 	                <mx:HDividedBox x="0" y="0" width="100%" height="100%">
 		                <mx:Canvas width="20%" height="100%">
-		                    <mx:ComboBox top="10" horizontalCenter="0"></mx:ComboBox>
-		                    <mx:DataGrid width="100%" horizontalCenter="0" top="40" bottom="70">
+		                    <mx:ComboBox top="10" horizontalCenter="0" id="groupsDomain" dataProvider="{freeswitch.getDirDomains.lastResult}" labelField="name"></mx:ComboBox>
+		                    <mx:DataGrid id="dgDirGroups" width="100%" horizontalCenter="0" top="40" bottom="70" dataProvider="{freeswitch.getDirGroups.lastResult}" 
+		                    	click="freeswitch.getDirGroup(dgDirGroups.selectedItem.uid)">
 		                        <mx:columns>
-		                            <mx:DataGridColumn headerText="Group" dataField="user_id"/>
+		                            <mx:DataGridColumn headerText="Group" dataField="name"/>
 		                        </mx:columns>
 		                    </mx:DataGrid>
-		                    <mx:Button label="Refresh Groups" horizontalCenter="0" bottom="10"/>
-		                    <mx:Button label="Refresh Domains" horizontalCenter="0" bottom="40"/>
+		                    <mx:Button label="Refresh Groups" horizontalCenter="0" bottom="10" click="freeswitch.getDirGroups(groupsDomain.selectedItem.uid)"/>
+		                    <mx:Button label="Refresh Domains" horizontalCenter="0" bottom="40" click="freeswitch.getDirDomains()"/>
 		                </mx:Canvas>
 		                <mx:Canvas width="80%" height="100%">
-		                	<mx:DataGrid width="45%" left="10" top="0" bottom="70">
+		                	<mx:DataGrid width="45%" left="10" top="0" bottom="70" dataProvider="{freeswitch.getDirGroup.lastResult.members}" 
+		                		dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
 		                		<mx:columns>
-		                			<mx:DataGridColumn headerText="Member" dataField="col1"/>
+		                			<mx:DataGridColumn headerText="Member" dataField="usersUsername"/>
 		                		</mx:columns>
 		                	</mx:DataGrid>
-		                	<mx:DataGrid width="45%" right="10" top="0" bottom="70">
+		                	<mx:DataGrid width="45%" right="10" top="0" bottom="70" dataProvider="{freeswitch.getDirGroup.lastResult.nonmembers}" 
+		                		dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
 		                		<mx:columns>
-		                			<mx:DataGridColumn headerText="Available to Join" dataField="col1"/>
+		                			<mx:DataGridColumn headerText="Available to Join" dataField="usersUsername"/>
 		                		</mx:columns>
 		                	</mx:DataGrid>
-		                	<mx:Button label="Refresh" left="10" bottom="40"/>
+		                	<mx:Button label="Refresh" left="10" bottom="40" click="freeswitch.getDirGroup(dgDirGroups.selectedItem.uid)"/>
 		                </mx:Canvas>
 		            </mx:HDividedBox>
                 </mx:Canvas>

Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php	(original)
+++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php	Sun Mar 15 20:12:05 2009
@@ -47,18 +47,17 @@
 		$db_username = 'root'; 		/* Database Server username */
 		$db_password = 'password'; 	/* Database Server password */
 		$db_database = 'shipment'; 	/* DataBase Name */
-		
-		$dbh = new PDO("$dbtype:host=$db_hostname;dbname=$db_database", $db_username, $db_password, array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,));
-		
+		if ($dbtype == 'mysql') {
+			$pdo_flags =  array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,);
+		}
+		$dbh = new PDO("$dbtype:host=$db_hostname;dbname=$db_database", $db_username, $db_password, $pdo_flags);
 		return $dbh;
 	}
 
         public function __construct() { 
-
 		$esl_server = "127.0.0.1"; 	/* ESL Server */
 		$esl_port = "8021"; 		/* ESL Port */
 		$esl_secret = "ClueCon"; 	/* ESL Secret */
-
 		$this->esl = new eslConnection($esl_server, $esl_port, $esl_secret);
 	}
 
@@ -67,14 +66,12 @@
 	public function getStatus() {
 		$e = $this->esl->sendRecv("api status");
 		$body = $e->getBody();
-		
 		return $body;
 	}
 
 	public function getChannels() {
 		$e = $this->esl->sendRecv("api show channels");
 		$body = $e->getBody();
-		
 		$temp = explode  ("\n", $body);
 		$total_count = sizeof($temp);
 		$i = -1;
@@ -100,7 +97,6 @@
 	public function getCalls() {
 		$e = $this->esl->sendRecv("api show calls");
 		$body = $e->getBody();
-		
 		$temp = explode  ("\n", $body);
 		$total_count = sizeof($temp);
 		$i = -1;
@@ -129,7 +125,6 @@
 		$dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout";
 		$e = $this->esl->sendRecv($dialstring);
 		$body = $e->getBody();
-
 		return $body;
 	}
 
@@ -150,7 +145,6 @@
 	public function getConferenceList() {
 		$e = $this->esl->sendRecv("api conference list");
 		$body = $e->getBody();
-		
 		$data=explode("\n", $body);
 		$y=0;
 		foreach($data as $row){
@@ -166,7 +160,6 @@
 	public function getConferenceUsers($conference_name) {
 		$e = $this->esl->sendRecv("api conference $conference_name list");
 		$body = $e->getBody();
-		
 		$data=explode("\n", $body);
 		$y=0;
 		foreach($data as $row){
@@ -206,7 +199,6 @@
 		} else {
 			$templist = glob("/usr/local/freeswitch/sounds/en/us/callie/*/*/*");
 		}
-		
 		$x=0;
 		foreach($templist as $file){
 			$temp_file = explode("/", $file);
@@ -215,7 +207,6 @@
 			// $filelist[$x] = $file;
 			$x++;
 		}
-		
 		return $filelist;
 	}
 
@@ -255,67 +246,27 @@
 	}
 
 	/*** Directory Methods ***/
-
+	
+	/* Directory Domain Methods */
 	public function getDirDomains(){
 		$dbh = $this->getDbh();
-
 		$query = sprintf("select * from domains");
 		$stmt = $dbh->query($query);
 		$results = $stmt->fetchAll();
-
 		return $results;
 	}
 
 	public function getDirDomain($domain_uid){
-
 		$dbh = $this->getDbh();
-
 		$query = sprintf("select * from domain_params where domains_uid = $domain_uid");
 		$stmt = $dbh->query($query);
 		$results['params'] = $stmt->fetchAll();
-
 		$query = sprintf("select * from domain_variables where domains_uid = $domain_uid");
 		$stmt = $dbh->query($query);
 		$results['variables'] = $stmt->fetchAll();
-
 		return $results;
 	}
 	
-	public function getDirUser($user_uid){
-
-		$dbh = $this->getDbh();
-
-		$query = sprintf("select * from user_params where users_uid = $user_uid");
-		$stmt = $dbh->query($query);
-		$results['params'] = $stmt->fetchAll();
-
-		$query = sprintf("select * from user_variables where users_uid = $user_uid");
-		$stmt = $dbh->query($query);
-		$results['variables'] = $stmt->fetchAll();
-
-		return $results;
-	}
-
-	public function getDirUsers($domain_uid){
-		$dbh = $this->getDbh();
-		
-		$query = sprintf("select * from users where domain_uid = $domain_uid");
-		$stmt = $dbh->query($query);
-		$results = $stmt->fetchAll();
-
-		return $results;
-	}
-
-	public function getDirGroups($domain_uid){
-		$dbh = $this->getDbh();
-
-		$query = sprintf("select * from groups where domain_uid = $domain_uid");
-		$stmt = $dbh->query($query);
-		$results = $stmt->fetchAll();
-
-		return $results;
-	}
-
 	public function addDirDomain($domain_name){
 		$dbh = $this->getDbh();
 		$query = sprintf('insert into domains (name) values ("%s")', $domain_name);
@@ -346,6 +297,47 @@
 		return $dbh->exec($query);
 	}
 
+
+	/* Directory User Methods */
+	public function getDirUser($user_uid){
+		$dbh = $this->getDbh();
+		$query = sprintf("select * from user_params where users_uid = $user_uid");
+		$stmt = $dbh->query($query);
+		$results['params'] = $stmt->fetchAll();
+		$query = sprintf("select * from user_variables where users_uid = $user_uid");
+		$stmt = $dbh->query($query);
+		$results['variables'] = $stmt->fetchAll();
+		return $results;
+	}
+
+	public function getDirUsers($domain_uid){
+		$dbh = $this->getDbh();
+		$query = sprintf("select * from users where domain_uid = $domain_uid");
+		$stmt = $dbh->query($query);
+		$results = $stmt->fetchAll();
+		return $results;
+	}
+
+	/* Directory Group Methods */
+	public function getDirGroups($domain_uid){
+		$dbh = $this->getDbh();
+		$query = sprintf("select * from groups where domains_uid = $domain_uid");
+		$stmt = $dbh->query($query);
+		$results = $stmt->fetchAll();
+		return $results;
+	}
+
+	public function getDirGroup($groups_uid){
+		$dbh = $this->getDbh();
+		$query = sprintf("select a.uid as groupMemberUid, a.users_uid as usersUid, b.username as usersUsername from group_members as a, users as b where a.groups_uid = $groups_uid and a.users_uid = b.uid") ;
+		$stmt = $dbh->query($query);
+		$results['members'] = $stmt->fetchAll();
+		$query = sprintf("select uid as usersUid, username as usersUsername from users where uid not in (select users_uid from group_members where groups_uid = $groups_uid) and domain_uid = (select domains_uid from groups where uid = $groups_uid)");
+		$stmt = $dbh->query($query);
+		$results['nonmembers'] = $stmt->fetchAll();
+		return $results;
+	}
+
 }
 /* For Emacs:
  * Local Variables:



More information about the Freeswitch-svn mailing list