Skip to content

Commit

Permalink
Add a checkbox to send an email to the user after the account creatio…
Browse files Browse the repository at this point in the history
…n. Still not functional
  • Loading branch information
jorgelzpz committed Mar 26, 2013
1 parent 46c670a commit b0ba878
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dictionaries/userregistration.definition.json
Expand Up @@ -331,5 +331,14 @@
},
"didnt_receive_verification_email": {
"en": "Didn't receive the verification email?"
},
"sendemail": {
"en": "Send details to user"
},
"mailNew_admin_header": {
"en": "Account created at %SNAME%"
},
"mailNew_admin_intro": {
"en": "An account for you has been created at %SNAME%. Your account credentials follow:"
}
}
9 changes: 9 additions & 0 deletions dictionaries/userregistration.translation.json
Expand Up @@ -431,5 +431,14 @@
},
"didnt_receive_verification_email": {
"es": "¿No recibió el email de verificación?"
},
"sendemail": {
"es": "Enviar detalles al usuario"
},
"mailNew_admin_header": {
"es": "Cuenta creada en %SNAME%"
},
"mailNew_admin_intro": {
"es": "Ha sido creada una cuenta para usted en %SNAME%. Encontrará sus credenciales a continuación:"
}
}
20 changes: 20 additions & 0 deletions lib/XHTML/Form.php
Expand Up @@ -15,6 +15,7 @@ class sspmod_userregistration_XHTML_Form {
private $submitName = 'sender';
private $submitValue = 'Submit';
private $tos = false;
private $sendemail = false;


public function __construct($fieldsDef = array(), $actionEndpoint = NULL){
Expand Down Expand Up @@ -62,6 +63,10 @@ public function addTOS($tos){
$this->tos = $tos;
}

public function addSendEmail($sendemail){
$this->sendemail = $sendemail;
}

/*
* String: field name
* or array of fieldnames
Expand Down Expand Up @@ -201,6 +206,18 @@ private function writeTOS($tos){
return $html;
}

private function writeSendEmail()
{
$template = new SimpleSAML_XHTML_Template(
SimpleSAML_Configuration::getInstance(),
'userregistration:step1_register.tpl.php',
'userregistration:userregistration');

$html = '<tr><td></td><td><input type="checkbox" name="sendemail" id="sendemail" value="sendemail"><label for="sendemail"> '.$template->t('sendemail').'</label></td></tr>';
return $html;
}


private function writeCountrySelect($value, $attr){
if(empty($value)) {
$value = 'US';
Expand Down Expand Up @@ -474,6 +491,9 @@ public function genFormHtml(){
if ($this->tos) {
$html .= $this->writeTOS($this->tos);
}
if ($this->sendemail) {
$html .= $this->writeSendEmail();
}
$html .= $this->writeFormSubmit();

$html .= $this->writeFormEnd();
Expand Down
9 changes: 9 additions & 0 deletions templates/mail_admin_created_account.tpl.php
@@ -0,0 +1,9 @@
<h1><?php echo $this->t('mailNew_admin_header', $this->data['systemName']);?></h1>

<p><?php echo $this->t('mailNew_admin_intro', $this->data['systemName']);?></p>
<ul>
<li>Nombre de usuario: <tt><?php echo $this->data['email']; ?></tt></li>
<li>Contraseña: <tt><?php echo $this->data['email']; ?></tt></li>
</ul>

<p><?php echo $this->t('mail1_signature', $this->data['systemName']);?></p>
6 changes: 6 additions & 0 deletions www/admin_newUser.php
Expand Up @@ -33,6 +33,10 @@

$store->addUser($userInfo);

if (isset($_POST['sendemail'])) {
echo "Se supone que lo avisaría";
}

$html = new SimpleSAML_XHTML_Template(
$config,
'userregistration:admin_create_complete.tpl.php',
Expand All @@ -54,6 +58,7 @@

$values = $validator->getRawInput();

$formGen->addSendEmail(true);
$formGen->setValues($values);
$formGen->setSubmitter('register');

Expand Down Expand Up @@ -88,6 +93,7 @@
$formGen->setReadOnly($readOnlyFields);

$formGen->setSubmitter('register');
$formGen->addSendEmail(true);
$formHtml = $formGen->genFormHtml();

$html = new SimpleSAML_XHTML_Template(
Expand Down
3 changes: 2 additions & 1 deletion www/resources/userregistration.css
Expand Up @@ -71,7 +71,8 @@ table.users td.teacher{
text-align: center;
}

label[for=tos] {
label[for=tos],
label[for=sendemail] {
display: inline;
vertical-align: middle;
}

0 comments on commit b0ba878

Please sign in to comment.