[Jaws-commits] r13382 - in trunk/jaws/html: gadgets/Users/actions/AdminHTML gadgets/Users/resources gadgets/Users/templates include/Jaws include/Jaws/Auth

afz at jaws-project.com afz at jaws-project.com
Sat Aug 11 17:23:29 UTC 2012


Author: afz
Date: 2012-08-11 17:23:29 +0000 (Sat, 11 Aug 2012)
New Revision: 13382

Modified:
   trunk/jaws/html/gadgets/Users/actions/AdminHTML/MyAccount.php
   trunk/jaws/html/gadgets/Users/resources/script.js
   trunk/jaws/html/gadgets/Users/resources/style.css
   trunk/jaws/html/gadgets/Users/resources/style.rtl.css
   trunk/jaws/html/gadgets/Users/templates/MyAccount.html
   trunk/jaws/html/include/Jaws/Auth/Default.php
   trunk/jaws/html/include/Jaws/User.php
Log:
[Users]:
- Update MyAccount action admin interface
- Some update for compatibility with new changes of avatar

Modified: trunk/jaws/html/gadgets/Users/actions/AdminHTML/MyAccount.php
===================================================================
--- trunk/jaws/html/gadgets/Users/actions/AdminHTML/MyAccount.php	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/gadgets/Users/actions/AdminHTML/MyAccount.php	2012-08-11 17:23:29 UTC (rev 13382)
@@ -22,11 +22,19 @@
         $this->CheckPermission('EditAccountInformation');
 
         require_once JAWS_PATH.'include/Jaws/User.php';
-        $username = $GLOBALS['app']->Session->GetAttribute('username');
-        $userModel = new Jaws_User();
-        $userInfo = $userModel->GetUser($username);
+        $uModel = new Jaws_User();
+        $uInfo = $uModel->GetUser($GLOBALS['app']->Session->GetAttribute('user'), true, true);
+        if (Jaws_Error::IsError($uInfo) || empty($uInfo)) {
+            return false;
+        }
 
         $this->AjaxMe('script.js');
+        $tpl = new Jaws_Template('gadgets/Users/templates/');
+        $tpl->Load('MyAccount.html');
+        $tpl->SetBlock('MyAccount');
+        $tpl->SetVariable('uid', $uInfo['id']);
+        $tpl->SetVariable('legend_title', _t('USERS_USERS_ACCOUNT_INFO'));
+
         $use_crypt = ($GLOBALS['app']->Registry->Get('/crypt/enabled') == 'true')? true : false;
         if ($use_crypt) {
             require_once JAWS_PATH . 'include/Jaws/Crypt.php';
@@ -36,81 +44,71 @@
 
         if ($use_crypt) {
             $GLOBALS['app']->Layout->AddScriptLink('libraries/js/rsa.lib.js');
+
+            $tpl->SetBlock('MyAccount/encryption');
+            // modulus
+            $modulus =& Piwi::CreateWidget('HiddenEntry',
+                                           'modulus',
+                                           $JCrypt->math->bin2int($JCrypt->pub_key->getModulus()));
+            $modulus->SetID('modulus');
+            $tpl->SetVariable('modulus', $modulus->Get());
+            //exponent
+            $exponent =& Piwi::CreateWidget('HiddenEntry',
+                                            'exponent',
+                                            $JCrypt->math->bin2int($JCrypt->pub_key->getExponent()));
+            $modulus->SetID('exponent');
+            $tpl->SetVariable('exponent', $exponent->Get());
+            $tpl->ParseBlock('MyAccount/encryption');
         }
 
-        $tpl = new Jaws_Template('gadgets/Users/templates/');
-        $tpl->Load('MyAccount.html');
-        $tpl->SetBlock('MyAccount');
-        if (!Jaws_Error::IsError($userInfo) && isset($userInfo['username'])) {
-            $tpl->SetVariable('incompleteUserFields', _t('USERS_MYACCOUNT_INCOMPLETE_FIELDS'));
-            $tpl->SetVariable('wrongPassword', _t('USERS_MYACCOUNT_PASSWORDS_DONT_MATCH'));
+        // username
+        $username =& Piwi::CreateWidget('Entry', 'username', $uInfo['username']);
+        $username->SetID('username');
+        $tpl->SetVariable('lbl_username', _t('USERS_USERS_USERNAME'));
+        $tpl->SetVariable('username', $username->Get());
 
-            $form =& Piwi::CreateWidget('Form', BASE_SCRIPT, 'post');
-            $form->Add(Piwi::CreateWidget('HiddenEntry', 'gadget', 'Users'));
-            $form->Add(Piwi::CreateWidget('HiddenEntry', 'action', 'UpdateMyAccount'));
-            $form->Add(Piwi::CreateWidget('HiddenEntry', 'id', $userInfo['id']));
+        // nickname
+        $nickname =& Piwi::CreateWidget('Entry', 'nickname', $uInfo['nickname']);
+        $nickname->SetID('nickname');
+        $tpl->SetVariable('lbl_nickname', _t('USERS_USERS_NICKNAME'));
+        $tpl->SetVariable('nickname', $nickname->Get());
 
-            if ($use_crypt) {
-                $form->Add(Piwi::CreateWidget('HiddenEntry',
-                                              'modulus', 
-                                              $JCrypt->math->bin2int($JCrypt->pub_key->getModulus())));
-                $form->Add(Piwi::CreateWidget('HiddenEntry',
-                                              'exponent',
-                                              $JCrypt->math->bin2int($JCrypt->pub_key->getExponent())));
-            }
+        // email
+        $email =& Piwi::CreateWidget('Entry', 'email', $uInfo['email']);
+        $email->SetID('email');
+        $tpl->SetVariable('lbl_email', _t('GLOBAL_EMAIL'));
+        $tpl->SetVariable('email', $email->Get());
 
-            include_once JAWS_PATH . 'include/Jaws/Widgets/FieldSet.php';
-            $fieldset = new Jaws_Widgets_FieldSet(_t('USERS_USERS_ACCOUNT_INFO'));
-            $fieldset->SetDirection('vertical');
+        // pass1
+        $pass1 =& Piwi::CreateWidget('PasswordEntry', 'pass1', '');
+        $pass1->SetID('pass1');
+        $tpl->SetVariable('lbl_pass1', _t('USERS_USERS_PASSWORD'));
+        $tpl->SetVariable('pass1', $pass1->Get());
 
-            $hbox =& Piwi::CreateWidget('HBox');
-            $hbox->setStyle('width: 100%;');
-            $hbox->_useTitles = true;
+        // pass2
+        $pass2 =& Piwi::CreateWidget('PasswordEntry', 'pass2', '');
+        $pass2->SetID('pass2');
+        $tpl->SetVariable('lbl_pass2', _t('USERS_USERS_PASSWORD_VERIFY'));
+        $tpl->SetVariable('pass2', $pass2->Get());
 
-            $usernameEntry =& Piwi::CreateWidget('Entry', 'username', $userInfo['username']);
-            $usernameEntry->SetTitle(_t('USERS_USERS_USERNAME'));
-            $hbox->packstart($usernameEntry);
-            $avatar =& Piwi::CreateWidget('Image',
-                                          $userModel->GetAvatar($userInfo['username'],
-                                                                $userInfo['email']),
-                                          $userInfo['username']);
-            $avatar->SetID('user_avatar');
-            $avatar->setStyle('float: right;');
-            $hbox->packstart($avatar);
+        $avatar =& Piwi::CreateWidget('Image',
+                                      $uModel->GetAvatar($uInfo['avatar'], $uInfo['email']),
+                                      $uInfo['username']);
+        $avatar->SetID('avatar');
+        $tpl->SetVariable('avatar', $avatar->Get());
 
-            $fieldset->Add($hbox);
 
-            $nameEntry =& Piwi::CreateWidget('Entry', 'nickname', $userInfo['nickname']);
-            $nameEntry->SetTitle(_t('USERS_USERS_NICKNAME'));
-            $nameEntry->SetStyle('width: 250px');
-            $fieldset->Add($nameEntry);
+        $btnSave =& Piwi::CreateWidget('Button',
+                                       'SubmitButton',
+                                       _t('GLOBAL_UPDATE'),
+                                       STOCK_SAVE);
+        $btnSave->AddEvent(ON_CLICK, "javascript: updateMyAccount();");
+        $tpl->SetVariable('save', $btnSave->Get());
 
-            $emailEntry =& Piwi::CreateWidget('Entry', 'email', $userInfo['email']);
-            $emailEntry->SetTitle(_t('GLOBAL_EMAIL'));
-            $emailEntry->SetStyle('width: 250px');
-            $fieldset->Add($emailEntry);
+        $tpl->SetVariable('incompleteUserFields', _t('USERS_MYACCOUNT_INCOMPLETE_FIELDS'));
+        $tpl->SetVariable('wrongPassword',        _t('USERS_MYACCOUNT_PASSWORDS_DONT_MATCH'));
 
-            $pass1Entry =& Piwi::CreateWidget('PasswordEntry', 'pass1', '');
-            $pass1Entry->SetTitle(_t('USERS_USERS_PASSWORD'));
-            $fieldset->Add($pass1Entry);
-            $pass2Entry =& Piwi::CreateWidget('PasswordEntry', 'pass2', '');
-            $pass2Entry->SetTitle(_t('USERS_USERS_PASSWORD_VERIFY'));
-            $fieldset->Add($pass2Entry);
-
-            $form->Add($fieldset);
-
-            $buttonbox =& Piwi::CreateWidget('HBox');
-            $buttonbox->SetStyle('float: right;'); //hig style
-            $submit =& Piwi::CreateWidget('Button', 'SubmitButton', _t('GLOBAL_UPDATE'), STOCK_SAVE);
-            $submit->AddEvent(ON_CLICK, "javascript: updateMyAccount();");
-            $buttonbox->Add($submit);
-
-            $form->Add($buttonbox);
-
-            $tpl->SetVariable('form', $form->Get());
-        }
         $tpl->ParseBlock('MyAccount');
-
         return $tpl->Get();
     }
 

Modified: trunk/jaws/html/gadgets/Users/resources/script.js
===================================================================
--- trunk/jaws/html/gadgets/Users/resources/script.js	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/gadgets/Users/resources/script.js	2012-08-11 17:23:29 UTC (rev 13382)
@@ -680,9 +680,11 @@
         return false;
     }
 
-    encryptedElement($('pass1'), $('exponent').value, $('modulus').value, true, 128);
-    $('pass2').value = $('pass1').value;
-    usersAsync.updatemyaccount($('id').value,
+    if ($('exponent')) {
+        encryptedElement($('pass1'), $('exponent').value, $('modulus').value, true, 128);
+        $('pass2').value = $('pass1').value;
+    }
+    usersAsync.updatemyaccount($('uid').value,
                                $('username').value,
                                $('pass1').value,
                                $('nickname').value,

Modified: trunk/jaws/html/gadgets/Users/resources/style.css
===================================================================
--- trunk/jaws/html/gadgets/Users/resources/style.css	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/gadgets/Users/resources/style.css	2012-08-11 17:23:29 UTC (rev 13382)
@@ -167,6 +167,15 @@
 width: 52px;
 }
 
+#my_account {
+margin: auto;
+width: 380px;
+padding: 5px;
+}
+#my_account table {
+padding: 5px;
+}
+
 #timezone, #editor,
 #theme, #language {
 width: 250px;

Modified: trunk/jaws/html/gadgets/Users/resources/style.rtl.css
===================================================================
--- trunk/jaws/html/gadgets/Users/resources/style.rtl.css	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/gadgets/Users/resources/style.rtl.css	2012-08-11 17:23:29 UTC (rev 13382)
@@ -195,6 +195,14 @@
 #users_filter .filter_label {
 width: 52px;
 }
+#my_account {
+margin: auto;
+width: 380px;
+padding: 5px;
+}
+#my_account table {
+padding: 5px;
+}
 
 #username, #email, #pass1, #pass2, #logins, #expiry_date,
 #dob, #url, #timezone, #language, #theme {

Modified: trunk/jaws/html/gadgets/Users/templates/MyAccount.html
===================================================================
--- trunk/jaws/html/gadgets/Users/templates/MyAccount.html	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/gadgets/Users/templates/MyAccount.html	2012-08-11 17:23:29 UTC (rev 13382)
@@ -3,7 +3,22 @@
   var incompleteUserFields  = "{incompleteUserFields}";
   var wrongPassword         = "{wrongPassword}";
 </script>
-<div id="main" align="center">
-{form}
+<input type="hidden" name="uid" id="uid" value="{uid}" />
+<!-- BEGIN encryption -->{modulus}{exponent}<!-- END encryption -->
+<div id="my_account" align="center">
+  <fieldset>
+    <legend><span id="legend_title">{legend_title}</span></legend>
+    <table width="100%" border="0" cellpadding="0" cellspacing="0">
+      <tr>
+        <td><label for="username">{lbl_username}:</label><br />{username}</td>
+        <td rowspan="3" id="user_avatar">{avatar}</td>
+      </tr>
+      <tr><td><label for="nickname">{lbl_nickname}:</label><br />{nickname}</td></tr>
+      <tr><td><label for="email">{lbl_email}:</label><br />{email}</td></tr>
+      <tr><td colspan="2"><label for="pass1">{lbl_pass1}:</label><br />{pass1}</td></tr>
+      <tr><td colspan="2"><label for="pass2">{lbl_pass2}:</label><br />{pass2}</td></tr>
+    </table>
+  </fieldset>
+  <div class="buttons">{save}</div>
 </div>
 <!-- END MyAccount -->

Modified: trunk/jaws/html/include/Jaws/Auth/Default.php
===================================================================
--- trunk/jaws/html/include/Jaws/Auth/Default.php	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/include/Jaws/Auth/Default.php	2012-08-11 17:23:29 UTC (rev 13382)
@@ -66,7 +66,7 @@
             }
 
             $info['groups'] = $groups;
-            $info['avatar'] = $this->_Model->GetAvatar($info['username'], $info['email']);
+            $info['avatar'] = $this->_Model->GetAvatar($info['avatar'], $info['email']);
             $info['superadmin'] = $info['superadmin'];
             $info['internal']   = true;
             // Update login time

Modified: trunk/jaws/html/include/Jaws/User.php
===================================================================
--- trunk/jaws/html/include/Jaws/User.php	2012-08-11 17:22:10 UTC (rev 13381)
+++ trunk/jaws/html/include/Jaws/User.php	2012-08-11 17:23:29 UTC (rev 13382)
@@ -269,9 +269,9 @@
      * @param  string   $email      Email
      * @return string   Url to avatar image
      */
-    function GetAvatar($username, $email)
+    function GetAvatar($avatar, $email)
     {
-        $avatar = $GLOBALS['app']->getDataURL("avatar/$username.png");
+        $avatar = $GLOBALS['app']->getDataURL("avatar/$avatar");
         if (!file_exists($avatar)) {
             require_once JAWS_PATH . 'include/Jaws/Gravatar.php';
             $avatar = Jaws_Gravatar::GetGravatar($email);



More information about the Jaws-commits mailing list