You are here

public function OgUiSetRoles::prepareRow in Organic groups 7.2

Default implementation of prepareRow(). This method is called from the source plugin upon first pulling the raw data from the source.

Parameters

$row: Object containing raw source data.

Return value

bool TRUE to process this row, FALSE to have the source skip it.

Overrides Migration::prepareRow

File

og_ui/includes/migrate/7000/set_roles.inc, line 49
Set permissions on group to upgrade group visibility.

Class

OgUiSetRoles
@file Set permissions on group to upgrade group visibility.

Code

public function prepareRow($row) {
  $anon_permissions = array();
  $auth_permissions = array(
    'unsubscribe' => TRUE,
  );
  switch ($row->og_selective) {

    // Open
    case 0:
      $anon_permissions = array(
        'subscribe' => FALSE,
        'subscribe without approval' => TRUE,
      );
      break;

    // Moderated.
    case 1:
      $anon_permissions = array(
        'subscribe' => TRUE,
        'subscribe without approval' => FALSE,
      );
      break;

    // Invite only.
    case 2:
      $anon_permissions = array(
        'subscribe' => FALSE,
        'subscribe without approval' => FALSE,
      );
      break;

    // Closed.
    case 3:
      $anon_permissions = array(
        'subscribe' => FALSE,
        'subscribe without approval' => FALSE,
      );
      $auth_permissions = array(
        'unsubscribe' => FALSE,
      );
      break;
  }
  $og_roles = og_roles('node', $row->type, $row->nid);
  $permissions = og_role_permissions($og_roles);
  $anon_rid = array_search(OG_ANONYMOUS_ROLE, $og_roles);
  $auth_rid = array_search(OG_AUTHENTICATED_ROLE, $og_roles);

  // Set the new permissions.
  og_role_change_permissions($anon_rid, $anon_permissions);
  og_role_change_permissions($auth_rid, $auth_permissions);

  // We don't need to really save the node, but if we return FALSE,
  // then the row is not counted as imported.
  return TRUE;
}