You are here

public function MerciItemRestrictionsMigration::prepareRow in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

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

merci_migrate/merci_restrictions.inc, line 69
Support for node destinations.

Class

MerciItemRestrictionsMigration

Code

public function prepareRow($row) {
  $result = db_query("SELECT rid FROM {role_permission} WHERE permission = :permission", array(
    ':permission' => 'edit own ' . $row->type . ' content',
  ));
  $row->rids = array();
  foreach ($result as $role) {
    $enabled = db_query("SELECT count(rid) FROM {role_permission} WHERE permission = 'merci permissions allowed role' AND rid = :rid", array(
      ':rid' => $role->rid,
    ))
      ->fetchField();
    if (!$enabled) {
      user_role_grant_permissions($role->rid, array(
        'merci permissions allowed role',
      ));
    }
    $row->rids[] = $role->rid;
  }
  return TRUE;
}