public function sendBookingConfirmation() { $responseMessages = array(); $fault = false; if (!v::required('email', get())) { $responseMessages[] = array('type' => 'error', 'message' => 'No email given, cheating ass bitch!'); $fault = true; } else { if (!v::email(get('email'))) { $responseMessages[] = array('type' => 'error', 'message' => 'No email given, cheating ass bitch!'); $fault = true; } } if (!v::required('productSelect', get())) { $responseMessages[] = array('type' => 'error', 'message' => 'No product given, cheating ass bitch!'); $fault = true; } if (!v::required('date', get())) { $responseMessages[] = array('type' => 'error', 'message' => 'No date given, cheating ass bitch!'); $fault = true; } else { if (!v::date(get('date'))) { $responseMessages[] = array('type' => 'error', 'message' => 'No valid Date, son of a bitch!'); $fault = true; } } if (!v::required('name', get())) { $responseMessages[] = array('type' => 'error', 'message' => 'No name given, cheating ass bitch!'); $fault = true; } else { if (!v::min(get('name'), 3)) { $responseMessages[] = array('type' => 'error', 'message' => 'At least 3 characters for a name, bitchass!'); $fault = true; } } if ($fault) { s::set('response', $responseMessages); go($this->getOriginId()); } $confirmationBody = self::buildMailText($this->getConfirmationText(), get()); $ownerConfirmation = $confirmationBody . self::createBookingApprovalLink(get('email'), array(), array()); $from = site()->contactmail()->value(); // Send To Owner $confirmationMail = new Email(array('to' => self::getBookingMail(), 'from' => $from, 'subject' => 'Hey, some new booking', 'body' => $ownerConfirmation)); // Send to User $userConfirmationMail = new Email(array('to' => get('email'), 'from' => $from, 'subject' => 'Hey, some new booking', 'body' => $confirmationBody)); if ($userConfirmationMail->send() && $confirmationMail->send()) { $responseMessages[] = array('type' => 'success', 'message' => 'Successfully send a booking request.'); s::set('response', $responseMessages); } else { go('error'); } go($this->getOriginId()); }
/** * Quickly decides if the request is valid so the server is minimally * stressed by scripted attacks. */ private function requestValid() { if (a::get($this->data, '_submit') !== $this->token) { return false; } if (v::required('_potty', $this->data)) { $this->message = l::get('sendform-filled-potty'); return false; } return true; }
* * @return boolean */ v::$validators['requiredWith'] = function ($key, $dependency, $array) { return !empty($array[$dependency]) && v::required($key, $array); }; /** * Required (Conditionally) * * Field has to be present only if the other specified field IS NOT present. * * @param string $key Name of the field to test. * @param string $dependency Name of the field the actual field depends on. * @param array $array Collection of data values. * * @return boolean */ v::$validators['requiredWithout'] = function ($key, $dependency, $array) { return !empty($array[$dependency]) || v::required($key, $array); }; /** * Username Validator * * Ensures the given user name exists in the system. * * @param mixed $value Value to test. * @return boolean */ v::$validators['user'] = function ($value) { return v::alphanum($value) && kirby()->site()->users()->find($value); };