]> git.defcon.no Git - hermes/blobdiff - alias.php
Added alias/list functionality! Also, moved some data around in lib/alias_functions...
[hermes] / alias.php
index 9adb4346e82dd896d9721854f64ede3b4fdbf9fa..6451b2eef3efa52c774c1997afbd9b072df6f3e5 100644 (file)
--- a/alias.php
+++ b/alias.php
@@ -27,6 +27,7 @@ if ( !$config['sql_link'] )
                        Required parameters should be...
                                destination
                        */
+                       $list = array();
                        $dest_username = "";
                        $dest_domain   = "";
                        $e164_only = false;
@@ -43,10 +44,12 @@ if ( !$config['sql_link'] )
                                if ( array_key_exists( 'e164', $_GET ) )
                                {
                                        if ( strtolower($_GET['e164']) == "true" ) $e164_only = true;
+                                       $list = get_e164_alias( $dest_username, $dest_domain );
+                               }
+                               else if ( $dest_username && $dest_domain )
+                               {
+                                       $list = get_aliases( $dest_username, $dest_domain );
                                }
-                               // TODO: Well. Code. This is a stub
-
-                               print json_encode ( array( 'response' => 'failed', 'cause' => 'notimplemented', 'detail' => 'Requested feature valid, but not implemented' ) );
                        }
                        else if ( array_key_exists( 'alias', $_GET) )
                        {
@@ -58,12 +61,13 @@ if ( !$config['sql_link'] )
                                }
                                list ( $alias_username, $alias_domain ) = $tmp;
 
-                               // TODO: Well. Code. This is a stub
-
-                               print json_encode ( array( 'response' => 'failed', 'cause' => 'notimplemented', 'detail' => 'Requested feature valid, but not implemented' ) );
+                               $list = get_destination( $alias_username, $alias_domain );
                        }
                        else 
-                               print json_encode( array( 'response' => 'invalid', 'cause' => 'parameters' ) );
+                               $list = get_aliases( null, null );
+
+                       
+                       print json_encode ( array( 'response' => 'ok', 'aliases' => $list ) );
                        break;
                case "/add":
                        if ( array_key_exists( 'destination', $_GET) 
@@ -134,7 +138,7 @@ if ( !$config['sql_link'] )
                                                        'response' => 'failed', 
                                                        'cause' => 'exists', 
                                                        'detail' => 'User already has E164 number alias', 
-                                                       'alias' => $t ));
+                                                       'alias' => $t['alias'] ));
                                                break;
                                        }
                                }