google-code-export / cpassman

Automatically exported from code.google.com/p/cpassman
0 stars 0 forks source link

Notifications on Editing Items #216

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Right now even when you assign users to be notified on a particular password, 
they only get notified when creating a new password. But, for example, if you 
change the password of an existing account, they will not be notified.

I manually modified the code in the items.queries.php to send mail also on 
edit, and I added a line in the languages file to represent a different subject 
title for editing (as opposed to a new item that was created).

I would like to suggest this be included as well, since we at least, and I 
assume others, modify passwords here and there, and it would be great if the 
app supported notifying the users of that item.

Original issue reported on code.google.com by r0bertc...@gmail.com on 15 Dec 2011 at 9:06

GoogleCodeExporter commented 9 years ago
Thank you for your suggestion.

Can you provide your modifications so that I can add it in the next release.

Thanks

Original comment by nils.cpa...@gmail.com on 15 Dec 2011 at 9:47

GoogleCodeExporter commented 9 years ago
In the file items.queries.php, under the section which begins with:

        /*
        * CASE
        * update an ITEM
        */
        case "update_item":

I added the following lines (basically copying the same code you added already 
in the create new item section above):

I added this code immediately following the lines:

                //Update CACHE table
                UpdateCacheTable("update_value", $data_received['id']);

                // This whole section added by Reuv                
                    //Announce by email?
                    if ( $data_received['annonce'] == 1 ){
                        require_once("../includes/libraries/phpmailer/class.phpmailer.php");
                        //envoyer email
                        $destinataire= explode(';',$data_received['diffusion']);
                        foreach($destinataire as $mail_destinataire){
                            //envoyer ay destinataire
                            $mail = new PHPMailer();
                            $mail->SetLanguage("en","../includes/libraries/phpmailer/language");
                            $mail->IsSMTP();                                   // send via SMTP
                            $mail->Host     = $smtp_server; // SMTP servers
                            $mail->SMTPAuth = $smtp_auth;     // turn on SMTP authentication
                            $mail->Username = $smtp_auth_username;  // SMTP username
                            $mail->Password = $smtp_auth_password; // SMTP password
                            $mail->From     = $email_from;
                            $mail->FromName = $email_from_name;
                            $mail->AddAddress($mail_destinataire);     //Destinataire
                            $mail->WordWrap = 80;                              // set word wrap
                            $mail->IsHTML(true);                               // send as HTML
                            $mail->Subject  =  $txt['email_itemedit_subject'];
                            $mail->AltBody     =  $txt['email_altbody_1']." ".mysql_real_escape_string(stripslashes(($_POST['label'])))." ".$txt['email_altbody_2'];
                            $corpsDeMail = $txt['email_body_1'].mysql_real_escape_string(stripslashes(($_POST['label']))).$txt['email_body_2'].
                            $_SESSION['settings']['cpassman_url']."/index.php?page=items&group=".$_POST['categorie']."&id=".$new_id.$txt['email_body_3'];
                            $mail->Body  =  $corpsDeMail;
                            $mail->Send();
                        }
                    }

                    // End of section added by Reuv

Finally, I added this piece into the languages files (I'm using english so I 
put it there):
$txt['email_itemedit_subject'] = "A password has been modified in TeamPass";

Obviously, the text there could be changed to whatever works for you. :-)

Keep up the good work,
Reuv

Original comment by r0bertc...@gmail.com on 18 Dec 2011 at 7:16

GoogleCodeExporter commented 9 years ago
Code modification (error pointed out by my colleague):

$_SESSION['settings']['cpassman_url']."/index.php?page=items&group=".$data_recei
ved['categorie']."&id=".$data_received['id'].$txt['email_body_3'];

The above replaces the similar line in the code above which wasn't working 
properly.

Reuv

Original comment by r0bertc...@gmail.com on 19 Dec 2011 at 1:02