コード例 #1
0
ファイル: function.custom_field.php プロジェクト: Rotron/hero
function smarty_function_custom_field($params, $smarty)
{
    $field = $params['field'];
    // we don't throw a nasty error here, because sometimes an empty $custom_fields array gets into the mix and
    // we have to be gentle with this
    if (empty($field)) {
        return FALSE;
    }
    // load field as object and display the field
    $smarty->CI->load->library('custom_fields/fieldtype');
    // initialize field
    $field_object =& $smarty->CI->fieldtype->load($field);
    // check for error
    if ($field_object === FALSE) {
        show_error('Unable to load custom field: ' . $field['type']);
    }
    // add value from parameter if it's there
    if (isset($params['value'])) {
        $field_object->value($params['value']);
    } else {
        // older templates are missing the "value" parameter declaration, let's do another check
        $values = $smarty->CI->input->get('values') ? unserialize(query_value_decode($smarty->CI->input->get('values'))) : array();
        if (isset($values[$field_object->name])) {
            $field_object->value($values[$field_object->name]);
        }
    }
    // use default parameter if supplied
    if (isset($params['default'])) {
        $field_object->default_value($params['default']);
    }
    // output field
    $html = $field_object->output_frontend();
    unset($field_object);
    return $html;
}
コード例 #2
0
ファイル: form.php プロジェクト: Rotron/hero
 function view($url_path)
 {
     // we may have a URL with "/" in it, so let's combine all the arguments into a URL string
     $args = func_get_args();
     $url_path = implode('/', $args);
     // end URL from arguments code
     $this->load->model('forms/form_model');
     $form_id = $this->form_model->get_form_id($url_path);
     if (empty($form_id)) {
         return show_404($url_path);
     }
     // get the form
     $form = $this->form_model->get_form($form_id);
     if (empty($form)) {
         die(show_404($url_path));
     }
     // do they have permissions?
     if (!$this->user_model->in_group($form['privileges'])) {
         $this->load->helper('paywall/paywall');
         if (paywall($form, 'form') !== FALSE) {
             die;
         }
     }
     // do we have passed values?
     $values = $this->input->get('values') ? unserialize(query_value_decode($this->input->get('values'))) : array();
     // we don't want non values, so we'll fill the $values array with empty placeholders
     if (empty($values)) {
         $this->load->model('custom_fields_model');
         $fields = $this->custom_fields_model->get_custom_fields(array('group' => $form['custom_field_group_id']));
         foreach ($fields as $field) {
             $values[$field['name']] = null;
         }
     }
     // errors
     $errors = $this->input->get('errors') == 'true' ? $this->session->flashdata('validation_errors') : FALSE;
     // show content
     $this->smarty->assign($form);
     $this->smarty->assign('validation_errors', $errors);
     $this->smarty->assign('values', $values);
     return $this->smarty->display($form['template']);
 }
コード例 #3
0
ファイル: users.php プロジェクト: Rotron/hero
 function post_login()
 {
     // get $return if available
     if ($this->input->post('return') != '') {
         $return = query_value_decode($this->input->post('return'));
     } else {
         $return = site_url('users');
     }
     // validate fields
     $this->load->library('form_validation');
     $this->form_validation->set_rules('username', 'Username/Email', 'trim|required');
     $this->form_validation->set_rules('password', 'Password', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         $this->session->set_flashdata('login_errors', validation_errors());
         return redirect('users/login?return=' . query_value_encode($return) . '&errors=true&username='******'username'));
     }
     // are we remembering this user?
     $remember = ($this->input->post('remember') and $this->input->post('remember') != '') ? TRUE : FALSE;
     // attempt login
     if ($this->user_model->login($this->input->post('username'), $this->input->post('password'), $remember)) {
         // success!
         // do we have a relative URL?
         if (strpos($return, 'http') === FALSE) {
             $return = site_url($return);
         }
         return header('Location: ' . $return);
     } else {
         if ($this->user_model->failed_due_to_activation == TRUE) {
             $this->session->set_flashdata('login_errors', '<p>Login failed.  Your account email has not been activated yet.  Please click the link in your activation email to activate your account.  If you cannot find the email in your inbox or junk folders, contact website support for assistance.');
         } elseif ($this->user_model->failed_due_to_duplicate_login == TRUE) {
             $this->session->set_flashdata('login_errors', '<p>Login failed.  Someone is already logged in with this account.  If you believe this is in error, wait 1 minute and try again.  Otherwise, ensure that you are not logged in the site on another device before continuing.');
         } else {
             $this->session->set_flashdata('login_errors', '<p>Login failed.  Please verify your username/email and password.');
         }
         return redirect('users/login?return=' . query_value_encode($return) . '&errors=true');
     }
 }
コード例 #4
0
ファイル: checkout.php プロジェクト: josev814/hero
 /**
  * Billing & Shipping Addresses
  */
 function billing_shipping()
 {
     // is this a free cart?  if so, it doesn't require an address
     // by doing this prior to the methods below, we can retain any notices that may need to be shown
     $this->load->model('store/cart_model');
     if ($this->cart_model->free_cart()) {
         return redirect('checkout/free_confirm');
     }
     $this->get_errors_and_notices();
     $this->prep_cart();
     $this->require_login();
     // show a new account thank you if we just registered a new account
     if ($this->input->get('new_account') == 'true') {
         $this->session->set_userdata('notices', '<p>You have successfully created a new account.  You may continue your checkout below.</p>');
         return redirect('checkout/billing_shipping');
     }
     // do we have a valid billing address on file?
     $valid_billing_address = $this->user_model->validate_billing_address($this->user_model->get('id')) == TRUE ? TRUE : FALSE;
     $billing_address = $this->user_model->get_billing_address($this->user_model->get('id'));
     $this->load->helper('format_street_address');
     $formatted_billing_address = format_street_address($billing_address);
     // get states & countries
     $this->load->model('states_model');
     $countries = $this->states_model->GetCountries();
     $states = $this->states_model->GetStates();
     // billing address values
     if ($this->input->get('billing_values')) {
         $billing_values = unserialize(query_value_decode($this->input->get('billing_values')));
     } else {
         if (empty($billing_address)) {
             $billing_values = array('first_name' => $this->user_model->get('first_name'), 'last_name' => $this->user_model->get('last_name'), 'address_1' => '', 'address_2' => '', 'company' => '', 'city' => '', 'state' => '', 'country' => '', 'postal_code' => '', 'phone_number' => '');
         } else {
             $billing_values = array('first_name' => $billing_address['first_name'], 'last_name' => $billing_address['last_name'], 'address_1' => $billing_address['address_1'], 'address_2' => $billing_address['address_2'], 'company' => $billing_address['company'], 'city' => $billing_address['city'], 'state' => $billing_address['state'], 'country' => $billing_address['country'], 'postal_code' => $billing_address['postal_code'], 'phone_number' => $billing_address['phone_number']);
         }
     }
     // shipping address values
     if ($this->input->get('shipping_values')) {
         $shipping_values = unserialize(query_value_decode($this->input->get('shipping_values')));
     } else {
         $shipping_values = array('first_name' => $this->user_model->get('first_name'), 'last_name' => $this->user_model->get('last_name'), 'company' => '', 'city' => '', 'state' => '', 'country' => '', 'postal_code' => '', 'phone_number' => '');
     }
     $this->smarty->assign('billing_values', $billing_values);
     $this->smarty->assign('shipping_values', $shipping_values);
     $this->smarty->assign('countries', $countries);
     $this->smarty->assign('states', $states);
     $this->smarty->assign('formatted_billing_address', $formatted_billing_address);
     $this->smarty->assign('valid_billing_address', $valid_billing_address);
     $this->smarty->assign('billing_address', $billing_address);
     return $this->smarty->display('checkout_templates/billing_shipping.thtml');
 }