You are here

function drupalgap_convert_d6_perms_to_d7 in DrupalGap 6

Converts a D6 {permission} result row to match that of D7's permission structure, this is so the mobile app only needs to understand one data set. It appends the result to the incoming results array.

Parameters

$results: Array to append the result to.

$data: Object result from the mysql row fetch.

$account: Object for the user account.

1 call to drupalgap_convert_d6_perms_to_d7()
_drupalgap_resource_user_roles_and_permissions in ./drupalgap.resource.inc
Returns a user's roles and permissions.

File

./drupalgap.resource.inc, line 394
This file implements the DrupalGap service resource call back functions.

Code

function drupalgap_convert_d6_perms_to_d7(&$results, $data, $account) {

  // Structure the roles and permissions result to match that of D7,
  // so the mobile app only needs to understand one set of data.
  $permissions = explode(", ", $data->perm);
  foreach ($permissions as $permission) {
    $result = new stdClass();
    $result->uid = $account->uid;
    $result->rid = $data->rid;
    $result->name = $account->roles[$data->rid];
    $result->permission = $permission;
    $results[] = $result;
  }
}