public function before() { if (!\Request::is_hmvc()) { throw new \HttpNotFoundException(); } parent::before(); }
public function after($response) { !\Request::is_hmvc() and $this->theme->get_template()->set_global($this->dataGlobal); // If nothing was returned set the theme instance as the response if (empty($response)) { $response = \Response::forge($this->theme); } if (!$response instanceof \Response) { $response = \Response::forge($response); } return parent::after($response); }
/** * Get enabled payments * * @access public * @param string $get = Get payments that are: enabled | disabled | all * @param string $load_config = Load payments config * @param bool $allowed * @return array * */ public function action_get_payments($get = 'enabled', $load_config = true, $allowed = true) { if (!\Request::is_hmvc()) { die('Access is denied.'); } $user = \Sentry::user(); $out = array(); $path = APPPATH . "modules" . DS . "payment" . DS . "config" . DS; $config_files = \File::read_dir($path); if (!empty($config_files)) { foreach ($config_files as $file) { $file_parts = pathinfo($file); $payment_config = (include_once $path . $file); // Check allowed if ($allowed && isset($payment_config['allowed']) && is_array($payment_config['allowed'])) { foreach ($payment_config['allowed'] as $key => $value) { if (!isset($user['metadata'][$key]) || !in_array($user['metadata'][$key], $value)) { continue 2; } } } switch ($get) { case 'enabled': if ($payment_config['enabled']) { $out[$payment_config['code']] = $payment_config['name']; if ($load_config) { \Config::load('payment::' . $file_parts['filename'], $file_parts['filename']); } } break; case 'disabled': if (!$payment_config['enabled']) { $out[$payment_config['code']] = $payment_config['name']; if ($load_config) { \Config::load('payment::' . $file_parts['filename'], $file_parts['filename']); } } break; default: case 'all': $out[$payment_config['code']] = $payment_config['name']; if ($load_config) { \Config::load('payment::' . $file_parts['filename'], $file_parts['filename']); } } } } return $out; }
public function before() { parent::before(); // Load translation \Lang::load('application'); if (Request::is_hmvc()) { $this->template = View::forge('user/hmvc/template'); } elseif (!Input::is_ajax()) { $this->template = View::forge('main_template'); $this->template->title = 'WSJ User Authentication'; $this->_navigation = View::forge('_templates/top_navbar'); $this->_header = View::forge('_templates/header'); // Put navigation view into header $this->_header->set('navigation', $this->_navigation); } }
/** * Get the sidebar view (HMVC Only) */ public function get_sidebar() { if (\Request::is_hmvc()) { // Get sidebar in cache try { $sidebar = \Cache::get('sidebar'); } catch (\CacheNotFoundException $e) { // If Cache doesn't exist, get data and cache the view $this->data['categories'] = \Model_Category::find('all'); $this->data['lastPosts'] = \Model_Post::query()->order_by('created_at', 'DESC')->limit(5)->get(); $sidebar = $this->theme->view('frontend/post/sidebar', $this->data); \Cache::set('sidebar', $sidebar); } return $sidebar; } }
/** * Form to submit to PayPal * * @access public * @param object $order = Order object * @param array of objects $products = Products from order * @return string $page */ public function action_form($order = false, $products = false) { if (!\Request::is_hmvc()) { die('Access is denied.'); } if (empty($order) || empty($products)) { return; } //send email to user //$this->send_email($order, $products); // Active config $active = \Config::get('details.config.active', 'test'); $config = \Config::get('details.config.' . $active, false); if ($config === false) { throw new \Exception('Invalid payment config.'); } // Seller account $business = $config['business']; // The URL to which PayPal posts information about the payment $notify_url = $config['notify_url']; // Return url $return = $config['return']; $fields = array(); $form = ''; // Form to submit to PayPal // https://www.x.com/developers/paypal/documentation-tools/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables $form .= '<form action="' . $config['url'] . '" method="post" id="payment_form" target="_parent">'; // Technical HTML Variables $form .= \Form::hidden('cmd', '_cart'); $form .= \Form::hidden('notify_url', $notify_url); $fields['cmd'] = '_cart'; $fields['notify_url'] = $notify_url; $fields['custom'] = 'paypal'; $fields['customvar'] = 'paypal'; // HTML Variables for Payment Transactions $form .= \Form::hidden('invoice', $order->id); $form .= \Form::hidden('currency_code', strtoupper($order->currency)); //$form .= \Form::hidden('address_override', '1'); $fields['invoice'] = $order->id; $fields['currency_code'] = strtoupper($order->currency); //$fields['address_override'] = '1'; // HTML Variables for Shopping Carts $form .= \Form::hidden('business', $business); $form .= \Form::hidden('upload', '1'); $fields['business'] = $business; $fields['upload'] = '1'; foreach ($products as $key => $product) { $form .= \Form::hidden('item_name_' . ($key + 1), $product->title); //$form .= \Form::hidden('item_number_' . $key, $product->id); $form .= \Form::hidden('amount_' . ($key + 1), $product->price); $form .= \Form::hidden('quantity_' . ($key + 1), $product->quantity); $fields['item_name_' . ($key + 1)] = $product->title; $fields['item_number_' . ($key + 1)] = $product->id; $fields['amount_' . ($key + 1)] = $product->price; $fields['quantity_' . ($key + 1)] = $product->quantity; } // HTML Variables for Filling Out PayPal Checkout Pages Automatically for Buyers // $form .= \Form::hidden('address1', $order->address); // $form .= \Form::hidden('city', $order->suburb); // $form .= \Form::hidden('country', strtoupper($order->country)); // $form .= \Form::hidden('email', $order->email); $form .= \Form::hidden('first_name', $order->first_name); $form .= \Form::hidden('last_name', $order->last_name); // $form .= \Form::hidden('state', strtoupper($order->state)); // $form .= \Form::hidden('zip', $order->postcode); // $fields['address1'] = $order->address; // $fields['city'] = $order->suburb; // $fields['country'] = $order->country; // $fields['email'] = $order->email; // $fields['first_name'] = $order->first_name; // $fields['last_name'] = $order->last_name; // $fields['state'] = $order->state; // $fields['zip'] = $order->postcode; // HTML Variables for Displaying PayPal Checkout Pages $form .= \Form::hidden('lc', 'AU'); $form .= \Form::hidden('return', $return); $form .= \Form::hidden('rm', 2); $fields['lc'] = 'AU'; $fields['return'] = $return; $form .= '</form>'; // // Send form with curl // $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, "https://www.' . $sandbox_str . 'paypal.com/cgi-bin/webscr"); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_POST, true); // curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // $output = curl_exec($ch); // //$info = curl_getinfo($ch); // curl_close($ch); return $form; //return \Theme::instance()->view($this->view_dir . 'payment_form', array('title' => 'Pluris shoes' ,'msg' => 'Please wait, you will be redirected to the PayPal payment.', 'form' => $form), false); }
/** * Delete content image * * @param $image_id = Image ID * @param $content_id = Content ID * @param $type = Type of content (infotab or hotspot) * @param $delete = If type is "hotspot" we can either delete image or video */ public function action_delete_infotab_image($image_id = false, $content_id = false, $type = 'infotab', $delete = 'image') { if ($image_id && $content_id) { $images = Model_Application_Image::find(array('where' => array('application_id' => $content_id), 'order_by' => array('sort' => 'asc')), 'id'); if ($images) { if (isset($images[$image_id])) { $image = $images[$image_id]; if (strtolower($type) == 'hotspot') { // Delete only part of hotspot, either image or video if ($delete == 'image') { // Delete only image but not whole hotspot $this->delete_infotab_image($image->image); $image->set(array('image' => null, 'alt_text' => null)); } else { // Delete only video but not whole hotspot $image->set(array('video' => null, 'video_title' => null)); } $image->save(); \Messages::success(ucfirst($type) . ' ' . strtolower($delete) . ' was successfully deleted.'); } else { // If there is only one image and image is required if (count($images) == 1) { if (\Config::get('infotab.image.required', false) && !\Request::is_hmvc()) { \Messages::error('You can\'t delete all images. Please add new image in order to delete this one.'); } else { // Reset sort fields \DB::update(Model_Application_Image::get_protected('_table_name'))->value('sort', \DB::expr('sort - 1'))->where('sort', '>', $image->sort)->execute(); // Delete image $this->delete_infotab_image($image->image); $image->delete(); \Messages::success(ucfirst($type) . ' image was successfully deleted.'); } } else { if ($image->cover == 1 && !\Request::is_hmvc()) { \Messages::error('You can\'t delete cover image. Set different image as cover in order to delete this one.'); } else { // Reset sort fields \DB::update(Model_Application_Image::get_protected('_table_name'))->value('sort', \DB::expr('sort - 1'))->where('sort', '>', $image->sort)->execute(); // Delete image $this->delete_infotab_image($image->image); $image->delete(); \Messages::success(ucfirst($type) . ' image was successfully deleted.'); } } } } else { \Messages::error(ucfirst($type) . ' image you are trying to delete don\'t exists. Check your url and try again.'); } } else { \Messages::error(ucfirst($type) . ' image you are trying to delete don\'t exists. Check your url and try again.'); } } if (\Input::is_ajax()) { \Messages::reset(); \Messages::success('Hotspot was successfully deleted.'); echo \Messages::display(); } else { if (\Request::is_hmvc()) { \Messages::reset(); } else { \Response::redirect(\Input::referrer()); } } }
public function action_delete($id = false) { if (is_numeric($id)) { // Get news item to edit if ($item = Model_Accordion::find_one_by_id($id)) { // Delete other content data like images, files, etc. if (!empty($item->images)) { foreach ($item->images as $image) { $this->delete_image($image->image); $image->delete(); } } try { $item->delete(); \Messages::success('Accordion successfully deleted.'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to delete accordion</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } } // If its a HMVC request than reset messages and do nothing \Request::is_hmvc() ? \Messages::reset() : \Response::redirect(\Input::referrer()); }
public function action_delete($id = false) { if (is_numeric($id)) { // Get news item to edit if ($item = Model_Attribute_Option::find_one_by_id($id)) { // Delete item try { $item->delete(); // NRB-Gem: remove from product_attributes and product_attribute_price $a_attr = \Product\Model_Attribute::find_by(array(array('attributes', 'like', '%"' . $item->attribute_id . '":"' . $id . '"%'))); $a_attr_id = array(); foreach ($a_attr as $o_attr) { $a_attr_id[] = $o_attr->id; } if (count($a_attr_id)) { $s_ids = '(' . implode(',', $a_attr_id) . ')'; \DB::delete('product_attributes')->where('id', 'IN', \DB::expr($s_ids))->execute(); \DB::delete('product_attribute_price')->where('product_attribute_id', 'IN', \DB::expr($s_ids))->execute(); } \Messages::success('Attribute option successfully deleted.'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to delete attribute option</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } } if (\Request::is_hmvc()) { \Messages::reset(); } else { \Response::redirect(\Input::referrer(\Uri::create('admin/attribute/list'))); } }
/** * Delete content image * * @param $content_id = Content ID */ public function action_delete_image($id = false) { if (is_numeric($id)) { // Get news item to edit if ($item = Model_Product_To_Infotabs::find_by_pk($id)) { // Delete hotspot images if (!empty($item->images)) { foreach ($item->images as $image) { \Request::forge('admin/product/delete_infotab_image/' . $image->id . '/' . $image->infotab_id)->execute()->response(); } } // Delete item try { $this->delete_image($item->image); $item->image = NULL; $item->alt_text = NULL; // Make infotab inactive as it cant show without image $item->active = 0; $item->save(); \Messages::success('Info Tab image successfully deleted.'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to delete info tab image</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } } if (\Request::is_hmvc()) { \Messages::reset(); } else { \Response::redirect(\Input::referrer(\Uri::create('admin/product/infotab/list'))); } }