Code

Phones, can be configured in three diffrent ways,
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 14 Jun 2005 09:35:35 +0000 (09:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 14 Jun 2005 09:35:35 +0000 (09:35 +0000)
This is only testing, won't work correct yet ....

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@704 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_phoneGeneric.inc
plugins/admin/systems/phone.tpl

index 417b6b31cf3dd36209ac27cf8baaccd0813ca454..dddc9499a37c0315031b0baf4c7466b40dbbfee0 100644 (file)
@@ -12,15 +12,43 @@ class phoneGeneric extends plugin
   var $ignore_account= TRUE;
 
   /* Needed values and lists */
-  var $base= "";
-  var $cn= "";
-  var $macAddress= "";
-  var $ipHostNumber= "";
-  var $description= "";
-  var $orig_dn= "";
+  var $base             = "";
+  var $cn               = "";
+  var $macAddress       = "";
+  var $ipHostNumber     = "";
+  var $description      = "";
+  var $orig_dn          = "";
+  var $goFonType        = "";
+  var $goFonDmtfMode    = "";
+  var $goFonHost        = "";
+  var $goFonDefaultIP   = "";
+  var $goFonQualify     = "";
+  var $goFonAuth        = "";
+  var $goFonSecret      = "";
+  var $goFonInkeys      = "";
+  var $goFonOutkey      = "";
+  var $goFonTrunk       = "";
+  var $goFonAccountCode = "";
+  var $goFonMSN         = "";
+  var $selected_categorie    = 0;
 
   /* attribute list for save action */
-  var $attributes= array("cn", "description", "macAddress", "ipHostNumber");
+  var $attributes= array("cn", "description", "macAddress", "ipHostNumber"
+                         ,"goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP",
+                          "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey",
+                          "goFonTrunk","goFonAccountCode","goFonMSN","selected_categorie" 
+                         );
+  var $usedattrs =    array( "0"=>array("cn", "description", "macAddress", "ipHostNumber",
+                                  "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP",
+                                  "goFonQualify"),
+                             "1"=>array("cn", "description", "macAddress", "ipHostNumber",
+                                  "goFonType","goFonHost","goFonDefaultIP",
+                                  "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey",
+                                  "goFonTrunk","goFonAccountCode","selected_categorie"),
+                             "2"=>array("cn", "description", "macAddress", "ipHostNumber","goFonMSN"));
+  
+
   var $objectclasses= array("top", "goFonHardware");
 
   function phonegeneric ($config, $dn= NULL)
@@ -35,6 +63,16 @@ class phoneGeneric extends plugin
     } else {
       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
     }
+  
+    if($this->goFonMSN != ""){
+      $this->selected_categorie = 2;
+    }elseif($this->goFonAccountCode != ""){
+      $this->selected_categorie = 1 ;
+    } else {
+      $this->selected_categorie = 0;
+    }
+    
+    
 
     /* Save dn for later references */
     $this->orig_dn= $this->dn;
@@ -42,6 +80,8 @@ class phoneGeneric extends plugin
 
   function execute()
   {
+  
+  
     /* Do we represent a valid phone? */
     if (!$this->is_account && $this->parent == NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
@@ -53,6 +93,23 @@ class phoneGeneric extends plugin
     $smarty= get_smarty();
     $smarty->assign("bases", $this->config->idepartments);
 
+    /* Create Arrays for samrty select boxes */
+    $smarty->assign("categories",     array("SIP - phones","IAX - phones","CAPI - phones"));
+    $smarty->assign("goFonTypes",     array("peer"      =>"peer"      ,"user"   =>"user"    ,"friend" =>"friend"));
+    $smarty->assign("goFonDmtfModes", array("inband"    =>"inband"    ,"rfc2833"=>"rfc2833" ,"info"   =>"info"));
+    $smarty->assign("goFonAuths",     array("plaintext" =>"plaintext" ,"md5"    =>"md5"     ,"rsa"    =>"rsa"));
+    $smarty->assign("goFonTrunks",    array("yes" =>"yes"             ,"no"     =>"no"));
+
+    /* deativate all fields that are not used by the specified type */
+    foreach($this->attributes as $att){
+      if(!in_array($att,$this->usedattrs[$this->selected_categorie])){
+        $smarty->assign($att."USED", "disabled" );
+      }else{
+        $smarty->assign($att."USED", "" );
+      }
+    }
+
+
     /* Assign attributes */
     foreach ($this->attributes as $attr){
       $smarty->assign($attr."ACL", chkacl($this->acl, $attr));
@@ -65,6 +122,7 @@ class phoneGeneric extends plugin
         
     /* Show main page */
     $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl");
+    $smarty->assign("phonesettings", dirname(__FILE__)."/phonesettings.tpl");
     return($smarty->fetch (get_template_path('phone.tpl', TRUE)));
   }
 
@@ -148,7 +206,21 @@ class phoneGeneric extends plugin
   function save()
   {
     plugin::save();
+   
+   
+    /* only to define which attrs to save*/ 
+    $mode = $this->attrs['selected_categorie'];
 
+    /* Remove all unwanted attrs */
+    foreach($this->attributes as $att){
+      if(!in_array($att,$this->usedattrs[$mode])){
+        $this->attrs[$att] = array();
+      }
+    }
+
+    /* unset the categorie*/
+    unset($this->attrs['selected_categorie']);
+    
     /* Remove all empty values */
     if ($this->orig_dn == 'new'){
       $attrs= array();
index a5d0ce49b552e5adddbd2f20c631492bbddc34c1..317a9b7ec4f46f0b6afc3fc50505b080c7746a99 100644 (file)
@@ -30,7 +30,9 @@
 </table>
 
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+{include file="$phonesettings"}
 
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 {include file="$netconfig"}
 
 <!-- Place cursor -->