Created
December 13, 2011 19:04
-
-
Save arturo-c/1473383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/www/sites/all/modules/apci_features/apci_public_api_services/apci_public_api_services.services.inc b/www/sites/all/modules/apci_features/apci_public_api_services/apci_public_api_services.services.inc | |
index de1ed1d..3eacceb 100755 | |
--- a/www/sites/all/modules/apci_features/apci_public_api_services/apci_public_api_services.services.inc | |
+++ b/www/sites/all/modules/apci_features/apci_public_api_services/apci_public_api_services.services.inc | |
@@ -128,6 +128,9 @@ function apci_public_api_services_default_services_endpoint() { | |
'subgroups' => array( | |
'enabled' => 1, | |
), | |
+ 'roles' => array( | |
+ 'enabled' => 1, | |
+ ), | |
), | |
), | |
'apci_albums' => array( | |
diff --git a/www/sites/all/modules/apci_features/apci_public_api_services/resources/groups_resource.inc b/www/sites/all/modules/apci_features/apci_public_api_services/resources/groups_resource.inc | |
index 82b55c0..6e7e47f 100755 | |
--- a/www/sites/all/modules/apci_features/apci_public_api_services/resources/groups_resource.inc | |
+++ b/www/sites/all/modules/apci_features/apci_public_api_services/resources/groups_resource.inc | |
@@ -648,6 +648,30 @@ function apci_public_api_services_groups_resource_definition() { | |
// 'access arguments' => array('view'), | |
// 'access arguments append' => TRUE, | |
),// subgroups | |
+ 'roles' => array( | |
+ 'help' => 'Retrieve the roles (uuid) belonging to a group optionally targeting a specific user (uuid).', | |
+ 'file' => array('type' => 'inc', 'module' => 'apci_public_api_services', 'name' => 'resources/groups_resource'), | |
+ 'callback' => '_apci_api_groups_roles_retrieve', | |
+ 'access callback' => '_apci_api_groups_access', | |
+ 'access arguments' => array('roles'), | |
+ 'access arguments append' => TRUE, | |
+ 'args' => array( | |
+ array( | |
+ 'name' => 'group_uuid', | |
+ 'optional' => FALSE, | |
+ 'description' => 'A uuid of a group on the system', | |
+ 'type' => 'string', | |
+ 'source' => array('path' => 0), | |
+ ), | |
+ array( | |
+ 'name' => 'uuid', | |
+ 'type' => 'string', | |
+ 'description' => 'A uuid of a user on the system', | |
+ 'source' => array('param' => 'uuid'), | |
+ 'optional' => TRUE, | |
+ ), | |
+ ), // args | |
+ ), // roles | |
),// relationships | |
),// apci_groups | |
);// end groups_resource | |
@@ -690,6 +714,9 @@ function _apci_api_groups_access($op, $args){ | |
case 'addrole': | |
$access = og_is_group_admin($node); | |
break; | |
+ case 'roles': | |
+ $access = og_is_group_admin($node); | |
+ break; | |
} | |
} | |
} | |
@@ -1612,6 +1639,7 @@ function _apci_api_groups_register_user($group_uuid, $uuid, $role_uuid = null, $ | |
$form_state['og_registration_obj'] = $og_registration; | |
$form_state['values']['rid'] = og_rap_rid_get_by_uuid($role_uuid)->rid; | |
$form_state['values']['uid'] = user_get_by_uuid($uuid)->uid; | |
+ dd($og_registration->rid); | |
// execute the register form | |
drupal_execute('og_registration_user_form', $form_state); | |
@@ -1628,3 +1656,18 @@ function _apci_api_groups_register_user($group_uuid, $uuid, $role_uuid = null, $ | |
} | |
return $form_state['og_registration_obj']; | |
} | |
+ | |
+/* | |
+ * Retrieve roles callback function. | |
+ */ | |
+function _apci_api_groups_roles_retrieve($group_uuid, $uuid = NULL) { | |
+ $group = node_get_by_uuid($group_uuid); | |
+ dd('test'); | |
+ if ($uuid) { | |
+ $user = user_get_by_uuid($uuid); | |
+ return og_rap_users_roles($user->uid, $group->nid, FALSE, TRUE); | |
+ } | |
+ else { | |
+ return og_rap_node_get_roles($group, TRUE, TRUE); | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment