Code

Updated base check
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 1 Feb 2010 09:41:10 +0000 (09:41 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 1 Feb 2010 09:41:10 +0000 (09:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15525 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/html/include/pwdStrength.js
gosa-core/include/class_baseSelector.inc
gosa-core/include/utils/class_msgPool.inc
gosa-core/plugins/admin/ogroups/class_ogroup.inc

index aebc1b1cfbcff8ee7caa0286d63962529c71f8c2..f4c08d0bd564e35637909b34da3fba4b09a6031b 100644 (file)
@@ -1,5 +1,4 @@
-
-/* ************************************************************
+/*************************************************************
 Created: 20060120
 Author:  Steve Moitozo <god at zilla dot us>
 Description: This is a quick and dirty password quality meter 
@@ -19,7 +18,8 @@ Revision Notes: - Verified to work in FF2, IE7 and Safari2
 Modified: 20061111 - Steve Moitozo corrected regex for letters and numbers
                      Thanks to Zack Smith -- zacksmithdesign.com
                      and put MIT License back in
-                                        
+Modified: 20100201 - Cajus Pollmeier stripped parts unnessesary for GOsa and
+                     moved to prototype. Stripped comments.
 ---------------------------------------------------------------
 Copyright (c) 2006 Steve Moitozo <god at zilla dot us>
 
@@ -32,7 +32,7 @@ sell copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:
 
-   The above copyright notice and this permission notice shall
+The above copyright notice and this permission notice shall
 be included in all copies or substantial portions of the
 Software.
 
@@ -46,77 +46,10 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
 OR OTHER DEALINGS IN THE SOFTWARE.
 ---------------------------------------------------------------
  
-USAGE: 
-
-You can play with the pwdTest div style to make it go where you want.
-In this case it sits to the right side of the input
-
-<!-- Code To Add To HTML Form Page -->
-
-<!-- the include -->
-<script type="text/javascript" src="scripts/pwdStrength.js"></script>
-
-<!-- the input -->
-<input type="text" name="password" id="password" onkeyup="testPassword(document.forms.YourFormName.password.value);">
-
-<!-- the "meter" -->
-<div id="pwdTest" style="padding:3px;float:right;font-size:.8em;width:180px;min-width:220;border:1px dashed;margin-top:-40px;">
-       Password Strength:<br>
-       <span id="meterEmpty" style="padding:0;margin:0;width:100%;background-color:##DC143C;display:block;height:5px;">
-       <span id="meterFull" style="padding:0;margin:0;z-index:100;width:0;background-color:##006400;display:block;height:5px;"></span></span>
-       <span id="Words" style="font-size:.8em; margin-top;-25px;">Minimum Strength Not Met</span>
-</div>         
-<!-- the submit button -->
-<input disabled type="submit" id ="formSubmit">        
-<!-- End of HTML -->
-
-===================================
-Password Strength Factors and Weightings
-
-password length:
-level 0 (3 point): less than 4 characters
-level 1 (6 points): between 5 and 7 characters
-level 2 (12 points): between 8 and 15 characters
-level 3 (18 points): 16 or more characters
-
-letters:
-level 0 (0 points): no letters
-level 1 (5 points): all letters are lower case
-level 2 (7 points): letters are mixed case
-
-numbers:
-level 0 (0 points): no numbers exist
-level 1 (5 points): one number exists
-level 1 (7 points): 3 or more numbers exists
-
-special characters:
-level 0 (0 points): no special characters
-level 1 (5 points): one special character exists
-level 2 (10 points): more than one special character exists
-
-combinatons:
-level 0 (1 points): letters and numbers exist
-level 1 (1 points): mixed case letters
-level 1 (2 points): letters, numbers and special characters 
-                                       exist
-level 1 (2 points): mixed case letters, numbers and special 
-                                       characters exist
-
-
 ************************************************************ */
 function testPasswordCss(passwd)
 {
-               var description = new Array();
-               description[0] = "Minimum Strength Not Met";
-               description[1] = "Weak";
-               description[2] = "Improving";
-               description[3] = "Strong";
-               description[4] = "Strongest";
-               description[5] = "Begin Typing";
-
                var intScore   = 0
-               var strVerdict = 0
                
                // PASSWORD LENGTH
                if (passwd.length==0 || !passwd.length)                         // length 0
@@ -183,65 +116,46 @@ function testPasswordCss(passwd)
                        intScore = (intScore+2)
                }
 
-        if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers
-        {
-                intScore = (intScore+2)
-        }
+               if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers
+               {
+                       intScore = (intScore+2)
+               }
 
-                                                                                                                                 // [verified] letters, numbers, and special characters
+               // [verified] letters, numbers, and special characters
                if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
                {
                        intScore = (intScore+2)
                }
 
        
-//if you don't want to prevent submission of weak passwords you can comment out
-//                document.getElementById("formSubmit").disabled = true;
-       
                if(intScore == -1)
                {
-                  strVerdict = description[5];
-                  document.getElementById("meterEmpty").style.width= "100%";
-                  document.getElementById("meterFull").style.width= "0";
-                  document.getElementById("formSubmit").disabled = true;
+                  $('meterEmpty').setStyle({width: '100%'});
+                  $('meterFull').setStyle({width: '0%'});
                }
                else if(intScore > -1 && intScore < 16)
                {
-                  strVerdict = description[0];
-                  document.getElementById("meterEmpty").style.width= "100%";
-                  document.getElementById("meterFull").style.width= "0%";
-                  document.getElementById("formSubmit").disabled = true;
+                  $('meterEmpty').setStyle({width: '100%'});
+                  $('meterFull').setStyle({width: '0%'});
                }
                else if (intScore > 15 && intScore < 25)
                {
-                  strVerdict = description[1];
-                  document.getElementById("meterEmpty").style.width= "100%";
-                  document.getElementById("meterFull").style.width= "25%";
-                  document.getElementById("formSubmit").disabled = false;
+                  $('meterEmpty').setStyle({width: '100%'});
+                  $('meterFull').setStyle({width: '25%'});
                }
                else if (intScore > 24 && intScore < 35)
                {
-                  strVerdict = description[2];
-                 document.getElementById("meterEmpty").style.width= "100%";
-                 document.getElementById("meterFull").style.width= "50%";
-                 document.getElementById("formSubmit").disabled = false;
+                  $('meterEmpty').setStyle({width: '100%'});
+                  $('meterFull').setStyle({width: '50%'});
                }
                else if (intScore > 34 && intScore < 45)
                {
-                  strVerdict = description[3];
-                  document.getElementById("meterEmpty").style.width= "100%";
-                  document.getElementById("meterFull").style.width= "75%";
-                  document.getElementById("formSubmit").disabled = false;
+                  $('meterEmpty').setStyle({width: '100%'});
+                  $('meterFull').setStyle({width: '75%'});
                }
                else
                {
-                  strVerdict = description[4];
-                  document.getElementById("meterEmpty").style.width= "100%";
-                  document.getElementById("meterFull").style.width= "100%";
-                  document.getElementById("formSubmit").disabled = false;
+                  $('meterEmpty').setStyle({width: '100%'});
+                  $('meterFull').setStyle({width: '100%'});
                }
-       
-       //Changed by <pollmeier@gonicus.de>: no need for words
-       //document.getElementById("Words").innerHTML= (strVerdict);
-       
 }
index ac62398db0eabcadba823fca6cebf41f2ef8bd15..b05ff5b211608d0287e2eaba5ed5963efec68d9b 100644 (file)
@@ -29,6 +29,7 @@ class baseSelector {
   private $submitButton= true;
   protected $tree;
   protected $pathMapping;
+  protected $lastState;
 
   // It would be better to get a dn -> [name, description, type] array
   // to avoid these tasks be done several times. Skipping for the moment.
@@ -77,6 +78,12 @@ class baseSelector {
   }
 
 
+  function checkLastBaseUpdate()
+  {
+    return $this->lastState;
+  }
+
+
   function setBases($bases)
   {
     global $config;
@@ -114,22 +121,28 @@ class baseSelector {
           $this->base= $new_base;
           $this->action= 'rebase';
         } else {
+          $this->lastState= false;
           return false;
         }
       }
-    } elseif (isset($_POST['bs_input_'.$this->pid])) {
 
-      // Take over input field base
-      if ($this->submitButton && isset($_POST['submit_base_'.$this->pid.'_x']) || !$this->submitButton) {
+      // Input field set?
+      if (isset($_POST['bs_input_'.$this->pid])) {
+
+        // Take over input field base
+        if ($this->submitButton && isset($_POST['submit_base_'.$this->pid.'_x']) || !$this->submitButton) {
 
-        // Check if base is available
-        foreach ($this->pathMapping as $key => $path) {
-          if (mb_strtolower($path) == mb_strtolower($_POST['bs_input_'.$this->pid])) {
-            $this->base= $key;
-            break;
+          // Check if base is available
+          $this->lastState= false;
+          foreach ($this->pathMapping as $key => $path) {
+            if (mb_strtolower($path) == mb_strtolower($_POST['bs_input_'.$this->pid])) {
+              $this->base= $key;
+              $this->lastState= true;
+              break;
+            }
           }
         }
-      }
+      } 
 
     }
 
@@ -200,6 +213,7 @@ class baseSelector {
     $this->tree.= "<input type='hidden' name='bs_rebase_".$this->pid."' id='bs_rebase_".$this->pid."'>";
     $this->tree.= "<input type='hidden' name='BPID' id='BPID' value='".$this->pid."'>";
 
+    $this->lastState= true;
     return true;
   }
 
index 025baf58e2fa5e66a0f29560c0f0786ece99993c..8dea7c25f2b3498323cf08da28db8e14ecbe6cbe 100644 (file)
@@ -568,6 +568,13 @@ class msgPool
   {
     return (sprintf(_("Cannot initialize class '%s'! Maybe there is a plugin missing in your gosa setup?"), $plugin));
   }
+
+
+  public static function check_base()
+  {
+    return _("The supplied base is not valid and has been reset to the previous value!");
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 6ad3e16fc8b90eb83aa007285e59d13f2ddafdf1..db538a1845c7308d745efa629ea5550dd4e755c7 100644 (file)
@@ -799,6 +799,11 @@ class ogroup extends plugin
       $message[]= msgPool::duplicated(_("Name"));
     } 
 
+    // Check if a wrong base was supplied
+    if(!$this->baseSelector->checkLastBaseUpdate()){
+      $message[]= msgPool::check_base();;
+    } 
+
     /* Set new acl base */
     if($this->dn == "new") {
       $this->set_acl_base($this->base);