Beispiel #1
0
 /**
  * Copy property values into the current DatbaseObject from another object
  *
  * Copies the property values from a specified object into the current
  * ShoppDatabaseObject where the property names match.
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @param object $data The source object or array to copy from
  * @param string $prefix (optional) A property prefix
  * @param array $ignores (optional) List of property names to ignore copying from
  * @return void
  **/
 public function copydata($data, $prefix = '', array $ignores = array('_datatypes', '_table', '_key', '_lists', '_map', 'id', 'created', 'modified'))
 {
     if (!is_array($ignores)) {
         $ignores = array();
     }
     $properties = is_object($data) ? get_object_vars($data) : $data;
     foreach ((array) $properties as $property => $value) {
         $property = $prefix . $property;
         if (property_exists($this, $property) && !in_array($property, $ignores)) {
             $this->{$property} = sDB::clean($value);
         }
     }
 }
Beispiel #2
0
 /**
  * Download record loader to map download file data to the loaded downloads for the customer
  *
  * @author Jonathan Davis
  * @since 1.3.2
  *
  * @param array $records The records to map to (unused becase they are mapped to the Customer->downloads records)
  * @param array $record	The record data loaded from the query
  * @return void
  **/
 public function download_loader(&$records, &$record)
 {
     // Lookup the download key
     if (empty($this->_filemap[$record->id])) {
         return;
     }
     $dkey = $this->_filemap[$record->id];
     // Find the purchased download
     if (empty($this->downloads[$dkey])) {
         return;
     }
     $Purchased =& $this->downloads[$dkey];
     // Unserialize the file data
     $data = maybe_unserialize($record->value);
     if (is_object($data)) {
         $properties = get_object_vars($data);
     } else {
         return;
     }
     // Map the file data to the purchased download record
     foreach ((array) $properties as $property => $value) {
         $Purchased->{$property} = sDB::clean($value);
     }
 }
Beispiel #3
0
 /**
  * Loads or constructs item properties from a purchased product
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return void
  **/
 public function load_purchased($Purchased)
 {
     $this->load(new ShoppProduct($Purchased->product), $Purchased->price, false);
     // Copy matching properties
     $properties = get_object_vars($Purchased);
     foreach ((array) $properties as $property => $value) {
         if (property_exists($this, $property)) {
             $this->{$property} = sDB::clean($value);
         }
     }
 }
Beispiel #4
0
 /**
  * Remove a setting from the registry and the database
  *
  * @since 1.0
  *
  * @param string $name Name of the setting to remove
  * @return boolean
  **/
 public function delete($name = false)
 {
     $null = null;
     if (empty($name)) {
         return false;
     }
     $Setting = $this->setting();
     $where = array("context='{$Setting->context}'", "type='{$Setting->type}'");
     if (!empty($name)) {
         $where[] = "name='" . sDB::clean($name) . "'";
     }
     $where = join(' AND ', $where);
     if (!sDB::query("DELETE FROM {$this->_table} WHERE {$where}")) {
         return false;
     }
     if (isset($this->registry[$name])) {
         $this->registry[$name] = $null;
     }
     return true;
 }