/** * Delete product * @param integer id of product * @return void */ public function delete($id) { // Check user permission if (user::is_got()) { // Settings $this->set_title(Kohana::lang('eshop.delete_product')); $this->add_breadcrumb(Kohana::lang('eshop.delete_product'), url::current()); if ($_POST) { if (isset($_POST['yes'])) { // clicked on yes = delete $cat = $this->products->get_product_cat($id); $cat = $cat[0]; $status = $this->products->delete_data($id); // Also delte images if deletition was successful if ($status == TRUE) { gallery::delete_images($id, 'products'); } url::redirect('/cat/' . $cat . '/' . cat::get_name($cat)); } else { url::redirect('/product/' . $id . '/' . string::to_url(product::get_name($id))); } } // page $this->template->content = new View('admin/product_delete'); } else { url::redirect('/denied'); } }
<em><?php echo Kohana::lang('eshop.no_subcats'); ?> </em> <?php } ?> <div class="right"> <?php if (cat::get_parent($id) != 0) { ?> <a href="/cat/<?php echo cat::get_parent($id); ?> /<?php echo cat::get_name(cat::get_parent($id)); ?> "><?php echo Kohana::lang('eshop.jump_to_parent'); ?> </a> | <?php } ?> <?php if (user::is_got()) { ?> <a href="/cat/add/<?php echo $id; ?> "><?php
/** * Delete category * @return void * @param integer id of category */ public function delete($id) { // Check user permission if (user::is_got()) { // Settings $this->set_title(Kohana::lang('eshop.delete_cat')); $this->add_breadcrumb(Kohana::lang('eshop.delete_cat'), url::current()); $errors = array(); if ($_POST) { if (isset($_POST['yes'])) { // clicked on yes = delete if (count($this->cats->get_children($id)) != 0 or count($this->products->get(1, 1, $id))) { $errors[] = Kohana::lang('eshop.cannot_be_deleted'); } else { $parent = cat::get_parent($id); $this->cats->delete_data($id); if ($parent == 0) { url::redirect('/'); } else { url::redirect('/cat/' . $parent . '/' . cat::get_name($parent)); } } } else { url::redirect('/cat/' . $id . '/' . cat::get_name($id)); } } // View $this->template->content = new View('admin/cat_delete'); $this->template->content->errors = $errors; } else { url::redirect('/denied'); } }
/** * Return array with ID and names * @return * @param object $ids */ public function add_names($ids) { foreach ($ids as $row) { $ids[$row] = cat::get_name($row); } // solving problem with gaps $new = array(); foreach ($ids as $key => $value) { if (!is_numeric($value)) { $new[$key] = $value; } } return $new; }