LTIToolProviderMembershipsEntityController.class.php

  1. cis7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  2. cle7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  3. ecd7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  4. elmsmedia7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  5. harmony7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  6. icor7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  7. meedjum_blog7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
  8. mooc7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php

Contains LTIToolProviderMembershipsEntityController.

Classes

Namesort descending Description
LTIToolProviderMembershipsEntityController Memberships Entity controller.

Interfaces

Namesort descending Description
LTIToolProviderMembershipsEntityControllerInterface Memberships Entity controller interface.

File

sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains LTIToolProviderMembershipsEntityController.
  5. */
  6. /**
  7. * Memberships Entity controller interface.
  8. */
  9. interface LTIToolProviderMembershipsEntityControllerInterface
  10. extends DrupalEntityControllerInterface {
  11. public function create();
  12. public function save($entity);
  13. public function delete($entity);
  14. }
  15. /**
  16. * Memberships Entity controller.
  17. */
  18. class LTIToolProviderMembershipsEntityController
  19. extends DrupalDefaultEntityController
  20. implements LTIToolProviderMembershipsEntityControllerInterface {
  21. public function create() {
  22. $entity = new stdClass();
  23. $entity->lti_tool_provider_memberships_id = 0;
  24. $entity->lti_tool_provider_memberships_context_id = NULL;
  25. $entity->lti_tool_provider_memberships_uid = NULL;
  26. $entity->lti_tool_provider_memberships_user_id = NULL;
  27. $entity->lti_tool_provider_memberships_role = '';
  28. $entity->lti_tool_provider_memberships_person_name_full = '';
  29. $entity->lti_tool_provider_memberships_status = 'Active';
  30. $entity->date_added = REQUEST_TIME;
  31. $entity->date_updated = NULL;
  32. $entity->date_dropped = NULL;
  33. return $entity;
  34. }
  35. /**
  36. * Save a memberships entity.
  37. *
  38. * @param object $entity
  39. * The memberships entity to be saved.
  40. *
  41. * @return object|boolean
  42. * The saved memberships entity or FALSE.
  43. */
  44. public function save($entity) {
  45. $transaction = db_transaction();
  46. try {
  47. $entity->is_new = empty($entity->lti_tool_provider_memberships_id);
  48. if (!isset($entity->date_dropped)) {
  49. $entity->date_updated = REQUEST_TIME;
  50. }
  51. field_attach_presave('lti_tool_provider_memberships', $entity);
  52. $primary_key = $entity->lti_tool_provider_memberships_id ? 'lti_tool_provider_memberships_id' : array();
  53. if (empty($primary_key)) {
  54. drupal_write_record('lti_tool_provider_memberships', $entity);
  55. field_attach_insert('lti_tool_provider_memberships', $entity);
  56. $op = 'insert';
  57. }
  58. else {
  59. drupal_write_record('lti_tool_provider_memberships', $entity, $primary_key);
  60. $op = 'update';
  61. }
  62. $function = 'field_attach_' . $op;
  63. $function('lti_tool_provider_memberships', $entity);
  64. module_invoke_all('entity_' . $op, $entity, 'lti_tool_provider_memberships');
  65. unset($entity->is_new);
  66. db_ignore_slave();
  67. return $entity;
  68. }
  69. catch (Exception $e) {
  70. $transaction->rollback();
  71. drupal_set_message(t('%e', array('%e' => $entity->$e)));
  72. watchdog_exception('lti_tool_provider_memberships', $e, NULL, WATCHDOG_ERROR);
  73. return FALSE;
  74. }
  75. }
  76. /**
  77. * Delete a memberships entity.
  78. *
  79. * @param object $entity
  80. * The memberships etity to be deleted.
  81. */
  82. public function delete($entity) {
  83. $this->delete_multiple(array($entity));
  84. }
  85. /**
  86. * Delete a list of memberships entities.
  87. *
  88. * @param array $entities
  89. * An array of memberships entities to be deleted.
  90. *
  91. * @throws Exception
  92. */
  93. public function delete_multiple($entities) {
  94. $ids = array();
  95. if (!empty($entities)) {
  96. $transaction = db_transaction();
  97. try {
  98. foreach ($entities as $entity) {
  99. module_invoke_all('lti_tool_provider_memberships_delete', $entity);
  100. module_invoke_all('entity_delete', $entity, 'lti_tool_provider_memberships');
  101. field_attach_delete('lti_tool_provider_memberships', $entity);
  102. $ids[] = $entity->lti_tool_provider_memberships_id;
  103. }
  104. db_delete('lti_tool_provider_memberships')
  105. ->condition('lti_tool_provider_memberships_id', $ids, 'IN')
  106. ->execute();
  107. }
  108. catch (Exception $e) {
  109. $transaction->rollback();
  110. watchdog_exception('lti_tool_provider_memberships', $e);
  111. throw $e;
  112. }
  113. }
  114. }
  115. }
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.