cis_example_cis_service.module

  1. cis7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  2. cle7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  3. ecd7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  4. elmsmedia7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  5. harmony7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  6. icor7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  7. meedjum_blog7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
  8. mooc7 sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module

Code for the Example CIS Service.

Functions

File

sites/all/modules/_my_modules/cis_examples/cis_example_cis_service/cis_example_cis_service.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Code for the Example CIS Service.
  5. */
  6. /**
  7. * Implements hook_cis_section_list_alter().
  8. */
  9. function cis_example_cis_service_cis_section_list_alter(&$sections) {
  10. // convert section identifiers to something human readable
  11. foreach ($sections as $key => $section) {
  12. // this breaks section up into parts for reproduction
  13. if ($parts = _cis_example_utility_section_parts($section)) {
  14. // list of semesters
  15. $semesters = _cis_example_utility_semester_list();
  16. // convert to readable word
  17. if (isset($semesters[strtolower($parts['semester'])])) {
  18. $parts['semester'] = $semesters[strtolower($parts['semester'])];
  19. }
  20. $sections[$key] = implode(' ', $parts);
  21. }
  22. }
  23. // should be in order already but to be safe
  24. asort($sections);
  25. }
  26. /**
  27. * Implements hook_set_cis_service_data().
  28. */
  29. function cis_example_cis_service_set_cis_service_data($delta) {
  30. // need to do clean up to ensure that staff members are part of master group
  31. if ($delta == 'initial') {
  32. $uids = array();
  33. // select all users that are staff
  34. $query = db_select('role', 'r');
  35. $query->join('users_roles', 'ur', 'r.rid = ur.rid');
  36. $query->join('users', 'u', 'ur.uid = u.uid');
  37. $query->fields('u',array('uid'))
  38. ->condition('r.name', 'staff');
  39. $result = $query->execute();
  40. $uids = $result->fetchCol();
  41. // figure out the master section, most likely node 1
  42. $query = new EntityFieldQuery();
  43. // pull all nodes
  44. $query->entityCondition('entity_type', 'node')
  45. // that are sections
  46. ->entityCondition('bundle', 'section')
  47. // that are published
  48. ->propertyCondition('status', 1)
  49. // that have a section like master_
  50. ->fieldCondition('field_section_id', 'value', 'master_%', 'like')
  51. ->addMetaData('account', user_load(1));
  52. // store results
  53. $result = $query->execute();
  54. // ensure we have results
  55. if (isset($result['node'])) {
  56. $nids = array_keys($result['node']);
  57. $sections = entity_load('node', $nids);
  58. $group = array_pop($sections);
  59. foreach ($uids as $uid) {
  60. // load account for saving to the group
  61. $account = user_load($uid);
  62. // add people to this group / default section
  63. $values = array(
  64. 'entity_type' => 'user',
  65. 'entity' => $account,
  66. );
  67. og_group('node',$group->nid, $values);
  68. }
  69. }
  70. }
  71. }
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.