$xpdo xPDO */ $sp = $scriptProperties; if ($mode != modSystemEvent::MODE_UPD || ! is_object($modx) || !empty($modx->xpdo->config[xPDO::OPT_SETUP])) { return ''; } $sendActivation = $modx->getOption('sendOnActivation',$sp,true) ? true : false; $sendDeactivation = $modx->getOption('sendOnDeactivation',$sp,false) ? true : false; $activationEmailTpl = $modx->getOption('activationEmailTpl',$sp,'ActivationEmailTpl'); $deactivationEmailTpl = $modx->getOption('deactivationEmailTpl',$sp,'DeactivationEmailTpl'); /* get the system setting */ $emailSender = $modx->getOption('emailsender'); /* This won't be used if activeReplyTo or deActiveReplyTo are set */ $replyTo = $modx->getOption('replyToAddress',$sp, null); $replyTo = empty($replyTo) ? $emailSender : $replyTo; /* This won't be used if activeFromName or deActiveFromName are set */ $fromName = $modx->getOption('fromName', $sp, null); $fromName = empty($fromName) ? $modx->getOption('site_name'): $fromName; /* If you hard-code these in the email templates, the settings of * these properties be ignored. Otherwise, the system settings will * be used unless the properties are set. */ $siteName = $modx->getOption('sitename',$sp); $siteName = empty($siteName)? $modx->getOption('site_name') : $siteName; $activeURL = $modx->getOption('activationURL', $sp,null); $activeURL = empty($activeURL)? $modx->getOption('site_url') : $activeURL ; $deActiveURL = $modx->getOption('deactivationURL', $sp,null); $deActiveURL = empty($deActiveURL)? $modx->getOption('site_url') : $deActiveURL ; $profile = $user->getOne('Profile'); $email = $profile->get('email'); $useFullName = $modx->getOption('useFullName', $sp, false); $name = $useFullname ? $profile->get('fullname') : $user->get('username'); $id = $user->get('id'); $dbUser = $modx->getObject('modUser',$id); $before = $dbUser->get('active'); $after = $user->get('active'); $fullName = $profile->get('fullname'); $fields = array( 'fullname' => $fullName, 'username' => $name, 'sitename' => $siteName, 'activationURL' => $activeURL, 'deactivationURL' => $deActiveURL, ); $send = false; if ($sendActivation && (empty($before) && $after)) { /* activation */ $_sender = $modx->getOption('activeSender', $sp, null); $_sender = empty($_sender)? $emailSender : $_sender; $_reply = $modx->getOption('activeReplyTo', $sp, null); $_reply = empty($_reply)? $replyTo : $_reply; $_from = $modx->getOption('activeFrom', $sp, null); $_from = empty($_from)? $emailSender : $_from; $_fromName = $modx->getOption('activeFromName', $sp, null); $_fromName = empty($_fromName)? $fromName : $_fromName; $fields['fromName'] = $_fromName; $subject = $modx->getOption('activeSubject', $sp,null); $_subject = empty($subject)? 'Registration Approved' : $subject ; $_msg = $modx->getChunk($activationEmailTpl,$fields); $send = true; $eventName = 'activate_user'; if (empty($_msg)) { $_msg = "
Dear " . $name . ",
Thank you for registering at " . $siteName . '.
Your registration has been approved and you may now access the Members area, please login here.
'; $_msg .= "Kind Regards,
Site Administrator
Dear " . $name . ',
Your status at ' . $siteName . ' has been changed to "inactive." '. 'If you believe this is an error please contact the site administrator at ' . $deActiveURL . '.
'; $_msg .= "Kind Regards,
Site Administrator