Code

Added handling of restriction IPs
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 3 Sep 2009 11:02:52 +0000 (11:02 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 3 Sep 2009 11:02:52 +0000 (11:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14204 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 4f4b16a8e42e558a87a1d5bf15b81d34c5ba3363..c34c0686ac81fc3a55378c261d5293b108b91ac3 100644 (file)
@@ -50,6 +50,7 @@ class user extends plugin
   var $o= "";
   var $ou= "";
   var $departmentNumber= "";
+  var $gosaLoginRestriction= array();
   var $employeeNumber= "";
   var $employeeType= "";
   var $roomNumber= "";
@@ -110,7 +111,7 @@ class user extends plugin
       "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage",
       "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto",
       "roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
-      "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
+      "postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate", "gosaLoginRestriction");
 
   var $objectclasses= array("top", "person", "organizationalPerson", "inetOrgPerson",
       "gosaAccount");
@@ -244,6 +245,29 @@ class user extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    /* 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;
+      } 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){
       $this->view_logged = TRUE;
@@ -624,6 +648,8 @@ 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);
     $smarty->assign("pw_configurable", $is_configurable);
index e0b138ff2f5f553b6a55bb030d3f5e365e6ac7ae..eba5a0127a246fd2e0cac8575765154a97b5255f 100644 (file)
     </tr>
     <tr>
      <td colspan=2>
-      <div style="height:20px;"></div>
+      <div style="height:10px;"></div>
      </td>
     </tr>
     <tr>
     </tr>
     {/if}
 
-       {if $gotoLastSystemLogin}
-               <tr>
-                       <td>{t}Last logon{/t}</td>
-                       <td>{$gotoLastSystemLogin}</td>
-               </tr>           
-       {/if}
+    {if !$multiple_support}
+    <tr>
+     <td colspan=2>
+      <div style="height:10px;"></div>
+     </td>
+    </tr>
+    <tr>
+     <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>
+             <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="-">
+{/render}
+     </td>
+    </tr>
+    {/if}
    </table>
   </td>
  </tr>