Beispiel #1
0
<?php

$logs = new Model_Mailform_Log();
$logs->order('`read`, datesubmitted DESC');
$logs->where('hidden = ?', 0);
// filter by the given id
if (!empty($_REQUEST['mailformid'])) {
    $logs->where('mailformid = ?', $_REQUEST['mailformid']);
}
$pagination = Pagination::Calculate(count($logs));
$logs->paginate($pagination['page'], $pagination['perpage']);
foreach ($logs->select() as $log) {
    $log['read'] = 1;
    $log->save();
}
$pm->setVariable('log', $logs);
$pm->setVariable('pagination', $pagination);
Beispiel #2
0
    Typeframe::Redirect('Invalid mailform specified.', TYPEF_WEB_DIR . '/', -1);
    return;
}
$pm->setVariable('mailform', $mailform);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $formHandler = new Form_Handler_Mailform($mailform['formfields'], $mailform['captcha']);
    if ($formHandler->validate()) {
        // Collect the form and submission data
        $inputs = $formHandler->input();
        $submission = array();
        foreach ($mailform['formfields'] as $field) {
            $submission[$field['key']] = $field;
            $submission[$field['key']]['value'] = $inputs[$field['key']];
        }
        // Log the submission
        $log = Model_Mailform_Log::Create();
        $log['mailformid'] = @$_REQUEST['mailformid'];
        $log['submission'] = $submission;
        $log['referrer'] = @$_SESSION['external_referrer'];
        $log->save();
        $pm->setVariable('submission', $submission);
        // Email the submission
        $sendTo = array();
        foreach ($mailform['recipients'] as $r) {
            if ($r['when'] == 'always') {
                $sendTo[] = array('name' => $r['name'], 'email' => $r['email']);
            } else {
                if (@$submission[$r['fieldname']]['value'] == @$r['fieldvalue']) {
                    $sendTo[] = array('name' => $r['name'], 'email' => $r['email']);
                }
            }
Beispiel #3
0
<?php

$mailform = Model_Mailform::Get($_REQUEST['mailformid']);
if ($mailform->exists()) {
    include 'form.inc.php';
    $log = new Model_Mailform_Log();
    $log->where('mailformid = ?', $_REQUEST['mailformid']);
    /*if ($log->count()) {
    		Typeframe::Redirect(
    			'This mailform has submissions. If you want to change the fields, it is recommended that you create a new mailform instead.',
    			Typeframe::CurrentPage()->applicationUri(), -1);
    		return;
    	}*/
    $pm->setVariable('mailform', $mailform);
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        require_once 'update.inc.php';
        Typeframe::Redirect('Mailform updated.', Typeframe::CurrentPage()->applicationUri());
    }
} else {
    Typeframe::Redirect('Invalid mailform specified.', Typeframe::CurrentPage()->applicationUri());
}
Beispiel #4
0
<?php

/*
	Mailform read/unread controller

	12 july 2011: created
*/
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// get and validate log id; delete it
$logid = trim(@$_GET['logid']);
$log = Model_Mailform_Log::Get($logid);
if (!$log->exists()) {
    Typeframe::Redirect('Requested submission log entry does not exist', $typef_app_dir);
    return;
}
// get mailform id
$mailformid = $log->get('mailformid');
$typef_app_dir = "{$typef_app_dir}/log?mailformid={$mailformid}";
// determine current state
$read = $log->get('read');
$what = 0 == $read ? 'read' : 'unread';
// toggle state
$log->set('read', 0 == $read ? 1 : 0);
$log->save();
// done; go back to listing
Typeframe::Redirect("Submission log entry marked as {$what}.", $typef_app_dir);
return;