We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4310
    • 2,310 Posts
    I’ve taken over the coding side of a site from a previous MODx developer and forum member Rachel Black, who sadly died earlier this year.
    There is a plugin that sends an email and writes two event log entries when a web user is changed from blocked to unblocked.
    It works fine in Firefox 2 on an XP SP2 machine and Firefox 3 on a Mac, but in Safari & IE7 no email or log entry.
    Can anyone think of an explanation?
    The code is below and the plugin is set to run on System Events => OnWUsrFormSave
    $e = &$modx->Event; 
    
    $p = print_r($_POST, true);
    
    
    if ($e->name == 'OnWUsrFormSave') {
      $wasBlocked = $_POST['blockedmode'];
      $blocked = $_POST['blocked'];
      if ($wasBlocked && !$blocked) {
        $modx->logEvent(1,3,"$p", 'OnWUsrFormSave - Send Email');
        $link = $this->config['site_url'].'index.php?id=281';  
        
        $message = $modx->getChunk('RegisteredEmail');
        $message = str_replace("[+name+]", $_POST['fullname'], $message);
        $message = str_replace("[+group+]", $_POST['group'], $message);
        $message = str_replace("[+link+]", $link, $message);
        
        $to = $_POST['email'];
        $subject = "$site_name Website registration";
        $sender = $modx->config['emailsender'];
        
    		include_once  $modx->config['filemanager_path'].'manager/includes/controls/class.phpmailer.php';
    		$mail = new PHPMailer();
    		$mail->IsMail();
    		$mail->IsHTML(true);
    		$mail->From			= $sender;
    		$mail->FromName	= $modx->config['site_name'];
    		$mail->Subject	= $subject;
    		$mail->Body	    = $message;
    		$mail->AddAddress($to);
    		$mail->send(); 
       
        $modx->logEvent(1,3,"$to, $subject, $message, $sender", "Email");
      } 
    }
      • 5340
      • 1,624 Posts
      have you checked the values of the POST variables?

      Where are they taken from?
        • 4310
        • 2,310 Posts
        This is the array info being written into the event log, but just to emphasise this only happens with Firefox.
        Array ( [mode] => 88 [id] => 72 [blockedmode] => 1 [stay] => [oldusername] => test [newusername] => test [newpassword] => 0 [passwordgenmethod] => g [specifiedpassword] => [confirmpassword] => [passwordnotifymethod] => s [fullname] => Test User [email] => [email protected] [oldemail] => [email protected] [phone] => [mobilephone] => [country] => [dob] => [gender] => [comment] => [zip] => [state] => [fax] => [failedlogincount] => 0 [blocked] => 0 [blockeduntil] => [blockedafter] => [login_home] => [allowed_ip] => [photo] => [user_groups] => Array ( [0] => 3 ) [save] => Submit Query )
          • 7231
          • 4,205 Posts
          I don’t see how the browser could effect this? This would make me think that it could be JS related but not sure how. What version of modx is this site using? I remember there being an update to a manager that addressed an issue with a js bug (sorry I can’t be more specific).
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 4310
            • 2,310 Posts
            MODx version 0.9.6
            I thought about the JS, but the update process of the web user works in all browsers and that uses JS.
            Yet the plugin is pure PHP and fails in IE7 & Safari.
              • 5340
              • 1,624 Posts
              Quote from: bunk58 at Aug 12, 2008, 01:34 PM

              This is the array info being written into the event log, but just to emphasise this only happens with Firefox.
              Array ( [mode] => 88 [id] => 72 [blockedmode] => 1 [stay] => [oldusername] => test [newusername] => test [newpassword] => 0 [passwordgenmethod] => g [specifiedpassword] => [confirmpassword] => [passwordnotifymethod] => s [fullname] => Test User [email] => [email protected] [oldemail] => [email protected] [phone] => [mobilephone] => [country] => [dob] => [gender] => [comment] => [zip] => [state] => [fax] => [failedlogincount] => 0 [blocked] => 0 [blockeduntil] => [blockedafter] => [login_home] => [allowed_ip] => [photo] => [user_groups] => Array ( [0] => 3 ) [save] => Submit Query )



              If so than everything below this line is not executed

              if ($wasBlocked && !$blocked) {

              And since these are POST variables IE might not send the values correctly. Do you have a test link?
              Maybe they are empty. Try using Firebug to see the posted values or you can display them somehow before they are processed.

              Add a

              var_dump($_POST)

              before the decision
                • 4310
                • 2,310 Posts
                This is hat I have from the POST Array for various updating the web users blocked state :

                IE7 unblocking
                Array ( [mode] => 88 [id] => 72 [blockedmode] => 0 [stay] [blocked] => 0


                IE7 blocking

                Array ( [mode] => 88 [id] => 72 [blockedmode] => 1 [stay] [blockedcheck] => on [blocked] => 1


                FF unblocking
                Array ( [mode] => 88 [id] => 72 [blockedmode] => 1[blocked] => 0


                FF blocking

                Array ( [mode] => 88 [id] => 72 [blockedmode] => 0 [blockedcheck] => on [blocked] => 1
                

                So it would seem as if the POST value of [blockedmode] is different in IE7.
                Is it updating the [blockedmode] value to the current [blocked] value instead of keeping it’s initial value?
                I’ll try this on another site that hasn’t had as much work done on it and report back.
                UPDATE
                Same thing on another site, IE7 posting wrong [blockedmode] value