Support for comment attachment added to Add form - See #33
Support for comment attachment added to Add form - See #33

--- a/Resources/main.js
+++ b/Resources/main.js
@@ -224,7 +224,8 @@
   var cred = document.getElementById('frmCredential'),
       user = document.getElementById('frmUser'),
       addr = document.getElementById('frmAddress'),
-      grp = document.getElementById('frmGroup');
+      grp = document.getElementById('frmGroup'),
+      comment = document.getElementById('frmComment');
       
       
       
@@ -248,6 +249,7 @@
  cred.value = Base64.encode(xorestr(cred.value,retKey()));
  user.value = Base64.encode(xorestr(user.value,retKey()));
  addr.value = Base64.encode(xorestr(addr.value,retKey()));
+ comment.value = Base64.encode(xorestr(comment.value,retKey()));
 }
 return true;
 

--- a/conf/lang.php
+++ b/conf/lang.php
@@ -21,3 +21,4 @@
 $lang['User'] = 'User';
 $lang['User Groups'] = 'User Groups';
 $lang['UserGroup'] = 'Group';
+$lang['Comment'] = 'Comment';

--- a/lib/db/Credentials.php
+++ b/lib/db/Credentials.php
@@ -211,7 +211,7 @@
 *
 * @return object
 */
-function addCred($cust,$credtype,$cred,$clicky,$group = 1,$address = '', $uname = '',$hidden = 0)
+function addCred($cust,$credtype,$cred,$comment,$clicky,$group = 1,$address = '', $uname = '',$hidden = 0)
 {
 
 
@@ -229,12 +229,17 @@
 
 if (!empty($cred)){
 $cred = $crypt->encrypt($cred,'Cre'.$credtype);
+}
+
+if (!empty($comment)){
+$comment = $crypt->encrypt($cred,'Cre'.$comment);
 }
 
 $address = $this->stringEscape($address);
 $uname = $this->stringEscape($uname);
 $credtype = $this->stringEscape($credtype);
 $cred = $this->stringEscape($cred);
+$comment = $this->stringEscape($comment);
 $cust = $this->stringEscape($cust);
 $clicky = $this->stringEscape($clicky);
 $date = date('Y-m-d H:i:s');
@@ -242,8 +247,8 @@
 $hidden = $this->stringEscape($hidden);
 
 
-$sql = "INSERT INTO #__Cred (`cust`,`Added`,`Group`,`Hash`,`CredType`,`Clicky`,`Address`,`UName`,`hidden`) ".
-"VALUES ('$cust','$date','$group','$cred','$credtype','$clicky','$address','$uname','$hidden')";
+$sql = "INSERT INTO #__Cred (`cust`,`Added`,`Group`,`Hash`,`CredType`,`Clicky`,`Address`,`UName`,`hidden`,`comment`) ".
+"VALUES ('$cust','$date','$group','$cred','$credtype','$clicky','$address','$uname','$hidden','$comment')";
 $this->setQuery($sql);
 
 $id = $this->insertID();

--- a/views/Creds/add.php
+++ b/views/Creds/add.php
@@ -21,6 +21,7 @@
   $addr = BTMain::getVar('frmAddress');
   $user = BTMain::getVar('frmUser');
   $hidden = BTMain::getVar('frmHidden');
+  $comment = BTMain::getVar('frmComment');
   
   if (!BTMain::getConnTypeSSL()){
 	    $crypt = new Crypto;
@@ -28,10 +29,11 @@
 	    $cred = $crypt->xordstring(base64_decode($cred),$tlskey);
 	    $addr = $crypt->xordstring(base64_decode($addr),$tlskey);
 	    $user = $crypt->xordstring(base64_decode($user),$tlskey);
+	    $comment = $crypt->xordstring(base64_decode($comment),$tlskey);
 	 }
 
 
-  $newcred = $creds->addCred(BTMain::getVar('cust'),BTMain::getVar('FrmCredType'),$cred,BTMain::getVar('frmClicky'),BTMain::getVar('frmGroup'),$addr,$user,$hidden);
+  $newcred = $creds->addCred(BTMain::getVar('cust'),BTMain::getVar('FrmCredType'),$cred,$comment,BTMain::getVar('frmClicky'),BTMain::getVar('frmGroup'),$addr,$user,$hidden);
   // Add the cred to the db
   if ($newcred){
   // Success
@@ -122,6 +124,8 @@
 <label for="frmCredential"><?php echo Lang::_("Password");?></label><textarea id="frmCredential" name="frmCredential"></textarea>
 <a href="javascript: genPwd('frmCredential',10);">Generate Password</a>
 
+<label for="frmComment"><?php echo Lang::_("Comment");?></label><input type="text" name="frmComment" id="frmComment">
+
 <label for="frmAddress"><?php echo Lang::_("Address");?></label><input type="text" name="frmAddress" id="frmAddress">