Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions controllers/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function index()
$contactEmails[$contact->id]['label'] = CONTACTUS_BOL_Service::getInstance()->getDepartmentLabel($contact->id);
$contactEmails[$contact->id]['email'] = $contact->email;
}

$config = OW::getConfig();
$userService = BOL_UserSerivce::getInstance();
$user = OW::getUser();

$form = new Form('contact_form');

Expand All @@ -64,15 +68,33 @@ public function index()
$fieldTo->setHasInvitation(false);
$fieldTo->setLabel($this->text('contactus', 'form_label_to'));
$form->addElement($fieldTo);

$fieldName = new TextField('name');
$fieldName->setLabel($this->text('contactus', 'form_label_name')); // TODO: Add language string in langs.zip
$fieldName->setRequired();

if ( $user->isAuthenticated() )
{
if ( $config->getValue('base', 'display_name_question') == 'username' )
{
$fieldName->setValue($userService->getUserName($user->getId()));
}
else if ( $config->getValue('base', 'display_name_question') == 'realname' )
{
$fieldName->setValue($userService->getDisplayName($user->getId()));
}
}

$form->addElement($fieldName);

$fieldFrom = new TextField('from');
$fieldFrom->setLabel($this->text('contactus', 'form_label_from'));
$fieldFrom->setRequired();
$fieldFrom->addValidator(new EmailValidator());

if ( ow::getUser()->isAuthenticated() )
if ( $user->isAuthenticated() )
{
$fieldFrom->setValue( OW::getUser()->getEmail() );
$fieldFrom->setValue( $user->getEmail() );
}

$form->addElement($fieldFrom);
Expand Down Expand Up @@ -111,7 +133,7 @@ public function index()

$mail = OW::getMailer()->createMail();
$mail->addRecipientEmail($contactEmails[$data['to']]['email']);
$mail->setSender($data['from']);
$mail->setSender($data['from'], $data['name']);
$mail->setSenderSuffix(false);
$mail->setSubject($data['subject']);
$mail->setTextContent($data['message']);
Expand Down Expand Up @@ -145,4 +167,4 @@ private function text( $prefix, $key, array $vars = null )
{
return OW::getLanguage()->text($prefix, $key, $vars);
}
}
}
10 changes: 7 additions & 3 deletions views/controllers/contact_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
<td class="ow_value">{input name='to'}{error name='to'}</td>
</tr>
<tr class="ow_alt2">
<td class="ow_label">{label name='name'}</td>
<td class="ow_value">{input name='name'}{error name='name'}</td>
</tr>
<tr class="ow_alt1">
<td class="ow_label">{label name='from'}</td>
<td class="ow_value">{input name='from'}{error name='from'}</td>
</tr>
<tr class="ow_alt1">
<tr class="ow_alt2">
<td class="ow_label">{label name='subject'}</td>
<td class="ow_value">{input name='subject'}{error name='subject'}</td>
</tr>
<tr class="ow_alt2">
<tr class="ow_alt1">
<td class="ow_label">{label name='message'}</td>
<td class="ow_value">{input name='message'}{error name='message'}</td>
</tr>
<tr class="ow_alt1 ow_tr_last">
<tr class="ow_alt2 ow_tr_last">
<td class="ow_label">{label name='captcha'}</td>
<td class="ow_value ow_center">{input name='captcha'}{error name='captcha'}</td>
</tr>
Expand Down