aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-09 17:42:32 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-09 17:42:32 +0000
commitb00fd305e57b20ad7ec075a7b612013573597b28 (patch)
tree7809e10ccab9c3a86195053054c9c97fe1724b95 /engine/lib
parent1091d22f391a73fd080c387dfe5470124fcff616 (diff)
downloadelgg-b00fd305e57b20ad7ec075a7b612013573597b28.tar.gz
elgg-b00fd305e57b20ad7ec075a7b612013573597b28.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Fixed copy constructor git-svn-id: https://code.elgg.org/elgg/trunk@124 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/sites.php36
1 files changed, 24 insertions, 12 deletions
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index ff8235b34..e310c2c93 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -40,19 +40,30 @@
$site = null;
- if (is_int($id))
- $site = get_site($id); // This is an integer ID
- else if (is_string($id))
- $site = get_site_byurl($id); // Otherwise assume URL
- else if ($id instanceof stdClass)
- $site = $id; // This is a db row, so serialise directly
- else if ($id instanceof ElggSite)
- $site = $id;
- else
- throw new InvalidParameterException("Unrecognised or unsupported type passed to ElggSite constructor.");
+ if ($id instanceof stdClass) {
+ $site = $id; // This is a db row, so serialise directly
+
+ } else if ($id instanceof ElggSite) {
+ //$site = $id;
+ $site = new stdClass;
+ foreach ($id->attributes as $k => $v)
+ $site->$k = $v;
+
+ error_log("**** 2");
+ } else if (strpos($id, "http") !== false) {
+ $site = get_site_byurl($id);
+ error_log("**** 3");
+ } else {
+ $tmp = get_site((int)$id); // This is an integer ID
+ $site = new stdClass;
+ foreach ($tmp->attributes as $k => $v)
+ $site->$k = $v;
+
+ }
if ($site) {
$objarray = (array) $site;
+
foreach($objarray as $key => $value) {
$this->attributes[$key] = $value;
error_log("$key => $value");
@@ -293,7 +304,7 @@
$url = sanitise_string(trim($url));
$access = get_access_list();
- return row_to_elggsite(get_data_row("select o.* from {$CONFIG->dbprefix}sites where url='$url' and (o.access_id in {$access} or (o.access_id = 0 and o.owner_id = {$_SESSION['id']}))"));
+ return row_to_elggsite(get_data_row("select * from {$CONFIG->dbprefix}sites where url='$url' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"));
}
@@ -378,6 +389,7 @@
$access_id = (int)$access_id;
$site_id = (int)$site_id;
$vartype = sanitise_string($vartype);
+ $owner_id = $_SESSION['id'];
$id = create_metadata($site_id, 'site', $name, $value, $vartype, $owner_id, $access_id);
return $id;
@@ -450,7 +462,7 @@
$offset = (int)$offset;
$owner_id = (int)$owner_id; if ($owner_id==0) $owner_id = $_SESSION['id']; // Consider adding the option to change in param?
- return get_annotations($site_id, 'site', $owner_id, "created desc", $limit, $offset);
+ return get_annotations($site_id, 'site', "","", $owner_id, "created desc", $limit, $offset);
}
/**