function account($redirect = '') { // check user is logged in, if not send them away from this controller if (!$this->session->userdata('session_user')) { redirect('/users/login/' . $this->core->encode($this->uri->uri_string())); } // required $this->core->required = array('email' => array('label' => 'Email', 'rules' => 'valid_email|unique[users.email]|required|trim'), 'firstName' => array('label' => 'First Name', 'rules' => 'required|trim|ucfirst'), 'lastName' => array('label' => 'Last Name', 'rules' => 'required|trim|ucfirst'), 'address1' => array('label' => 'Address1', 'rules' => 'trim|ucfirst'), 'address2' => array('label' => 'Address2', 'rules' => 'trim|ucfirst'), 'address3' => array('label' => 'Address3', 'rules' => 'trim|ucfirst'), 'city' => array('label' => 'City / State', 'rules' => 'trim|ucfirst'), 'displayName' => array('label' => 'Display Name', 'rules' => 'unique[users.displayName]|max_length[15]|min_length[3]|alpha_dash|trim')); // set object ID $objectID = array('userID' => $this->session->userdata('userID')); // get values $data = $this->core->get_values('users', $objectID); if (count($_POST)) { // set default error message $error = ''; // upload image if (@$_FILES['image']['name'] != '') { // set upload config $img_upload_path = site_url() . 'static/uploads/avatars'; $this->uploads->allowedTypes = 'gif|jpg|png'; $this->uploads->uploadsPath .= '/avatars'; $this->uploads->maxSize = '100000'; $this->uploads->maxWidth = '2000'; $this->uploads->maxHeight = '2000'; // upload avatar if ($imageData = $this->uploads->upload_image(FALSE)) { $this->core->set['avatar'] = $imageData['file_name']; } // set error $error = $this->uploads->errors ? 'Problem with your image: ' . $this->uploads->errors : ''; } // upload logo if (@$_FILES['logo']['name'] != '') { // set upload config $this->uploads->allowedTypes = 'gif|jpg|png'; $this->uploads->uploadsPath .= '/avatars'; $this->uploads->maxSize = '100000'; $this->uploads->maxWidth = '2000'; $this->uploads->maxHeight = '2000'; // upload logo if ($imageData = $this->uploads->upload_image(FALSE, NULL, 'logo')) { $this->core->set['companyLogo'] = $imageData['file_name']; } // set error $error = $this->uploads->errors ? 'Problem with your logo: ' . $this->uploads->errors : ''; } // get image errors if there are any if ($error) { $this->form_validation->set_error($error); } else { // security check if ($this->input->post('username')) { $this->core->set['username'] = $data['username']; } if ($this->input->post('subscribed')) { $this->core->set['subscribed'] = $data['subscribed']; } if ($this->input->post('siteID')) { $this->core->set['siteID'] = $this->siteID; } if ($this->input->post('userID')) { $this->core->set['userID'] = $data['userID']; } if ($this->input->post('resellerID')) { $this->core->set['resellerID'] = $data['resellerID']; } if ($this->input->post('kudos')) { $this->core->set['kudos'] = $data['kudos']; } if ($this->input->post('posts')) { $this->core->set['posts'] = $data['posts']; } // update if ($this->core->update('users', $objectID)) { // get updated row $row = $this->core->viewall('users', $objectID, NULL, 1); // remove the password field unset($row['users'][0]['password']); // set session data $this->session->set_userdata($row['users'][0]); // update image data in session if (isset($imageData)) { $this->session->set_userdata('avatar', $imageData['file_name']); } // set success message $this->session->set_flashdata('success', 'Your details have been updated.'); // redirect if ($redirect) { redirect('/users/' . $redirect); } else { redirect('/users/account'); } } } } // set title $output['page:title'] = $this->site->config['siteName'] . ' - Account'; // load errors $output['errors'] = validation_errors() ? validation_errors() : FALSE; // if reverted show a message if ($message = $this->session->flashdata('success')) { $output['message'] = $message; } // populate template $output['user:avatar'] = anchor('/users/profile/' . $data['userID'], display_image($this->users->get_avatar($data['avatar']), 'User Avatar', 150, 'class="bordered"', base_url() . $this->config->item('staticPath') . '/images/noavatar.gif')); $output['user:logo'] = anchor('/users/profile/' . $data['userID'], display_image($this->users->get_avatar($data['companyLogo']), 'Company Logo', 150, 'class="bordered"')); $output['form:email'] = set_value('email', $data['email']); $output['form:displayName'] = set_value('displayName', $data['displayName']); $output['form:firstName'] = set_value('firstName', $data['firstName']); $output['form:lastName'] = set_value('lastName', $data['lastName']); $output['form:bio'] = set_value('bio', $data['bio']); $output['form:website'] = set_value('website', $data['website']); $output['form:signature'] = set_value('signature', $data['signature']); $output['form:companyName'] = set_value('companyName', $data['companyName']); $output['form:companyEmail'] = set_value('companyEmail', $data['companyEmail']); $output['form:companyWebsite'] = set_value('companyWebsite', $data['companyWebsite']); $output['form:companyDescription'] = set_value('companyDescription', $data['companyDescription']); $output['form:address1'] = set_value('address1', $data['address1']); $output['form:address2'] = set_value('address2', $data['address2']); $output['form:address3'] = set_value('address3', $data['address3']); $output['form:city'] = set_value('city', $data['city']); $output['form:postcode'] = set_value('postcode', $data['postcode']); $output['form:phone'] = set_value('phone', $data['phone']); $output['select:country'] = @display_countries('country', set_value('country', $data['country']), 'id="country" class="formelement"'); $values = array('V' => 'Everyone can see my profile', 'H' => 'Hide my profile and feed'); $output['select:privacy'] = @form_dropdown('privacy', $values, set_value('privacy', $data['privacy']), 'id="privacy" class="formelement"'); $values = array(0 => 'No', 1 => 'Yes'); $output['select:notifications'] = @form_dropdown('notifications', $values, set_value('notifications', $data['notifications']), 'id="notifications" class="formelement"'); $output['select:currency'] = @form_dropdown('currency', currencies(), set_value('currency', $data['currency']), 'id="currency" class="formelement"'); $output['select:language'] = @form_dropdown('language', languages(), set_value('language', $data['language']), 'id="language" class="formelement"'); // display with cms layer $this->pages->view('community_account', $output, 'community'); }
<input type="text" name="bank_swift2" value="<?php echo $hotel->bank_swift2; ?> " class="form-control input-sm"> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label"><?php echo sprintf(lang('bank_account'), '2'); ?> </label> <div class="col-sm-2"> <select name="bank_currency2" size="1" class="form-control input-sm"> <?php foreach (currencies() as $key => $value) { $selected = $hotel->bank_currency2 == $value ? 'selected="selected"' : ''; echo '<option value="' . $value . '" ' . $selected . '>' . $value . '</option>'; } ?> </select> </div> <div class="col-sm-4"> <input type="text" name="bank_account2" value="<?php echo $hotel->bank_account2; ?> " class="form-control input-sm"> </div> </div>
} ?> </div> <?php if (@in_array('shop', $this->permission->sitePermissions)) { ?> <div id="shopconfig" class="tab"> <h2>Shop Preferences</h2> <label for="currency">Currency:</label> <?php echo @form_dropdown('currency', currencies(), set_value('currency', $data['currency']), 'id="currency" class="formelement"'); ?> <br class="clear" /> <label for="shopGateway">Payment Gateway:</label> <?php $values = ''; $values = array('paypal' => 'PayPal', 'paypalpro' => 'PayPal Pro', 'authorize' => 'Authorize.net', 'rbsworldpay' => 'RBS Worldpay', 'sagepay' => 'SagePay'); ?> <?php echo @form_dropdown('shopGateway', $values, set_value('shopGateway', $data['shopGateway']), 'id="shopGateway" class="formelement"'); ?> <br class="clear" /> <label for="shopEmail">PayPal Email:</label> <?php