</div>'; break; /** EDIT STORE */ /** EDIT STORE */ case 'edit': if (!ab_to(array('stores' => 'edit'))) { die; } $csrf = \site\utils::str_random(10); echo '<div class="title"> <h2>' . $LANG['stores_edit_title'] . '</h2> <div style="float:right; margin: 0 2px 0 0;">'; if (isset($_GET['id']) && ($store_exists = \query\main::store_exists($_GET['id']))) { $info = \query\main::store_infos($_GET['id']); echo '<div class="options"> <a href="#" class="btn">' . $LANG['options'] . '</a> <ul>'; if (ab_to(array('coupons' => 'add'))) { echo '<li><a href="?route=coupons.php&action=add&store=' . $_GET['id'] . '&token=' . $csrf . '">' . $LANG['coupons_add_button'] . '</a></li>'; } if (ab_to(array('stores' => 'delete'))) { echo '<li><a href="?route=stores.php&action=delete&id=' . $_GET['id'] . '&token=' . $csrf . '" data-delete-msg="' . $LANG['delete_store'] . '">' . $LANG['delete'] . '</a></li>'; } if ($info->visible) { echo '<li><a href="?route=stores.php&action=list&type=unpublish&id=' . $_GET['id'] . '&token=' . $csrf . '">' . $LANG['unpublish'] . '</a></li>'; } else { echo '<li><a href="?route=stores.php&action=list&type=publish&id=' . $_GET['id'] . '&token=' . $csrf . '">' . $LANG['publish'] . '</a></li>'; }
/* SHOWING COUPONS OR PRODUCTS */ function searched_type() { if (isset($_GET['type']) && strtolower($_GET['type']) === 'products') { return 'products'; } return 'coupons'; } /* PUT THE OBJECT INTO A GLOBAL VARIABLE */ $GLOBALS['searched_type'] = searched_type(); $GLOBALS['item'] = \query\main::store_infos(0, array('update_views' => '')); $GLOBALS['exists'] = \query\main::store_exists(0, array('user_view' => '')); /* CHECK IF STORE EXISTS */ function exists() { return $GLOBALS['exists']; } /* INFORMATIONS ABOUT STORE */ function the_item() { return $GLOBALS['item']; } /*
<?php /* PUT THE OBJECT INTO A GLOBAL VARIABLE */ $GLOBALS['item'] = \query\main::store_infos(); $GLOBALS['exists'] = \query\main::store_exists(); /* CHECK IF STORE EXISTS */ function exists() { return $GLOBALS['exists']; } /* INFORMATIONS ABOUT STORE */ function the_item() { return $GLOBALS['item']; } /* CHECK IF HAVE ITEMS */ function have_items($category = array()) { $GLOBALS['have_items'] = \query\main::have_reviews($category, 'store'); /* ACTIVATE PAGES INFORMATIONS IF FUNCTION have_items() IS CALLED */ /*
public static function delete_store_image($id) { global $db; if (!ab_to(array('stores' => 'edit'))) { return false; } $id = (array) $id; $stmt = $db->stmt_init(); foreach ($id as $ID) { if (\query\main::store_exists($ID)) { $store = \query\main::store_infos($ID); $stmt->prepare("UPDATE " . DB_TABLE_PREFIX . "stores SET image = '' WHERE id = ?"); $stmt->bind_param("i", $ID); $stmt->execute(); if (!empty($store->image)) { @unlink(DIR . '/' . $store->image); } } } @$stmt->close(); return true; }