/** * Deletes a contact. * * @param Model_Contact $contact The contact to delete. * * @return bool */ public static function delete(Model_Contact $contact) { try { $contact->delete(); } catch (FuelException $e) { Log::error($e); return false; } return true; }
public function run() { $contacts = \Model_Contact::find('all'); foreach ($contacts as $contact) { $this->sendMailToAdmin($contact); } }
public function action_submit() { if (!Security::check_token()) { Response::redirect('_404_'); } if (Session::get_flash('name')) { $contact = Model_Contact::forge(); $contact->title = Session::get_flash("title"); $contact->body = Session::get_flash("body"); $body = View::forge("email/contact"); $body->set("name", Session::get_flash('name')); $body->set("email", Session::get_flash('email')); $body->set("body", Session::get_flash('body')); $sendmail = Email::forge("JIS"); $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name")); $sendmail->to(Config::get("statics.info_email")); $sendmail->subject("We got contact/ Game-bootcamp"); $sendmail->body($body); $sendmail->send(); } $this->template->title = "Contact"; $this->template->sub = "How can we help you?"; $view = View::forge("contacts/send"); $this->template->content = $view; }
public function action_home($page = null) { // To store any form errors $errors = array(); // Store success message $session = Session::instance(); $success_message = null; if ($session->get('success_message')) { $success_message = $session->get('success_message'); $session->delete('success_message'); } $this->template->scripts = array('media/js/contact.js'); // Make sure this is a POST request if ($this->request->method() == 'POST') { // Get required parameters from the web form for the request $fields = array(); $fields['name'] = urlencode(arr::get($_POST, 'name')); $fields['company'] = urlencode(arr::get($_POST, 'company')); $fields['email'] = arr::get($_POST, 'email'); $fields['website'] = arr::get($_POST, 'website'); $fields['subject'] = urlencode(arr::get($_POST, 'subject')); $fields['message'] = urlencode(arr::get($_POST, 'message')); // validates fields $validation = Validation::factory($fields); $contact = new Model_Contact(); $rules = $contact->rules(); $validation->rules('name', $rules['name'])->rules('company', $rules['company'])->rules('email', $rules['email'])->rules('website', $rules['website'])->rules('subject', $rules['subject'])->rules('message', $rules['message']); if ($validation->check()) { // Send email to admin $template = View::factory('emails/contact', array('name' => $fields['name'], 'company' => $fields['company'], 'email' => $fields['email'], 'website' => $fields['website'], 'subject' => $fields['subject'], 'message' => $fields['message']))->render(); Email::send($this->config['global']['email_info'], $fields['email'], $fields['subject'], $template, TRUE); // Redirect user $session->set('success_message', "Thank you. Your message was successfully sent."); $this->request->redirect('/contact'); } else { // If form did not pass, get errors $e = new ORM_Validation_Exception('payment', $validation); $errors = $e->errors('models'); } } $this->template->title = __("Contact Us - gowork@"); $this->template->content = View::factory("static/contact_us", array('errors' => $errors, 'success_message' => $success_message)); }
/** * @author Bui Dang <*****@*****.**> * action detail contact */ public function action_index($id = null) { $data = array(); if (!isset($id) or !\Model_Contact::find_by_pk($id)) { Response::redirect(Uri::base() . 'support/contacts'); } $data['contact'] = \Model_Contact::find_by_pk($id); $this->template->title = 'UOS求人システム'; $this->template->content = \View::forge('contact/index', $data); }
public function action_index() { $where = [["deleted_at", 0]]; $data["contacts"] = Model_Contact::find("all", ["where" => $where, "order_by" => [["id", "desc"]]]); $config = array('pagination_url' => "", 'uri_segment' => "p", 'num_links' => 9, 'per_page' => 20, 'total_items' => count($data["contacts"])); $data["pager"] = Pagination::forge('mypagination', $config); $data["contacts"] = array_slice($data["contacts"], $data["pager"]->offset, $data["pager"]->per_page); $view = View::forge("admin/contacts", $data); $this->template->content = $view; }
public function action_delete($id = null) { is_null($id) and Response::redirect('contact'); if ($contact = Model_Contact::find($id)) { $contact->delete(); Session::set_flash('success', 'Deleted contact #' . $id); } else { Session::set_flash('error', 'Could not delete contact #' . $id); } Response::redirect('contact'); }
/** * POST create action. * * @return void */ public function post_create() { $this->get_create(); $contact = new Model_Contact(); $contact->populate(Input::post()); $validator = Validation_Contact::create('seller'); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $data = $validator->validated(); $data['first_name'] = ''; $data['last_name'] = ''; if (!($new_contact = Service_Contact::create($data))) { Session::set_alert('error', 'There was an error creating the contact.'); return; } Service_Contact::link($new_contact, Seller::active()); Session::set_alert('success', 'The contact has been created.'); Response::redirect('settings/contacts'); }
public function action_change_status() { if ($contact_id = Input::post('contact_id')) { $user_login = Session::get('login_info'); $contact = \Model_Contact::find_by_pk($contact_id); if (Input::post('status') == 0) { $contact->set(array('status' => 1, 'user_id' => $user_login['user_id'], 'update_at' => date('Y-m-d H:i:s'))); } if (Input::post('status') == 1) { $contact->set(array('status' => 0, 'user_id' => null, 'update_at' => null)); } $contact->save(); Response::redirect(Uri::base() . 'support/contacts?' . Session::get('url_filter_contacts')); } Response::redirect(Uri::base() . 'support/contacts?' . Session::get('url_filter_contacts')); }
public function action_submit() { if (!Security::check_token()) { Response::redirect('_404_'); } if (Session::get_flash('title')) { $contact = Model_Contact::forge(); $contact->title = Session::get_flash("title"); $contact->body = Session::get_flash("body"); $contact->user_id = $this->user->id; $contact->save(); } else { Response::redirect('_404_'); } $this->template->content = View::forge('teachers/contact/finish'); }
/** * Processes the shopping cart with the payment processor, saves the user's * cart, clears it and redirects to a success method. * * @return null */ public function action_process() { $order = Auth::instance()->get_user()->cart(); $user_post = arr::get($_POST, 'user', array()); $user = arr::get($_POST, 'user', Auth::instance()->get_user()); if (!is_object($user)) { $temp = $user; $user = AutoModeler_ORM::factory('user'); $user->set_fields($temp); } $address = AutoModeler_ORM::factory('vendo_address'); $address->set_fields(arr::get($_POST, 'address', array())); // Build the contact model $contact = new Model_Contact(); $contact->set_fields(array('email' => $user->email, 'first_name' => $user->first_name, 'last_name' => $user->last_name)); // Build the credit card model $credit_card_post = arr::get($_POST, 'payment'); $credit_card = new Model_Credit_Card(arr::get($credit_card_post, 'card_number'), arr::get($credit_card_post, 'months') . arr::get($credit_card_post, 'years'), arr::get($credit_card_post, 'card_code'), $contact, $address); $errors = array(); // Check for a new user registration, and make a user if so if ($this->should_create_account($user)) { $status = $this->process_new_account($user, $user_post, $address); if (!$status) { return; } $contact->save(); $order->user_id = $user->id; } else { $user_address = $user->address->as_array(); unset($user_address['id']); if ($user_address != $address and TRUE === $address->is_valid()) { $address->save(); $user->address_id = $address->id; } elseif (TRUE !== $address->is_valid()) { $errors += $address->errors('form_errors'); } else { $address = $user->address; } $contact->address_id = $address->id; if (TRUE !== $contact->is_valid()) { $errors += $contact->errors('form_errors'); } if (Auth::instance()->logged_in()) { $order->user_id = $user->id; } } // Verify the credit card is valid if (TRUE !== ($cc_errors = $credit_card->validate())) { $errors += $cc_errors; } if ($errors) { // If we've failed, and we aren't registering a new user, delete // the address if (!$user->id) { $address->delete(); } $this->request->response = new View_Checkout_Index(); $this->request->response->set(array('user' => $user->as_array(), 'address' => $address->as_array(), 'cart' => Auth::instance()->get_user()->cart(), 'credit_card' => $credit_card)); $errors = (string) View::factory('form_errors')->set(array('errors' => $errors)); $this->request->response->errors = $errors; return; } $order->credit_card = $credit_card; // Process the credit card try { $status = Payment::process($order); if (1 != $status->response_code) { throw new Payment_Exception('Problem processing your payment.'); } // Persist the order $contact->save(); $order->contact_id = $contact->id; $order->address_id = $address->id; $order->save(); Auth::instance()->get_user()->cart(new Model_Order()); // Show success message! $this->request->response = new View_Checkout_Process(); } catch (Payment_Exception $e) { // If we've failed, and we aren't registering a new user, delete // the address if (!$user->id) { $address->delete(); } $this->request->response = new View_Checkout_Index(); $this->request->response->set(array('user' => $user->as_array(), 'address' => $address->as_array(), 'cart' => Auth::instance()->get_user()->cart(), 'credit_card' => $credit_card)); $errors = (string) View::factory('form_errors')->set(array('errors' => array('general' => $e->getMessage()))); $this->request->response->errors = $errors; return; } }
/** * contacts テーブルへの登録 * * @access private * @return Model_Contactオブジェクト */ private function registerContact() { $data = $this->getContactData(); if (!$data) { throw new Exception(\Model_Error::ER00603); } else { $contact = Model_Contact::forge(); $contact->set($data); $contact->save(NULL, true); return $contact; } }
public function post_changecontactstatus() { $code = 0; $message = "ok"; if ($this->auth_status) { $contact = Model_Contact::find(Input::post("id", 0)); if ($contact != null) { $contact->status = Input::post("status", 0); $contact->save(); } else { $code = 404; $message = "Content not found."; } } else { $code = 500; $message = "Auth error."; } $this->response(array('code' => $code, 'message' => $message)); }
public function after_load(Model $contact) { $contact->inquiry_type_label = \Model_Contact::inquiry_type_to_label($contact->inquiry_type); }
public function save($data) { unset($data['to'], $data['to_name']); $contact = Model_Contact::forge($data); if (!$contact->save()) { throw new EmailSavingFailedException('One or more email did not saved ' . $item); } }
<?php $input = $fieldset->input(); ?> <div id="contentForm" class="row"> <!-- form --> <div id="form" class="container"> <div class="box clearfix"> <h3>お問い合わせフォーム</h3> <form action="/inquiry/thanks" method="POST" class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">お問い合わせの種類</label> <div class="col-sm-6"> <?php echo e(\Model_Contact::inquiry_type_to_label($input['inquiry_type'])); ?> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">名前</label> <div class="col-sm-6"> <?php echo e($input['last_name']); echo e($input['first_name']); ?> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">件名</label> <div class="col-sm-6">