function perch_forms_form_handler($SubmittedForm) { if ($SubmittedForm->validate()) { $API = new PerchAPI(1.0, 'perch_forms'); $Forms = new PerchForms_Forms($API); $formKey = $SubmittedForm->id; $Form = $Forms->find_by_key($formKey); if (!is_object($Form)) { $data = array(); $data['formKey'] = $formKey; $data['formTemplate'] = $SubmittedForm->templatePath; $data['formOptions'] = PerchUtil::json_safe_encode(array('store' => true)); $attrs = $SubmittedForm->get_form_attributes(); if ($attrs->label()) { $data['formTitle'] = $attrs->label(); } else { $data['formTitle'] = PerchUtil::filename($formKey, false); } $Form = $Forms->create($data); } if (is_object($Form)) { $Form->process_response($SubmittedForm); } } $Perch = Perch::fetch(); PerchUtil::debug($Perch->get_form_errors($SubmittedForm->formID)); }
public function mark_as_spam() { $data = array(); $data['responseSpam'] = '1'; $this->update($data); $json = PerchUtil::json_safe_decode($this->responseSpamData(), true); if (PerchUtil::count($json)) { $API = new PerchAPI(1, 'perch_forms'); $Forms = new PerchForms_Forms($API); $Form = $Forms->find($this->formID()); if ($Form) { $opts = $Form->get_settings(); if (isset($opts['akismet']) && $opts['akismet']) { if (isset($opts['akismetAPIKey']) && $opts['akismetAPIKey'] != '') { PerchForms_Akismet::submit_spam($opts['akismetAPIKey'], $json['fields'], $json['environment']); } } } } }
<?php $Forms = new PerchForms_Forms($API); $HTML = $API->get('HTML'); $forms = $Forms->all(); if (PerchUtil::count($forms) == 0) { // Install $Forms->attempt_install(); }
<?php $Forms = new PerchForms_Forms($API); $Responses = new PerchForms_Responses($API); $HTML = $API->get('HTML'); $Paging = $API->get('Paging'); $Paging->set_per_page(10); $filter = 'all'; if (isset($_GET['id']) && $_GET['id'] != '') { $Form = $Forms->find($_GET['id']); $spam = false; if (isset($_GET['spam']) && ($_GET['spam'] = 1)) { $spam = true; $filter = 'spam'; } $responses = $Responses->get_for_from($_GET['id'], $Paging, $spam); } else { PerchUtil::redirect($API->app_path()); }
<?php if (!$CurrentUser->has_priv('perch_forms.delete')) { exit; } $Forms = new PerchForms_Forms($API); $HTML = $API->get('HTML'); $Form = $API->get('Form'); $Form->set_name('delete'); $message = false; if (isset($_GET['id']) && $_GET['id'] != '') { $ThisForm = $Forms->find($_GET['id'], true); } else { PerchUtil::redirect($API->app_path()); } if ($Form->submitted()) { if (is_object($ThisForm)) { $ThisForm->delete(); if ($Form->submitted_via_ajax) { echo $API->app_path(); exit; } else { PerchUtil::redirect($API->app_path() . '/'); } } else { $message = $HTML->failure_message('Sorry, that form could not be deleted.'); } } $details = $ThisForm->to_array();
<?php include 'PerchForms_Forms.class.php'; include 'PerchForms_Form.class.php'; include 'PerchForms_Responses.class.php'; include 'PerchForms_Response.class.php'; $API = new PerchAPI(1.0, 'perch_forms'); $Lang = $API->get('Lang'); $Forms = new PerchForms_Forms($API); $forms = $Forms->all(); ?> <div class="widget"> <h2> <?php echo $Lang->get('Forms'); ?> </h2> <div class="bd"> <?php if (PerchUtil::count($forms)) { echo '<ul>'; foreach ($forms as $Form) { echo '<li>'; echo '<a href="' . PerchUtil::html(PERCH_LOGINPATH . '/addons/apps/perch_forms/responses/?id=' . $Form->id()) . '">'; echo PerchUtil::html($Form->formTitle()); echo '</a>'; echo '<a class="action" href="' . PerchUtil::html(PERCH_LOGINPATH . '/addons/apps/perch_forms/responses/export/?id=' . $Form->id()) . '">'; echo $Lang->get('CSV'); echo '</a>'; echo '<span class="note">' . $Lang->get('%s responses', $Form->number_of_responses()) . '</span>'; echo '</li>';
<?php if (!$CurrentUser->has_priv('perch_forms.configure')) { exit; } $Forms = new PerchForms_Forms($API); $HTML = $API->get('HTML'); $Form = $API->get('Form'); $message = false; if (isset($_GET['id']) && $_GET['id'] != '') { $formID = (int) $_GET['id']; $ThisForm = $Forms->find($formID); $details = $ThisForm->to_array(); $settings = $ThisForm->get_settings(); } else { $message = $HTML->failure_message('Sorry, that form could not be updated.'); } $Form->require_field('formTitle', 'Required'); if ($Form->submitted()) { $postvars = array('formTitle'); $data = $Form->receive($postvars); $settingvars = array('store', 'fileLocation', 'email', 'emailAddress', 'adminEmailMessage', 'adminEmailTemplate', 'adminEmailSubject', 'adminEmailFromName', 'adminEmailFromAddress', 'akismet', 'akismetAPIKey', 'successURL', 'responseEmailSubject', 'responseEmailMessage', 'formEmailFieldID', 'sendAutoResponse', 'autoresponseTemplate'); $settingdata = $Form->receive($settingvars); if (isset($settingdata['successURL']) && trim($settingdata['successURL']) == '') { unset($settingdata['successURL']); } $data['formOptions'] = PerchUtil::json_safe_encode($settingdata); $ThisForm->update($data); if (is_object($ThisForm)) { $message = $HTML->success_message('Your form has been successfully edited. Return to %sform listing%s', '<a href="' . $API->app_path() . '">', '</a>'); } else {