Beispiel #1
0
 /**
  * Get a database object
  *
  * Returns a reference to the global {@link FiveDatabase} object, only creating it
  * if it doesn't already exist.
  *
  * @return object FiveDatabase
  */
 function &getDBO($database = null)
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     if (is_null($database)) {
         $database = config('base.database');
     }
     if (!isset($instances[$database]) || !is_object($instances[$database])) {
         //get the debug configuration setting
         $debug = config('base.debug');
         $instances[$database] = FiveFactory::_createDBO($database);
         $instances[$database]->debug($debug);
     }
     return $instances[$database];
 }
/**
 * Function is responsible for reading and writting configurations
 * @param unknown_type $property
 * @param unknown_type $value
 */
function config($property, $value = null)
{
    $conf =& FiveFactory::getConfig();
    $tmp = $conf;
    $parts = explode('.', $property);
    if (!is_null($value)) {
        //@TODO Save the configuration
    }
    foreach ((array) $parts as $part) {
        if (!$part) {
            return false;
        }
        if (!isset($tmp->{$part})) {
            return false;
        }
        $tmp = $tmp->{$part};
    }
    if (count(get_object_vars($tmp)) < 2) {
        return (string) $tmp;
    }
    return $tmp;
}
Beispiel #3
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;
 }
Beispiel #4
0
 /**
  * Validation and filtering
  *
  * @return boolean True is satisfactory
  */
 function check()
 {
     // Validate business information
     if (trim($this->promo) == '') {
         $this->setError('Please enter the promo text.');
         return false;
     }
     if ($this->dateAdded == null) {
         // Set the registration timestamp
         $now =& FiveFactory::getDate();
         $this->dateAdded = strtotime($now->toMySQL());
     }
     return true;
 }
Beispiel #5
0
 /**
  * Method is responsible for loading the featured businesses
  * 
  */
 function loadFeatured()
 {
     $db =& $this->getDBO();
     $now =& FiveFactory::getDate();
     $query = 'SELECT *' . ' FROM ' . $this->_tbl . ' WHERE ' . strtotime($now->toMySQL()) . ' BETWEEN `feat_start` and `feat_end`';
     $db->setQuery($query);
     //echo _520($query);
     if ($results = $db->loadList($this->_tbl_key, $this->_type)) {
         return $results;
     }
 }
Beispiel #6
0
/**
 * function is responsible for returning the themes path
 */
function get_theme_path()
{
    $conf = FiveFactory::getConfig();
    return url() . 'five-contents/themes/' . $conf->theme->name . '/';
}
Beispiel #7
0
/**
 * Function is responsible for echoing the avatar
 * 
 * @param unknown_type $id_or_email
 * @param unknown_type $size
 * @param unknown_type $default
 * @param unknown_type $alt
 */
function avatar($id_or_email = null, $size = '150', $default = '', $alt = false)
{
    if (is_null($id_or_email)) {
        $id_or_email = FiveFactory::getUser();
    }
    echo get_avatar($id_or_email, $size, $default, $alt);
}
<?php

$user = FiveFactory::getUser();
?>
<div class="sidebar_profile_left" id="leftCol">
	<div id="pagelet_profile_picture">
		<div class="profile-picture">
			<span class="profile-picture-overlay"></span>
			<a class="edit_profilepicture" href="<?php 
echo Router::url(array('controller' => 'user', 'action' => 'social'));
?>
">
				Change Picture<span class="edit_profilepicture_icon"></span></a>
			<?php 
avatar();
?>
		</div>
	</div>


<div id="pagelet_fbx_navigation" data-referrer="pagelet_fbx_navigation">
<div id="sideNav" class="mvm profileSelf">
<div class="expandableSideNav expandedMode">
<div>
<ul class="uiSideNav" role="navigation">
	<li class="sideNavItem selectedItem">
		<a class="item" 
		href="<?php 
echo Router::url(array('controller' => 'user', 'action' => 'profile'));
?>
">
Beispiel #9
0
 /**
  * Sets the Routing prefixes. Includes compatibilty for existing Routing.admin
  * configurations.
  *
  * @return void
  * @access private
  * @todo Remove support for Routing.admin in future versions.
  */
 function __setPrefixes()
 {
     $conf =& FiveFactory::getConfig();
     $routing = (array) $conf->routing;
     if (!empty($routing['admin'])) {
         $this->__prefixes[] = $routing['admin'];
     }
     if (!empty($routing['prefixes'])) {
         $this->__prefixes = array_merge($this->__prefixes, (array) $routing['prefixes']);
     }
 }
Beispiel #10
0
 /**
  * Validation and filtering
  *
  * @return boolean True is satisfactory
  */
 function check()
 {
     // Validate user information
     if (trim($this->_ccName) == '') {
         $this->setError('Please enter your name as it appears on your credit card.');
         return false;
     }
     if (!checkCreditCard($this->_ccNum, $this->_ccType)) {
         global $errortext;
         $this->setError($errortext);
         return false;
     }
     $now =& FiveFactory::getDate();
     if ($now->isAfter($this->_ccExpYY . '-' . $this->_ccExpMM . '-28')) {
         $this->setError("Your credit card has expired.");
         return false;
     }
     if ($this->date_transaction == null) {
         // Set the registration timestamp
         $now =& FiveFactory::getDate();
         $this->date_transaction = strtotime($now->toMySQL());
     }
     return true;
 }
Beispiel #11
0
 /**
  * Updates last visit time of user
  *
  * @param int The timestamp, defaults to 'now'
  * @return boolean False if an error occurs
  */
 function setLastVisit($timeStamp = null, $id = null)
 {
     // check for User ID
     if (is_null($id)) {
         if (isset($this)) {
             $id = $this->id;
         } else {
             // do not translate
             exit('WARNUSER');
         }
     }
     // if no timestamp value is passed to functon, than current time is used
     $date =& FiveFactory::getDate($timeStamp);
     // updates user lastvistdate field with date and time
     $query = 'UPDATE ' . $this->_tbl . ' SET lastvisitDate = ' . $this->_db->Quote($date->toMySQL()) . ' WHERE id = ' . (int) $id;
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }