diff options
author | Malf Furious <m@lfurio.us> | 2017-02-04 20:34:37 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2017-02-04 20:34:37 -0500 |
commit | b2c9f4633ddf09e2bec7133e63c96ce205d3b80f (patch) | |
tree | e756b7bec30a7d77eb4468c8583ba89f2d6d7440 /examples/class/object.class.php | |
parent | 7342f00a0624ec0e89732ad476f44dc95d0129de (diff) | |
download | scrott-b2c9f4633ddf09e2bec7133e63c96ce205d3b80f.tar.gz scrott-b2c9f4633ddf09e2bec7133e63c96ce205d3b80f.zip |
Purge old content
Diffstat (limited to 'examples/class/object.class.php')
-rw-r--r-- | examples/class/object.class.php | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/examples/class/object.class.php b/examples/class/object.class.php index 0c02176..3acea4f 100644 --- a/examples/class/object.class.php +++ b/examples/class/object.class.php @@ -1,131 +1,7 @@ <?php -/* - * SCROTT Copyright (C) 2016 Malf Furious - * - * Scrott is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, - * or (at your option) any later version. - * - * Scrott is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - */ - -require_once "class/framework.class.php"; -require_once "class/user.class.php"; - -/* - * Base class for Scrott database objects - */ abstract class Object extends Framework { - var $DEFAULT_OBJECT_PERMISSIONS = 120; - - /* - * Constructor - */ - function __construct($childTable = "object", $childCols = null) - { - $this->db = $this->getDbConnection(); - - $this->table = "object"; - $this->cols = array( - "guid", - "perms", - "owner", - "parent", - "name", - "timeCreated", - "timeUpdated", - "type" - ); - - $this->childTable = $this->db->esc($childTable); - $this->childCols = array(); - - if (is_array($childCols)) - { - foreach ($childCols as $col) - $this->childCols[] = $this->db->esc($col); - } - } - - /* - * Get current timestamp for object database purposes - */ - function getCurrentTimestamp() - { - $query = "SELECT now() AS stamp"; - $result = $this->db->query($query); - return $result[0]['stamp']; - } - - /* - * Check whether given GUID exists - */ - function isGUID($guid) - { - $query = "SELECT `guid` FROM `object` WHERE `guid` = '" . $this->db->esc($guid) . "'"; - $result = $this->db->query($query); - - if (count($result) > 0) - return true; - - return false; - } - - /* - * Get a new, unique GUID for a new system object - */ - function getNewGUID() - { - do - { - $guid = substr($this->getBlob(), 0, 8); - } - while ($this->isGUID($guid)); - - return $guid; - } - - /* - * Get a random sha256 blob - */ - function getBlob() - { - return hash("sha256", openssl_random_pseudo_bytes(64)); - } - - /* - * Get a user object for this object's owner - */ - function getOwner() - { - if (isset($this->owner)) - return new User($this->owner); - - return null; - } - - /* - * Get an array of all members of this object - */ - function getMembers() - { - $query = "SELECT member FROM obj_member WHERE guid = '" . $this->db->esc($this->guid) . "'"; - $result = $this->db->query($query); - - $members = array(); - - foreach ($result as $m) - $members[] = new User($m['member']); - - return $members; - } - /* * Check if given user (or group) is the owner of this object */ @@ -467,19 +343,4 @@ abstract class Object extends Framework } } -/* - * Concrete Database Object which can be used in a polymorphic way - */ -class DBObject extends Object -{ - /* - * Constructor - */ - function __construct($guid = null) - { - parent::__construct(); - $this->loadObj($guid); - } -} - ?> |