示例#1
0
 /**
  * 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');
     }
 }
示例#2
0
		<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