]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2220: Pulled remaining classes out of lib files. Core classes now autoloaded...
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 15 Sep 2010 19:31:39 +0000 (19:31 +0000)
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 15 Sep 2010 19:31:39 +0000 (19:31 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6941 36083f99-b078-4883-b0ff-0f9b5a30f544

69 files changed:
engine/classes/APIException.php [new file with mode: 0644]
engine/classes/AccessControlQueryComponent.php [new file with mode: 0644]
engine/classes/CallException.php [new file with mode: 0644]
engine/classes/ClassException.php [new file with mode: 0644]
engine/classes/ClassNotFoundException.php [new file with mode: 0644]
engine/classes/ConfigurationException.php [new file with mode: 0644]
engine/classes/DataFormatException.php [new file with mode: 0644]
engine/classes/DatabaseException.php [new file with mode: 0644]
engine/classes/DeleteQueryTypeQueryComponent.php [new file with mode: 0644]
engine/classes/IOException.php [new file with mode: 0644]
engine/classes/InsertQueryTypeQueryComponent.php [new file with mode: 0644]
engine/classes/InstallationException.php [new file with mode: 0644]
engine/classes/InvalidClassException.php [new file with mode: 0644]
engine/classes/InvalidParameterException.php [new file with mode: 0644]
engine/classes/JoinQueryComponent.php [new file with mode: 0644]
engine/classes/LimitOffsetQueryComponent.php [new file with mode: 0644]
engine/classes/NotImplementedException.php [new file with mode: 0644]
engine/classes/NotificationException.php [new file with mode: 0644]
engine/classes/OrderQueryComponent.php [new file with mode: 0644]
engine/classes/PluginException.php [new file with mode: 0644]
engine/classes/Query.php [new file with mode: 0644]
engine/classes/QueryComponent.php [new file with mode: 0644]
engine/classes/QueryTypeQueryComponent.php [new file with mode: 0644]
engine/classes/RegistrationException.php [new file with mode: 0644]
engine/classes/SecurityException.php [new file with mode: 0644]
engine/classes/SelectFieldQueryComponent.php [new file with mode: 0644]
engine/classes/SelectQueryTypeQueryComponent.php [new file with mode: 0644]
engine/classes/SetQueryComponent.php [new file with mode: 0644]
engine/classes/SimpleQuery.php [new file with mode: 0644]
engine/classes/TableQueryComponent.php [new file with mode: 0644]
engine/classes/UpdateQueryTypeQueryComponent.php [new file with mode: 0644]
engine/classes/WhereQueryComponent.php [new file with mode: 0644]
engine/classes/WhereSetQueryComponent.php [new file with mode: 0644]
engine/classes/WhereStaticQueryComponent.php [new file with mode: 0644]
engine/lib/access.php
engine/lib/actions.php
engine/lib/admin.php
engine/lib/annotations.php
engine/lib/api.php
engine/lib/cache.php
engine/lib/calendar.php
engine/lib/cron.php
engine/lib/elgglib.php
engine/lib/entities.php
engine/lib/exceptions.php
engine/lib/export.php
engine/lib/extender.php
engine/lib/filestore.php
engine/lib/group.php
engine/lib/input.php
engine/lib/install.php
engine/lib/location.php
engine/lib/memcache.php
engine/lib/metadata.php
engine/lib/notification.php
engine/lib/objects.php
engine/lib/opendd.php
engine/lib/plugins.php
engine/lib/query.php
engine/lib/relationships.php
engine/lib/river.php
engine/lib/sessions.php
engine/lib/sites.php
engine/lib/system_log.php
engine/lib/tags.php
engine/lib/users.php
engine/lib/widgets.php
engine/lib/xml-rpc.php
engine/lib/xml.php

diff --git a/engine/classes/APIException.php b/engine/classes/APIException.php
new file mode 100644 (file)
index 0000000..d6eb9ce
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * APIException\r
+ * The API Exception class, thrown by the API layer when an API call has an issue.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class APIException extends Exception {}\r
diff --git a/engine/classes/AccessControlQueryComponent.php b/engine/classes/AccessControlQueryComponent.php
new file mode 100644 (file)
index 0000000..ad5410d
--- /dev/null
@@ -0,0 +1,40 @@
+<?php\r
+/**\r
+ * @class AccessControlQueryComponent\r
+ * Access control component.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class AccessControlQueryComponent extends QueryComponent\r
+{\r
+       /**\r
+        * Construct the ACL.\r
+        *\r
+        * @param string $acl_table The table where the access control field is.\r
+        * @param string $acl_field The field containing the access control.\r
+        * @param string $object_owner_table The table containing the owner information for the stuff you're retrieving.\r
+        * @param string $object_owner_id_field The field in $object_owner_table containing the owner information\r
+        */\r
+       function __construct($acl_table = "entities", $acl_field = "access_id", $object_owner_table = "entities", $object_owner_id_field = "owner_guid")\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->acl_table = $CONFIG->dbprefix . sanitise_string($acl_table);\r
+               $this->acl_field = sanitise_string($acl_field);\r
+               $this->object_owner_table = $CONFIG->dbprefix . sanitise_string($object_owner_table);\r
+               $this->object_owner_id_field = sanitise_string($object_owner_id_field);\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               //$access = get_access_list();\r
+               // KJ - changed to use get_access_sql_suffix\r
+               // Note: currently get_access_sql_suffix is hardwired to use\r
+               // $acl_field = "access_id", $object_owner_table = $acl_table, and\r
+               // $object_owner_id_field = "owner_guid"\r
+               // @todo recode get_access_sql_suffix to make it possible to specify alternate field names\r
+               return "and ".get_access_sql_suffix($this->acl_table); // Add access controls\r
+\r
+               //return "and ({$this->acl_table}.{$this->acl_field} in {$access} or ({$this->acl_table}.{$this->acl_field} = 0 and {$this->object_owner_table}.{$this->object_owner_id_field} = {$_SESSION['id']}))";\r
+       }\r
+}\r
diff --git a/engine/classes/CallException.php b/engine/classes/CallException.php
new file mode 100644 (file)
index 0000000..369ce19
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * CallException\r
+ * An exception thrown when there is a problem calling something.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class CallException extends Exception {}\r
diff --git a/engine/classes/ClassException.php b/engine/classes/ClassException.php
new file mode 100644 (file)
index 0000000..6dfb57b
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * ClassException\r
+ * A class Exception, throw when there is a class error.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class ClassException extends Exception {}\r
diff --git a/engine/classes/ClassNotFoundException.php b/engine/classes/ClassNotFoundException.php
new file mode 100644 (file)
index 0000000..f344e6b
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * ClassNotFoundException\r
+ * An Class not found Exception, throw when an class can not be found occurs.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class ClassNotFoundException extends ClassException {}
\ No newline at end of file
diff --git a/engine/classes/ConfigurationException.php b/engine/classes/ConfigurationException.php
new file mode 100644 (file)
index 0000000..a3c7c38
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * ConfigurationException\r
+ * There is a configuration error\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class ConfigurationException extends Exception {}\r
diff --git a/engine/classes/DataFormatException.php b/engine/classes/DataFormatException.php
new file mode 100644 (file)
index 0000000..2038f1f
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * Data format exception\r
+ * An exception thrown when there is a problem in the format of some data.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class DataFormatException extends Exception {}\r
diff --git a/engine/classes/DatabaseException.php b/engine/classes/DatabaseException.php
new file mode 100644 (file)
index 0000000..ffc414a
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * DatabaseException\r
+ * An database exception, throw when a database exception happens, subclass if more detail is needed.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class DatabaseException extends Exception {}\r
diff --git a/engine/classes/DeleteQueryTypeQueryComponent.php b/engine/classes/DeleteQueryTypeQueryComponent.php
new file mode 100644 (file)
index 0000000..645e95c
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+/**\r
+ * @class DeleteQueryTypeQueryComponent\r
+ * A delete query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class DeleteQueryTypeQueryComponent extends QueryTypeQueryComponent\r
+{\r
+       function __construct()\r
+       {\r
+               $this->query_type = "DELETE FROM";\r
+       }\r
+}\r
diff --git a/engine/classes/IOException.php b/engine/classes/IOException.php
new file mode 100644 (file)
index 0000000..683be32
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * IOException\r
+ * An IO Exception, throw when an IO Exception occurs. Subclass for specific IO Exceptions.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class IOException extends Exception {}\r
diff --git a/engine/classes/InsertQueryTypeQueryComponent.php b/engine/classes/InsertQueryTypeQueryComponent.php
new file mode 100644 (file)
index 0000000..20d1a7a
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+/**\r
+ * @class InsertQueryTypeQueryComponent\r
+ * An insert query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class InsertQueryTypeQueryComponent extends QueryTypeQueryComponent\r
+{\r
+       function __construct()\r
+       {\r
+               $this->query_type = "INSERT INTO";\r
+       }\r
+}\r
diff --git a/engine/classes/InstallationException.php b/engine/classes/InstallationException.php
new file mode 100644 (file)
index 0000000..96bd9be
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * InstallationException\r
+ * Thrown when there is a major problem with the installation.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class InstallationException extends ConfigurationException {}\r
diff --git a/engine/classes/InvalidClassException.php b/engine/classes/InvalidClassException.php
new file mode 100644 (file)
index 0000000..84d3b36
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * InvalidClassException\r
+ * An invalid class Exception, throw when a class is invalid.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class InvalidClassException extends ClassException {}\r
diff --git a/engine/classes/InvalidParameterException.php b/engine/classes/InvalidParameterException.php
new file mode 100644 (file)
index 0000000..a94904d
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * InvalidParameterException\r
+ * A parameter is invalid.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class InvalidParameterException extends CallException {}\r
diff --git a/engine/classes/JoinQueryComponent.php b/engine/classes/JoinQueryComponent.php
new file mode 100644 (file)
index 0000000..8300cf7
--- /dev/null
@@ -0,0 +1,33 @@
+<?php\r
+/**\r
+ * @class JoinQueryComponent Join query.\r
+ * Represents a join query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class JoinQueryComponent extends QueryComponent\r
+{\r
+       /**\r
+        * Construct a join query.\r
+        * @param string $table Table one to join...\r
+        * @param string $field Field 1 with...\r
+        * @param string $table2 Table 2 ...\r
+        * @param string $field2 Field...\r
+        * @param string $operator Using this operator\r
+        */\r
+       function __construct($table1, $field1, $table2, $field2, $operator = "=")\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->table1 = $CONFIG->dbprefix . sanitise_string($table1);\r
+               $this->field1 = sanitise_string($field1);\r
+               $this->table2 = $CONFIG->dbprefix . sanitise_string($table2);\r
+               $this->field2 = sanitise_string($field2);\r
+               $this->operator = sanitise_string($operator);\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return "join {$this->table2} on {$this->$table}.{$this->$field} {$this->$operator} {$this->$table2}.{$this->$field2}";\r
+       }\r
+}\r
diff --git a/engine/classes/LimitOffsetQueryComponent.php b/engine/classes/LimitOffsetQueryComponent.php
new file mode 100644 (file)
index 0000000..2cc77dd
--- /dev/null
@@ -0,0 +1,26 @@
+<?php\r
+/**\r
+ * @class LimitOffsetQueryComponent\r
+ * Limit and offset clauses of a query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class LimitOffsetQueryComponent extends QueryComponent\r
+{\r
+       /**\r
+        * Specify a limit and an offset.\r
+        *\r
+        * @param int $limit The limit.\r
+        * @param int $offset The offset.\r
+        */\r
+       function __construct($limit = 25, $offset = 0)\r
+       {\r
+               $this->limit = (int)$limit;\r
+               $this->offset = (int)$offset;\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return "limit {$this->offset}, {$this->limit}";\r
+       }\r
+}\r
diff --git a/engine/classes/NotImplementedException.php b/engine/classes/NotImplementedException.php
new file mode 100644 (file)
index 0000000..f95c88c
--- /dev/null
@@ -0,0 +1,11 @@
+<?php\r
+/**\r
+ * NotImplementedException\r
+ * Thrown when a method or function has not been implemented, primarily used in development... you should\r
+ * not see these!\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class NotImplementedException extends CallException {}\r
diff --git a/engine/classes/NotificationException.php b/engine/classes/NotificationException.php
new file mode 100644 (file)
index 0000000..78ea4c5
--- /dev/null
@@ -0,0 +1,6 @@
+<?php\r
+/**\r
+ * Notification exception.\r
+ * @author Curverider Ltd\r
+ */\r
+class NotificationException extends Exception {}\r
diff --git a/engine/classes/OrderQueryComponent.php b/engine/classes/OrderQueryComponent.php
new file mode 100644 (file)
index 0000000..04bb309
--- /dev/null
@@ -0,0 +1,23 @@
+<?php\r
+/**\r
+ * @class OrderQueryComponent\r
+ * Order the query results.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class OrderQueryComponent extends QueryComponent\r
+{\r
+       function __construct($table, $field, $order = "asc")\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->table = $CONFIG->dbprefix . sanitise_string($table);\r
+               $this->field = sanitise_string($field);\r
+               $this->order = sanitise_string($order);\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return "order by {$this->table}.{$this->field} {$this->order}";\r
+       }\r
+}\r
diff --git a/engine/classes/PluginException.php b/engine/classes/PluginException.php
new file mode 100644 (file)
index 0000000..4da1579
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * PluginException\r
+ *\r
+ * A plugin Exception, thrown when an Exception occurs relating to the plugin mechanism. Subclass for specific plugin Exceptions.\r
+ *\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class PluginException extends Exception {}
\ No newline at end of file
diff --git a/engine/classes/Query.php b/engine/classes/Query.php
new file mode 100644 (file)
index 0000000..ebc7e14
--- /dev/null
@@ -0,0 +1,286 @@
+<?php\r
+/**\r
+ * @class Query Provides a framework to construct complex queries in a safer environment.\r
+ *\r
+ * The usage of this class depends on the type of query you are executing, but the basic idea is to\r
+ * construct a query out of pluggable classes.\r
+ *\r
+ * Once constructed SQL can be generated using the toString method, this should happen automatically\r
+ * if you pass the Query object to get_data or similar.\r
+ *\r
+ * To construct a query, create a new Query() object and begin populating it with the various classes\r
+ * that define the various aspects of the query.\r
+ *\r
+ * Notes:\r
+ *     - You do not have to specify things in any particular order, provided you specify all required\r
+ *       components.\r
+ *  - With database tables you do not have to specify your db prefix, this will be added automatically.\r
+ *  - When constructing your query keep an eye on the error log - any problems will get spit out here.\r
+ *       Note also that __toString won't let you throw Exceptions (!!!) so these are caught and echoed to\r
+ *    the log instead.\r
+ *\r
+ * Here is an example of a select query which requests some data out of the entities table with an\r
+ * order and limit that uses a subset where and some normal where queries:\r
+ *\r
+ * <blockquote>\r
+ *             // Construct the query\r
+ *             $query = new Query();\r
+ *\r
+ *             // Say which table we're interested in\r
+ *             $query->addTable(new TableQueryComponent("entities"));\r
+ *\r
+ *             // What fields are we interested in\r
+ *             $query->addSelectField(new SelectFieldQueryComponent("entities","*"));\r
+ *\r
+ *             // Add access control (Default access control uses default fields on entities table.\r
+ *             // Note that it will error without something specified here!\r
+ *             $query->setAccessControl(new AccessControlQueryComponent());\r
+ *\r
+ *             // Set a limit and offset, may be omitted.\r
+ *             $query->setLimitAndOffset(new LimitOffsetQueryComponent(10,0));\r
+ *\r
+ *             // Specify the order, may be omitted\r
+ *             $query->setOrder(new OrderQueryComponent("entities", "subtype", "desc"));\r
+ *\r
+ *             // Construct a where query\r
+ *             //\r
+ *             // This demonstrates a WhereSet which lets you have sub wheres, a\r
+ *             // WhereStatic which lets you compare a table field against a value and a\r
+ *             // Where which lets you compare a table/field with another table/field.\r
+ *             $query->addWhere(\r
+ *                     new WhereSetQueryComponent(\r
+ *                             array(\r
+ *                                     new WhereStaticQueryComponent("entities", "subtype","=", 1),\r
+ *                                     new WhereQueryComponent("entities","subtype","=", "entities", "subtype")\r
+ *                             )\r
+ *                     )\r
+ *             );\r
+ *\r
+ *             get_data($query);\r
+ * </blockquote>\r
+ *\r
+ * @author Curverider Ltd\r
+ */\r
+class Query\r
+{\r
+\r
+       /// The limit of the query\r
+       private $limit_and_offset;\r
+\r
+       /// Fields to return on a query\r
+       private $fields;\r
+\r
+       /// Tables to use in a from query\r
+       private $tables;\r
+\r
+       /// Join tables\r
+       private $joins;\r
+\r
+       /// Set values\r
+       private $sets;\r
+\r
+       /// Where query\r
+       private $where;\r
+\r
+       /// Order by\r
+       private $order;\r
+\r
+       /// The query type\r
+       private $query_type;\r
+\r
+       /// ACL\r
+       private $access_control;\r
+\r
+       /**\r
+        * Construct query & initialise variables\r
+        */\r
+       function __construct()\r
+       {\r
+               $this->fields = array();\r
+               $this->tables = array();\r
+               $this->joins = array();\r
+               $this->where = array();\r
+               $this->sets = array();\r
+\r
+               $this->setQueryType(new SelectQueryTypeQueryComponent());\r
+       }\r
+\r
+       /**\r
+        * Add limits and offsets to the query.\r
+        *\r
+        * @param LimitOffsetQueryComponent $component The limit and offset.\r
+        */\r
+       public function setLimitAndOffset(LimitOffsetQueryComponent $component) { $this->limit_and_offset = $component; }\r
+\r
+       /**\r
+        * Reset and set the field to the select statement.\r
+        *\r
+        * @param SelectFieldQueryComponent $component Table and field component.\r
+        */\r
+       public function setSelectField(SelectFieldQueryComponent $component)\r
+       {\r
+               $this->fields = array();\r
+               return $this->addSelectField($component);\r
+       }\r
+\r
+       /**\r
+        * Add a select field.\r
+        *\r
+        * @param SelectFieldQueryComponent $component Add a component.\r
+        */\r
+       public function addSelectField(SelectFieldQueryComponent $component) { $this->fields[] = $component; }\r
+\r
+       /**\r
+        * Add a join to the component.\r
+        *\r
+        * @param JoinQueryComponent $component The join.\r
+        */\r
+       public function addJoin(JoinQueryComponent $component) { $this->joins[] = $component; }\r
+\r
+       /**\r
+        * Set a field value in an update or insert statement.\r
+        *\r
+        * @param SetQueryComponent $component Fields to set.\r
+        */\r
+       public function addSet(SetQueryComponent $component) { $this->sets[] = $component; }\r
+\r
+       /**\r
+        * Set the query type, i.e. "select", "update", "insert" & "delete".\r
+        *\r
+        * @param QueryTypeQueryComponent $component The query type.\r
+        */\r
+       public function setQueryType(QueryTypeQueryComponent $component) { $this->query_type = $component; }\r
+\r
+       /**\r
+        * Attach an order component.\r
+        *\r
+        * @param OrderQueryComponent $component The order component.\r
+        */\r
+       public function setOrder(OrderQueryComponent $component) { $this->order = $component; }\r
+\r
+       /**\r
+        * Add a table to the query.\r
+        *\r
+        * @param TableQueryComponent $component Table to add.\r
+        */\r
+       public function addTable(TableQueryComponent $component) { $this->tables[] = $component; }\r
+\r
+       /**\r
+        * Add a where clause to the query.\r
+        *\r
+        * @param WhereQueryComponent $component The where component\r
+        */\r
+       public function addWhere(WhereQueryComponent $component) { $this->where[] = $component; }\r
+\r
+       /**\r
+        * Set access control.\r
+        *\r
+        * @param AccessControlQueryComponent $component Access control.\r
+        */\r
+       public function setAccessControl(AccessControlQueryComponent $component) { $this->access_control = $component; }\r
+\r
+       public function __toString()\r
+       {\r
+               global $CONFIG;\r
+\r
+               $sql = "";\r
+\r
+               try\r
+               {\r
+                       // Query prefix & fields\r
+                       if (!empty($this->query_type))\r
+                       {\r
+                               $sql .= "{$this->query_type} ";\r
+\r
+                               if (!empty($this->fields))\r
+                               {\r
+                                       $fields = "";\r
+\r
+                                       foreach ($this->fields as $field)\r
+                                               $fields .= "$field";\r
+\r
+                                       $sql .= " $fields from ";\r
+                               }\r
+                               else\r
+                                       throw new DatabaseException(elgg_echo('DatabaseException:SelectFieldsMissing'));\r
+                       }\r
+                       else\r
+                               throw new DatabaseException(elgg_echo('DatabaseException:UnspecifiedQueryType'));\r
+\r
+                       // Tables\r
+                       if (!empty($this->tables))\r
+                       {\r
+                               foreach($this->tables as $table)\r
+                                       $sql .= "$table, ";\r
+\r
+                               $sql = trim($sql, ", ");\r
+                       }\r
+                       else\r
+                               throw new DatabaseException(elgg_echo('DatabaseException:NoTablesSpecified'));\r
+\r
+                       // Joins on select queries\r
+                       if ($this->query_type->query_type == 'select')\r
+                       {\r
+                               if (!empty($this->joins))\r
+                               {\r
+                                       foreach($this->joins as $join)\r
+                                               $sql .= "$join ";\r
+                               }\r
+                       }\r
+\r
+                       // Setting values\r
+                       if (\r
+                               ($this->query_type->query_type == 'update') ||\r
+                               ($this->query_type->query_type == 'insert')\r
+                       )\r
+                       {\r
+                               $sql .= "set ";\r
+\r
+                               foreach ($this->sets as $set)\r
+                                       $sql .= "$set, ";\r
+\r
+                               $sql = trim($sql, ", ") . " ";\r
+                       }\r
+\r
+                       // Where\r
+                       if (!empty($this->where))\r
+                       {\r
+                               $sql .= " where 1 ";\r
+\r
+                               foreach ($this->where as $where)\r
+                                       $sql .= "$where ";\r
+                       }\r
+\r
+                       // Access control\r
+                       if (!empty($this->access_control))\r
+                       {\r
+\r
+                               // Catch missing Where\r
+                               if (empty($this->where))\r
+                                       $sql .= " where 1 ";\r
+\r
+                               $sql .= "{$this->access_control} ";\r
+                       }\r
+                       else\r
+                               throw new DatabaseException(elgg_echo('DatabaseException:NoACL'));\r
+\r
+                       // Order by\r
+                       if (!empty($this->order))\r
+                               $sql .= "{$this->order} ";\r
+\r
+                       // Limits\r
+                       if (!empty($this->limit_and_offset))\r
+                               $sql .= "{$this->limit_and_offset} ";\r
+\r
+\r
+\r
+               } catch (Exception $e) {\r
+                       trigger_error($e, E_USER_WARNING);\r
+               }\r
+\r
+\r
+               return $sql;\r
+       }\r
+\r
+}\r
+\r
diff --git a/engine/classes/QueryComponent.php b/engine/classes/QueryComponent.php
new file mode 100644 (file)
index 0000000..cfe7683
--- /dev/null
@@ -0,0 +1,42 @@
+<?php\r
+/**\r
+ * @class QueryComponent Query component superclass.\r
+ * Component of a query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+abstract class QueryComponent\r
+{\r
+       /**\r
+        * Associative array of fields and values\r
+        */\r
+       private $fields;\r
+\r
+       function __construct()\r
+       {\r
+               $this->fields = array();\r
+       }\r
+\r
+       /**\r
+        * Class member get overloading\r
+        *\r
+        * @param string $name\r
+        * @return mixed\r
+        */\r
+       function __get($name) {\r
+               return $this->fields[$name];\r
+       }\r
+\r
+       /**\r
+        * Class member set overloading\r
+        *\r
+        * @param string $name\r
+        * @param mixed $value\r
+        * @return void\r
+        */\r
+       function __set($name, $value) {\r
+               $this->fields[$name] = $value;\r
+\r
+               return true;\r
+       }\r
+}\r
diff --git a/engine/classes/QueryTypeQueryComponent.php b/engine/classes/QueryTypeQueryComponent.php
new file mode 100644 (file)
index 0000000..231faa7
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+/**\r
+ * @class QueryTypeQueryComponent\r
+ * What type of query is this?\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+abstract class QueryTypeQueryComponent extends QueryComponent\r
+{\r
+       function __toString()\r
+       {\r
+               return $this->query_type;\r
+       }\r
+}\r
diff --git a/engine/classes/RegistrationException.php b/engine/classes/RegistrationException.php
new file mode 100644 (file)
index 0000000..5efea39
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * RegistrationException\r
+ * Could not register a new user for whatever reason.\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class RegistrationException extends InstallationException {}
\ No newline at end of file
diff --git a/engine/classes/SecurityException.php b/engine/classes/SecurityException.php
new file mode 100644 (file)
index 0000000..3075f0b
--- /dev/null
@@ -0,0 +1,10 @@
+<?php\r
+/**\r
+ * SecurityException\r
+ * An Security Exception, throw when a Security Exception occurs. Subclass for specific Security Execeptions (access problems etc)\r
+ *\r
+ * @author Curverider Ltd <info@elgg.com>\r
+ * @package Elgg\r
+ * @subpackage Exceptions\r
+ */\r
+class SecurityException extends Exception {}\r
diff --git a/engine/classes/SelectFieldQueryComponent.php b/engine/classes/SelectFieldQueryComponent.php
new file mode 100644 (file)
index 0000000..fbc4a81
--- /dev/null
@@ -0,0 +1,28 @@
+<?php\r
+/**\r
+ * @class SelectFieldQueryComponent Class representing a select field.\r
+ * This class represents a select field component.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class SelectFieldQueryComponent extends QueryComponent\r
+{\r
+       /**\r
+        * Construct a select field component\r
+        *\r
+        * @param string $table The table containing the field.\r
+        * @param string $field The field or "*"\r
+        */\r
+       function __construct($table, $field)\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->table = $CONFIG->dbprefix . sanitise_string($table);\r
+               $this->field = sanitise_string($field);\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return "{$this->table}.{$this->field}";\r
+       }\r
+}\r
diff --git a/engine/classes/SelectQueryTypeQueryComponent.php b/engine/classes/SelectQueryTypeQueryComponent.php
new file mode 100644 (file)
index 0000000..61e7e50
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+/**\r
+ * @class SelectQueryTypeQueryComponent\r
+ * A select query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class SelectQueryTypeQueryComponent extends QueryTypeQueryComponent\r
+{\r
+       function __construct()\r
+       {\r
+               $this->query_type = "SELECT";\r
+       }\r
+}\r
diff --git a/engine/classes/SetQueryComponent.php b/engine/classes/SetQueryComponent.php
new file mode 100644 (file)
index 0000000..0acd571
--- /dev/null
@@ -0,0 +1,33 @@
+<?php\r
+/**\r
+ * @class SetQueryComponent Set query.\r
+ * Represents an update set query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class SetQueryComponent extends QueryComponent\r
+{\r
+       /**\r
+        * Construct a setting query\r
+        *\r
+        * @param string $table The table to modify\r
+        * @param string $field The field to modify\r
+        * @param mixed $value The value to set it to\r
+        */\r
+       function __construct($table, $field, $value)\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->table = $CONFIG->dbprefix . sanitise_string($table);\r
+               $this->field = sanitise_string($field);\r
+               if (is_numeric($value))\r
+                       $this->value = (int)$value;\r
+               else\r
+                       $this->value = "'".sanitise_string($value)."'";\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return "{$this->table}.{$this->field}={$this->value}";\r
+       }\r
+}\r
diff --git a/engine/classes/SimpleQuery.php b/engine/classes/SimpleQuery.php
new file mode 100644 (file)
index 0000000..cf5a18a
--- /dev/null
@@ -0,0 +1,152 @@
+<?php\r
+/**\r
+ * @class SimpleQuery A wrapper for Query which provides simple interface for common functions.\r
+ *\r
+ * This class provides simple interface functions for constructing a (reasonably) standard database\r
+ * query.\r
+ *\r
+ * The constructor for this class sets a number of defaults, for example sets default access controls\r
+ * and a limit and offset - to change this then set it manually.\r
+ *\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class SimpleQuery extends Query\r
+{\r
+       function __construct()\r
+       {\r
+               parent::__construct();\r
+\r
+               // Set a default query type (select)\r
+               $this->simpleQueryType();\r
+\r
+               // Set a default access control\r
+               $this->simpleAccessControl();\r
+\r
+               // Set default limit and offset\r
+               $this->simpleLimitAndOffset();\r
+       }\r
+\r
+       /**\r
+        * Set the query type.\r
+        *\r
+        * @param string $type The type of search - available are "select", "update", "delete", "insert".\r
+        */\r
+       public function simpleQueryType($type = "select")\r
+       {\r
+               $type = strtolower(sanitise_string($type));\r
+\r
+               switch ($type)\r
+               {\r
+                       case "insert" :\r
+                               return $this->setQueryType(InsertQueryTypeQueryComponent());\r
+                       break;\r
+                       case "delete" :\r
+                               return $this->setQueryType(DeleteQueryTypeQueryComponent());\r
+                       break;\r
+                       case "update" :\r
+                               return $this->setQueryType(UpdateQueryTypeQueryComponent());\r
+                       break;\r
+                       default: return $this->setQueryType(SelectQueryTypeQueryComponent());\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Set a field to query in a select statement.\r
+        *\r
+        * @param string $table Table to query.\r
+        * @param string $field Field in that table.\r
+        */\r
+       public function simpleSelectField($table, $field) { return $this->setSelectField(new SelectFieldQueryComponent($table, $field)); }\r
+\r
+       /**\r
+        * Add a select field to query in a select statement.\r
+        *\r
+        * @param string $table Table to query.\r
+        * @param string $field Field in that table.\r
+        */\r
+       public function simpleAddSelectField($table, $field) { return $this->addSelectField(new SelectFieldQueryComponent($table, $field)); }\r
+\r
+       /**\r
+        * Add a set value to an update query.\r
+        *\r
+        * @param string $table The table to update.\r
+        * @param string $field The field in the table.\r
+        * @param mixed $value The value to set it to.\r
+        */\r
+       public function simpleSet($table, $field, $value) { return $this->addSet(new SetQueryComponent($table, $field, $value)); }\r
+\r
+       /**\r
+        * Add a join to the table.\r
+        *\r
+        * @param string $table Table one to join...\r
+        * @param string $field Field 1 with...\r
+        * @param string $table2 Table 2 ...\r
+        * @param string $field2 Field...\r
+        * @param string $operator Using this operator\r
+        */\r
+       public function simpleJoin($table1, $field1, $table2, $field2, $operator = "=") { return $this->addJoin(new JoinQueryComponent($table1, $field1, $table2, $field2, $operator)); }\r
+\r
+       /**\r
+        * Add a table to the query.\r
+        *\r
+        * @param string $table The table.\r
+        */\r
+       public function simpleTable($table) { return $this->addTable(new TableQueryComponent($table)); }\r
+\r
+       /**\r
+        * Compare one table/field to another table/field.\r
+        *\r
+        * @param string $left_table The table on the left of the operator\r
+        * @param string $left_field The left field\r
+        * @param string $operator The operator eg "=" or "<"\r
+        * @param string $right_table The table on the right of the operator\r
+        * @param string $right_field The right field\r
+        * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"\r
+        */\r
+       public function simpleWhereOnTable($left_table, $left_field, $operator, $right_table, $right_field, $link_operator = "and") { return $this->addWhere(new WhereQueryComponent($left_table, $left_field, $operator, $right_table, $right_field, $link_operator)); }\r
+\r
+       /**\r
+        * Compare one table/field to a value.\r
+        *\r
+        * @param string $left_table The table on the left of the operator\r
+        * @param string $left_field The left field\r
+        * @param string $operator The operator eg "=" or "<"\r
+        * @param string $value The value\r
+        * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"\r
+        */\r
+       public function simpleWhereOnValue($left_table, $left_field, $operator, $value, $link_operator = "and") { return $this->addWhere(new WhereStaticQueryComponent($left_table, $left_field, $operator, $value, $link_operator)); }\r
+\r
+       /**\r
+        * Set access control.\r
+        *\r
+        * @param string $acl_table The table where the access control field is.\r
+        * @param string $acl_field The field containing the access control.\r
+        * @param string $object_owner_id_field The field in $object_owner_table containing the owner information.\r
+        */\r
+       public function simpleAccessControl($acl_table = "entities", $acl_field = "access_id", $object_owner_id_field = "owner_guid") { return $this->setAccessControl(new AccessControlQueryComponent($acl_table, $acl_field, $acl_table, $object_owner_id_field)); }\r
+\r
+       /**\r
+        * Set the limit and offset.\r
+        *\r
+        * @param int $limit The limit.\r
+        * @param int $offset The offset.\r
+        */\r
+       public function simpleLimitAndOffset($limit = 25, $offset = 0) { return $this->setLimitAndOffset(new LimitOffsetQueryComponent($limit, $offset)); }\r
+\r
+       /**\r
+        * Set the order query.\r
+        *\r
+        * @param string $table The table to query\r
+        * @param string $field The field to query\r
+        * @param string $order Order the query\r
+        */\r
+       public function simpleOrder($table, $field, $order = "desc")\r
+       {\r
+               $table = sanitise_string($table);\r
+               $field = sanitise_string($field);\r
+               $order = strtolower(sanitise_string($order));\r
+\r
+               return $this->setOrder(new OrderQueryComponent($table, $field, $order)); break;\r
+       }\r
+}\r
diff --git a/engine/classes/TableQueryComponent.php b/engine/classes/TableQueryComponent.php
new file mode 100644 (file)
index 0000000..54e6ab0
--- /dev/null
@@ -0,0 +1,21 @@
+<?php\r
+/**\r
+ * @class TableQueryComponent\r
+ * List of tables to select from or insert into.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class TableQueryComponent extends QueryComponent\r
+{\r
+       function __construct($table)\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->table = $CONFIG->dbprefix . sanitise_string($table);\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return $this->table;\r
+       }\r
+}\r
diff --git a/engine/classes/UpdateQueryTypeQueryComponent.php b/engine/classes/UpdateQueryTypeQueryComponent.php
new file mode 100644 (file)
index 0000000..226b14b
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+/**\r
+ * @class UpdateQueryTypeQueryComponent\r
+ * An update query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class UpdateQueryTypeQueryComponent extends QueryTypeQueryComponent\r
+{\r
+       function __construct()\r
+       {\r
+               $this->query_type = "UPDATE";\r
+       }\r
+}\r
diff --git a/engine/classes/WhereQueryComponent.php b/engine/classes/WhereQueryComponent.php
new file mode 100644 (file)
index 0000000..3130be7
--- /dev/null
@@ -0,0 +1,44 @@
+<?php\r
+/**\r
+ * @class WhereQueryComponent\r
+ * A component of a where query.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class WhereQueryComponent extends QueryComponent\r
+{\r
+       /**\r
+        * A where query.\r
+        *\r
+        * @param string $left_table The table on the left of the operator\r
+        * @param string $left_field The left field\r
+        * @param string $operator The operator eg "=" or "<"\r
+        * @param string $right_table The table on the right of the operator\r
+        * @param string $right_field The right field\r
+        * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"\r
+        */\r
+       function __construct($left_table, $left_field, $operator, $right_table, $right_field, $link_operator = "and")\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->link_operator = sanitise_string($link_operator);\r
+               $this->left_table = $CONFIG->dbprefix . sanitise_string($left_table);\r
+               $this->left_field = sanitise_string($left_field);\r
+               $this->operator = sanitise_string($operator);\r
+               $this->right_table = $CONFIG->dbprefix . sanitise_string($right_table);\r
+               $this->right_field = sanitise_string($right_field);\r
+       }\r
+\r
+       /**\r
+        * Return the SQL without the link operator.\r
+        */\r
+       public function toStringNoLink()\r
+       {\r
+               return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->right_table}.{$this->right_field}";\r
+       }\r
+\r
+       function __toString()\r
+       {\r
+               return "{$this->link_operator} " . $this->toStringNoLink();\r
+       }\r
+}\r
diff --git a/engine/classes/WhereSetQueryComponent.php b/engine/classes/WhereSetQueryComponent.php
new file mode 100644 (file)
index 0000000..b5fe439
--- /dev/null
@@ -0,0 +1,41 @@
+<?php\r
+/**\r
+ * @class WhereSetQueryComponent\r
+ * A where query that may contain other where queries (in brackets).\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class WhereSetQueryComponent extends WhereQueryComponent\r
+{\r
+       /**\r
+        * Construct a subset of wheres.\r
+        *\r
+        * @param array $wheres An array of WhereQueryComponent\r
+        * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"\r
+        */\r
+       function __construct(array $wheres, $link_operator = "and")\r
+       {\r
+               $this->link_operator = sanitise_string($link_operator);\r
+               $this->wheres = $wheres;\r
+       }\r
+\r
+       public function toStringNoLink()\r
+       {\r
+               $cnt = 0;\r
+               $string = " (";\r
+               foreach ($this->wheres as $where) {\r
+                       if (!($where instanceof WhereQueryComponent))\r
+                               throw new DatabaseException(elgg_echo('DatabaseException:WhereSetNonQuery'));\r
+\r
+                       if (!$cnt)\r
+                               $string.= $where->toStringNoLink();\r
+                       else\r
+                               $string.=" $where ";\r
+\r
+                       $cnt ++;\r
+               }\r
+               $string .= ")";\r
+\r
+               return $string;\r
+       }\r
+}\r
diff --git a/engine/classes/WhereStaticQueryComponent.php b/engine/classes/WhereStaticQueryComponent.php
new file mode 100644 (file)
index 0000000..ddc036f
--- /dev/null
@@ -0,0 +1,40 @@
+<?php\r
+/**\r
+ * @class WhereStaticQueryComponent\r
+ * A component of a where query where there is no right hand table, rather a static value.\r
+ * @author Curverider Ltd\r
+ * @see Query\r
+ */\r
+class WhereStaticQueryComponent extends WhereQueryComponent\r
+{\r
+       /**\r
+        * A where query.\r
+        *\r
+        * @param string $left_table The table on the left of the operator\r
+        * @param string $left_field The left field\r
+        * @param string $operator The operator eg "=" or "<"\r
+        * @param string $value The value\r
+        * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"\r
+        */\r
+       function __construct($left_table, $left_field, $operator, $value, $link_operator = "and")\r
+       {\r
+               global $CONFIG;\r
+\r
+               $this->link_operator = sanitise_string($link_operator);\r
+               $this->left_table = $CONFIG->dbprefix . sanitise_string($left_table);\r
+               $this->left_field = sanitise_string($left_field);\r
+               $this->operator = sanitise_string($operator);\r
+               if (is_numeric($value))\r
+                       $this->value = (int)$value;\r
+               else\r
+                       $this->value = "'".sanitise_string($value)."'";\r
+       }\r
+\r
+       /**\r
+        * Return the SQL without the link operator.\r
+        */\r
+       public function toStringNoLink()\r
+       {\r
+               return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->value}";\r
+       }\r
+}\r
index 4155fc4084bbad22cba280f4a79755e764d6e04f..80065fa7252519fb2159a07a29c7376b777b997e 100644 (file)
@@ -11,9 +11,6 @@
  * @link http://elgg.org/
  */
 
-include dirname(dirname(__FILE__)).'/classes/ElggAccess.php';
-
-
 /**
  * Return a string of access_ids for $user_id appropriate for inserting into an SQL IN clause.
  *
index c7abd5f181eee2e709ce14623057fb98d86b5ab3..cdad8ebab60efa509a2d5cb7d13c2969918b119f 100644 (file)
@@ -257,5 +257,4 @@ function elgg_action_exist($action) {
        return (isset($CONFIG->actions[$action]) && file_exists($CONFIG->actions[$action]['file']));
 }
 
-
 register_elgg_event_handler("init","system","actions_init");
index 8426adf8b1c94cf10812d76ef1666afdf751d47e..2fb38c2306d6d5cd06f3da9039ee1e5f2b553069 100644 (file)
@@ -9,7 +9,6 @@
  * @link http://elgg.org/
  */
 
-
 /**
  * Register an admin page with the admin panel.
  * This function extends the view "admin/main" with the provided view. This view should provide a description
@@ -292,7 +291,6 @@ function elgg_admin_notice_exists($id) {
        return ($notice) ? TRUE : FALSE;
 }
 
-
 // Register init functions
 register_elgg_event_handler('init', 'system', 'admin_init');
 register_elgg_event_handler('pagesetup', 'system', 'admin_pagesetup');
index 3c8bb2aade267daba0c5fb6b4e00d78f97079376..806b4c806b2df37fabe69d466a64f2804d829796 100644 (file)
@@ -9,10 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once 'extender.php';
-
-require_once dirname(dirname(__FILE__)).'/classes/ElggAnnotation.php';
-
 /**
  * Convert a database row to a new ElggAnnotation
  *
index 7a6fd54af8d1eb9884a5b14c881f548c5febe003..d6e4557cb36d15f74c2366ce3912ddd632722bf0 100644 (file)
@@ -9,13 +9,6 @@
  * @link http://elgg.org/
  */
 
-// Result classes /////////////////////////////////////////////////////////////////////////
-
-require_once dirname(dirname(__FILE__)).'/classes/GenericResult.php';
-require_once dirname(dirname(__FILE__)).'/classes/SuccessResult.php';
-require_once dirname(dirname(__FILE__)).'/classes/ErrorResult.php';
-require_once dirname(dirname(__FILE__)).'/classes/ElggHMACCache.php';
-
 // Primary Services API Server functions /////////////////////////////////////////////////////////////////////
 
 /**
index 3e8a75d7b24d67923982df6be35cadccba9f094a..3414be1403dac4e9bb11e2009d672b13da3eec83 100644 (file)
@@ -7,9 +7,5 @@
  * @subpackage API
  * @author Curverider Ltd <info@elgg.com>
  * @link http://elgg.org/
+ * @todo deprecate this file?
  */
-
-require_once dirname(dirname(__FILE__)).'/classes/ElggCache.php';
-require_once dirname(dirname(__FILE__)).'/classes/ElggSharedMemoryCache.php';
-require_once dirname(dirname(__FILE__)).'/classes/ElggStaticVariableCache.php';
-require_once dirname(dirname(__FILE__)).'/classes/ElggFileCache.php';
index 5e4584515a614b82da01de9b3a5d46204fed5e43..115defa0163855997d936b54a8cd2648668d1a06 100644 (file)
@@ -8,8 +8,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/Notable.php';
-
 /**
  * Return a timestamp for the start of a given day (defaults today).
  *
index 408a5c51fa937cd5d0f5af5e2636a5d43e70b5af..7dc2ff3bd2e07c962e1ced6b9da9bbe090283335 100644 (file)
@@ -8,8 +8,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/CronException.php';
-
 /**
  * Initialisation
  *
index ae65094548872892d7a7b402443bd48f2b5c67ab..7ddb91600b18f52b8643215fffe74aa363f7b0bb 100644 (file)
@@ -1919,8 +1919,6 @@ function is_ip_in_array(array $networks, $ip) {
        return false;
 }
 
-require_once dirname(dirname(__FILE__)).'/classes/Friendable.php';
-
 /**
  * Builds a URL from the a parts array like one returned by {@link parse_url()}.
  *
@@ -2268,6 +2266,10 @@ function js_page_handler($page) {
        }
 }
 
+function __autoload($class) {
+    require_once dirname(dirname(__FILE__))."/classes/$class.php";
+}
+
 /**
  * Emits a shutdown:system event upon PHP shutdown, but before database connections are dropped.
  *
index f2ff5108cec677fc09e6d396591030011de3d385..c7592325034be174c735e7010ed464f4ab38b2a3 100644 (file)
@@ -15,12 +15,6 @@ $ENTITY_CACHE = NULL;
 /// Cache subtype searches
 $SUBTYPE_CACHE = NULL;
 
-/// Require the locatable interface
-// @todo Move this into start.php?
-require_once('location.php');
-
-require_once dirname(dirname(__FILE__)).'/classes/ElggEntity.php';
-
 /**
  * Initialise the entity cache.
  */
index ccf0170620072eae204f2562bea4b45e0ca283a6..740ff885b606f01e5ee2b7ff9553a08abee14bb2 100644 (file)
@@ -9,153 +9,3 @@
  * @link http://elgg.org/
  */
 
-// Top level //////////////////////////////////////////////////////////////////////////////
-
-/**
- * IOException
- * An IO Exception, throw when an IO Exception occurs. Subclass for specific IO Exceptions.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class IOException extends Exception {}
-
-/**
- * ClassException
- * A class Exception, throw when there is a class error.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class ClassException extends Exception {}
-
-/**
- * ConfigurationException
- * There is a configuration error
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class ConfigurationException extends Exception {}
-
-/**
- * SecurityException
- * An Security Exception, throw when a Security Exception occurs. Subclass for specific Security Execeptions (access problems etc)
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class SecurityException extends Exception {}
-
-/**
- * ClassNotFoundException
- * An database exception, throw when a database exception happens, subclass if more detail is needed.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class DatabaseException extends Exception {}
-
-/**
- * APIException
- * The API Exception class, thrown by the API layer when an API call has an issue.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class APIException extends Exception {}
-
-/**
- * CallException
- * An exception thrown when there is a problem calling something.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class CallException extends Exception {}
-
-/**
- * Data format exception
- * An exception thrown when there is a problem in the format of some data.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class DataFormatException extends Exception {}
-
-// Class exceptions ///////////////////////////////////////////////////////////////////////
-
-/**
- * InvalidClassException
- * An invalid class Exception, throw when a class is invalid.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class InvalidClassException extends ClassException {}
-
-/**
- * ClassNotFoundException
- * An Class not found Exception, throw when an class can not be found occurs.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class ClassNotFoundException extends ClassException {}
-
-// Configuration exceptions ///////////////////////////////////////////////////////////////
-
-/**
- * InstallationException
- * Thrown when there is a major problem with the installation.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class InstallationException extends ConfigurationException {}
-
-// Call exceptions ////////////////////////////////////////////////////////////////////////
-
-/**
- * NotImplementedException
- * Thrown when a method or function has not been implemented, primarily used in development... you should
- * not see these!
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class NotImplementedException extends CallException {}
-
-/**
- * InvalidParameterException
- * A parameter is invalid.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class InvalidParameterException extends CallException {}
-
-// Installation exception /////////////////////////////////////////////////////////////////
-
-/**
- * RegistrationException
- * Could not register a new user for whatever reason.
- *
- * @author Curverider Ltd <info@elgg.com>
- * @package Elgg
- * @subpackage Exceptions
- */
-class RegistrationException extends InstallationException {}
\ No newline at end of file
index 9fbd62a4d1d4729fbb0d89006d36cfe9915ac7cf..5e97feceadb73e3ba8027b9f3ba57e2be2db5dca 100644 (file)
@@ -8,11 +8,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/Exportable.php';
-require_once dirname(dirname(__FILE__)).'/classes/Importable.php';
-require_once dirname(dirname(__FILE__)).'/classes/ExportException.php';
-require_once dirname(dirname(__FILE__)).'/classes/ImportException.php';
-
 /**
  * Get a UUID from a given object.
  *
index e222c29268a33ad04e96ffb4fe5f70ade5efad7c..b36eefe04864aebc9767a1cbf4a843e9ccdf0546 100644 (file)
@@ -9,8 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggExtender.php';
-
 /**
  * Detect the value_type for a given value.
  * Currently this is very crude.
index 74a8b0315aa38d9adf99127ba259ae8d7fafd38a..a7f3957043dfa9390034455600be0aa136b05a4d 100644 (file)
  * @link http://elgg.org/
  */
 
-include_once("objects.php");
-
-require_once dirname(dirname(__FILE__)).'/classes/ElggFilestore.php';
-require_once dirname(dirname(__FILE__)).'/classes/ElggDiskFilestore.php';
-require_once dirname(dirname(__FILE__)).'/classes/ElggFile.php';
-
 /**
  * Get the size of the specified directory.
  *
index 22badc4b9c9d87125de72c1c63257daecd7bbc92..d103026bfb8da328a73e268b69f1b4047d911e56 100644 (file)
@@ -12,8 +12,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggGroup.php';
-
 /**
  * Get the group entity.
  *
index 7e650c8de27b809a12e1249b33a05600ea5dd987..17a330851bbfe1673d0b85534525fec43a502141 100644 (file)
@@ -250,7 +250,6 @@ function input_livesearch_page_handler($page) {
        exit;
 }
 
-
 function input_init() {
        // register an endpoint for live search / autocomplete.
        register_page_handler('livesearch', 'input_livesearch_page_handler');
index 42df3e17faa702b6c0032b7ed8b7329290974b8b..f1ad74b23287afa648b075bd6c365609ca780b4f 100644 (file)
@@ -67,7 +67,6 @@ function db_check_settings($user, $password, $dbname, $host) {
        return $result;
 }
 
-
 /**
  * Returns whether or not the database has been installed
  *
index a424ece25ee2a4b7ba94d1613f523c81cac8f6fe..d0b3d63390f4ead46fdc1262fc31fb68cb5d7734 100644 (file)
@@ -8,8 +8,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/Locatable.php';
-
 /**
  * Encode a location into a latitude and longitude, caching the result.
  *
index de1c001b58bd9a20cc05b8c464c282a6753f8478..d20e04625d68af72f1fb4acf5c9ed5be78c3baf8 100644 (file)
@@ -10,8 +10,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggMemcache.php';
-
 /**
  * Return true if memcache is available and configured.
  *
index 9ab32912a0656334ed5528e5550112d7ef459f80..b0a2a1e53b14ea3ce6928031630332f98e29997e 100644 (file)
@@ -9,10 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once 'extender.php';
-
-require_once dirname(dirname(__FILE__)).'/classes/ElggMetadata.php';
-
 /**
  * Convert a database row to a new ElggMetadata
  *
index 475a590ec4ca3662916f7d0612acfa64986e6ecd..1bf6c3e7976dc4af20366df4a68c3049eec5c86d 100644 (file)
@@ -212,13 +212,6 @@ function set_user_notification_setting($user_guid, $method, $value) {
        return false;
 }
 
-/**
- * Notification exception.
- * @author Curverider Ltd
- */
-class NotificationException extends Exception {}
-
-
 /**
  * Send a notification via email.
  *
index 1c7f1640ccaeaf8e169839a3170ead2432177031..21fcf4cf734fd586812af167832bb3205fc19cfc 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Elgg objects
  * Functions to manage multiple or single objects in an Elgg install
@@ -10,8 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggObject.php';
-
 /**
  * Return the object specific details of a object by a row.
  *
index dae6bc9d0fe637ad52fb3ea6abda12756602b555..ae382881f652503b791f1fdeaee0266f1cbf3b8d 100644 (file)
@@ -9,12 +9,6 @@
  * @link http://elgg.org/
  */
 
-include_once("xml.php");
-
-require_once dirname(dirname(__FILE__)).'/classes/ODDDocument.php';
-require_once dirname(dirname(__FILE__)).'/classes/ODD.php';
-require_once dirname(dirname(__FILE__)).'/classes/ODDEntity.php';
-
 /**
  * Attempt to construct an ODD object out of a XmlElement or sub-elements.
  *
index e89e6007a83ae28cae63011b2dee24bd45b8eebd..a36f2bf6dfdd2bdd531173c3f35a638e9951a79f 100644 (file)
@@ -9,22 +9,9 @@
  * @link http://elgg.org/
  */
 
-
 /// Cache enabled plugins per page
 $ENABLED_PLUGINS_CACHE = NULL;
 
-/**
- * PluginException
- *
- * A plugin Exception, thrown when an Exception occurs relating to the plugin mechanism. Subclass for specific plugin Exceptions.
- *
- * @package Elgg
- * @subpackage Exceptions
- */
-class PluginException extends Exception {}
-
-require_once dirname(dirname(__FILE__)).'/classes/ElggPlugin.php';
-
 /**
  * Returns a list of plugins to load, in the order that they should be loaded.
  *
index bdb28559fbde29c809ac8dd12d0d3ad9d085ae5d..d03d4333975f536c617c00cd5195bd511e1e7a69 100644 (file)
 <?php
-       /**
-        * Elgg database query
-        * Contains a wrapper for performing database queries in a structured way.
-        *
-        * @package Elgg
-        * @subpackage Core
-        * @author Curverider Ltd
-        * @link http://elgg.org/
-        */
-
-
-       /**
-        * @class QueryComponent Query component superclass.
-        * Component of a query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       abstract class QueryComponent
-       {
-               /**
-                * Associative array of fields and values
-                */
-               private $fields;
-
-               function __construct()
-               {
-                       $this->fields = array();
-               }
-
-               /**
-                * Class member get overloading
-                *
-                * @param string $name
-                * @return mixed
-                */
-               function __get($name) {
-                       return $this->fields[$name];
-               }
-
-               /**
-                * Class member set overloading
-                *
-                * @param string $name
-                * @param mixed $value
-                * @return void
-                */
-               function __set($name, $value) {
-                       $this->fields[$name] = $value;
-
-                       return true;
-               }
-       }
-
-       /**
-        * @class SelectFieldQueryComponent Class representing a select field.
-        * This class represents a select field component.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class SelectFieldQueryComponent extends QueryComponent
-       {
-               /**
-                * Construct a select field component
-                *
-                * @param string $table The table containing the field.
-                * @param string $field The field or "*"
-                */
-               function __construct($table, $field)
-               {
-                       global $CONFIG;
-
-                       $this->table = $CONFIG->dbprefix . sanitise_string($table);
-                       $this->field = sanitise_string($field);
-               }
-
-               function __toString()
-               {
-                       return "{$this->table}.{$this->field}";
-               }
-       }
-
-       /**
-        * @class LimitOffsetQueryComponent
-        * Limit and offset clauses of a query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class LimitOffsetQueryComponent extends QueryComponent
-       {
-               /**
-                * Specify a limit and an offset.
-                *
-                * @param int $limit The limit.
-                * @param int $offset The offset.
-                */
-               function __construct($limit = 25, $offset = 0)
-               {
-                       $this->limit = (int)$limit;
-                       $this->offset = (int)$offset;
-               }
-
-               function __toString()
-               {
-                       return "limit {$this->offset}, {$this->limit}";
-               }
-       }
-
-       /**
-        * @class OrderQueryComponent
-        * Order the query results.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class OrderQueryComponent extends QueryComponent
-       {
-               function __construct($table, $field, $order = "asc")
-               {
-                       global $CONFIG;
-
-                       $this->table = $CONFIG->dbprefix . sanitise_string($table);
-                       $this->field = sanitise_string($field);
-                       $this->order = sanitise_string($order);
-               }
-
-               function __toString()
-               {
-                       return "order by {$this->table}.{$this->field} {$this->order}";
-               }
-       }
-
-       /**
-        * @class TableQueryComponent
-        * List of tables to select from or insert into.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class TableQueryComponent extends QueryComponent
-       {
-               function __construct($table)
-               {
-                       global $CONFIG;
-
-                       $this->table = $CONFIG->dbprefix . sanitise_string($table);
-               }
-
-               function __toString()
-               {
-                       return $this->table;
-               }
-       }
-
-       /**
-        * @class AccessControlQueryComponent
-        * Access control component.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class AccessControlQueryComponent extends QueryComponent
-       {
-               /**
-                * Construct the ACL.
-                *
-                * @param string $acl_table The table where the access control field is.
-                * @param string $acl_field The field containing the access control.
-                * @param string $object_owner_table The table containing the owner information for the stuff you're retrieving.
-                * @param string $object_owner_id_field The field in $object_owner_table containing the owner information
-                */
-               function __construct($acl_table = "entities", $acl_field = "access_id", $object_owner_table = "entities", $object_owner_id_field = "owner_guid")
-               {
-                       global $CONFIG;
-
-                       $this->acl_table = $CONFIG->dbprefix . sanitise_string($acl_table);
-                       $this->acl_field = sanitise_string($acl_field);
-                       $this->object_owner_table = $CONFIG->dbprefix . sanitise_string($object_owner_table);
-                       $this->object_owner_id_field = sanitise_string($object_owner_id_field);
-               }
-
-               function __toString()
-               {
-                       //$access = get_access_list();
-                       // KJ - changed to use get_access_sql_suffix
-                       // Note: currently get_access_sql_suffix is hardwired to use
-                       // $acl_field = "access_id", $object_owner_table = $acl_table, and
-                       // $object_owner_id_field = "owner_guid"
-                       // @todo recode get_access_sql_suffix to make it possible to specify alternate field names
-                       return "and ".get_access_sql_suffix($this->acl_table); // Add access controls
-
-                       //return "and ({$this->acl_table}.{$this->acl_field} in {$access} or ({$this->acl_table}.{$this->acl_field} = 0 and {$this->object_owner_table}.{$this->object_owner_id_field} = {$_SESSION['id']}))";
-               }
-       }
-
-       /**
-        * @class JoinQueryComponent Join query.
-        * Represents a join query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class JoinQueryComponent extends QueryComponent
-       {
-               /**
-                * Construct a join query.
-                * @param string $table Table one to join...
-                * @param string $field Field 1 with...
-                * @param string $table2 Table 2 ...
-                * @param string $field2 Field...
-                * @param string $operator Using this operator
-                */
-               function __construct($table1, $field1, $table2, $field2, $operator = "=")
-               {
-                       global $CONFIG;
-
-                       $this->table1 = $CONFIG->dbprefix . sanitise_string($table1);
-                       $this->field1 = sanitise_string($field1);
-                       $this->table2 = $CONFIG->dbprefix . sanitise_string($table2);
-                       $this->field2 = sanitise_string($field2);
-                       $this->operator = sanitise_string($operator);
-               }
-
-               function __toString()
-               {
-                       return "join {$this->table2} on {$this->$table}.{$this->$field} {$this->$operator} {$this->$table2}.{$this->$field2}";
-               }
-       }
-
-       /**
-        * @class SetQueryComponent Set query.
-        * Represents an update set query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class SetQueryComponent extends QueryComponent
-       {
-               /**
-                * Construct a setting query
-                *
-                * @param string $table The table to modify
-                * @param string $field The field to modify
-                * @param mixed $value The value to set it to
-                */
-               function __construct($table, $field, $value)
-               {
-                       global $CONFIG;
-
-                       $this->table = $CONFIG->dbprefix . sanitise_string($table);
-                       $this->field = sanitise_string($field);
-                       if (is_numeric($value))
-                               $this->value = (int)$value;
-                       else
-                               $this->value = "'".sanitise_string($value)."'";
-               }
-
-               function __toString()
-               {
-                       return "{$this->table}.{$this->field}={$this->value}";
-               }
-       }
-
-       /**
-        * @class WhereQueryComponent
-        * A component of a where query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class WhereQueryComponent extends QueryComponent
-       {
-               /**
-                * A where query.
-                *
-                * @param string $left_table The table on the left of the operator
-                * @param string $left_field The left field
-                * @param string $operator The operator eg "=" or "<"
-                * @param string $right_table The table on the right of the operator
-                * @param string $right_field The right field
-                * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
-                */
-               function __construct($left_table, $left_field, $operator, $right_table, $right_field, $link_operator = "and")
-               {
-                       global $CONFIG;
-
-                       $this->link_operator = sanitise_string($link_operator);
-                       $this->left_table = $CONFIG->dbprefix . sanitise_string($left_table);
-                       $this->left_field = sanitise_string($left_field);
-                       $this->operator = sanitise_string($operator);
-                       $this->right_table = $CONFIG->dbprefix . sanitise_string($right_table);
-                       $this->right_field = sanitise_string($right_field);
-               }
-
-               /**
-                * Return the SQL without the link operator.
-                */
-               public function toStringNoLink()
-               {
-                       return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->right_table}.{$this->right_field}";
-               }
-
-               function __toString()
-               {
-                       return "{$this->link_operator} " . $this->toStringNoLink();
-               }
-       }
-
-       /**
-        * @class WhereStaticQueryComponent
-        * A component of a where query where there is no right hand table, rather a static value.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class WhereStaticQueryComponent extends WhereQueryComponent
-       {
-               /**
-                * A where query.
-                *
-                * @param string $left_table The table on the left of the operator
-                * @param string $left_field The left field
-                * @param string $operator The operator eg "=" or "<"
-                * @param string $value The value
-                * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
-                */
-               function __construct($left_table, $left_field, $operator, $value, $link_operator = "and")
-               {
-                       global $CONFIG;
-
-                       $this->link_operator = sanitise_string($link_operator);
-                       $this->left_table = $CONFIG->dbprefix . sanitise_string($left_table);
-                       $this->left_field = sanitise_string($left_field);
-                       $this->operator = sanitise_string($operator);
-                       if (is_numeric($value))
-                               $this->value = (int)$value;
-                       else
-                               $this->value = "'".sanitise_string($value)."'";
-               }
-
-               /**
-                * Return the SQL without the link operator.
-                */
-               public function toStringNoLink()
-               {
-                       return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->value}";
-               }
-       }
-
-       /**
-        * @class WhereSetQueryComponent
-        * A where query that may contain other where queries (in brackets).
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class WhereSetQueryComponent extends WhereQueryComponent
-       {
-               /**
-                * Construct a subset of wheres.
-                *
-                * @param array $wheres An array of WhereQueryComponent
-                * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
-                */
-               function __construct(array $wheres, $link_operator = "and")
-               {
-                       $this->link_operator = sanitise_string($link_operator);
-                       $this->wheres = $wheres;
-               }
-
-               public function toStringNoLink()
-               {
-                       $cnt = 0;
-                       $string = " (";
-                       foreach ($this->wheres as $where) {
-                               if (!($where instanceof WhereQueryComponent))
-                                       throw new DatabaseException(elgg_echo('DatabaseException:WhereSetNonQuery'));
-
-                               if (!$cnt)
-                                       $string.= $where->toStringNoLink();
-                               else
-                                       $string.=" $where ";
-
-                               $cnt ++;
-                       }
-                       $string .= ")";
-
-                       return $string;
-               }
-       }
-
-       /**
-        * @class QueryTypeQueryComponent
-        * What type of query is this?
-        * @author Curverider Ltd
-        * @see Query
-        */
-       abstract class QueryTypeQueryComponent extends QueryComponent
-       {
-               function __toString()
-               {
-                       return $this->query_type;
-               }
-       }
-
-       /**
-        * @class SelectQueryTypeQueryComponent
-        * A select query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class SelectQueryTypeQueryComponent extends QueryTypeQueryComponent
-       {
-               function __construct()
-               {
-                       $this->query_type = "SELECT";
-               }
-       }
-
-       /**
-        * @class InsertQueryTypeQueryComponent
-        * An insert query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class InsertQueryTypeQueryComponent extends QueryTypeQueryComponent
-       {
-               function __construct()
-               {
-                       $this->query_type = "INSERT INTO";
-               }
-       }
-
-       /**
-        * @class DeleteQueryTypeQueryComponent
-        * A delete query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class DeleteQueryTypeQueryComponent extends QueryTypeQueryComponent
-       {
-               function __construct()
-               {
-                       $this->query_type = "DELETE FROM";
-               }
-       }
-
-       /**
-        * @class UpdateQueryTypeQueryComponent
-        * An update query.
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class UpdateQueryTypeQueryComponent extends QueryTypeQueryComponent
-       {
-               function __construct()
-               {
-                       $this->query_type = "UPDATE";
-               }
-       }
-
-       /**
-        * @class Query Provides a framework to construct complex queries in a safer environment.
-        *
-        * The usage of this class depends on the type of query you are executing, but the basic idea is to
-        * construct a query out of pluggable classes.
-        *
-        * Once constructed SQL can be generated using the toString method, this should happen automatically
-        * if you pass the Query object to get_data or similar.
-        *
-        * To construct a query, create a new Query() object and begin populating it with the various classes
-        * that define the various aspects of the query.
-        *
-        * Notes:
-        *      - You do not have to specify things in any particular order, provided you specify all required
-        *        components.
-        *  - With database tables you do not have to specify your db prefix, this will be added automatically.
-        *  - When constructing your query keep an eye on the error log - any problems will get spit out here.
-        *        Note also that __toString won't let you throw Exceptions (!!!) so these are caught and echoed to
-        *    the log instead.
-        *
-        * Here is an example of a select query which requests some data out of the entities table with an
-        * order and limit that uses a subset where and some normal where queries:
-        *
-        * <blockquote>
-        *              // Construct the query
-        *              $query = new Query();
-        *
-        *              // Say which table we're interested in
-        *              $query->addTable(new TableQueryComponent("entities"));
-        *
-        *              // What fields are we interested in
-        *              $query->addSelectField(new SelectFieldQueryComponent("entities","*"));
-        *
-        *              // Add access control (Default access control uses default fields on entities table.
-        *              // Note that it will error without something specified here!
-        *              $query->setAccessControl(new AccessControlQueryComponent());
-        *
-        *              // Set a limit and offset, may be omitted.
-        *              $query->setLimitAndOffset(new LimitOffsetQueryComponent(10,0));
-        *
-        *              // Specify the order, may be omitted
-        *              $query->setOrder(new OrderQueryComponent("entities", "subtype", "desc"));
-        *
-        *              // Construct a where query
-        *              //
-        *              // This demonstrates a WhereSet which lets you have sub wheres, a
-        *              // WhereStatic which lets you compare a table field against a value and a
-        *              // Where which lets you compare a table/field with another table/field.
-        *              $query->addWhere(
-        *                      new WhereSetQueryComponent(
-        *                              array(
-        *                                      new WhereStaticQueryComponent("entities", "subtype","=", 1),
-        *                                      new WhereQueryComponent("entities","subtype","=", "entities", "subtype")
-        *                              )
-        *                      )
-        *              );
-        *
-        *              get_data($query);
-        * </blockquote>
-        *
-        * @author Curverider Ltd
-        */
-       class Query
-       {
-
-               /// The limit of the query
-               private $limit_and_offset;
-
-               /// Fields to return on a query
-               private $fields;
-
-               /// Tables to use in a from query
-               private $tables;
-
-               /// Join tables
-               private $joins;
-
-               /// Set values
-               private $sets;
-
-               /// Where query
-               private $where;
-
-               /// Order by
-               private $order;
-
-               /// The query type
-               private $query_type;
-
-               /// ACL
-               private $access_control;
-
-               /**
-                * Construct query & initialise variables
-                */
-               function __construct()
-               {
-                       $this->fields = array();
-                       $this->tables = array();
-                       $this->joins = array();
-                       $this->where = array();
-                       $this->sets = array();
-
-                       $this->setQueryType(new SelectQueryTypeQueryComponent());
-               }
-
-               /**
-                * Add limits and offsets to the query.
-                *
-                * @param LimitOffsetQueryComponent $component The limit and offset.
-                */
-               public function setLimitAndOffset(LimitOffsetQueryComponent $component) { $this->limit_and_offset = $component; }
-
-               /**
-                * Reset and set the field to the select statement.
-                *
-                * @param SelectFieldQueryComponent $component Table and field component.
-                */
-               public function setSelectField(SelectFieldQueryComponent $component)
-               {
-                       $this->fields = array();
-                       return $this->addSelectField($component);
-               }
-
-               /**
-                * Add a select field.
-                *
-                * @param SelectFieldQueryComponent $component Add a component.
-                */
-               public function addSelectField(SelectFieldQueryComponent $component) { $this->fields[] = $component; }
-
-               /**
-                * Add a join to the component.
-                *
-                * @param JoinQueryComponent $component The join.
-                */
-               public function addJoin(JoinQueryComponent $component) { $this->joins[] = $component; }
-
-               /**
-                * Set a field value in an update or insert statement.
-                *
-                * @param SetQueryComponent $component Fields to set.
-                */
-               public function addSet(SetQueryComponent $component) { $this->sets[] = $component; }
-
-               /**
-                * Set the query type, i.e. "select", "update", "insert" & "delete".
-                *
-                * @param QueryTypeQueryComponent $component The query type.
-                */
-               public function setQueryType(QueryTypeQueryComponent $component) { $this->query_type = $component; }
-
-               /**
-                * Attach an order component.
-                *
-                * @param OrderQueryComponent $component The order component.
-                */
-               public function setOrder(OrderQueryComponent $component) { $this->order = $component; }
-
-               /**
-                * Add a table to the query.
-                *
-                * @param TableQueryComponent $component Table to add.
-                */
-               public function addTable(TableQueryComponent $component) { $this->tables[] = $component; }
-
-               /**
-                * Add a where clause to the query.
-                *
-                * @param WhereQueryComponent $component The where component
-                */
-               public function addWhere(WhereQueryComponent $component) { $this->where[] = $component; }
-
-               /**
-                * Set access control.
-                *
-                * @param AccessControlQueryComponent $component Access control.
-                */
-               public function setAccessControl(AccessControlQueryComponent $component) { $this->access_control = $component; }
-
-               public function __toString()
-               {
-                       global $CONFIG;
-
-                       $sql = "";
-
-                       try
-                       {
-                               // Query prefix & fields
-                               if (!empty($this->query_type))
-                               {
-                                       $sql .= "{$this->query_type} ";
-
-                                       if (!empty($this->fields))
-                                       {
-                                               $fields = "";
-
-                                               foreach ($this->fields as $field)
-                                                       $fields .= "$field";
-
-                                               $sql .= " $fields from ";
-                                       }
-                                       else
-                                               throw new DatabaseException(elgg_echo('DatabaseException:SelectFieldsMissing'));
-                               }
-                               else
-                                       throw new DatabaseException(elgg_echo('DatabaseException:UnspecifiedQueryType'));
-
-                               // Tables
-                               if (!empty($this->tables))
-                               {
-                                       foreach($this->tables as $table)
-                                               $sql .= "$table, ";
-
-                                       $sql = trim($sql, ", ");
-                               }
-                               else
-                                       throw new DatabaseException(elgg_echo('DatabaseException:NoTablesSpecified'));
-
-                               // Joins on select queries
-                               if ($this->query_type->query_type == 'select')
-                               {
-                                       if (!empty($this->joins))
-                                       {
-                                               foreach($this->joins as $join)
-                                                       $sql .= "$join ";
-                                       }
-                               }
-
-                               // Setting values
-                               if (
-                                       ($this->query_type->query_type == 'update') ||
-                                       ($this->query_type->query_type == 'insert')
-                               )
-                               {
-                                       $sql .= "set ";
-
-                                       foreach ($this->sets as $set)
-                                               $sql .= "$set, ";
-
-                                       $sql = trim($sql, ", ") . " ";
-                               }
-
-                               // Where
-                               if (!empty($this->where))
-                               {
-                                       $sql .= " where 1 ";
-
-                                       foreach ($this->where as $where)
-                                               $sql .= "$where ";
-                               }
-
-                               // Access control
-                               if (!empty($this->access_control))
-                               {
-
-                                       // Catch missing Where
-                                       if (empty($this->where))
-                                               $sql .= " where 1 ";
-
-                                       $sql .= "{$this->access_control} ";
-                               }
-                               else
-                                       throw new DatabaseException(elgg_echo('DatabaseException:NoACL'));
-
-                               // Order by
-                               if (!empty($this->order))
-                                       $sql .= "{$this->order} ";
-
-                               // Limits
-                               if (!empty($this->limit_and_offset))
-                                       $sql .= "{$this->limit_and_offset} ";
-
-
-
-                       } catch (Exception $e) {
-                               trigger_error($e, E_USER_WARNING);
-                       }
-
-
-                       return $sql;
-               }
-
-       }
-
-       /**
-        * @class SimpleQuery A wrapper for Query which provides simple interface for common functions.
-        *
-        * This class provides simple interface functions for constructing a (reasonably) standard database
-        * query.
-        *
-        * The constructor for this class sets a number of defaults, for example sets default access controls
-        * and a limit and offset - to change this then set it manually.
-        *
-        * @author Curverider Ltd
-        * @see Query
-        */
-       class SimpleQuery extends Query
-       {
-               function __construct()
-               {
-                       parent::__construct();
-
-                       // Set a default query type (select)
-                       $this->simpleQueryType();
-
-                       // Set a default access control
-                       $this->simpleAccessControl();
-
-                       // Set default limit and offset
-                       $this->simpleLimitAndOffset();
-               }
-
-               /**
-                * Set the query type.
-                *
-                * @param string $type The type of search - available are "select", "update", "delete", "insert".
-                */
-               public function simpleQueryType($type = "select")
-               {
-                       $type = strtolower(sanitise_string($type));
-
-                       switch ($type)
-                       {
-                               case "insert" :
-                                       return $this->setQueryType(InsertQueryTypeQueryComponent());
-                               break;
-                               case "delete" :
-                                       return $this->setQueryType(DeleteQueryTypeQueryComponent());
-                               break;
-                               case "update" :
-                                       return $this->setQueryType(UpdateQueryTypeQueryComponent());
-                               break;
-                               default: return $this->setQueryType(SelectQueryTypeQueryComponent());
-                       }
-               }
-
-               /**
-                * Set a field to query in a select statement.
-                *
-                * @param string $table Table to query.
-                * @param string $field Field in that table.
-                */
-               public function simpleSelectField($table, $field) { return $this->setSelectField(new SelectFieldQueryComponent($table, $field)); }
-
-               /**
-                * Add a select field to query in a select statement.
-                *
-                * @param string $table Table to query.
-                * @param string $field Field in that table.
-                */
-               public function simpleAddSelectField($table, $field) { return $this->addSelectField(new SelectFieldQueryComponent($table, $field)); }
-
-               /**
-                * Add a set value to an update query.
-                *
-                * @param string $table The table to update.
-                * @param string $field The field in the table.
-                * @param mixed $value The value to set it to.
-                */
-               public function simpleSet($table, $field, $value) { return $this->addSet(new SetQueryComponent($table, $field, $value)); }
-
-               /**
-                * Add a join to the table.
-                *
-                * @param string $table Table one to join...
-                * @param string $field Field 1 with...
-                * @param string $table2 Table 2 ...
-                * @param string $field2 Field...
-                * @param string $operator Using this operator
-                */
-               public function simpleJoin($table1, $field1, $table2, $field2, $operator = "=") { return $this->addJoin(new JoinQueryComponent($table1, $field1, $table2, $field2, $operator)); }
-
-               /**
-                * Add a table to the query.
-                *
-                * @param string $table The table.
-                */
-               public function simpleTable($table) { return $this->addTable(new TableQueryComponent($table)); }
-
-               /**
-                * Compare one table/field to another table/field.
-                *
-                * @param string $left_table The table on the left of the operator
-                * @param string $left_field The left field
-                * @param string $operator The operator eg "=" or "<"
-                * @param string $right_table The table on the right of the operator
-                * @param string $right_field The right field
-                * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
-                */
-               public function simpleWhereOnTable($left_table, $left_field, $operator, $right_table, $right_field, $link_operator = "and") { return $this->addWhere(new WhereQueryComponent($left_table, $left_field, $operator, $right_table, $right_field, $link_operator)); }
-
-               /**
-                * Compare one table/field to a value.
-                *
-                * @param string $left_table The table on the left of the operator
-                * @param string $left_field The left field
-                * @param string $operator The operator eg "=" or "<"
-                * @param string $value The value
-                * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
-                */
-               public function simpleWhereOnValue($left_table, $left_field, $operator, $value, $link_operator = "and") { return $this->addWhere(new WhereStaticQueryComponent($left_table, $left_field, $operator, $value, $link_operator)); }
-
-               /**
-                * Set access control.
-                *
-                * @param string $acl_table The table where the access control field is.
-                * @param string $acl_field The field containing the access control.
-                * @param string $object_owner_id_field The field in $object_owner_table containing the owner information.
-                */
-               public function simpleAccessControl($acl_table = "entities", $acl_field = "access_id", $object_owner_id_field = "owner_guid") { return $this->setAccessControl(new AccessControlQueryComponent($acl_table, $acl_field, $acl_table, $object_owner_id_field)); }
-
-               /**
-                * Set the limit and offset.
-                *
-                * @param int $limit The limit.
-                * @param int $offset The offset.
-                */
-               public function simpleLimitAndOffset($limit = 25, $offset = 0) { return $this->setLimitAndOffset(new LimitOffsetQueryComponent($limit, $offset)); }
-
-               /**
-                * Set the order query.
-                *
-                * @param string $table The table to query
-                * @param string $field The field to query
-                * @param string $order Order the query
-                */
-               public function simpleOrder($table, $field, $order = "desc")
-               {
-                       $table = sanitise_string($table);
-                       $field = sanitise_string($field);
-                       $order = strtolower(sanitise_string($order));
-
-                       return $this->setOrder(new OrderQueryComponent($table, $field, $order)); break;
-               }
-       }
+/**
+ * Elgg database query
+ * Contains a wrapper for performing database queries in a structured way.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ * @todo deprecate this file?
+ */
\ No newline at end of file
index 81d18d1ca7faffd18f7969f82141481a06101789..7096ba8824369b1ff6dfb2ecca03426cd524a1ec 100644 (file)
@@ -9,8 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggRelationship.php';
-
 /**
  * Convert a database row to a new ElggRelationship
  *
index 09799aa5960beae2e7dbb995844529839453ee5d..15ad69c4b1254e012f6eee113a93b59a4496bd2b 100644 (file)
@@ -135,7 +135,6 @@ function remove_from_river_by_id($id) {
        return delete_data("delete from {$CONFIG->dbprefix}river where id = {$id}");
 }
 
-
 /**
  * Sets the access ID on river items for a particular object
  *
index f2a5342948ddd66789ad91ed958d4fb1e984f33e..3af571f5c18747ab2350279d953601e302ef1ebd 100644 (file)
@@ -13,9 +13,6 @@
 /** Elgg magic session */
 global $SESSION;
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggSession.php';
-
-
 /**
  * Return the current logged in user, or NULL if no user is logged in.
  *
index ee556e86cb70e3826a01156beb056a990a358f11..98f29952a008c6e6a89b2e46c729ef0f95ee4c0c 100644 (file)
@@ -9,8 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggSite.php';
-
 /**
  * Return the site specific details of a site by a row.
  *
index 9a94fb94e2b43b783cb3444340eccb600750db52..257f6e064674266773b30bd44d22c6526052d351 100644 (file)
@@ -9,8 +9,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/Loggable.php';
-
 /**
  * Retrieve the system log based on a number of parameters.
  *
index e7344493075c0399b786c7e3480d148930d943e2..bb3b0e6870ca2bbde13411b8eec6634a3686b4d8 100644 (file)
@@ -9,7 +9,6 @@
  * @link http://elgg.org/
  */
 
-
 /**
  * The algorithm working out the size of font based on the number of tags.
  * This is quick and dirty.
index 03d0d06c4d88cbb5f2d985e61b1932e51153dc84..2818336257190e74cca08ea8f514a8be180f7bd9 100644 (file)
@@ -15,8 +15,6 @@ $USERNAME_TO_GUID_MAP_CACHE = array();
 /// Map a user code to a cached GUID
 $CODE_TO_GUID_MAP_CACHE = array();
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggUser.php';
-
 /**
  * Return the user specific details of a user by a row.
  *
index 210aa198fcd5895de270a3e4f647eb86f0bcfc2a..d8c0984b8bfd23a6e247ebcb0c8b3186226a11ba 100644 (file)
@@ -8,8 +8,6 @@
  * @link http://elgg.org/
  */
 
-require_once dirname(dirname(__FILE__)).'/classes/ElggWidget.php';
-
 /**
  * Register a particular context for use with widgets.
  *
index 79c3eba0789a02b304461790a173886a82632271..1c7f4ba38bbf0e1ef3400efff31f8eaf0b83afa9 100644 (file)
@@ -9,26 +9,6 @@
         * @link http://elgg.org/
         */
 
-       // XMLRPC Call ////////////////////////////////////////////////////////////////////////////
-
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCCall.php';
-
-       
-       // Response classes ///////////////////////////////////////////////////////////////////////
-
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCIntParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCBoolParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCStringParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCDoubleParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCDateParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCBase64Parameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCStructParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCArrayParameter.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCResponse.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCSuccessResponse.php';
-       require_once dirname(dirname(__FILE__)).'/classes/XMLRPCErrorResponse.php';
-       
        // Helper functions ///////////////////////////////////////////////////////////////////////
        
        /**
index f9c5985c9cae2f9be63b5cfc1ee5619451bfda36..f186dd4bfd75d591d06ca8cc2752009e2ee7f784 100644 (file)
@@ -9,8 +9,6 @@
         * @link http://elgg.org/
         */
 
-       require_once dirname(dirname(__FILE__)).'/classes/XmlElement.php';
-
        /**
         * This function serialises an object recursively into an XML representation.
         * The function attempts to call $data->export() which expects a stdClass in return, otherwise it will attempt to