public function __construct($items, $c) { $s = Model::load('ShippingAddress'); $s->id = \Empathy\Session::get('shipping_address_id'); $s->load(); $o = Model::load('OrderItem'); $o->user_id = CurrentUser::getUserID(); $o->status = 'DEFAULT'; $o->stamp = 'MYSQLTIME'; $o->first_name = $s->first_name; $o->last_name = $s->last_name; $o->address1 = $s->address1; $o->address2 = $s->address2; $o->city = $s->city; $o->state = $s->state; $o->zip = $s->zip; $o->country = $s->country; $this->invoice_no = $o->insert(Model::getTable('OrderItem'), 1, array(), 0); if (!defined('ELIB_PAYPAL_TEST_MODE') || defined('ELIB_PAYPAL_TEST_MODE') && !ELIB_PAYPAL_TEST_MODE) { $this->invoice_no = time() . '/' . $this->invoice_no; } $l = Model::load('LineItem'); foreach ($items as $item) { if (is_numeric($item['qty']) && $item['qty'] > 0) { $l->order_id = $this->invoice_no; $l->variant_id = $item['id']; $l->price = $item['price']; $l->quantity = $item['qty']; $l->insert(Model::getTable('LineItem'), 1, array(), 0); } } }
public function __construct($boot) { parent::__construct($boot); if (!CurrentUser::loggedIn()) { $this->authFailed(); } }
public function __construct($boot) { parent::__construct($boot); if (!(CurrentUser::loggedIn() && CurrentUser::isAuthLevel(Access::VENDOR))) { $this->redirect(''); } }
public function logout() { if (1 || isset($_POST['logout'])) { $u = CurrentUser::getUser(); Session::down(); $this->logoutSuccess($u); $this->redirect(''); } }
public function __construct($boot) { parent::__construct($boot); CurrentUser::detectUser($this); $this->elib_tpl_dirs = Util\Libs::detect(); if (sizeof($this->elib_tpl_dirs) > 1) { $this->assign('elibtpl_arr', $this->elib_tpl_dirs); } else { $this->assign('elibtpl', $this->elib_tpl_dirs[0]); } if (Util\Libs::getStoreActive()) { CurrentUser::detectUser($this, true); } }
private function submitComment() { $bc = Model::load('BlogComment'); $bc->blog_id = $_GET['id']; $bc->status = 1; $bc->body = $_POST['body']; $bc->heading = ''; $bc->user_id = CurrentUser::getUserId(); $bc->validates(); if ($bc->hasValErrors()) { $this->presenter->assign('comment', $bc); $this->presenter->assign('errors', $bc->val->errors); } else { $bc->stamp = date('Y-m-d H:i:s', time()); $bc->insert(Model::getTable('BlogComment'), 1, array('body'), 1); $this->redirect('blog/item/' . $bc->blog_id); } }
public function add_event() { if (isset($_POST['submit'])) { $time = array('day' => $_POST['start_day'], 'month' => $_POST['start_month'] + 1, 'year' => $_POST['start_year'], 'hour' => $_POST['start_hour'], 'minute' => $_POST['start_minute'], 'second' => 0); $start = new DateTime($time); $time = array('day' => $_POST['end_day'], 'month' => $_POST['end_month'] + 1, 'year' => $_POST['end_year'], 'hour' => $_POST['end_hour'], 'minute' => $_POST['end_minute'], 'second' => 0); $end = new DateTime($time); $e = Model::load('Event'); if (!$start->getValid()) { $e->addValError('invalid start date', 'start_time'); } if (!$end->getValid()) { $e->addValError('invalid end date', 'end_time'); } $e->user_id = CurrentUser::getUserID(); $e->start_time = $start->getMySQLTime(); $e->end_time = $end->getMySQLTime(); if ($end->getTime() <= $start->getTime()) { $e->addValError('invalid end date/time', 'end_time'); } $e->event_name = $_POST['event_name']; $e->short_desc = $_POST['short_desc']; $e->long_desc = $_POST['long_desc']; $e->tickets_link = $_POST['tickets_link']; $e->event_link = $_POST['event_link']; $e->status = 'DEFAULT'; $e->validates(); if ($e->hasValErrors()) { $e->start_day = $_POST['start_day']; $e->start_month = $_POST['start_month']; $e->start_year = $_POST['start_year']; $e->start_hour = $_POST['start_hour']; $e->start_minute = $_POST['start_minute']; $e->end_day = $_POST['end_day']; $e->end_month = $_POST['end_month']; $e->end_year = $_POST['end_year']; $e->end_hour = $_POST['end_hour']; $e->end_minute = $_POST['end_minute']; $this->assign('event', $e); $this->assign('errors', $e->getValErrors()); } else { $e->insert(Model::getTable('Event'), 1, array(), 1); $this->redirect('admin/events'); } } elseif (isset($_POST['cancel'])) { $this->redirect('admin/events'); } else { $e = Model::load('Event'); // default (mostly empty) event $date = $this->filterInt('date'); if (strlen($date) != 8) { $date = 0; } if ($date != 0) { $y = substr($date, 0, 4); $m = substr($date, 4, 2); $d = substr($date, 6, 2); $time = mktime(0, 0, 0, $m, $d, $y); $e->start_day = $d; $e->start_month = $m - 1; $e->start_year = $y; $e->start_hour = 20; $e->start_minute = 0; $e->end_day = $d; $e->end_month = $m - 1; $e->end_year = $y; $e->end_hour = 20; $e->end_minute = 0; $this->assign('event', $e); } } $this->assignEventDefs(); $this->setTemplate('elib://admin/add_event.tpl'); }
public function __construct($boot) { parent::__construct($boot); CurrentUser::assertAdmin($this); $this->detectHelp(); }
public function addProduct() { $_GET['id'] = (int) $_GET['id']; if ($_GET['id'] > 0) { $c = Model::load('CategoryItem'); $c->id = $_GET['id']; if (!$c->hasChildren()) { $p = Model::load('ProductItem'); $p->category_id = $_GET['id']; $p->name = 'New Product'; $p->description = 'No description.'; $p->status = 'DEFAULT'; if (defined('ELIB_MULTIPLE_VENDORS') && ELIB_MULTIPLE_VENDORS == true) { $user_id = CurrentUser::getUserID(); $v = Model::load('Vendor'); $v->id = $v->getIDByUserID($user_id); if ($v->id > 0) { $v->load(); if ($v->verified !== null) { $p->vendor_verified = 1; } else { $p->vendor_verified = 0; } $p->vendor_id = $v->id; } } $p->id = $p->insert(Model::getTable('ProductItem'), 1, array(), 0); $this->addProductVariantInternal($p->id); // create first variant $this->c->redirect('storeadmin/edit_product/' . $p->id); } } $this->c->redirect('storeadmin/products/' . $_GET['id']); }
public function __construct($boot) { parent::__construct($boot); CurrentUser::detectUser($this); $this->assignELibTemplateDir(); }
public function checkout() { $this->setTemplate('checkout.tpl'); $s = Model::load('ShippingAddress'); $sql = ' WHERE user_id = ' . CurrentUser::getUserID() . ' ORDER BY id DESC'; $addresses = $s->getAllCustom(Model::getTable('ShippingAddress'), $sql); $this->assign('addresses', $addresses); if (isset($_GET['checkout'])) { Session::set('shipping_address_id', $_GET['shipping_address_id']); $this->redirect('paypal/paypal'); } }
public function add_address() { $this->setTemplate('address.tpl'); $countries = Country::build(); $this->presenter->assign('countries', $countries); $this->presenter->assign('sc', 'GB'); if (isset($_POST['save'])) { $s = Model::load('ShippingAddress'); $s->user_id = CurrentUser::getUserID(); $s->first_name = $_POST['first_name']; $s->last_name = $_POST['last_name']; $s->address1 = $_POST['address1']; $s->address2 = $_POST['address2']; $s->city = $_POST['city']; $s->state = $_POST['state']; $s->zip = $_POST['zip']; $s->country = $_POST['country']; $s->validates(); if ($s->hasValErrors()) { $this->presenter->assign('address', $s); $this->presenter->assign('sc', $s->country); $this->presenter->assign('errors', $s->getValErrors()); } else { $s->insert(Model::getTable('ShippingAddress'), 1, array(), 0); $this->redirect('store/checkout'); } } }