public function toggle_help() { $help_shown = Session::get('help_shown'); if ($help_shown) { Session::set('help_shown', false); } else { Session::set('help_shown', true); } echo json_encode(1); exit; }
public static function detectUser($c) { self::$u = Model::load('UserItem'); self::$user_id = Session::get('user_id'); if (is_numeric(self::$user_id) && self::$user_id > 0) { self::$u->id = self::$user_id; self::$u->load(); $c->assign('current_user', self::$u->username); $c->assign('user_id', self::$u->id); $c->assign('user_is_vendor', self::$u->auth == Access::VENDOR); } }
public function toggle_help() { if ($this->isXMLHttpRequest()) { $help_shown = Session::get('help_shown'); if ($help_shown) { Session::set('help_shown', false); } else { Session::set('help_shown', true); } header('Content-type: application/json'); echo json_encode(1); exit; } }
public static function detectUser($c = NULL, $store_active = false) { self::$u = Model::load('UserItem'); self::$user_id = Session::get('user_id'); if (is_numeric(self::$user_id) && self::$user_id > 0) { self::$u->id = self::$user_id; self::$u->load(); if ($c !== null) { $c->assign('current_user', self::$u->username); $c->assign('user_id', self::$u->id); } if ($store_active) { $c->assign('user_is_vendor', self::$u->auth == \Empathy\ELib\Store\Access::VENDOR); } } }
public static function dump() { $c = Session::get('cart'); print_r($c); }
public function cart() { $this->setTemplate('cart.tpl'); $c = new ShoppingCart(); if (isset($_POST['update'])) { foreach ($_POST['qty'] as $v => $qty) { if (is_numeric($qty) && $qty > 0) { $c->update($v, $qty); } elseif (is_numeric($qty) && $qty == 0) { $c->remove($v); // vendor locking if ($c->isEmpty()) { Session::clear('vendor_lock'); } } } $this->redirect('store/cart'); } elseif (isset($_POST['checkout'])) { $this->redirect('store/checkout'); } $items = $c->loadFromCart($this); if (sizeof($items) > 0) { $ids = array(); foreach ($items as $item) { array_push($ids, $item['id']); } $v = Model::load('ProductVariant'); $cat_ids = $v->getCategories($ids); $cat = Model::load('CategoryItem'); $calc = new ShippingCalculator($c->calcTotal($items), $cat_ids, $cat, sizeof($items), false); $shipping = $calc->getFee(); $shipping = 0; $this->assign('shipping', $shipping); $this->assign('total', $c->calcTotal($items) + $shipping); $this->assign('items', $items); } if (isset($this->vendor_lock)) { $this->assign('vendor_id', $this->vendor_lock); } $this->assign('last_cat', Session::get('last_cat')); }
public function create() { $c = Model::load('BlogCategory'); $cats = $c->getAllCustom(Model::getTable('BlogCategory'), ''); $cats_arr = array(); foreach ($cats as $index => $item) { $id = $item['id']; $cats_arr[$id] = $item['label']; } $this->presenter->assign('cats', $cats_arr); $this->setTemplate('elib:/admin/create_blog.tpl'); if (isset($_POST['save'])) { $b = Model::load('BlogItem'); $tags_arr = $b->buildTags(); // errors ? $b->heading = $_POST['heading']; $b->body = $_POST['body']; $b->status = DRAFT; $b->slug = $_POST['slug']; $b->checkForDuplicates($tags_arr); $b->validates(); if ($b->hasValErrors()) { $this->presenter->assign('blog', $b); $this->presenter->assign('blog_tags', $_POST['tags']); $this->presenter->assign('errors', $b->getValErrors()); $this->assign('blog_cats', $_POST['category']); } else { $b->assignFromPost(array('user_id', 'id', 'stamp', 'tags', 'status')); $b->user_id = Session::get('user_id'); $b->stamp = date('Y-m-d H:i:s', time()); $b->id = $b->insert(Model::getTable('BlogItem'), 1, array(), 1); $bc = Model::load('BlogCategory'); $bc->createForBlogItem($_POST['category'], $b->id); $this->processTags($b, $tags_arr); $this->redirect('admin/blog'); } } }
public function tags() { if (!isset($_GET['active_tags'])) { $this->redirect(''); } if (Session::get('blog_category') > 0) { $this->doSetCategory('any'); } $_GET['active_tags'] = $this->getTags(); $this->default_event(); }