public function default_event() { if (isset($_POST['verify'])) { $v = Model::load('Vendor'); $v->id = $_POST['vendor_id']; $v->load(); $u = Model::load('UserItem'); $u->id = $v->user_id; $u->load(); if ($u->active && $v->name != '') { $u->auth = Access::VENDOR; $u->save(Model::getTable('UserItem'), array(), 2); $v->verified = 'MYSQLTIME'; $v->save(Model::getTable('Vendor'), array(), 2); $p = Model::load('ProductItem'); $p->verify($v->id); } $this->redirect('admin/vendors'); } else { $v = Model::load('Vendor'); $select = '*,UNIX_TIMESTAMP(registered) AS registered, t2.id as vendor_id'; $t1 = Model::getTable('UserItem'); $t2 = Model::getTable('Vendor'); $t3 = Model::getTable('ShippingAddress'); $sql = ' WHERE t1.id = t2.user_id AND t1.id = t3.user_id AND t3.default_address = 1'; $page = 1; $per_page = 10; $vendors = $v->getAllCustomPaginateMultiJoin($select, $t1, $t2, $t3, $sql, $page, $per_page); $paginate = $v->getPaginatePagesMultiJoin($select, $t1, $t2, $t3, $sql, $page, $per_page); $this->assign('vendors', $vendors); $this->assign('paginate', $paginate); $this->setTemplate('elib://admin/vendors.tpl'); } }
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 password() { $this->setTemplate('elib:/admin/password.tpl'); if (isset($_POST['submit'])) { $errors = array(); $old_password = md5(SALT . $_POST['old_password'] . SALT); $password1 = $_POST['password1']; $password2 = $_POST['password2']; $u = Model::load('UserItem'); $u->id = Session::get('user_id'); $u->load(); if ($old_password != $u->password) { array_push($errors, 'The existing password you have entered is not correct'); } if ($password1 != $password2) { array_push($errors, 'The new password entered does not match the confirmation'); } if (!ctype_alnum($password1) || !ctype_alnum($password2)) { array_push($errors, 'Please only use alpha and numeric characters for new passwords'); } if (sizeof($errors) < 1) { $u->password = md5(SALT . $password1 . SALT); $u->save(Model::getTable('UserItem'), array(), 0); $this->redirect('admin'); } else { $this->presenter->assign('error', $errors); } } elseif (isset($_POST['cancel'])) { $this->redirect('admin'); } }
public function loadFromCart($c) { $ids = array(); $product_data = array(); if (($cart = Session::get('cart')) != false) { foreach ($cart as $v => $qty) { array_push($ids, $v); } $v = Model::load('ProductVariant'); $id_string = $v->buildUnionString($ids); $product_data = $v->getCartData($id_string); foreach ($product_data as $index => $value) { $id = $value['id']; $price = $value['price']; $qty = $cart[$id]['qty']; $product_data[$index]['qty'] = $qty; $product_data[$index]['line'] = $qty * $price; $product_data[$index]['stamp'] = $cart[$id]['stamp']; } // sort foreach ($product_data as $key => $row) { $stamp[$key] = $row['stamp']; unset($row['stamp']); } array_multisort($stamp, SORT_ASC, $product_data); } return $product_data; }
public function default_event() { $o = Model::load('OrderItem'); $orders = $o->getOrders(); $this->presenter->assign('orders', $orders); $this->setTemplate('elib://admin/orders.tpl'); }
public function rename() { $this->setTemplate('elib://admin/properties.tpl'); if (isset($_GET['id']) && is_numeric($_GET['id'])) { if (isset($_POST['save'])) { $p = Model::load('Property'); $p->id = $_GET['id']; $p->load(); $p->name = $_POST['name']; $p->validates(); if ($p->hasValErrors()) { $this->presenter->assign('property', $p); $this->presenter->assign('errors', $p->getValErrors()); } else { $p->save(Model::getTable('Property'), array(), 1); $this->redirect('admin/properties'); } } else { $p = Model::load('Property'); $p->id = $_GET['id']; $p->load(); $this->presenter->assign('property', $p); } } }
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"); } }
private function getCommentsFetch($id) { $bc = Model::load('BlogComment'); $sql = ' WHERE t1.user_id = t2.id'; $sql .= ' AND t1.status = 1'; $sql .= ' AND t1.blog_id = ' . $id; $sql .= ' ORDER BY t1.stamp'; return $bc->getAllCustomPaginateSimpleJoin('*,t1.id AS id', Model::getTable('BlogComment'), Model::getTable('UserItem'), $sql, 1, 200); }
public function __construct($boot) { parent::__construct($boot); $this->section = Model::load('SectionItem'); $this->data_item = Model::load('DataItem'); $this->section->id = $_GET['section']; $this->section->load(); $this->assign('template', $this->section->template); }
public function default_event() { $this->setTemplate('events.tpl'); $now = new DateTime(array(time() - 43200)); // minus 12 hours $e = Model::load('Event'); $events = $e->getEvents(true, $now); $this->assign('events', $events); }
public function createForBlogItem($categories, $blog_id) { $bc = Model::load('BlogItemCategory'); foreach ($categories as $cat) { $bc->blog_id = $blog_id; $bc->blog_category_id = $cat; $bc->insert(Model::getTable('BlogItemCategory'), false, array(), 1); } }
public function add() { if (isset($_GET['id']) && is_numeric($_GET['id'])) { $p = Model::load('PromoItem'); $p->category_id = $_GET['id']; $p->name = 'New Promo'; $p->hidden = 'DEFAULT'; $id = $p->insert(Model::getTable('PromoItem'), 1, array(), 0); } $this->redirect('admin/promo_category/' . $_GET['id']); }
public static function addToIndex($b) { if (defined('ELIB_BLOG_ELASTIC') && ELIB_BLOG_ELASTIC) { $bt = Model::load('BlogTag'); $bc = Model::load('BlogCategory'); $cats = $bc->getCategoriesForBlogItem($b->id); $cats_arr = array(); foreach ($cats as $c) { $item = Model::load('BlogCategory'); $item->id = $c; $item->load(); array_push($cats_arr, $item->label); } $params = ['index' => 'elib_blog', 'type' => 'blog', 'id' => $b->id, 'body' => ['heading' => $b->heading, 'stamp' => $b->stamp, 'tags' => $bt->getTags($b->id), 'body' => strip_tags($b->body), 'slug' => $b->slug, 'categories' => $cats_arr]]; //header('Content-type: application/json'); //echo json_encode($params); exit(); $client = ClientBuilder::create()->build(); $response = $client->index($params); } }
public function oAuthSignIn($username, $name, $image) { $user_id = 0; if ($this->id = $this->getID($username)) { $this->load(); $user_id = $this->id; } else { unset($this->id); $this->email = '*****@*****.**'; $this->auth = 'DEFAULT'; $this->username = $username; $this->password = '******'; $this->reg_code = '1'; $this->active = 1; $this->registered = 'MYSQLTIME'; $this->activated = 'MYSQLTIME'; $this->validates(false); if (!$this->hasValErrors()) { $up = Model::load('UserProfile'); $up->fullname = $name; $up->picture = $image; $up->about = ''; $this->user_profile_id = $up->insert(Model::getTable('UserProfile'), true, array(), 0); $this->id = $this->insert(self::TABLE, true, array(), 0); $user_id = $this->id; } else { $errors = $this->getValErrors(); throw new \Exception('Could not validate new user: '******' - ', $errors)); } } return $user_id; }
public function monthView() { $month = $this->filterInt('month'); if (strlen($month) != 6) { $month = 0; } if ($month == 0) { $time = time(); } else { $y = substr($month, 0, 4); $m = substr($month, 4, 2); $time = mktime(0, 0, 0, $m, 1, $y); } $date = new DateTime(array($time)); $c = new Calendar(); $date->resetToFirst(); $days = $date->getLastDay(); $start_days = $date->getDayOfWeek() - 1; // days needed to pad beginning $date_prev_month = clone $date; $date_prev_month->adjustMonth(-1); $date_prev_month->resetToLast(); $date_prev_month->adjustDay(($start_days - 1) * -1); $date_next_month = clone $date; $date_next_month->adjustMonth(1); $e = Model::load('Event'); $events = $e->getEvents(false, $date_prev_month, $date_next_month); $month = $c->newBuildByMonth($date_prev_month->getDay(), $date_prev_month->getMonth(), $date_prev_month->getYear(), $date_prev_month->getLastDay(), $date->getLastDay(), $events); $this->assign('month', $date->getMonthText()); $this->assign('year', $date->getYear()); $this->assign('current_month', vsprintf("%02d", $date->getMonth())); $this->assign('cal_month', $month); if ($date->getMonth() == 12) { $next_month_link = $date->getYear() . '01'; } else { $next_month_link = $date->getYear() . vsprintf("%02d", $date->getMonth() + 1); } if ($date->getMonth() == 1) { $prev_month_link = $date->getYear() . '12'; } else { $prev_month_link = $date->getYear() . vsprintf("%02d", $date->getMonth() - 1); } $this->assign('prev_month_link', $prev_month_link); $this->assign('next_month_link', $next_month_link); $prev_year_link = $date->getYear() - 1 . vsprintf("%02d", $date->getMonth()); $next_year_link = $date->getYear() + 1 . vsprintf("%02d", $date->getMonth()); $this->assign('prev_year_link', $prev_year_link); $this->assign('next_year_link', $next_year_link); $this->setTemplate('elib://admin/events_month.tpl'); }
public function day() { if (isset($_GET['month']) && $_GET['month'] != '' && isset($_GET['year']) && is_numeric($_GET['year']) && isset($_GET['day']) && is_numeric($_GET['day'])) { $year = $_GET['year']; $m = $this->convertMonth($_GET['month']); $day = $_GET['day']; $b = Model::load('BlogItem'); $blogs = array(); if (!checkdate($m, $day, $year)) { die('not valid date'); } else { $blogs = $b->getDay($m, $year, $day); } // copied from default_event foreach ($blogs as $index => $item) { $body_arr = array(); $body_new = array(); $i = 0; $body = $item['body']; $body_arr = preg_split('/<\\/p>\\s+<p>/', $body); if (sizeof($body_arr) > 2) { while ($i < 2) { array_push($body_new, $body_arr[$i]); $i++; } $blogs[$index]['body'] = implode($body_new, '</p><p>') . '</p>'; $blogs[$index]['truncated'] = 1; } else { $blogs[$index]['truncated'] = 0; } $blogs[$index]['month_slug'] = strtolower(substr(date("F", $item['stamp']), 0, 3)); } $month = $b->getMonthName($m, $year); $this->presenter->assign('month', $month); $this->presenter->assign('month_slug', substr(strtolower($month), 0, 3)); $this->presenter->assign('year', $year); $this->presenter->assign('day', preg_replace('/^0+/', '', $day)); $date = mktime(0, 0, 0, $m, $day, $year); $suffix = date("S", $date); $day_name = date("l", $date); $this->presenter->assign('suffix', $suffix); $this->presenter->assign('day_name', $day_name); $this->presenter->assign('custom_title', "Archive for {$day_name}, " . preg_replace('/^0+/', '', $day) . "{$suffix} {$month} {$year}"); $this->presenter->assign('blogs', $blogs); } $this->setTemplate('elib://blog_day.tpl'); }
public function upload_image() { $this->setTemplate('elib://admin/artist.tpl'); if (isset($_POST['upload'])) { $_GET['id'] = $_POST['id']; } elseif (isset($_POST['cancel'])) { $this->redirect('admin/artist/' . $_POST['id']); } $a = Model::load('ArtistItem'); $a->id = $_GET['id']; $a->load(); $this->presenter->assign("artist", $a); if (isset($_POST['upload'])) { $d = array(array('tn_', 70, 80), array('mid_', 1000, 370)); $u = new ImageUpload('', true, $d); if ($u->error != '') { $this->presenter->assign("error", $u->error); } else { if ($a->image != "") { $u->remove(array($a->image)); } // update db $a->image = $u->file; $a->save(Model::getTable('ArtistItem'), array(), 2); $this->redirect('admin/artist/' . $a->id); } } }
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'); } } }
public function variantProperties() { //$this->setTemplate('elib://admin/product.tpl'); //$this->assertID(); if (isset($_POST['cancel'])) { $v = Model::load('ProductVariant'); $v->id = $_GET['id']; $v->load(); $this->c->redirect('storeadmin/product/' . $v->product_id); } elseif (isset($_POST['save'])) { $p = Model::load('ProductVariantPropertyOption'); $p->emptyByVariant($_GET['id']); $p->product_variant_id = $_GET['id']; //if(isset($_POST['property'])) // { foreach ($_POST['property'] as $index => $item) { if ($item > 0 && is_numeric($item)) { $p->property_option_id = $item; $p->insert(Model::getTable('ProductVariantPropertyOption'), 1, array(), 0); } } // } $v = Model::load('ProductVariant'); $v->id = $_GET['id']; $v->load(); $this->c->redirect('storeadmin/product/' . $v->product_id); } $v = Model::load('ProductVariant'); $v->id = $_GET['id']; $v->load(); $p = Model::load('ProductItem'); $p->id = $v->product_id; $p->load(); $c = Model::load('CategoryItem'); $cats = $c->getAncestorIds($p->category_id, array()); $cp = Model::load('CategoryProperty'); array_push($cats, $p->category_id); $props = $cp->getPropertiesByCategory($cats); //array_push($props, 2); // always allow colour property $this->c->assign('product', $p); $this->c->assign('variant', $v); if (sizeof($props) > 0) { $property = Model::load('Property'); $properties = $property->getAllWithOptions($props); $this->c->assign('properties', $properties); $pv = Model::load('ProductVariantPropertyOption'); $sql = ' WHERE product_variant_id = ' . $_GET['id']; $options = $pv->getAllCustom(Model::getTable('ProductVariantPropertyOption'), $sql); $o = array(); foreach ($options as $index => $value) { array_push($o, $value['property_option_id']); } $this->c->assign('options', $o); } }
public function variants_wizard() { $this->setTemplate('elib://admin/product.tpl'); if (isset($_POST['submit'])) { $sets = array(); foreach ($_POST['property'] as $index => $value) { array_push($sets, $value); } $g = new CombGen($sets); $results = $g->getResults(); $v = Model::load('ProductVariant'); $v->product_id = $_POST['product_id']; $v->weight_g = $_POST['weight_g']; $v->weight_lb = $_POST['weight_lb']; $v->weight_oz = $_POST['weight_oz']; $v->price = $_POST['price']; $v->validates(); if ($v->hasValErrors()) { //die('errors'); } else { foreach ($results as $item) { $v->id = $v->insert(Model::getTable('ProductVariant'), 1, array(), 0); $options = explode('-', $item); foreach ($options as $o) { $p = Model::load('ProductVariantPropertyOption'); $p->product_variant_id = $v->id; $p->property_option_id = $o; $p->insert(Model::getTable('ProductVariantPropertyOption'), 1, array(), 0); } } } $this->redirect('admin/product/' . $v->product_id); } $p = Model::load('ProductItem'); $p->id = $_GET['id']; $p->load(); $this->presenter->assign('product', $p); $c = Model::load('CategoryItem'); $cats = $c->getAncestorIds($p->category_id, array()); $cp = Model::load('CategoryProperty'); array_push($cats, $p->category_id); $props = $cp->getPropertiesByCategory($cats); //array_push($props, 2); // always allow colour property if (sizeof($props) > 0) { $property = Model::load('Property'); $properties = $property->getAllWithOptions($props); $this->presenter->assign('properties', $properties); /* $pv = new ProductVariantPropertyOption($this); $sql = ' WHERE product_variant_id = '.$_GET['id']; $options = $pv->getAllCustom(ProductVariantPropertyOption::$table, $sql); $o = array(); foreach ($options as $index => $value) { array_push($o, $value['property_option_id']); } $this->presenter->assign('options', $o); */ } $v = Model::load('ProductVariant'); $v->weight_g = 0; $v->weight_lb = '0.00'; $v->weight_oz = 0; $v->price = '0.00'; $this->presenter->assign('variant', $v); // get colours $c = Model::load('ProductColour'); $colours = $c->getColourOptionIDs($p->id); $this->presenter->assign('colours', $colours); }
public function getPropertiesAndOptions($p, $colours) { /* $v = new ProductVariant($this); $v->id = $_GET['id']; $v->load(ProductVariant::$table); */ //$p = Model::load('ProductItem'); //$p->id = $product_id; //$p->load(); $c = Model::load('CategoryItem'); $cats = $c->getAncestorIds($p->category_id, array()); $cp = Model::load('CategoryProperty'); array_push($cats, $p->category_id); $props = $cp->getPropertiesByCategory($cats); if (!$colours && $p->category_id != 8) { array_push($props, 2); // always allow colour property } // $this->assign('product', $p); //$this->assign('variant', $v); $opts = array(); $pv = Model::load('ProductVariantPropertyOption'); $opts = $pv->buildUnionString($pv->getActiveOptions($p->id)); if (sizeof($props) > 0) { $property = Model::load('Property'); $properties = $property->getAllWithOptionsForProduct($props, $opts); $this->assign('properties', $properties); /* $pv = new ProductVariantPropertyOption($this); $sql = ' WHERE product_variant_id = '.$_GET['id']; $options = $pv->getAllCustom(ProductVariantPropertyOption::$table, $sql); $o = array(); foreach ($options as $index => $value) { array_push($o, $value['property_option_id']); } $this->assign('options', $o); */ } }
public function active_properties() { $this->buildNav(); if (isset($_POST['save'])) { $c = Model::load('CategoryProperty'); $c->emptyByCategory($_GET['id']); if (isset($_POST['property']) && sizeof($_POST['property'] > 0)) { foreach ($_POST['property'] as $index => $item) { $c->category_id = $_GET['id']; $c->property_id = $index; $c->insert(Model::getTable('CategoryProperty'), 1, array(), 0); } } $this->redirect('admin/category/' . $_GET['id']); } else { $p = Model::load('Property'); $properties = $p->getAllWithOptions(array()); $this->presenter->assign('properties', $properties); $c = Model::load('CategoryItem'); $ancestors = $c->getAncestorIds($_GET['id'], array()); $cp = Model::load('CategoryProperty'); $inherited = array(); if (sizeof($ancestors) > 0) { $inherited = $cp->getPropertiesByCategory($ancestors); } $active = $cp->getPropertiesByCategory(array($_GET['id'])); //array_push($inherited, 2); // always use colour $this->presenter->assign('active_properties', $active); $this->presenter->assign('inherited_properties', $inherited); } }
public function default_event() { $c = new ShoppingCart(); if ($c->isEmpty()) { $this->redirect('paypal/cancel'); } $items = $c->loadFromCart($this); $co = new Checkout($items, $this); $invoice_no = $co->getInvoiceNo(); $o = Model::load('OrderItem'); $o->id = $invoice_no; $o->load(); $products = array(); //$product[0]['alias'] = 'Some product'; //$product[0]['price'] = 1.99; //$product[0]['code'] = 23; $interface = 'http://' . WEB_ROOT . PUBLIC_DIR . '/paypal/'; $message = ''; $p = new PaypalClass(); $p->ipn_log = false; $p->add_field('cmd', '_cart'); $p->add_field('upload', '1'); // address $p->add_field('first_name', $o->first_name); $p->add_field('last_name', $o->last_name); $p->add_field('address1', $o->address1); $p->add_field('address2', $o->address2); $p->add_field('city', $o->city); $p->add_field('state', $o->state); $p->add_field('zip', $o->zip); $p->add_field('country', $o->country); $p->add_field('address_override', 1); $p->add_field('no_shipping', 1); // shipping $ids = array(); foreach ($items as $item) { array_push($ids, $item['id']); } $v = Model::load('ProductVariant'); $cat_ids = $v->getCategories($ids); $cat = Model::load('CategoryItem'); if ($o->country != 'GB') { $intl = true; } else { $intl = false; } $calc = new ShippingCalculator($c->calcTotal($items), $cat_ids, $cat, sizeof($items), $intl); $shipping = $calc->getFee(); $shipping = $this->getShipping(); $p->add_field('shipping_1', $shipping); $o->shipping = $shipping; $o->save(Model::getTable('OrderItem'), array(), 1); $i = 1; foreach ($items as $index => $item) { $p->add_field('item_name_' . $i, $item['name']); $p->add_field('amount_' . $i, $item['price']); $p->add_field('item_number_' . $i, $this->getItemNumber($item['id'])); $p->add_field('quantity_' . $i, $item['qty']); $o = explode(', ', $item['options']); $pr = explode(', ', $item['properties']); foreach ($o as $index => $item) { $p->add_field('os' . $index . '_' . $i, $o[$index]); $p->add_field('on' . $index . '_' . $i, $pr[$index]); } $i++; } // $p->add_field('image_url', 'http://'.WEB_ROOT.PUBLIC_DIR.'/img/pier.png'); $p->add_field('invoice', $this->getInvoiceNumber($invoice_no)); $p->add_field('no_shipping', 1); $p->add_field('currency_code', 'GBP'); $p->add_field('business', '*****@*****.**'); //$p->add_field('business', '*****@*****.**'); //$p->add_field('business', $this->getBusiness()); $p->add_field('return', $interface . 'success'); $p->add_field('notify_url', $interface . 'ipn'); $p->add_field('cancel_return', $interface . 'cancel'); $p->paypal_url = $this->getPayPalURL(); $c->emptyCart(); $this->presenter->assign('paypal_url', $p->paypal_url); $this->presenter->assign('fields', $p->fields); //$p->dump_fields(); }
public function edit_bio() { if (isset($_POST['save'])) { $b = Model::load('BrandItem'); $b->id = $_POST['id']; $b->load(); $b->about = $_POST['bio']; $b->validates(); if ($b->hasValErrors()) { $this->presenter->assign('brand', $b); $this->presenter->assign('errors', $b->getValErrors()); } else { $b->save(Model::getTable('BrandItem'), array('bio'), 1); $this->redirect('admin/brand/' . $_GET['id']); } } $this->buildNav(); $b = Model::load('BrandItem'); $b->id = $_GET['id']; $b->load(); $this->presenter->assign('brand', $b); }
public function rename_category() { $this->buildNav(); if (isset($_POST['save'])) { $b = Model::load('BlogCategory'); $b->id = $_POST['id']; $b->load(); $b->label = $_POST['label']; $b->validates(); if ($b->hasValErrors()) { $this->presenter->assign('blog_category', $b); $this->presenter->assign('errors', $b->getValErrors()); } else { $b->save(Model::getTable('BlogCategory'), array(), 1); $this->redirect('admin/blog/category/' . $b->id); } } else { $b = Model::load('BlogCategory'); $b->id = $_GET['id']; $b->load(); $this->presenter->assign('blog_category', $b); } $this->setTemplate('elib:/admin/blog_cat.tpl'); $this->assign('class', 'blog_cat'); $this->assign('event', 'rename'); }
public function findBlogsByTags($active_tags) { $t = Model::load('TagItem'); $bt = Model::load('BlogTag'); $tags = $t->getIds($active_tags, true); if (sizeof($tags) != sizeof($active_tags)) { return false; // contains invalid tags } else { return $bt->buildUnionString($bt->getBlogs($tags)); } }
public function delete() { $p = Model::load('PromoItem'); $p->id = $_GET['id']; $p->load(); $images_removed = false; if ($p->image != '') { $u = new ImageUpload('', false, array()); if ($u->remove(array($p->image))) { $images_removed = true; } } if ($p->image == '' || $images_removed) { $p->delete(); $this->redirect('admin/promo_category/' . $p->category_id); } }
public function update_image_sizes() { $i = Model::load('ImageSize'); $i->id = $_GET['id']; $i->load(); $images = $i->getDataFiles(); $d = array(array($i->prefix . '_', $i->width, $i->height)); $u = new ImageUpload('', false, $d); set_time_limit(300); $u->resize($images); $this->redirect('admin/dsection/image_sizes'); }
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.'); } }
public static function getTopCats() { $categories = array(); if ($_GET['module'] == 'store') { $c = Model::load('CategoryItem'); $sql = ' WHERE category_id = 0 AND hidden = 0 ORDER BY name'; $categories = $c->getAllCustom(Model::getTable('CategoryItem'), $sql); } return $categories; }