aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggGroup.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes/ElggGroup.php')
-rw-r--r--engine/classes/ElggGroup.php30
1 files changed, 18 insertions, 12 deletions
diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php
index 0190e5eac..f7f67bf41 100644
--- a/engine/classes/ElggGroup.php
+++ b/engine/classes/ElggGroup.php
@@ -5,6 +5,9 @@
*
* @package Elgg.Core
* @subpackage Groups
+ *
+ * @property string $name A short name that captures the purpose of the group
+ * @property string $description A longer body of content that gives more details about the group
*/
class ElggGroup extends ElggEntity
implements Friendable {
@@ -26,12 +29,12 @@ class ElggGroup extends ElggEntity
}
/**
- * Construct a new user entity, optionally from a given id value.
+ * Construct a new group entity, optionally from a given guid value.
*
* @param mixed $guid If an int, load that GUID.
- * If a db row then will attempt to load the rest of the data.
+ * If an entity table db row, then will load the rest of the data.
*
- * @throws Exception if there was a problem creating the user.
+ * @throws Exception if there was a problem creating the group.
*/
function __construct($guid = null) {
$this->initializeAttributes();
@@ -40,15 +43,15 @@ class ElggGroup extends ElggEntity
$this->initialise_attributes(false);
if (!empty($guid)) {
- // Is $guid is a DB row - either a entity row, or a user table row.
+ // Is $guid is a entity table DB row
if ($guid instanceof stdClass) {
// Load the rest
- if (!$this->load($guid->guid)) {
+ if (!$this->load($guid)) {
$msg = elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid->guid));
throw new IOException($msg);
}
- // Is $guid is an ElggGroup? Use a copy constructor
+ // Is $guid is an ElggGroup? Use a copy constructor
} else if ($guid instanceof ElggGroup) {
elgg_deprecated_notice('This type of usage of the ElggGroup constructor was deprecated. Please use the clone method.', 1.7);
@@ -56,11 +59,11 @@ class ElggGroup extends ElggEntity
$this->attributes[$key] = $value;
}
- // Is this is an ElggEntity but not an ElggGroup = ERROR!
+ // Is this is an ElggEntity but not an ElggGroup = ERROR!
} else if ($guid instanceof ElggEntity) {
throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggGroup'));
- // We assume if we have got this far, $guid is an int
+ // Is it a GUID
} else if (is_numeric($guid)) {
if (!$this->load($guid)) {
throw new IOException(elgg_echo('IOException:FailedToLoadGUID', array(get_class(), $guid)));
@@ -316,11 +319,9 @@ class ElggGroup extends ElggEntity
}
/**
- * Override the load function.
- * This function will ensure that all data is loaded (were possible), so
- * if only part of the ElggGroup is loaded, it'll load the rest.
+ * Load the ElggGroup data from the database
*
- * @param int $guid GUID of an ElggGroup entity
+ * @param mixed $guid GUID of an ElggGroup entity or database row from entity table
*
* @return bool
*/
@@ -330,6 +331,11 @@ class ElggGroup extends ElggEntity
return false;
}
+ // Only work with GUID from here
+ if ($guid instanceof stdClass) {
+ $guid = $guid->guid;
+ }
+
// Check the type
if ($this->attributes['type'] != 'group') {
$msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class()));