public function logout() { \CI::auth()->logout(); //when someone logs out, automatically redirect them to the login page. \CI::session()->set_flashdata('message', lang('message_logged_out')); redirect('admin/login'); }
public function index($slug) { $product = \CI::Products()->slug($slug); if (!$product) { throw_404(); } else { $product->images = json_decode($product->images, true); if ($product->images) { $product->images = array_values($product->images); } else { $product->images = []; } //set product options $data['options'] = \CI::ProductOptions()->getProductOptions($product->id); $data['posted_options'] = \CI::session()->flashdata('option_values'); //get related items $data['related'] = $product->related_products; //create view variable $data['page_title'] = $product->name; $data['meta'] = $product->meta; $data['seo_title'] = !empty($product->seo_title) ? $product->seo_title : $product->name; $data['product'] = $product; //load the view $this->view('product', $data); } }
public function delete($direction = false, $id = false) { if ($id) { \CI::db()->delete($this->_db_table[$direction], array('id' => $id)); } else { //if they do not provide an id send them to the product list page with an error \CI::session()->set_flashdata('error', lang('error_not_found')); } redirect('admin/materials/' . $direction); }
public function completeSitemap() { $xml = $this->partial('sitemap_xml_foot', [], true); echo $xml; $file = fopen('sitemap.xml', 'a'); fwrite($file, $xml); fclose($file); \CI::session()->set_flashdata('message', lang('success_sitemap_generate') . ' File location ' . site_url('sitemap.xml')); redirect('admin/sitemap'); }
public function forgotPassword() { $data['page_title'] = lang('forgot_password'); $submitted = \CI::input()->post('submitted'); \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', ['email_callable', function ($str) { $reset = \CI::Customers()->reset_password($str); if (!$reset) { \CI::form_validation()->set_message('email_callable', lang('error_no_account_record')); return FALSE; } else { //user does exist. and the password is reset. return TRUE; } }]]); if (\CI::form_validation()->run() == FALSE) { $this->view('forgot_password', $data); } else { \CI::session()->set_flashdata('message', lang('message_new_password')); redirect('login'); } }
public function delete($id = false) { if ($id) { $product = \CI::Products()->find($id); //if the product does not exist, redirect them to the customer list with an error if (!$product) { \CI::session()->set_flashdata('error', lang('error_not_found')); redirect('admin/products'); } else { //if the product is legit, delete them \CI::Products()->delete_product($id); \CI::session()->set_flashdata('message', lang('message_deleted_product')); redirect('admin/products'); } } else { //if they do not provide an id send them to the product list page with an error \CI::session()->set_flashdata('error', lang('error_not_found')); redirect('admin/products'); } }
function delete($id) { $category = \CI::Categories()->find($id); //if the category does not exist, redirect them to the customer list with an error if ($category) { \CI::Categories()->delete($id); \CI::session()->set_flashdata('message', lang('message_delete_category')); redirect('admin/categories'); } else { \CI::session()->set_flashdata('error', lang('error_not_found')); } }
function delete($id) { $page = \CI::Pages()->get_page($id); if ($page) { \CI::Pages()->delete_page($id); \CI::session()->set_flashdata('message', lang('message_deleted_page')); } else { \CI::session()->set_flashdata('error', lang('error_page_not_found')); } redirect('admin/pages'); }
public function delete_message($id) { \CI::Messages()->delete_message($id); \CI::session()->set_flashdata('message', lang('message_deleted_message')); redirect('admin/settings/canned_messages'); }
public function zone_area_form($zone_id, $area_id = false) { \CI::load()->helper('form'); \CI::load()->library('form_validation'); \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>'); $zone = \CI::Locations()->get_zone($zone_id); $data['zone'] = $zone; //default values are empty if the product is new $data['id'] = ''; $data['code'] = ''; $data['zone_id'] = $zone_id; $data['tax'] = 0; if ($area_id) { $area = (array) \CI::Locations()->get_zone_area($area_id); //if the country does not exist, redirect them to the country list with an error if (!$area) { \CI::session()->set_flashdata('error', lang('error_zone_area_not_found')); redirect('admin/locations/zone_areas/' . $zone_id); } $data = array_merge($data, $area); } \CI::form_validation()->set_rules('code', 'lang:code', 'trim|required'); \CI::form_validation()->set_rules('tax', 'lang:tax', 'trim|numeric'); if (\CI::form_validation()->run() == FALSE) { $this->view('country_zone_area_form', $data); } else { $save['id'] = $area_id; $save['zone_id'] = $zone_id; $save['code'] = \CI::input()->post('code'); $save['tax'] = \CI::input()->post('tax'); \CI::Locations()->save_zone_area($save); \CI::session()->set_flashdata('message', lang('message_saved_zone_area')); //go back to the product list redirect('admin/locations/zone_areas/' . $save['zone_id']); } }
public function delete($id = false) { if ($id) { $coupon = \CI::Coupons()->getCoupon($id); //if the promo does not exist, redirect them to the customer list with an error if (!$coupon) { \CI::session()->set_flashdata('error', lang('error_not_found')); redirect('admin/coupons'); } else { \CI::Coupons()->deleteCoupon($id); \CI::session()->set_flashdata('message', lang('message_coupon_deleted')); redirect('admin/coupons'); } } else { //if they do not provide an id send them to the promo list page with an error \CI::session()->set_flashdata('message', lang('error_not_found')); redirect('admin/coupons'); } }
</li> </ul> </div> </div> </nav> <?php } ?> <div class="container"> <?php //lets have the flashdata overright "$message" if it exists if (CI::session()->flashdata('message')) { $message = CI::session()->flashdata('message'); } if (CI::session()->flashdata('error')) { $error = CI::session()->flashdata('error'); } if (function_exists('validation_errors') && validation_errors() != '') { $error = validation_errors(); } ?> <div id="js_error_container" class="alert alert-error" style="display:none;"> <p id="js_error"></p> </div> <div id="js_note_container" class="alert alert-note" style="display:none;"> </div> <?php
<br class="clear"> <div class="productDetails"> <div class="productExcerpt"> <?php echo (new content_filter($product->excerpt))->display(); ?> </div> <?php echo form_open('cart/add-to-cart', 'id="add-to-cart"'); ?> <input type="hidden" name="cartkey" value="<?php echo CI::session()->flashdata('cartkey'); ?> " /> <input type="hidden" name="id" value="<?php echo $product->id; ?> "/> <?php if (count($options) > 0) { ?> <?php foreach ($options as $option) { $required = ''; if ($option->required) { $required = ' class="required"';
function remove_compare($type) { $url[] = $_POST['url']; $compare = \CI::session()->userdata('compare'); $compare = array_diff($compare, $url); \CI::session()->set_userdata('compare', $compare); //print_r( $compare ); if (count($compare) > 0) { echo true; } exit; }
private function createGuest() { //create a temp customer $customerID = CI::Customers()->createGuest(); $customer = CI::db()->where('id', $customerID)->get('customers')->row(); CI::session()->set_userdata('customer', $customer); }
public function delete($id) { \CI::DigitalProducts()->delete($id); \CI::session()->set_flashdata('message', lang('message_deleted_file')); redirect('admin/digital_products'); }
function delete($id) { $category = \CI::Categories()->find($id); //if the category does not exist, redirect them to the customer list with an error if ($category) { if ($category->image != '') { $file = []; $file[] = 'uploads/images/full/' . $category->image; $file[] = 'uploads/images/medium/' . $category->image; $file[] = 'uploads/images/small/' . $category->image; $file[] = 'uploads/images/thumbnails/' . $category->image; foreach ($file as $f) { //delete the existing file if needed if (file_exists($f)) { unlink($f); } } } \CI::Categories()->delete($id); \CI::session()->set_flashdata('message', lang('message_delete_category')); redirect('admin/categories'); } else { \CI::session()->set_flashdata('error', lang('error_not_found')); } }
</div> </div> <nav class="navPrimary"> <ul class="nav mobileNav"> <li><a href="/"><i class="icon-home"></i> <span class="homeLinkText">Home</span></a></li> <?php category_loop(0, false, false); page_loop(0, false, false); ?> </ul> </nav> </div> </header> <div class="main container"> <?php if (CI::session()->flashdata('message')) { ?> <div class="alert blue"> <?php echo CI::session()->flashdata('message'); ?> </div> <?php } ?> <?php echo CI::breadcrumbs()->generate();
public function form($id = false) { \CI::load()->helper('form'); \CI::load()->library('form_validation'); \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>'); $data['page_title'] = lang('admin_form'); //default values are empty if the customer is new $data['id'] = ''; $data['firstname'] = ''; $data['lastname'] = ''; $data['email'] = ''; $data['username'] = ''; $data['access'] = ''; if ($id) { $this->admin_id = $id; $admin = \CI::auth()->getAdmin($id); //if the administrator does not exist, redirect them to the admin list with an error if (!$admin) { \CI::session()->set_flashdata('message', lang('admin_not_found')); redirect('admin/users'); } //set values to db values $data['id'] = $admin->id; $data['firstname'] = $admin->firstname; $data['lastname'] = $admin->lastname; $data['email'] = $admin->email; $data['username'] = $admin->username; $data['access'] = $admin->access; } \CI::form_validation()->set_rules('firstname', 'lang:firstname', 'trim|max_length[32]'); \CI::form_validation()->set_rules('lastname', 'lang:lastname', 'trim|max_length[32]'); \CI::form_validation()->set_rules('email', 'lang:email', 'trim|required|valid_email|max_length[128]'); \CI::form_validation()->set_rules('username', 'lang:username', ['trim', 'required', 'max_length[128]', ['username_callable', function ($str) { $email = \CI::auth()->check_username($str, $this->admin_id); if ($email) { \CI::form_validation()->set_message('username_callable', lang('error_username_taken')); return FALSE; } else { return TRUE; } }]]); \CI::form_validation()->set_rules('access', 'lang:access', 'trim|required'); //if this is a new account require a password, or if they have entered either a password or a password confirmation if (\CI::input()->post('password') != '' || \CI::input()->post('confirm') != '' || !$id) { \CI::form_validation()->set_rules('password', 'lang:password', 'required|min_length[6]|sha1'); \CI::form_validation()->set_rules('confirm', 'lang:confirm_password', 'required|sha1|matches[password]'); } if (\CI::form_validation()->run() == FALSE) { $this->view('user_form', $data); } else { $save['id'] = $id; $save['firstname'] = \CI::input()->post('firstname'); $save['lastname'] = \CI::input()->post('lastname'); $save['email'] = \CI::input()->post('email'); $save['username'] = \CI::input()->post('username'); $save['access'] = \CI::input()->post('access'); if (\CI::input()->post('password') != '' || !$id) { $save['password'] = \CI::input()->post('password'); } \CI::auth()->save($save); \CI::session()->set_flashdata('message', lang('message_user_saved')); //go back to the customer list redirect('admin/users'); } }
public function logout() { CI::session()->unset_userdata('admin'); //force expire the cookie $this->generateCookie('[]', time() - 3600); }
public function index($offset = 0) { //make sure they're logged in \CI::Login()->isLoggedIn('my-account'); $data['customer'] = (array) \CI::Customers()->get_customer($this->customer->id); $data['addresses'] = \CI::Customers()->get_address_list($this->customer->id); $data['customer_addresses'] = \CI::Customers()->get_address_list($this->customer->id); // load other page content //\CI::load()->model('banner_model'); \CI::load()->helper('directory'); \CI::load()->helper('date'); // paginate the orders \CI::load()->library('pagination'); $config['base_url'] = site_url('my_account'); $config['total_rows'] = \CI::Orders()->countCustomerOrders($this->customer->id); $config['per_page'] = '15'; $config['first_link'] = 'First'; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['full_tag_open'] = '<div class="pagination"><ul>'; $config['full_tag_close'] = '</ul></div>'; $config['cur_tag_open'] = '<li class="active"><a href="#">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>'; $config['prev_link'] = '«'; $config['prev_tag_open'] = '<li>'; $config['prev_tag_close'] = '</li>'; $config['next_link'] = '»'; $config['next_tag_open'] = '<li>'; $config['next_tag_close'] = '</li>'; \CI::pagination()->initialize($config); $data['orders_pagination'] = \CI::pagination()->create_links(); $data['orders'] = \CI::Orders()->getCustomerOrders($this->customer->id, $offset); //print_r($offset); \CI::load()->library('form_validation'); // \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]'); \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) { return $this->check_email($str); }]]); \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email_subscribe', 'lang:account_newsletter_subscribe', 'trim|numeric|max_length[1]'); if (\CI::input()->post('password') != '' || \CI::input()->post('confirm') != '') { \CI::form_validation()->set_rules('password', 'Password', 'required|min_length[6]|sha1'); \CI::form_validation()->set_rules('confirm', 'Confirm Password', 'required|matches[password]'); } else { \CI::form_validation()->set_rules('password', 'Password'); \CI::form_validation()->set_rules('confirm', 'Confirm Password'); } if (\CI::form_validation()->run() == FALSE) { $this->view('my_account', $data); } else { $customer = []; $customer['id'] = $this->customer->id; // $customer['company'] = \CI::input()->post('company'); $customer['firstname'] = \CI::input()->post('firstname'); $customer['lastname'] = \CI::input()->post('lastname'); $customer['email'] = \CI::input()->post('email'); $customer['phone'] = \CI::input()->post('phone'); $customer['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe')); if (\CI::input()->post('password') != '') { $customer['password'] = \CI::input()->post('password'); } \GC::save_customer($this->customer); \CI::Customers()->save($customer); \CI::session()->set_flashdata('message', lang('message_account_updated')); redirect('my-account'); } }
public function deleteAddress($customer_id = false, $id = false) { if ($id) { $address = \CI::Customers()->get_address($id); //if the customer does not exist, redirect them to the customer list with an error if (!$address) { \CI::session()->set_flashdata('error', lang('error_address_not_found')); if ($customer_id) { redirect('admin/customers/addresses/' . $customer_id); } else { redirect('admin/customers'); } } else { //if the customer is legit, delete them \CI::Customers()->delete_address($id, $customer_id); \CI::session()->set_flashdata('message', lang('message_address_deleted')); if ($customer_id) { redirect('admin/customers/addresses/' . $customer_id); } else { redirect('admin/customers'); } } } else { //if they do not provide an id send them to the customer list page with an error \CI::session()->set_flashdata('error', lang('error_address_not_found')); if ($customer_id) { redirect('admin/customers/addresses/' . $customer_id); } else { redirect('admin/customers'); } } }
public function index() { $redirect = \CI::Login()->isLoggedIn(false, false); //if they are logged in, we send them back to the my_account by default if ($redirect) { redirect('my-account'); } \CI::load()->library('form_validation'); //default values are empty if the customer is new $data = ['company' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'phone' => '', 'address1' => '', 'address2' => '', 'city' => '', 'state' => '', 'zip' => '', 'redirect' => \CI::session()->flashdata('redirect')]; \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]'); \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) { return $this->check_email($str); }]]); \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email_subscribe', 'lang:account_newsletter_subscribe', 'trim|numeric|max_length[1]'); \CI::form_validation()->set_rules('password', 'Password', 'required|min_length[6]'); \CI::form_validation()->set_rules('confirm', 'Confirm Password', 'required|matches[password]'); if (\CI::form_validation()->run() == FALSE) { //if they have submitted the form already and it has returned with errors, reset the redirect if (\CI::input()->post('submitted')) { $data['redirect'] = \CI::input()->post('redirect'); } // load other page content //\CI::load()->model('banner_model'); \CI::load()->helper('directory'); $this->view('register', $data); } else { $save['id'] = false; $save['firstname'] = \CI::input()->post('firstname'); $save['lastname'] = \CI::input()->post('lastname'); $save['email'] = \CI::input()->post('email'); $save['phone'] = \CI::input()->post('phone'); $save['company'] = \CI::input()->post('company'); $save['active'] = config_item('new_customer_status'); $save['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe')); $save['password'] = \CI::input()->post('password'); $redirect = \CI::input()->post('redirect'); //if we don't have a value for redirect if ($redirect == '') { $redirect = 'my-account'; } // save the customer info and get their new id $id = \CI::Customers()->save($save); /* send an email */ // get the email template $row = \CI::db()->where('id', '6')->get('canned_messages')->row_array(); // set replacement values for subject & body // {customer_name} $row['subject'] = str_replace('{customer_name}', \CI::input()->post('firstname') . ' ' . \CI::input()->post('lastname'), $row['subject']); $row['content'] = str_replace('{customer_name}', \CI::input()->post('firstname') . ' ' . \CI::input()->post('lastname'), $row['content']); // {url} $row['subject'] = str_replace('{url}', config_item('base_url'), $row['subject']); $row['content'] = str_replace('{url}', config_item('base_url'), $row['content']); // {site_name} $row['subject'] = str_replace('{site_name}', config_item('company_name'), $row['subject']); $row['content'] = str_replace('{site_name}', config_item('company_name'), $row['content']); \CI::load()->library('email'); $config['mailtype'] = 'html'; \CI::email()->initialize($config); \CI::email()->from(config_item('email'), config_item('company_name')); \CI::email()->to($save['email']); \CI::email()->bcc(config_item('email')); \CI::email()->subject($row['subject']); \CI::email()->message(html_entity_decode($row['content'])); \CI::email()->send(); \CI::session()->set_flashdata('message', sprintf(lang('registration_thanks'), \CI::input()->post('firstname'))); //lets automatically log them in \CI::Login()->loginCustomer($save['email'], \CI::input()->post('confirm')); //we're just going to make this secure regardless, because we don't know if they are //wanting to redirect to an insecure location, if it needs to be secured then we can use the secure redirect in the controller //to redirect them, if there is no redirect, the it should redirect to the homepage. redirect($redirect); } }
public function delete($id) { \CI::GiftCards()->delete($id); \CI::session()->set_flashdata('message', lang('message_deleted_gift_card')); redirect('admin/gift-cards'); }
public function register() { $redirect = \CI::Login()->isLoggedIn(false, false); //if they are logged in, we send them back to the my_account by default if ($redirect) { redirect('my-account'); } \CI::load()->library('form_validation'); //default values are empty if the customer is new $data = ['company' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'phone' => '', 'address1' => '', 'address2' => '', 'city' => '', 'state' => '', 'zip' => '', 'redirect' => \CI::session()->flashdata('redirect')]; \CI::form_validation()->set_rules('company', 'lang:account_company', 'trim|max_length[128]'); \CI::form_validation()->set_rules('firstname', 'lang:account_firstname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('lastname', 'lang:account_lastname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email', 'lang:account_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) { return $this->check_email($str); }]]); \CI::form_validation()->set_rules('phone', 'lang:account_phone', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email_subscribe', 'lang:email_subscribe', 'trim|numeric|max_length[1]'); \CI::form_validation()->set_rules('password', 'lang:account_password', 'required|min_length[6]'); \CI::form_validation()->set_rules('confirm', 'lang:account_confirm', 'required|matches[password]'); if (\CI::form_validation()->run() == FALSE) { //if they have submitted the form already and it has returned with errors, reset the redirect if (\CI::input()->post('submitted')) { $data['redirect'] = \CI::input()->post('redirect'); } // load other page content //\CI::load()->model('banner_model'); \CI::load()->helper('directory'); $data['registrationErrors'] = \CI::form_validation()->get_error_array(); $this->view('login', $data); } else { $save['id'] = false; $save['firstname'] = \CI::input()->post('firstname'); $save['lastname'] = \CI::input()->post('lastname'); $save['email'] = \CI::input()->post('email'); $save['phone'] = \CI::input()->post('phone'); $save['company'] = \CI::input()->post('company'); $save['active'] = (bool) config_item('new_customer_status'); $save['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe')); $save['password'] = \CI::input()->post('password'); $redirect = \CI::input()->post('redirect'); //if we don't have a value for redirect if ($redirect == '') { $redirect = 'my-account'; } // save the customer info and get their new id $id = \CI::Customers()->save($save); //send the registration email \GoCart\Emails::registration($save); //load twig for this language string $loader = new \Twig_Loader_String(); $twig = new \Twig_Environment($loader); //if they're automatically activated log them in and send them where they need to go if ($save['active']) { \CI::session()->set_flashdata('message', $twig->render(lang('registration_thanks'), $save)); //lets automatically log them in \CI::Login()->loginCustomer($save['email'], \CI::input()->post('confirm')); //to redirect them, if there is no redirect, the it should redirect to the homepage. redirect($redirect); } else { //redirect to the login page if they need to wait for activation \CI::session()->set_flashdata('message', $twig->render(lang('registration_awaiting_activation'), $save)); redirect('login'); } } }
public function delete_banner($banner_id) { $banner = \CI::Banners()->banner($banner_id); if (!$banner) { \CI::session()->set_flashdata('error', lang('banner_not_found')); } else { \CI::Banners()->delete_banner($banner_id); \CI::session()->set_flashdata('message', lang('message_delete_banner')); } redirect('admin/banners/banner_collection/' . $banner->banner_collection_id); }
public function delete($id) { \CI::Orders()->delete($id); \CI::session()->set_flashdata('message', lang('message_order_deleted')); //redirect as to change the url redirect('admin/orders'); }
<td><?php echo $admin->username; ?> </td> <td><?php echo $admin->access; ?> </td> <td class="text-right"> <div class="btn-group"> <a class="btn btn-default" href="<?php echo site_url('admin/users/form/' . $admin->id); ?> "><i class="icon-pencil"></i></a> <?php $current_admin = \CI::session()->userdata('admin'); if ($current_admin['id'] != $admin->id) { ?> <a class="btn btn-danger" href="<?php echo site_url('admin/users/delete/' . $admin->id); ?> " onclick="return areyousure();"><i class="icon-times "></i></a> <?php } ?> </div> </td> </tr> <?php } ?>