Skip to content

Instantly share code, notes, and snippets.

@kodi
Created February 2, 2009 16:24
Show Gist options
  • Save kodi/56961 to your computer and use it in GitHub Desktop.
Save kodi/56961 to your computer and use it in GitHub Desktop.
<?php
class user_shop extends DPLS_Controller{
function __construct(){
global $_user;
$this->_user=$_user;
global $db;
$this->db=$db;
}
public function defaultAction(){
// GET SEGMENT (subdomain that corespond to store owners username)
$this->_segment=$this->_req->_segment;
// CHECK IS CURRENT USER STORE ADMINISTRATOR
$this->_user->isStoreAdmin=false;
if($this->_segment==$this->_user->username){
$this->_user->isStoreAdmin=true;
}
// GET BASIC STORE INFO
$store=new Store($this->db);
$storeInfo=$store->getByUsername($this->_segment);
//GET PRODUCTS FROM STORE
$products=$store->getProducts($this->_segment);
// PASS VARIABLES TO TEMPLATE
$template= new DPLS_Template();
$template->assign('store',$storeInfo);
$template->assign('user',$this->_user);
// RENDER TEMPLATE
$template->show('user_shop');
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment