Code

First try with exchanging lists
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 17:31:10 +0000 (17:31 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 17:31:10 +0000 (17:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15215 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/generic/class_user.inc
gosa-core/plugins/personal/generic/generic.tpl

index cefc0113a4b38942c67177e2a6e62085f69d993e..a2b3b1db29d3e92947c8f5771b6e1544a47d4870 100644 (file)
@@ -51,6 +51,7 @@ class user extends plugin
   var $ou= "";
   var $departmentNumber= "";
   var $gosaLoginRestriction= array();
+  var $gosaLoginRestrictionWidget;
   var $employeeNumber= "";
   var $employeeType= "";
   var $roomNumber= "";
@@ -242,6 +243,11 @@ class user extends plugin
         $this->gosaLoginRestriction[] = $this->attrs['gosaLoginRestriction'][$i];
       }
     }
+    $this->gosaLoginRestrictionWidget= new sortableListing($this->gosaLoginRestriction);
+    $this->gosaLoginRestrictionWidget->setDeleteable(true);
+    $this->gosaLoginRestrictionWidget->setColspecs(array('*'));
+    $this->gosaLoginRestrictionWidget->setWidth("320px");
+    $this->gosaLoginRestrictionWidget->setHeight("70px");
  
     $this->orig_base = $this->base;
   }
@@ -253,28 +259,21 @@ class user extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    /* Let the lists update themselves */
+    $this->gosaLoginRestrictionWidget->setAcl($this->getacl('gosaLoginRestriction', (!is_object($this->parent) && !session::is_set('edit'))));
+    $this->gosaLoginRestrictionWidget->update();
+
     /* Handle add/delete for restriction mode */
     if (isset($_POST['add_res']) && isset($_POST['res'])) {
       $val= validate($_POST['res']);
       if (preg_match('/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/', $val) ||
           preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+)$/', $val) ||
           preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/', $val)) {
-        $this->gosaLoginRestriction[]= $val;
+        $this->gosaLoginRestrictionWidget->addEntry($val);
       } else {
         msg_dialog::display(_("Error"), _("Please add a single IP address or a network/netmask combination!"), ERROR_DIALOG);
       }
     }
-    if (isset($_POST['del_res']) && isset($_POST['restrictions'])) {
-      $res= $_POST['restrictions'];
-      if (!is_array($res)){
-        $res= array($res);
-      }
-      foreach ($res as $restriction) {
-        if (in_array($restriction, $this->gosaLoginRestriction)) {
-          $this->gosaLoginRestriction= array_remove_entries(array($restriction), $this->gosaLoginRestriction);
-        }
-      }
-    }
 
     /* Log view */
     if($this->is_account && !$this->view_logged){
@@ -284,6 +283,7 @@ class user extends plugin
 
     $smarty= get_smarty();
     $smarty->assign("usePrototype", "true");
+    $smarty->assign("gosaLoginRestrictionWidget", $this->gosaLoginRestrictionWidget->render());
 
     /* Assign sex */
     $sex= array(0 => "&nbsp;", "F" => _("female"), "M" => _("male"));
@@ -607,7 +607,6 @@ class user extends plugin
       $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !session::is_set('edit'))));
     }
 
-    $smarty->assign("gosaLoginRestriction", $this->gosaLoginRestriction);
     $smarty->assign("gosaLoginRestrictionACL", $this->getacl('gosaLoginRestriction', (!is_object($this->parent) && !session::is_set('edit'))));
     $smarty->assign("pwmode", $pwd_methods);
     $smarty->assign("pwmode_select", $this->pw_storage);
@@ -756,6 +755,11 @@ class user extends plugin
       /* Parents save function */
       plugin::save_object ();
 
+      /* Sync lists */
+      if ($this->gosaLoginRestrictionWidget->isModified()) {
+        $this->gosaLoginRestriction= $this->gosaLoginRestrictionWidget->getMaintainedData();
+      }
+
       /* Save government mode attributes */
       if ($this->governmentmode){
         foreach ($this->govattrs as $val){
index 9833e7b30a134dd58cfd40d58acebeca3251c8f6..34da9d013412015e451b4c4635c60dbf69c5f84e 100644 (file)
      <td style='vertical-align:top'><label for="edit_perms">{t}Restrict login to{/t}</label></td>
      <td>
 {render acl=$gosaLoginRestrictionACL}
-             <select size="3" multiple style='width:100%' id="restrictions" name="restrictions">
-              {html_options values=$gosaLoginRestriction output=$gosaLoginRestriction}
-             </select><br>
+              {$gosaLoginRestrictionWidget}
              <input id="res" name="res" size=22 maxlength=33 value="{t}IP or network{/t}" onFocus='document.getElementById("res").value=""'>
-             <input id="add_res" type="submit" name="add_res" value="+">
-             <input id="del_res" type="submit" name="del_res" value="-">
+             <input id="add_res" type="submit" name="add_res" value="{t}Add{/t}">
+
 {/render}
      </td>
     </tr>