aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-22 23:11:29 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-22 23:11:29 +0000
commitda4c15449dd48b3135ac14924e04c88bed8da427 (patch)
treec8afab45e5105afc0631445572c0aa9b1a934196
parent63722e11e656df0328f0051f68ad993e04b8947f (diff)
downloadelgg-da4c15449dd48b3135ac14924e04c88bed8da427.tar.gz
elgg-da4c15449dd48b3135ac14924e04c88bed8da427.tar.bz2
updated the deprecated list_site_members() to use new ElggSite::listMembers() method and updated ElggSite::getMembers() to accept all the arguments from elgg_get_entities()
git-svn-id: http://code.elgg.org/elgg/trunk@7422 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/classes/ElggSite.php56
-rw-r--r--engine/lib/sites.php38
2 files changed, 61 insertions, 33 deletions
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index 93d442e0a..aa94b9fd2 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -196,22 +196,60 @@ class ElggSite extends ElggEntity {
}
/**
- * Returns an array of ElggUser entities who are members of the site.
+ * Gets an array of ElggUser entities who are members of the site.
*
- * @param int $limit Limit
- * @param int $offset Offset
+ * @param array $options An associative array for key => value parameters
+ * accepted by elgg_get_entities(). Common parameters
+ * include 'limit', and 'offset'.
+ * Note: this was $limit before version 1.8
+ * @param int $offset Offset @deprecated parameter
+ *
+ * @todo remove $offset in 2.0
*
* @return array of ElggUsers
*/
- public function getMembers($limit = 10, $offset = 0) {
- return elgg_get_entities_from_relationship(array(
+ public function getMembers($options = array(), $offset = 0) {
+ if (!is_array($limit)) {
+ elgg_deprecated_notice("ElggSite::getMembers has a different arguments!", 1.8);
+ $options = array(
+ 'limit' => $options,
+ 'offset' => $offset,
+ );
+ }
+
+ $defaults = array(
'relationship' => 'member_of_site',
'relationship_guid' => $this->getGUID(),
'inverse_relationship' => TRUE,
- 'types' => 'user',
- 'limit' => $limit,
- 'offset' => $offset
- ));
+ 'type' => 'user',
+ );
+
+ $options = array_merge($defaults, $options);
+
+ return elgg_get_entities_from_relationship($options);
+ }
+
+ /**
+ * List the members of this site
+ *
+ * @param array $options An associative array for key => value parameters
+ * accepted by elgg_list_entities(). Common parameters
+ * include 'full_view', 'limit', and 'offset'.
+ *
+ * @return string
+ * @since 1.8.0
+ */
+ public function listMembers($options = array()) {
+ $defaults = array(
+ 'relationship' => 'member_of_site',
+ 'relationship_guid' => $this->getGUID(),
+ 'inverse_relationship' => TRUE,
+ 'type' => 'user',
+ );
+
+ $options = array_merge($defaults, $options);
+
+ return elgg_list_entities_from_relationship($options);
}
/**
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index ac048c26b..f8590a4e0 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -136,17 +136,12 @@ function get_site_members($site_guid, $limit = 10, $offset = 0) {
elgg_deprecated_notice("get_site_members() deprecated.
Use ElggSite::getMembers()", 1.8);
- $site_guid = (int)$site_guid;
- $limit = (int)$limit;
- $offset = (int)$offset;
+ $site = get_entity($site_guid);
+ if ($site) {
+ return $site->getMembers($limit, $offset);
+ }
- return elgg_get_entities_from_relationship(array(
- 'relationship' => 'member_of_site',
- 'relationship_guid' => $site_guid,
- 'inverse_relationship' => TRUE,
- 'types' => 'user',
- 'limit' => $limit, 'offset' => $offset
- ));
+ return false;
}
/**
@@ -157,28 +152,23 @@ function get_site_members($site_guid, $limit = 10, $offset = 0) {
* @param bool $fullview Whether or not to display the full view (default: true)
*
* @return string A displayable list of members
- * @deprecated 1.8 Use elgg_list_entities_from_relationships() with relationship
- * 'member_of_site'
+ * @deprecated 1.8 Use ElggSite::listMembers()
*/
function list_site_members($site_guid, $limit = 10, $fullview = true) {
elgg_deprecated_notice("list_site_members() deprecated.
- Use elgg_list_entities_from_relationships()", 1.8);
+ Use ElggSite::listMembers()", 1.8);
- $offset = (int) get_input('offset');
- $limit = (int) $limit;
$options = array(
- 'relationship' => 'member_of_site',
- 'relationship_guid' => $site_guid,
- 'inverse_relationship' => TRUE,
- 'types' => 'user',
'limit' => $limit,
- 'offset' => $offset,
- 'count' => TRUE
+ 'full_view' => $full_view,
);
- $count = (int) elgg_get_entities_from_relationship($options);
- $entities = get_site_members($site_guid, $limit, $offset);
- return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview);
+ $site = get_entity($site_guid);
+ if ($site) {
+ return $site->listMembers($options);
+ }
+
+ return '';
}
/**