Commit 438752e7 authored by chealer's avatar chealer

Contact Us: cleanup code duplication from anonymous vs non-anonymous and...

Contact Us: cleanup code duplication from anonymous vs non-anonymous and generally update to current standards
parent 27a105a3
{title}{tr}Contact Us{/tr}{/title}
{if $prefs.feature_messages eq 'y' and $tiki_p_messages eq 'y' or $prefs.contact_anon eq 'y'}
{if $message}<br />
<div class="simplebox highlight">{if $sent ne '1'}{icon _id=exclamation style="vertical-align:middle" alt="{tr}Error{/tr}"}{else}{icon _id=accept alt="{tr}OK{/tr}" style="vertical-align:middle;"}{/if} {$message}</div>
<br />
{/if}
{if $sent ne '1'}
<h2>{tr}Send a message to us{/tr}</h2>
<form method="post" action="tiki-contact.php">
<input type="hidden" name="to" value="{$prefs.contact_user|escape}" />
<table class="formcolor">
<tr>
<td>{tr}Priority:{/tr}</td>
<td style="width:99%">
<select name="priority">
<option value="1" {if $priority eq 1}selected="selected"{/if}>1 -{tr}Lowest{/tr}-</option>
<option value="2" {if $priority eq 2}selected="selected"{/if}>2 -{tr}Low{/tr}-</option>
<option value="3" {if $priority eq 3}selected="selected"{/if}>3 -{tr}Normal{/tr}-</option>
<option value="4" {if $priority eq 4}selected="selected"{/if}>4 -{tr}High{/tr}-</option>
<option value="5" {if $priority eq 5}selected="selected"{/if}>5 -{tr}Very High{/tr}-</option>
</select>
</td>
</tr>
{if $user eq ''}
<tr>
<td>{tr}From:{/tr}</td>
<td>
<input type="text" name="from" value="{$from}" maxlength="255" style="width:25%" />
</td>
</tr>
{/if}
<tr>
<td>{tr}Subject:{/tr}</td>
<td>
<input type="text" name="subject" value="{$subject}" maxlength="255" style="width:99%" />
</td>
</tr>
<tr>
<td>{tr}Message:{/tr}</td>
<td>
{textarea rows="20" name="body" cols="80" _simple='y' _toolbars='n' }{$body}{/textarea}
</td>
</tr>
{if $prefs.feature_antibot eq 'y' && $user eq ''}
{include file='antibot.tpl' td_style="form"}
{/if}
<tr>
<td></td>
<td>
<input type="submit" name="send" value="{tr}Send{/tr}" />
</td>
</tr>
</table>
</form>
{/if}
{if strlen($email)>0}
<h2>{tr}Contact us by email{/tr}</h2>
{tr}Click here to send us an email:{/tr} {mailto text="$email" address="$email0" encode="javascript" extra='class="link"'}
{else}
<p><a class="link" href="tiki-contact.php">{tr}Send another message{/tr}</a></p>
{if $sent eq '1'}
{remarksbox icon="accept" title="{tr}Success{/tr}"}{$message}{/remarksbox}
{else}
<h2>{tr}Send a message to us{/tr}</h2>
{if isset($errorMessage)}
{remarksbox title="Invalid" type="errors"}{$errorMessage}{/remarksbox}
{/if}
<form method="post" action="tiki-contact.php">
{ticket}
<input type="hidden" name="to" value="{$prefs.contact_user|escape}" />
<table class="formcolor">
<tr>
<td>{tr}Priority:{/tr}</td>
<td style="width:99%">
<select name="priority">
<option value="1" {if $priority eq 1}selected="selected"{/if}>1 -{tr}Lowest{/tr}-</option>
<option value="2" {if $priority eq 2}selected="selected"{/if}>2 -{tr}Low{/tr}-</option>
<option value="3" {if $priority eq 3}selected="selected"{/if}>3 -{tr}Normal{/tr}-</option>
<option value="4" {if $priority eq 4}selected="selected"{/if}>4 -{tr}High{/tr}-</option>
<option value="5" {if $priority eq 5}selected="selected"{/if}>5 -{tr}Very High{/tr}-</option>
</select>
</td>
</tr>
{if $user eq ''}
<tr>
<td>{tr}From:{/tr}</td>
<td>
<input type="text" name="from" value="{$from}" maxlength="255" style="width:25%" />
</td>
</tr>
{/if}
<tr>
<td>{tr}Subject:{/tr}</td>
<td>
<input type="text" name="subject" value="{$subject}" maxlength="255" style="width:99%" />
</td>
</tr>
<tr>
<td>{tr}Message:{/tr}</td>
<td>
{textarea rows="20" name="body" cols="80" _simple='y' _toolbars='n' }{$body}{/textarea}
</td>
</tr>
{if $prefs.feature_antibot eq 'y' && $user eq ''}
{include file='antibot.tpl' td_style="form"}
{/if}
<tr>
<td></td>
<td>
<input type="submit" name="send" value="{tr}Send{/tr}" />
</td>
</tr>
</table>
</form>
{/if}
{if strlen($email)>0}
<h2>{tr}Contact us by email{/tr}</h2>
{tr}Click here to send us an email:{/tr} {mailto text="$email" address="$email0" encode="javascript" extra='class="link"'}
{else}
<p><a class="link" href="tiki-contact.php">{tr}Send another message{/tr}</a></p>
{/if}
......@@ -15,73 +15,55 @@ $access->check_feature(array('feature_contact', 'feature_messages'));
$auto_query_args = array();
$smarty->assign('mid', 'tiki-contact.tpl');
if ($user == '') {
if ($user) {
$access->check_permission('tiki_p_messages');
} else {
$access->check_feature('contact_anon');
$smarty->assign('sent', 0);
if (isset($_REQUEST['send'])) {
check_ticket('contact');
}
$message = '';
// Validation:
// must have a subject or body non-empty (or both)
if (empty($_REQUEST['subject']) && empty($_REQUEST['body']) || empty($_REQUEST['from'])) {
$smarty->assign('message', tra('ERROR: you must include a subject or a message. You must also make sure to have a valid e-mail in the FROM field'));
$smarty->assign('priority', $_REQUEST['priority']);
$smarty->assign('sent', 0);
if (!empty($_REQUEST['from'])) $smarty->assign_by_ref('from', $_REQUEST['from']);
if (!empty($_REQUEST['subject'])) $smarty->assign_by_ref('subject', $_REQUEST['subject']);
if (!empty($_REQUEST['body'])) $smarty->assign_by_ref('body', $_REQUEST['body']);
if (!empty($_REQUEST['priority'])) $smarty->assign_by_ref('priority', $_REQUEST['priority']);
$priority = 3;
$from = $user ? $user : '';
$subject = '';
$body = '';
if (isset($_REQUEST['send'])) {
if (isset($_REQUEST['priority'])) {
$priority = $_REQUEST['priority'];
}
if (!$user && isset($_REQUEST['from'])) {
$from = $_REQUEST['from'];
}
if (isset($_REQUEST['subject'])) {
$subject = $_REQUEST['subject'];
}
if (isset($_REQUEST['body'])) {
$body = $_REQUEST['body'];
}
}
$smarty->display("tiki.tpl");
die;
}
if ($prefs['feature_antibot'] == 'y') {
if(!$captchalib->validate()) {
$smarty->assign('message', $captchalib->getErrors());
$smarty->assign('errortype', 'no_redirect_login');
if (!empty($_REQUEST['from'])) $smarty->assign_by_ref('from', $_REQUEST['from']);
if (!empty($_REQUEST['subject'])) $smarty->assign_by_ref('subject', $_REQUEST['subject']);
if (!empty($_REQUEST['body'])) $smarty->assign_by_ref('body', $_REQUEST['body']);
if (!empty($_REQUEST['priority'])) $smarty->assign_by_ref('priority', $_REQUEST['priority']);
$smarty->display("tiki.tpl");
die;
}
if (isset($_REQUEST['send'])) {
// Validation:
// must have a subject or body non-empty (or both)
$hasContent = !empty($_REQUEST['subject']) || !empty($_REQUEST['body']);
$failsCaptcha = !$user && $prefs['feature_antibot'] == 'y' && !$captchalib->validate();
if (!$hasContent || empty($from) || $failsCaptcha) {
if (!$hasContent) {
$message = tra("You must include a subject or a message.");
} elseif (empty($from)) {
$message = tra("You must make sure to have a valid e-mail address in the From field.");
} else {
$message = $captchalib->getErrors();
}
$smarty->assign('sent', 1);
$body = tr("%0 sent you a message:", $_REQUEST['from']) . "\n" . $_REQUEST['body'];
$messulib->post_message($prefs['contact_user'], $_REQUEST['from'], $_REQUEST['to'],
$smarty->assign('errorMessage', $message);
} else {
$access->check_ticket();
$body = tr("%0 sent you a message:", $from) . "\n" . $_REQUEST['body'];
$messulib->post_message($prefs['contact_user'], $from, $_REQUEST['to'],
'', $_REQUEST['subject'], $body, $_REQUEST['priority']);
$message = tra('Message sent to'). ': ' . $prefs['contact_user'] . '<br />';
$smarty->assign('message', $message);
}
} else {
$access->check_permission('tiki_p_messages');
$smarty->assign('sent', 0);
if (isset($_REQUEST['send'])) {
check_ticket('contact');
$message = '';
// Validation:
// must have a subject or body non-empty (or both)
if (empty($_REQUEST['subject']) && empty($_REQUEST['body'])) {
$smarty->assign('message', tra('ERROR: Either the subject or body must be non-empty'));
$smarty->display("tiki.tpl");
die;
}
$smarty->assign('sent', 1);
$message = tra('Message sent to'). ': ' . $prefs['contact_user'] . '<br />';
$body = tra("{$user} sent you a message:") . "\n" . $_REQUEST['body'];
$messulib->post_message($prefs['contact_user'], $user, $_REQUEST['to'],
'', $_REQUEST['subject'], $body, $_REQUEST['priority']);
$smarty->assign('message', $message);
}
}
......@@ -92,7 +74,10 @@ $smarty->assign('email0', $email);
$email = scrambleEmail($email, $tikilib->get_user_preference('admin', "email is public"));
$smarty->assign('email', $email);
$smarty->assign('priority', 3);
ask_ticket('contact');
$smarty->assign('priority', $priority);
$smarty->assign('from', $from);
$smarty->assign('subject', $subject);
$smarty->assign('body', $body);
$smarty->assign('mid', 'tiki-contact.tpl');
$smarty->display("tiki.tpl");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment