Esempio n. 1
0
 /**
  * Returns a reference to the a Table object, always creating it
  *
  * @param type 		$type 	 The table type to instantiate
  * @param string 	$prefix	 A prefix for the table class name. Optional.
  * @param array		$options Configuration array for model. Optional.
  * @return database A database object
  * @since 1.5
  */
 function &getInstance($type, $prefix = 'FiveTable', $config = array())
 {
     $false = false;
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
     $tableClass = $prefix . ucfirst($type);
     if (!class_exists($tableClass)) {
         if ($path = FivePath::find(FiveTable::addIncludePath(), strtolower($type) . '.php')) {
             require_once $path;
             if (!class_exists($tableClass)) {
                 trigger_error('Table class ' . $tableClass . ' not found in file.', E_USER_WARNING);
                 return $false;
             }
         } else {
             trigger_error('Table ' . $type . ' not supported. File not found.', E_USER_WARNING);
             return $false;
         }
     }
     //Make sure we are returning a DBO object
     if (array_key_exists('dbo', $config)) {
         $db =& $config['dbo'];
     } else {
         $db =& FiveFactory::getDBO();
     }
     $instance = new $tableClass($db);
     $instance->_type = $type;
     return $instance;
 }
Esempio n. 2
0
 /**
  * @param database A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__user_groups', 'id', $db);
     //initialise
     $this->id = 0;
     $this->userid = 0;
     $this->admin = 0;
     $this->business = 0;
     $this->user = 1;
 }
Esempio n. 3
0
 /**
  * Saving this
  *
  * @return boolean True is satisfactory
  */
 function store($updateNulls = false)
 {
     /*
     if ($img = BRequest::getVar('img', false, 'files')) {
     	//delete the old
     	if (!is_null($this->img)) @unlink($this->img);
     	//save the new
     	$this->img = save_file($img, 'image', 'product');
     }
     */
     return parent::store($updateNulls);
 }
Esempio n. 4
0
 /**
  * Get an user object
  *
  * Returns a reference to the global {@link JUser} object, only creating it
  * if it doesn't already exist.
  *
  * @param 	int 	$id 	The user to load - Can be an integer or string - If string, it is converted to ID automatically.
  *
  * @access public
  * @return object JUser
  */
 function &getUser($id = null)
 {
     static $users;
     if (!isset($users)) {
         $users = array();
     }
     if (is_null($id)) {
         $id = get_current_user_id();
     }
     if (!isset($users[$id])) {
         $user = FiveTable::getInstance('user');
         $user->load($id);
         $users[$id] =& $user;
     }
     return $users[$id];
 }
Esempio n. 5
0
/**
 * Function is responsible for authenticating users and redirecting 
 * them upon a succesful login.
 * 
 * @param unknown_type $username
 * @param unknown_type $password
 * @param unknown_type $remember
 */
function interal_authentication($username, $password, $remember = false)
{
    //redirect if successful already
    if (is_user_logged_in()) {
        redirect(Router::url(array('controller' => 'user', 'action' => 'profile')));
    }
    if (login_has_error()) {
        return false;
    }
    $user = FiveTable::getInstance('user');
    if (!$user->authenticate($username, $password)) {
        set_error($user->getErrors());
        login_has_error(1);
    } else {
        //success
        redirect(Router::url(array('controller' => 'user', 'action' => 'profile')));
    }
}
Esempio n. 6
0
 /**
  * Method converts the Assoc list into a class list.
  */
 function loadList($key = '', $type)
 {
     if (!($results = $this->loadAssocList($key))) {
         return false;
     }
     $products = array();
     foreach ((array) $results as $key => $result) {
         if (!$result) {
             continue;
         }
         $product = FiveTable::getInstance($type);
         $product->reset();
         $product->bind($result);
         $products[$key] = $product;
     }
     return $products;
 }
Esempio n. 7
0
 /**
  * Function is responsible for loading the group class if it hasn't already been loaded.
  */
 function loadGroup()
 {
     if (!$this->_groups) {
         $this->_groups = FiveTable::getInstance('groups');
     }
     if (!isset($this->_groups->id) || !$this->_groups->id) {
         $this->_groups->load($this->id);
         @($_SESSION['user']['group']['admin'] = $this->_groups->admin);
         @($_SESSION['user']['group']['business'] = $this->_groups->business);
         @($_SESSION['user']['group']['user'] = $this->_groups->user);
     }
     return true;
 }
<?php

/**
 * @Author	Jonathon byrd
 * @link http://www.5twentystudios.com
 * @Package Five Twenty CMS
 * @SubPackage PublicMarketSpace
 * @Since 1.0.0
 * @copyright  Copyright (C) 2011 5Twenty Studios
 * 
 */
defined('ABSPATH') or die("Cannot access pages directly.");
//initializing
$bizid = get_bizid(get_current_user_id());
$business = FiveTable::getInstance('business');
$business->load($bizid);
require $view;
Esempio n. 9
0
 /**
  * Loads a row from the database and binds the fields to the object properties
  *
  * @access	public
  * @param	mixed	Optional primary key.  If not specifed, the value of current key is used
  * @return	boolean	True if successful
  */
 function loadByParentAndName($parentCat, $name = null)
 {
     $parent = FiveTable::getInstance('categories');
     $parent->loadByName($parentCat);
     if ($name === null) {
         return false;
     }
     $this->reset();
     $db =& $this->getDBO();
     $query = 'SELECT `col`.*' . ' FROM ' . $parent->_tbl . ' as cat' . ' LEFT JOIN ' . $this->_relTable . ' ON ' . $this->_relTable . '.`catid` = `cat`.`id`' . ' LEFT JOIN ' . $this->_tbl . ' col ON ' . $this->_relTable . '.`colid` = col.`id`' . ' WHERE `col`.`name` = ' . $db->Quote($name);
     $db->setQuery($query);
     if ($result = $db->loadAssoc()) {
         return $this->bind($result);
     } else {
         $this->setError($db->getErrorMsg());
         return false;
     }
 }
Esempio n. 10
0
 /**
  * @param database A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__transactions', 'id', $db);
     //initialise
     $this->id = 0;
     $this->userid = 0;
     $this->bizid = 0;
     $this->status = 'pending';
 }
Esempio n. 11
0
 /**
  * 
  */
 function getUserTable()
 {
     static $user;
     if (!isset($user)) {
         $user = FiveTable::getInstance('user');
         $user->load($this->userid);
     }
     return $user;
 }
        $_SESSION['registration']['reqtoken'] = 'PROMO';
        $_SESSION['registration']['amt'] = 0.0;
    }
    //@todo process the credit card
    if ($has && !$promo) {
        $post['amount'] = '20.00';
        $post['products'] = array(array('name' => 'Services Registration', 'price' => '20.00', 'qty' => '1', 'sku' => '02201'));
        $auth = apply_filters('captureCreditCard', $post);
        if ($auth['auth'] == 'ACCEPT') {
            $query = "update cybersource set reqid='" . $auth['reqid'] . "',reqtoken='" . $auth['reqtoken'] . "' where id='" . $csid . "'";
            if (!mysql_query($query)) {
                die(ERROR_MSG_CRITICAL1);
            }
            $_SESSION['registration']['reqid'] = $auth['reqid'];
            $_SESSION['registration']['reqtoken'] = $auth['reqtoken'];
            $_SESSION['registration']['amt'] = BRequest::getVar('total');
        } else {
            set_error($auth['errorMsg']);
            $has = false;
        }
    }
    //If there's no error, then redirect
    if ($has) {
        $groups =& FiveTable::getInstance('groups');
        $groups->loadByUserID(get_current_user_id());
        $groups->business = 1;
        $groups->store();
        redirect(Router::url(array('controller' => 'user', 'action' => 'profile')));
    }
}
require $view;
Esempio n. 13
0
<?php

/**
 * @Author	Jonathon byrd
 * @link http://www.5twentystudios.com
 * @Package Five Twenty CMS
 * @SubPackage PublicMarketSpace
 * @Since 1.0.0
 * @copyright  Copyright (C) 2011 5Twenty Studios
 * 
 */
defined('ABSPATH') or die("Cannot access pages directly.");
//initializing
$user = FiveTable::getInstance('user');
if (BRequest::getVar('verify', false)) {
    // LOGIN USER
    mysql_query("update user set status='active' where secToken='" . BRequest::getVar('verify', false) . "'") or die(mysql_error());
    $result = mysql_query("select id,username,email,zip from user where secToken='" . BRequest::getVar('verify', false) . "'") or die(mysql_error());
    $row = mysql_fetch_row($result);
    set_session($row[0], stripslashes($row[1]), stripslashes($row[2]), $row[3]);
    $user->load(get_current_user_id());
    set_notice('Please make sure to update your password before continuing.');
}
//redirect if successful
if (!is_user_logged_in()) {
    redirect(Router::url(array('controller' => 'user', 'action' => 'login')));
}
//loading the user
$user->load(get_current_user_id());
if ($post = BRequest::get('post', false)) {
    //$user->load( get_current_user_id() );
Esempio n. 14
0
$urlCat = false;
if (isset($url['category'])) {
    $urlCat = $url['category'];
}
$urlCol = false;
if (isset($url['collection'])) {
    $urlCol = $url['collection'];
}
$urlAss = false;
if (isset($url['assortments'])) {
    $urlAss = $url['assortments'];
}
if ($urlCat == 'services') {
    $type = 'services';
    $product = FiveTable::getInstance('services');
    $products = $product->getServices($urlCol, $urlAss);
} else {
    $type = 'products';
    $product = FiveTable::getInstance('products');
    $products = $product->getProducts($urlCat, $urlCol, $urlAss);
}
if (!$products || empty($products)) {
    echo '<div class="site_errors rounded-eight">No ' . ucfirst($type) . ' are currently in this view.</div>';
} else {
    foreach ((array) $products as $product) {
        if (!$products) {
            continue;
        }
        require $view;
    }
}
Esempio n. 15
0
 /**
  * method is responsible for loading products from a category
  * @param $catName
  */
 function getCategoryProducts($catName = null)
 {
     $category = FiveTable::getInstance('categories');
     $category->loadByName($catName);
     $db =& $this->getDBO();
     $db->resetTree();
     $db->setTree('SELECT', '`' . $this->_tbl . '`.*');
     $db->setTree('FROM', '`#__rel_prod_cca`');
     $db->setTree('INNER JOIN', '`' . $this->_tbl . '` ON `#__rel_prod_cca`.prodid=' . $this->_tbl . '.id');
     $db->setTree('WHERE', '`' . $this->_tbl . '`.`status`=' . $db->Quote('active'));
     $db->setTree('WHERE', '`#__rel_prod_cca`.catid = ' . $db->Quote($category->id));
     if (BRequest::getCmd('p', false) == 'h' && BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'o') {
         $db->setTree('ORDER BY', '`' . $this->_tbl . '`.`price` DESC');
     } elseif (BRequest::getCmd('p', false) == 'l' && BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'o') {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.`price` ASC");
     } elseif (BRequest::getCmd('s', false) == 'l' && BRequest::getCmd('r', false) == 'o') {
         //@todo doesn't work as expected
         $db->setTree('SELECT', "sum((`likes`.`like`)) AS `tlikes`");
         $db->setTree('LEFT JOIN', "`likes` ON `{$this->_tbl}`.`id` = `likes`.`itemid`");
         $db->setTree('ORDER BY', "tlikes ASC");
     } elseif (BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'n') {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.`dateAdded` DESC");
     } elseif (BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'o') {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.`dateAdded` ASC");
     } elseif (BRequest::getCmd('s', false) == 'r') {
         //@todo doesn't work as expected
         $db->setTree('SELECT', "sum((`ratings`.`like`)) AS `ratingsum`");
         $db->setTree('LEFT JOIN', "`ratings` ON `{$this->_tbl}`.`id` = `ratings`.`itemid`");
         $db->setTree('ORDER BY', "ratingsum ASC");
     }
     //default ordering
     if (empty($sql['ORDER BY'])) {
         $db->setTree('ORDER BY', "`prod_name` ASC");
     }
     $per_page = config('products.per_page');
     $db->setTree('LIMIT', $per_page);
     if ($offset = (BRequest::getInt('ppage', 1) - 1) * $per_page) {
         $db->setTree('OFFSET', $offset);
     }
     $q = $db->queryTree();
     if ($results = $db->loadList($this->_tbl_key, $this->_type)) {
         return $results;
     }
     return false;
 }
Esempio n. 16
0
<?php

/**
 * @Author	Jonathon byrd
 * @link http://www.5twentystudios.com
 * @Package Five Twenty CMS
 * @SubPackage PublicMarketSpace
 * @Since 1.0.0
 * @copyright  Copyright (C) 2011 5Twenty Studios
 * 
 */
defined('ABSPATH') or die("Cannot access pages directly.");
//redirect if successful
if (!is_user_logged_in()) {
    redirect(Router::url(array('controller' => 'user', 'action' => 'login')));
}
//initializing
$service = FiveTable::getInstance('services');
$bizid = get_bizid(get_current_user_id());
$service->loadByBizID($bizid);
if ($post = BRequest::get('post', false)) {
    if ($service->save($post)) {
        set_notice("Profile Saved.");
    } else {
        set_error($service->getErrors());
    }
}
require $view;
Esempio n. 17
0
    $collection = FiveTable::getInstance('collections');
    $collections = $collection->loadAll($urlCat);
    $categoryUrl = 'collections';
    $catList = array();
    foreach ((array) $collections as $col) {
        if (!$col) {
            continue;
        }
        $catList[$col->id] = array();
        $catList[$col->id]['name'] = strtoupper($col->name);
        $catList[$col->id]['url'] = array('controller' => 'categories', 'action' => $urlCat);
        $catList[$col->id]['url'][] = $col->name;
    }
    //If we're being asked for an assortment
    if ($urlCol) {
        $assortment = FiveTable::getInstance('assortments');
        $assortments = $assortment->loadByParents($urlCat, $urlCol);
        $categoryUrl = 'assortments';
        $catList = array();
        foreach ((array) $assortments as $ass) {
            if (!$ass) {
                continue;
            }
            $catList[$ass->id] = array();
            $catList[$ass->id]['name'] = strtoupper($ass->name);
            $catList[$ass->id]['url'] = array('controller' => 'categories', 'action' => $urlCat, $urlCol, $ass->name);
        }
    }
}
?>
<div class="widget">
Esempio n. 18
0
 /**
  * @param database A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__categories', 'id', $db);
     //initialise
     $this->id = 0;
 }
Esempio n. 19
0
 /**
  * Loads a row from the database and binds the fields to the object properties
  *
  * @access	public
  * @param	mixed	Optional primary key.  If not specifed, the value of current key is used
  * @return	boolean	True if successful
  */
 function loadByParents($parentCat = null, $parentCol = null)
 {
     $category = FiveTable::getInstance('categories');
     $category->loadByName($parentCat);
     $collection = FiveTable::getInstance('collections');
     $collection->loadByParentAndName($parentCat, $parentCol);
     $cacid = get_cacid($category->id, $collection->id);
     $this->reset();
     $db =& $this->getDBO();
     $query = "select `" . $this->_tbl . "`.* from rel_cac_assts rca \n\t\t\t\t\tjoin rel_cats_cols rcac on rca.cacid=rcac.id \n\t\t\t\t\tleft join categories cat on rcac.catid=cat.id\n\t\t\t\t\tleft join collections col on rcac.colid=col.id\n\n\t\t\t\t\tleft join assortments on rca.asstid = `" . $this->_tbl . "`.id\n\t\t\t\t\t\twhere rca.cacid='" . $cacid . "'\n\t\t\t\t\t\torder by `" . $this->_tbl . "`.sortOrder asc, `" . $this->_tbl . "`.name asc";
     $db->setQuery($query);
     if ($result = $db->loadList($this->_tbl_key, $this->_type)) {
         return $result;
     } else {
         $this->setError($db->getErrorMsg());
         return false;
     }
 }