function cleanCart() { session_start(); $user = $_SESSION['userid']; $cart = $_SESSION[$user . 'cart']; if ($cart) { $items = explode(',', $cart); $contents = array(); foreach ($items as $item) { $contents[$item] = isset($contents[$item]) ? $contents[$item] + 1 : 1; } foreach ($contents as $i => $qty) { $id = substr($i, 2); $sql = 'SELECT * FROM mdl_shoppingcart_store_inventory WHERE id = ' . $id . ' and active =1'; $result = db_getrecords($sql); if ($result == null || is_array($result) && empty($result)) { if ($cart) { $items = explode(',', $cart); $newcart = ''; foreach ($items as $item) { if ($i != $item) { if ($newcart != '') { $newcart .= ',' . $item; } else { $newcart = $item; } } } } $cart = $newcart; } } } $_SESSION[$user . 'cart'] = $cart; }
function db_getAllUsers() { try { $sql = "SELECT u.id, u.username, u.firstname, u.lastname FROM mdl_user u WHERE u.id IN"; $sql .= "( SELECT ra.userid FROM mdl_role_assignments ra WHERE ra.roleid = 5 AND ra.contextid IN"; $sql .= "( SELECT mc.id FROM mdl_context mc WHERE mc.contextlevel = 50)) ORDER BY u.lastname"; $users = db_getrecords($sql); return $users; } catch (Exception $e) { echo $e->getMessage(); return null; } }
function isPackageBeingUsed($packageid) { $sql = "SELECT * FROM module_vlabs_shoppingcart_order_summary "; $sql .= "WHERE itemid = " . $packageid; $order_items = db_getrecords($sql); $counter = 0; foreach ($order_items as $o) { $counter++; } if ($counter > 0) { return true; } else { return false; } }
function isItemBeingUsed($itemid) { $sql_orders = 'SELECT * FROM mdl_shoppingcart_order_summary WHERE itemid =' . $itemid; $sql_packages = 'SELECT * FROM mdl_shoppingcart_package_summary WHERE itemid =' . $itemid; $dborders = db_getrecords($sql_orders); $dbpackages = db_getrecords($sql_packages); if ($dborders != null || $dbpackages != null) { return true; } else { return false; } }
function isItemBeingUsed($itemid) { $sql_orders = 'SELECT * FROM module_vlabs_shoppingcart_order_summary WHERE itemid =' . $itemid; $sql_packages = 'SELECT * FROM module_vlabs_shoppingcart_package_summary WHERE itemid =' . $itemid; $dborders = db_getrecords($sql_orders); $dbpackages = db_getrecords($sql_packages); $dborders_counter = 0; $dbpackages_counter = 0; foreach ($dborders as $dbO) { $dborders_counter++; } foreach ($dbpackages as $dbP) { $dbpackages_counter++; } if ($dborders_counter > 0 || $dbpackages_counter > 0) { return true; } else { return false; } }
function isPackageBeingUsed($packageid) { $sql = "SELECT * FROM mdl_shoppingcart_order_summary "; $sql .= "WHERE itemid = " . $packageid; $order_items = db_getrecords($sql); if ($order_items != null) { return true; } else { return false; } }