function cis_example_cis_service_set_cis_service_data

cis7 cis_example_cis_service.module cis_example_cis_service_set_cis_service_data($delta)
cle7 cis_example_cis_service.module cis_example_cis_service_set_cis_service_data($delta)
elmsmedia7 cis_example_cis_service.module cis_example_cis_service_set_cis_service_data($delta)
icor7 cis_example_cis_service.module cis_example_cis_service_set_cis_service_data($delta)
meedjum_blog7 cis_example_cis_service.module cis_example_cis_service_set_cis_service_data($delta)
mooc7 cis_example_cis_service.module cis_example_cis_service_set_cis_service_data($delta)

Implements hook_set_cis_service_data().

File

sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module, line 31
Code for the Example CIS Service.

Code

function cis_example_cis_service_set_cis_service_data($delta) {
  // need to do clean up to ensure that staff members are part of master group
  if ($delta == 'initial') {
    $uids = array();
    // select all users that are staff
    $query = db_select('role', 'r');
    $query->join('users_roles', 'ur', 'r.rid = ur.rid');
    $query->join('users', 'u', 'ur.uid = u.uid');
    $query->fields('u', array('uid'))->condition('r.name', 'staff');
    $result = $query->execute();
    $uids = $result->fetchCol();
    // figure out the master section, most likely node 1
    $query = new EntityFieldQuery();
    // pull all nodes
    $query->entityCondition('entity_type', 'node')
    // that are sections
    ->entityCondition('bundle', 'section')
    // that are published
    ->propertyCondition('status', 1)
    // that have a section like master_
    ->fieldCondition('field_section_id', 'value', 'master_%', 'like')->addMetaData('account', user_load(1));
    // store results
    $result = $query->execute();
    // ensure we have results
    if (isset($result['node'])) {
      $nids = array_keys($result['node']);
      $sections = entity_load('node', $nids);
      $group = array_pop($sections);
      foreach ($uids as $uid) {
        // load account for saving to the group
        $account = user_load($uid);
        // add people to this group / default section
        $values = array(
          'entity_type' => 'user',
          'entity' => $account,
        );
        og_group('node', $group->nid, $values);
      }
    }
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.