Code

Multiple edit.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Dec 2007 14:54:17 +0000 (14:54 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Dec 2007 14:54:17 +0000 (14:54 +0000)
-Added PhoneAccounts to multiple edit pluigns.
-Some checks and improvements are still missing.

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

gosa-core/plugins/gofon/phoneaccount/class_phoneAccount.inc
gosa-core/plugins/gofon/phoneaccount/generic.tpl

index 6871854ed0ca6e340c17d13bae1fa597766bb164..23d2031e384c4864b839d7d835b8923b23ee4c3a 100644 (file)
@@ -47,6 +47,7 @@ class phoneAccount extends plugin
   var $uid;
 
   var $view_logged = FALSE;
+  var $multiple_support = TRUE;
 
   function phoneAccount (&$config, $dn= NULL, $parent= NULL)
   {
@@ -220,6 +221,7 @@ class phoneAccount extends plugin
       /* Check if makro has been removed */
       if(!isset($this->macros[$this->macro])){
         $this->macrostillavailable = false;
+        echo "1";
       }else{
         $this->macrostillavailable = true;
       }
@@ -822,6 +824,7 @@ class phoneAccount extends plugin
         /* Check if macro has been removed */
         if(!isset($this->macroarray[$this->macro])){
           $this->macrostillavailable = false;
+        echo "2";
         }else{
           $this->macrostillavailable = true;
         }
@@ -854,6 +857,33 @@ class phoneAccount extends plugin
       $this->is_account= !$this->is_account;
     }
 
+    /* Do we represent a valid account? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+        _("This account has no phone extensions.")."</b>";
+      $display.= back_to_main();
+      return($display);
+    }
+
+    $display= "";
+
+    /* Show tab dialog headers */
+    
+    if (!$this->multiple_support_active && $this->parent !== NULL){
+      if ($this->is_account){
+        $display= $this->show_disable_header(_("Remove phone account"),
+            _("This account has phone features enabled. You can disable them by clicking below."));
+      } else {
+        if(empty($this->uid)){
+          $display= $this->show_enable_header(_("Create phone account"),
+              _("This account has phone features disabled. You can't enable them while no uid is set."),TRUE,TRUE);
+        }else{
+          $display= $this->show_enable_header(_("Create phone account"),
+              _("This account has phone features disabled. You can enable them by clicking below."));
+        }
+        return ($display);
+      }
+    }
     /* Select no macro if, state is empty, this is the case, if the selected macro is no longer available */
     if(empty($this->macro)){
       $this->macro ="none";
@@ -971,32 +1001,6 @@ class phoneAccount extends plugin
     $smarty->assign("macrotab",$macrotab);
 
 
-    /* Do we represent a valid account? */
-    if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
-        _("This account has no phone extensions.")."</b>";
-      $display.= back_to_main();
-      return($display);
-    }
-
-    $display= "";
- /* Show tab dialog headers */
-    if ($this->parent !== NULL){
-      if ($this->is_account){
-        $display= $this->show_disable_header(_("Remove phone account"),
-            _("This account has phone features enabled. You can disable them by clicking below."));
-      } else {
-        if(empty($this->uid)){
-          $display= $this->show_enable_header(_("Create phone account"),
-              _("This account has phone features disabled. You can't enable them while no uid is set."),TRUE,TRUE);
-        }else{
-          $display= $this->show_enable_header(_("Create phone account"),
-              _("This account has phone features disabled. You can enable them by clicking below."));
-        }
-        return ($display);
-      }
-    }
-
     /* Add phone number */
     if (isset($_POST["add_phonenumber"]) && $_POST['phonenumber']){
       if (is_phone_nr($_POST['phonenumber'])){
@@ -1071,8 +1075,18 @@ class phoneAccount extends plugin
     $hl.= "</select>\n";
     $smarty->assign ("hardware_list", $hl);
 
+
+    foreach($this->attributes as $attr){
+      if(in_array($attr,$this->multi_boxes)){
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
+
     /* Show main page */
     $this->lastmacro = $this->macro;
+    $smarty->assign("multiple_support",$this->multiple_support_active);
     $display.= $smarty->fetch(get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
     return($display);
   }
@@ -1506,6 +1520,58 @@ class phoneAccount extends plugin
             "goFonVoicemailPIN"   => _("Voicemail pin"))
           ));
   }
+
+
+
+  function multiple_execute()
+  {
+    plugin::multiple_execute();
+    return($this->execute());
+  }
+
+  function get_multi_init_values()
+  {
+    $ret = plugin::get_multi_init_values();
+    $ret['phoneNumbers'] = array();
+    foreach($this->phoneNumbers as $number){
+      $ret['phoneNumbers'][] = $number."  [".$this->attrs['cn'][0]."]"; 
+    }
+    $ret['phoneNumbers']['count'] = count($ret['phoneNumbers']);
+    return($ret);
+  }
+
+  function init_multiple_support($attrs,$all)
+  {
+    plugin::init_multiple_support($attrs,$all);
+
+    $this->phoneNumbers = array();
+    if(isset($all['phoneNumbers'])){
+      for($i = 0 ; $i < $all['phoneNumbers']['count'] ; $i++){
+        $this->phoneNumbers[$all['phoneNumbers'][$i]] = $all['phoneNumbers'][$i];
+      }
+    }
+  }
+
+  function multiple_save_object()
+  {
+    /* Simply call parents save_object */
+    $this->save_object();
+    echo "<pre>Not finsihed yet 
+ Checks, Save_object anpassen.
+  Tests.
+ </pre>";
+  }
+
+  function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    if(in_array("macro",$this->multi_boxes)){
+      $ret['macro'] = $this->macro;
+      $ret['macroarray'] = $this->macroarray;
+      $ret['macros'] = $this->macros;
+    }
+    return($ret);
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index f034afeb7157b7b747474590a1a710078c0749c7..9680c93081c292fd2085853a5cd5790e2350d515 100644 (file)
@@ -5,6 +5,16 @@
     <img class="center" alt="" align="middle" src="images/banana.png" />
     &nbsp;{t}Phone numbers{/t}
    </h2>
+
+{if $multiple_support}
+
+   <select style="width:100%;" name="dummy1" size=7 >
+    {html_options options=$phoneNumbers}
+    <option disabled>&nbsp;</option>
+   </select>
+
+{else}
+
 {render acl=$telephoneNumberACL}
    <select style="width:100%;" name="phonenumber_list[]" size=7 multiple>
     {html_options options=$phoneNumbers}
@@ -21,6 +31,8 @@
 {render acl=$telephoneNumberACL}
       <input type="submit" value="{t}Delete{/t}" name="delete_phonenumber">
 {/render}
+
+{/if}
   </td>
   <td style="vertical-align:top; width:50%;">
    <table summary="" style="width:100%" border=0>
    <h2><img class="center" alt="" align="middle" src="images/hardware.png" />&nbsp;{t}Telephone hardware{/t}</h2>
 
       <table summary="{t}Telephone{/t}" border=0>
+          {if !$multiple_support}
        <tr>
-        <td>{t}Telephone{/t}</td>
-        <td>{$hardware_list}</td>
+        <td>
+                       {t}Telephone{/t}
+               </td>
+        <td>
+                       {$hardware_list}
+               </td>
        </tr>
+          {/if}
        <tr>
         <td>{t}Home server{/t}{$must}
         </td>
         <td>
-{render acl=$goFonHomeServerACL}
+{render acl=$goFonHomeServerACL checkbox=$multiple_support checked=$use_goFonHomeServer}
          <select name='goFonHomeServer' title='{t}Select the accounts home server{/t}'>
           {html_options options=$goFonHomeServers selected=$goFonHomeServer}
          </select>
@@ -50,7 +68,7 @@
         <label for="goFonVoicemailPIN">{t}Voicemail PIN{/t}{$must}</label>
        </td>
        <td>
-{render acl=$goFonVoicemailPINACL}
+{render acl=$goFonVoicemailPINACL checkbox=$multiple_support checked=$use_goFonVoicemailPIN}
         <input type="password" id="goFonVoicemailPIN" name="goFonVoicemailPIN" value="{$goFonVoicemailPIN}">
 {/render}
       </td>
@@ -60,7 +78,7 @@
         <label for="goFonPIN">{t}Phone PIN{/t}{$must}</label>
        </td>
        <td>
-{render acl=$goFonPINACL}
+{render acl=$goFonPINACL checkbox=$multiple_support checked=$use_goFonPIN}
         <input type="password" id="goFonPIN" name="goFonPIN" value="{$goFonPIN}">
 {/render}
       </td>
   <table summary="{t}Phone macro{/t}">
    <tr>
     <td colspan=2>
-{render acl=$goFonMacroACL}
-     <select name="macro" onchange="document.mainform.submit()">
+{render acl=$goFonMacroACL  checkbox=$multiple_support checked=$use_macro}
+     <select id="macro" name="macro" onchange="document.mainform.submit()">
       {html_options options=$macros selected=$macro}
       <option disabled>&nbsp;</option>
      </select>