Code

Updated class password to support password proposal
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Jul 2010 15:08:21 +0000 (15:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Jul 2010 15:08:21 +0000 (15:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18908 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/password/class_password.inc
gosa-core/plugins/personal/password/password.tpl

index 696e3e0d8491e30f6d9d1fbe7dd28c1b8699c343..13cdb6144f8b8be5944e4b987a9f705c08e6d455 100644 (file)
@@ -27,18 +27,28 @@ class password extends plugin
     var $plDescription  = "Change user password";
 
     var $proposal = "";
+    var $proposalEnabled = FALSE;
+    var $proposalSelected = FALSE;
 
     function password(&$config, $dn= NULL, $parent= NULL)
     {
         plugin::plugin($config, $dn, $parent);
 
-        $this->reloadProposal();
+        // Try to generate a password proposal, if this is successfull 
+        //  then preselect the proposal usage. 
+        $this->refreshProposal();
+        if($this->proposal != ""){
+            $this->proposalSelected = TRUE;
+        }
     }
 
 
-    function reloadProposal()
+    function refreshProposal()
     {
         $this->proposal = passwordMethod::getPasswordProposal($this->config);
+        if($this->proposal != ""){
+            $this->proposalEnabled  =TRUE;
+        }
     }
 
 
@@ -60,6 +70,12 @@ class password extends plugin
                 return($smarty->fetch(get_template_path("nochange.tpl", TRUE)));
             }
         }
+        
+        // Refresh proposal if requested
+        if(isset($_POST['refreshProposal'])) $this->refreshProposal();
+        $smarty->assign("proposal" , $this->proposal);
+        $smarty->assign("proposalEnabled" , $this->proposalEnabled);
+        $smarty->assign("proposalSelected" , $this->proposalSelected);
 
         /* Pwd change requested */
         if (isset($_POST['password_finish'])){
index a7b7b29ff918d81641ac26d04a44e459a2a13d68..7c928183025052f9b80a2a5fbad14ebbbcdde662 100644 (file)
@@ -4,35 +4,80 @@
   {t}To change your personal password use the fields below. The changes take effect immediately. Please memorize the new password, because you wouldn't be able to login without it.{/t}
 </p>
 
-<table cellpadding=4 border=0 summary="{t}Password change dialog{/t}">
-  <tr>
-    <td><b><LABEL for="current_password">{t}Current password{/t}</LABEL></b></td>
-    <td>
-        {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"}
-    </td>
-  </tr>
-  <tr>
-    <td><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
-    <td>
-        {factory type='password' name='new_password' id='new_password' 
-            onkeyup="testPasswordCss(\$('new_password').value)"  onfocus="nextfield= 'repeated_password';"}
-    </td>
-  </tr>
-  <tr>
-    <td><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
-    <td>
-        {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"}
-    </td>
-  </tr>
-  <tr>
-    <td><b>{t}Password strength{/t}</b></td>
-    <td>
-       <span id="meterEmpty" style="padding:0;margin:0;width:100%;background-color:#DC143C;display:block;height:7px;">
-       <span id="meterFull" style="padding:0;margin:0;z-index:100;width:0;background-color:#006400;display:block;height:7px;"></span></span>
-    </td>
-  </tr>
-</table>
+<hr>
 
+{if !proposalEnabled}
+  <table cellpadding=4 border=0 summary="{t}Password change dialog{/t}">
+    <tr>
+      <td><b><LABEL for="current_password">{t}Current password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='new_password' id='new_password' 
+              onkeyup="testPasswordCss(\$('new_password').value)"  onfocus="nextfield= 'repeated_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"}
+      </td>
+    </tr>
+    <tr>
+      <td><b>{t}Password strength{/t}</b></td>
+      <td>
+      <span id="meterEmpty" style="padding:0;margin:0;width:100%;background-color:#DC143C;display:block;height:7px;">
+      <span id="meterFull" style="padding:0;margin:0;z-index:100;width:0;background-color:#006400;display:block;height:7px;"></span></span>
+      </td>
+    </tr>
+  </table>
+{else}
+  <table cellpadding=4 border=0 summary="{t}Password change dialog{/t}">
+    <tr>
+      <td><b><LABEL for="current_password">{t}Current password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='current_password' id='current_password' onfocus="nextfield= 'new_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <input type='radio' value='1' name='proposalSelected'
+            {if $proposalSelected} checked {/if}>&nbsp;<b>{t}Use proposal{/t}</b>
+      </td>
+      <td><b>{$proposal}</b>&nbsp;{image path='images/lists/reload.png' action='refreshProposal'}</td>
+    </tr>
+    <tr>
+      <td>
+        <input type='radio' value='0' name='proposalSelected'
+            {if !$proposalSelected} checked {/if}>&nbsp;<b>{t}Manually specify a password{/t}</b>
+      </td>
+    </tr>
+    <tr>
+      <td style='padding-left:40px;'><b><LABEL for="new_password">{t}New password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='new_password' id='new_password' 
+              onkeyup="testPasswordCss(\$('new_password').value)"  onfocus="nextfield= 'repeated_password';"}
+      </td>
+    </tr>
+    <tr>
+      <td style='padding-left:40px;'><b><LABEL for="repeated_password">{t}Repeat new password{/t}</LABEL></b></td>
+      <td>
+          {factory type='password' name='repeated_password' id='repeated_password' onfocus="nextfield= 'password_finish';"}
+      </td>
+    </tr>
+    <tr>
+      <td  style='padding-left:40px;'><b>{t}Password strength{/t}</b></td>
+      <td>
+      <span id="meterEmpty" style="padding:0;margin:0;width:100%;background-color:#DC143C;display:block;height:7px;">
+      <span id="meterFull" style="padding:0;margin:0;z-index:100;width:0;background-color:#006400;display:block;height:7px;"></span></span>
+      </td>
+    </tr>
+  </table>
+{/if}
 <br>
 
 <hr>