コード例 #1
0
 public static function assertAdmin($c)
 {
     $ua = Model::load('UserAccess', null, false);
     if (self::$u->id < 1 || self::$u->getAuth(self::$u->id) < $ua->getLevel('admin')) {
         Session::down();
         $c->redirect("user/login");
     }
 }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: Store.php プロジェクト: mikejw/elib-experimental
 public function productsView()
 {
     $ui_array = array('order_by', 'page', 'id', 'brand_id');
     Session::loadUIVars('ui_catalogue', $ui_array);
     if (!isset($_GET['page']) || $_GET['page'] == '') {
         $_GET['page'] = 1;
     }
     if (!isset($_GET['id']) || $_GET['id'] == '') {
         $_GET['id'] = 0;
     }
     if (!isset($_GET['order_by']) || $_GET['order_by'] == '') {
         $_GET['order_by'] = 'id';
     }
     if (!isset($_GET['brand_id']) || $_GET['brand_id'] == '') {
         $_GET['brand_id'] = 0;
     }
     $this->c->assign('order_by', $_GET['order_by']);
     $this->c->assign('page', $_GET['page']);
     $this->c->assign('category_id', $_GET['id']);
     $this->buildNav();
     $p = Model::load('ProductItem');
     if (isset($_GET['id']) && is_numeric($_GET['id'])) {
         $showCat = $_GET['id'];
     } else {
         $showCat = 0;
     }
     $sql = ' WHERE category_id = ' . $_GET['id'];
     if ($_GET['brand_id'] > 0) {
         $sql .= ' AND brand_id = ' . $_GET['brand_id'];
     }
     // status
     $sql .= ' AND status != ' . ProductItemStatus::DELETED;
     // vendor
     $v = Model::load('Vendor');
     $vendor_id = $v->getIDByUserID(CurrentUser::getUserID());
     $sql .= ' AND vendor_id = ' . $vendor_id;
     $sql .= ' ORDER BY ' . $_GET['order_by'];
     $p_nav = $p->getPaginatePages(Model::getTable('ProductItem'), $sql, $_GET['page'], REQUESTS_PER_PAGE);
     $this->c->assign('p_nav', $p_nav);
     $product = $p->getAllCustomPaginate(Model::getTable('ProductItem'), $sql, $_GET['page'], REQUESTS_PER_PAGE);
     foreach ($product as &$p_item) {
         $p_item['status_text'] = ProductItemStatus::getStatus($p_item['status']);
         //$p_item['min_price'] = $p->getMinPrice($p_item['id']);
         // min price is now stored in products table
     }
     $c = Model::load('CategoryItem');
     $c->id = $_GET['id'];
     $category = $c->loadIndexed($c->category_id);
     $this->c->assign("products", $product);
 }
コード例 #4
0
 public function confirm_reg()
 {
     $reg_code = $_GET['code'];
     $u = Model::load('UserItem');
     $id = $u->findUserForActivation($reg_code);
     if ($id > 0) {
         $u->id = $id;
         $u->load();
         $password = $u->password;
         $u->password = md5(SALT . $password . SALT);
         $u->active = 1;
         $u->activated = 'MYSQLTIME';
         $u->save(Model::getTable('UserItem'), array(), 0);
         Session::set('user_id', $u->id);
         $message = "\nHi ___,\n\n" . "Thanks for confirming your registration. You can now log in to the " . ELIB_EMAIL_ORGANISATION . " website using your username " . " '___' and the password '" . $password . "'.\n\nCheers\n\n";
         $r[0]['alias'] = $u->username;
         $r[0]['address'] = $u->email;
         $m = new Mailer($r, 'Welcome to ' . ELIB_EMAIL_ORGANISATION, $message, ELIB_EMAIL_FROM);
         $this->redirect('user/thanks/2');
     } else {
         throw new \Exception('Unable to activate user.');
     }
 }
コード例 #5
0
 public static function dump()
 {
     $c = Session::get('cart');
     print_r($c);
 }
コード例 #6
0
ファイル: AdminController.php プロジェクト: mikejw/elib-base
 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;
     }
 }
コード例 #7
0
 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');
     }
 }
コード例 #8
0
 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');
         }
     }
 }
コード例 #9
0
 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();
 }