lti_tool_provider.admin.inc

  1. cis7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  2. cle7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  3. ecd7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  4. elmsmedia7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  5. harmony7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  6. icor7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  7. meedjum_blog7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
  8. mooc7 sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc

Admin forms for LTI Tool Provider module.

Functions

Namesort descending Description
lti_tool_provider_consumers_admin Generate the consumer admin form.
lti_tool_provider_consumer_add Add a consumer.
lti_tool_provider_consumer_confirm_delete_form Confirms the delete action.
lti_tool_provider_consumer_confirm_delete_form_submit Submit handler for the consumer form delete.
lti_tool_provider_consumer_edit_delete Edit or delete a consumer entity.
lti_tool_provider_consumer_form Generate the consumer entity form.
lti_tool_provider_consumer_form_delete_submit Button submit function: handle the 'Delete' button on the consumer form.
lti_tool_provider_consumer_form_submit Update or create a consumer entity.
lti_tool_provider_consumer_form_validate Validate the consumer entity form.
lti_tool_provider_consumer_view View a single consumer entity.
lti_tool_provider_global_roles Admin form for the global roles.
lti_tool_provider_global_roles_submit Submit handler for the global roles form.
lti_tool_provider_user_attributes Menu page callback.
lti_tool_provider_user_attributes_submit Submit handler for the user attributes form.
lti_tool_provider_user_attributes_validate Validation for the user attributes form.

File

sites/all/modules/ulmus/lti_tool_provider/lti_tool_provider.admin.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Admin forms for LTI Tool Provider module.
  5. */
  6. /**
  7. * Menu page callback.
  8. *
  9. * Configure settings for mapping user attributes from the
  10. * LTI context variables.
  11. *
  12. * @param array $form
  13. * The form.
  14. * @param array $form_state
  15. * The form state.
  16. *
  17. * @return array
  18. * The form.
  19. */
  20. function lti_tool_provider_user_attributes($form, &$form_state) {
  21. $form['description'] = array(
  22. '#type' => 'item',
  23. '#title' => t('LTI Context to User Attribute Mapping'),
  24. '#description' => 'Choose the user attributes to be mapped from each LTI context variable.',
  25. );
  26. $fields_array = _lti_tool_provider_retrieve_user_field_types('TEXT');
  27. $lis_list = lti_tool_provider_user_mapping_lis_details();
  28. $saved_settings = variable_get('lti_tool_provider_user_attribute_mapping', array());
  29. $form['mapping'] = array(
  30. '#tree' => TRUE,
  31. '#theme' => 'table',
  32. '#header' => array(t('LTI Context Variable'), t('User Attribute')),
  33. '#rows' => array(),
  34. );
  35. foreach ($lis_list as $detail) {
  36. $variable = array(
  37. '#type' => 'item',
  38. '#title' => check_plain($detail),
  39. );
  40. $value = $saved_settings[$detail];
  41. $attribute = array(
  42. '#type' => 'select',
  43. '#options' => $fields_array,
  44. '#default_value' => $value,
  45. );
  46. $form['mapping'][] = array(
  47. 'variable' => &$variable,
  48. 'attribute' => &$attribute,
  49. );
  50. $form['mapping']['#rows'][] = array(
  51. array('data' => &$variable),
  52. array('data' => &$attribute),
  53. );
  54. unset($variable);
  55. unset($attribute);
  56. }
  57. $form['submit'] = array(
  58. '#type' => 'submit',
  59. '#value' => t('Save User Attributes'),
  60. );
  61. return $form;
  62. }
  63. /**
  64. * Validation for the user attributes form.
  65. *
  66. * @param array $form
  67. * The form.
  68. * @param array $form_state
  69. * The form state.
  70. */
  71. function lti_tool_provider_user_attributes_validate($form, &$form_state) {
  72. $check = TRUE;
  73. $lis_list = lti_tool_provider_user_mapping_lis_details();
  74. $field_options = _lti_tool_provider_retrieve_user_field_types('TEXT');
  75. $counters = array();
  76. foreach ($field_options as $field => $desc) {
  77. $counters[$field] = 0;
  78. }
  79. foreach ($lis_list as $key => $variable) {
  80. $counters[$form_state['values']['mapping'][$key]['attribute']]++;
  81. }
  82. foreach ($field_options as $field => $desc) {
  83. if ($field != 'none' && $counters[$field] > 1) {
  84. $check = FALSE;
  85. break;
  86. }
  87. }
  88. if (!$check) {
  89. form_set_error('mapping', t('You may not map multiple values to the same attribute.'));
  90. }
  91. }
  92. /**
  93. * Submit handler for the user attributes form.
  94. *
  95. * @param array $form
  96. * The form.
  97. * @param array $form_state
  98. * The form state.
  99. */
  100. function lti_tool_provider_user_attributes_submit($form, &$form_state) {
  101. $lis_list = lti_tool_provider_user_mapping_lis_details();
  102. $settings = array();
  103. foreach ($lis_list as $key => $lis) {
  104. $setting[$lis] = $form_state['values']['mapping'][$key]['attribute'];
  105. }
  106. variable_set('lti_tool_provider_user_attribute_mapping', $setting);
  107. drupal_set_message(t('User attribute mapping saved.'));
  108. }
  109. /**
  110. * Admin form for the global roles.
  111. *
  112. * @param array $form
  113. * The form.
  114. * @param array $form_state
  115. * The form state.
  116. */
  117. function lti_tool_provider_global_roles($form, &$form_state) {
  118. $form['description'] = array(
  119. '#type' => 'item',
  120. '#title' => t('Map LTI Roles to Global Drupal Roles'),
  121. '#description' => t('Map each LTI role to a global Drupal role.'),
  122. );
  123. $select_roles = user_roles(TRUE, NULL);
  124. $old_role_array = variable_get('lti_tool_provider_global_role_array');
  125. $form['roles'] = array(
  126. '#tree' => TRUE,
  127. '#theme' => 'table',
  128. '#header' => array(t('LTI Roles'), t('Global Roles')),
  129. '#rows' => array(),
  130. );
  131. foreach (lti_tool_provider_get_lti_roles() as $role) {
  132. $lti_role = array(
  133. '#type' => 'item',
  134. '#title' => $role,
  135. );
  136. $global_role = array(
  137. '#type' => 'select',
  138. '#options' => $select_roles,
  139. );
  140. if (isset($old_role_array[$role]) && isset($select_roles[$old_role_array[$role]])) {
  141. $global_role['#default_value'] = $old_role_array[$role];
  142. }
  143. else {
  144. $global_role['#default_value'] = array_search(DRUPAL_AUTHENTICATED_RID, $select_roles);
  145. }
  146. $form['roles'][] = array(
  147. 'lti_role' => &$lti_role,
  148. 'global_role' => &$global_role,
  149. );
  150. $form['roles']['#rows'][] = array(
  151. array('data' => &$lti_role),
  152. array('data' => &$global_role),
  153. );
  154. unset($lti_role);
  155. unset($global_role);
  156. }
  157. $form['submit'] = array(
  158. '#type' => 'submit',
  159. '#value' => t('Save Global Roles'),
  160. '#submit' => array('lti_tool_provider_global_roles_submit'),
  161. );
  162. return $form;
  163. }
  164. /**
  165. * Submit handler for the global roles form.
  166. *
  167. * @param array $form
  168. * The form.
  169. * @param array $form_state
  170. * The form state.
  171. */
  172. function lti_tool_provider_global_roles_submit($form, &$form_state) {
  173. $settings = array();
  174. foreach (lti_tool_provider_get_lti_roles() as $key => $role) {
  175. $settings[$role] = $form_state['values']['roles'][$key]['global_role'];
  176. }
  177. variable_set('lti_tool_provider_global_role_array', $settings);
  178. drupal_set_message(t('LTI global roles mapping saved.'));
  179. }
  180. /**
  181. * Generate the consumer admin form.
  182. *
  183. * @return array
  184. * The form array.
  185. */
  186. function lti_tool_provider_consumers_admin() {
  187. $content = array();
  188. $content[] = array(
  189. '#type' => 'item',
  190. '#markup' => t('Administration page for LTI Tool Consumers.'),
  191. );
  192. $content[] = array(
  193. '#type' => 'item',
  194. '#markup' => l(t('Add a new LTI Tool Consumer'), 'lti_tool_provider_consumer/add'),
  195. );
  196. $content['table'] = array();
  197. // Load all of our entities.
  198. $consumers = lti_tool_provider_consumer_load_multiple();
  199. $content['consumer_table'] = array(
  200. '#theme' => 'table',
  201. '#rows' => array(),
  202. '#header' => array(
  203. t('ID'),
  204. t('Consumer'),
  205. t('Key'),
  206. t('Secret'),
  207. t('Domain'),
  208. t('Dummy Account'),
  209. t('Date Joined'),
  210. t('Operations'),
  211. ),
  212. );
  213. $destination = drupal_get_destination();
  214. $loop_counter = 0;
  215. foreach ($consumers as $key => $consumer) {
  216. // Create tabular rows for our entities.
  217. $id = $consumer->lti_tool_provider_consumer_id;
  218. // This statement can create url to view individual keys.
  219. $consumer_name = array(
  220. '#type' => 'link',
  221. '#title' => t('@consumer', array('@consumer' => $consumer->lti_tool_provider_consumer_consumer)),
  222. '#href' => 'lti_tool_provider_consumer/' . $consumer->lti_tool_provider_consumer_id . '/view',
  223. '#options' => array('query' => $destination),
  224. );
  225. $key = $consumer->lti_tool_provider_consumer_key;
  226. $secret = $consumer->lti_tool_provider_consumer_secret;
  227. $domain = $consumer->lti_tool_provider_consumer_domain;
  228. $dummy_pref = lti_tool_provider_trans_bool($consumer->lti_tool_provider_consumer_dummy_pref);
  229. $date_joined = format_date($consumer->date_joined);
  230. // Build a list of all the operations for the current consumer.
  231. $operations = array(
  232. 'edit' => array(
  233. '#type' => 'link',
  234. '#title' => t('edit'),
  235. '#href' => 'lti_tool_provider_consumer/' . $consumer->lti_tool_provider_consumer_id . '/edit',
  236. '#options' => array('query' => $destination),
  237. ),
  238. 'nbsp' => array('#markup' => '&nbsp;&nbsp;'),
  239. 'delete' => array(
  240. '#type' => 'link',
  241. '#title' => t('delete'),
  242. '#href' => 'lti_tool_provider_consumer/' . $consumer->lti_tool_provider_consumer_id . '/delete',
  243. '#options' => array('query' => $destination),
  244. ),
  245. );
  246. $content['consumer_table'][] = array(
  247. 'id' => &$id,
  248. 'Consumer' => &$consumer_name,
  249. 'Key' => &$key,
  250. 'Secret' => &$secret,
  251. 'Domain' => &$domain,
  252. 'Dummy_Pref' => &$dummy_pref,
  253. 'Date Joined' => &$date_joined,
  254. 'operations' => &$operations,
  255. );
  256. $content['consumer_table']['#rows'][] = array(
  257. array('data' => &$id),
  258. array('data' => &$consumer_name),
  259. array('data' => &$key),
  260. array('data' => &$secret),
  261. array('data' => &$domain),
  262. array('data' => &$dummy_pref),
  263. array('data' => &$date_joined),
  264. array('data' => &$operations),
  265. );
  266. unset($id);
  267. unset($consumer_name);
  268. unset($key);
  269. unset($secret);
  270. unset($domain);
  271. unset($dummy_pref);
  272. unset($date_joined);
  273. unset($operations);
  274. }
  275. $content['consumer_table']['#empty'] = t('No LTITP Consumer entities currently exist.');
  276. return $content;
  277. }
  278. /**
  279. * Add a consumer.
  280. *
  281. * @return array
  282. * A consumer add form.
  283. */
  284. function lti_tool_provider_consumer_add() {
  285. // Create a basic entity structure to be used and passed to the
  286. // validation and submission functions.
  287. $entity = entity_get_controller('lti_tool_provider_consumer')->create();
  288. return drupal_get_form('lti_tool_provider_consumer_form', $entity);
  289. }
  290. /**
  291. * Generate the consumer entity form.
  292. *
  293. * @param array $form
  294. * The form.
  295. * @param array $form_state
  296. * The form state.
  297. * @param object $consumer
  298. * The consumer entity to display.
  299. *
  300. * @return array
  301. * The form array.
  302. */
  303. function lti_tool_provider_consumer_form($form, &$form_state, $consumer) {
  304. if (!isset($form_state['#consumer'])) {
  305. $form_state['#consumer'] = $consumer;
  306. }
  307. $form['lti_tool_provider_consumer_consumer'] = array(
  308. '#type' => 'textfield',
  309. '#title' => t('Consumer'),
  310. '#required' => TRUE,
  311. '#default_value' => $consumer->lti_tool_provider_consumer_consumer,
  312. );
  313. $form['lti_tool_provider_consumer_key'] = array(
  314. '#type' => 'textfield',
  315. '#title' => t('Key'),
  316. '#required' => TRUE,
  317. '#default_value' => $consumer->lti_tool_provider_consumer_key,
  318. );
  319. $form['lti_tool_provider_consumer_secret'] = array(
  320. '#type' => 'textfield',
  321. '#title' => t('Secret'),
  322. '#required' => TRUE,
  323. '#default_value' => $consumer->lti_tool_provider_consumer_secret,
  324. );
  325. $form['lti_tool_provider_consumer_domain'] = array(
  326. '#type' => 'textfield',
  327. '#title' => t('Domain'),
  328. '#required' => FALSE,
  329. '#default_value' => $consumer->lti_tool_provider_consumer_domain,
  330. );
  331. $form['lti_tool_provider_consumer_dummy_pref'] = array(
  332. '#type' => 'checkbox',
  333. '#title' => t('Use a dummy account for unidentified users'),
  334. '#default_value' => $consumer->lti_tool_provider_consumer_dummy_pref,
  335. );
  336. $form['lti_tool_provider_consumer_id'] = array(
  337. '#type' => 'value',
  338. '#value' => $consumer->lti_tool_provider_consumer_id,
  339. );
  340. $form['lti_tool_provider_consumer'] = array(
  341. '#type' => 'value',
  342. '#value' => $consumer,
  343. );
  344. field_attach_form('lti_tool_provider_consumer', $consumer, $form, $form_state);
  345. $form['submit'] = array(
  346. '#type' => 'submit',
  347. '#value' => t('Save'),
  348. '#weight' => 100,
  349. );
  350. if ($consumer->lti_tool_provider_consumer_id != 0) {
  351. $form['delete'] = array(
  352. '#type' => 'submit',
  353. '#value' => t('Delete'),
  354. '#submit' => array('lti_tool_provider_consumer_form_delete_submit'),
  355. '#weight' => 200,
  356. );
  357. }
  358. return $form;
  359. }
  360. /**
  361. * Validate the consumer entity form.
  362. *
  363. * @param array $form
  364. * The form.
  365. * @param array $form_state
  366. * The form state.
  367. */
  368. function lti_tool_provider_consumer_form_validate($form, &$form_state) {
  369. $check_key = FALSE;
  370. $check_domain = FALSE;
  371. $new_consumer = $form_state['values']['lti_tool_provider_consumer_id'];
  372. if ($new_consumer == 0) {
  373. // Create.
  374. $query = new EntityFieldQuery();
  375. $query
  376. ->entityCondition('entity_type', 'lti_tool_provider_consumer')
  377. ->propertyCondition('lti_tool_provider_consumer_key', $form_state['values']['lti_tool_provider_consumer_key']);
  378. $result = $query->execute();
  379. if (empty($result)) {
  380. $check_key = TRUE;
  381. }
  382. if ($form_state['values']['lti_tool_provider_consumer_domain'] == '') {
  383. $check_domain = TRUE;
  384. }
  385. else {
  386. $query = new EntityFieldQuery();
  387. $query
  388. ->entityCondition('entity_type', 'lti_tool_provider_consumer')
  389. ->propertyCondition('lti_tool_provider_consumer_domain', $form_state['values']['lti_tool_provider_consumer_domain']);
  390. $result = $query->execute();
  391. if (empty($result)) {
  392. $check_domain = TRUE;
  393. }
  394. }
  395. }
  396. else {
  397. // Edit or delete.
  398. $query = new EntityFieldQuery();
  399. $query
  400. ->entityCondition('entity_type', 'lti_tool_provider_consumer')
  401. ->propertyCondition('lti_tool_provider_consumer_key', $form_state['values']['lti_tool_provider_consumer_key'])
  402. ->propertyCondition('lti_tool_provider_consumer_id', $form_state['values']['lti_tool_provider_consumer_id'], '!=');
  403. $result = $query->execute();
  404. if (empty($result)) {
  405. $check_key = TRUE;
  406. }
  407. if ($form_state['values']['lti_tool_provider_consumer_domain'] == '') {
  408. $check_domain = TRUE;
  409. }
  410. else {
  411. $query = new EntityFieldQuery();
  412. $query
  413. ->entityCondition('entity_type', 'lti_tool_provider_consumer')
  414. ->propertyCondition('lti_tool_provider_consumer_domain', $form_state['values']['lti_tool_provider_consumer_domain'])
  415. ->propertyCondition('lti_tool_provider_consumer_id', $form_state['values']['lti_tool_provider_consumer_id'], '!=');
  416. $result = $query->execute();
  417. if (empty($result)) {
  418. $check_domain = TRUE;
  419. }
  420. }
  421. }
  422. if ($check_key && $check_domain) {
  423. $submitted = (object) $form_state['values']['lti_tool_provider_consumer'];
  424. field_attach_form_validate('lti_tool_provider_consumer', $submitted, $form, $form_state);
  425. }
  426. if (!$check_domain) {
  427. form_set_error('lti_tool_provider_consumer_domain', t('Domains must be unique.'));
  428. }
  429. if (!$check_key) {
  430. form_set_error('lti_tool_provider_consumer_key', t('Keys must be unique.'));
  431. }
  432. $pattern = '/([A-Z0-9 _!@#$%=+*.?<>\/\r\n])/';
  433. $domain_char_check = preg_match($pattern, $form_state['values']['lti_tool_provider_consumer_domain']);
  434. if ($domain_char_check) {
  435. form_set_error('lti_tool_provider_consumer_domain', t('The domain must not contain numeric value, special characters, spaces and upper cases'));
  436. }
  437. }
  438. /**
  439. * Update or create a consumer entity.
  440. *
  441. * @param array $form
  442. * The form.
  443. * @param array $form_state
  444. * The form state.
  445. */
  446. function lti_tool_provider_consumer_form_submit($form, &$form_state) {
  447. $entity = $form_state['values']['lti_tool_provider_consumer'];
  448. $entity->lti_tool_provider_consumer_key = $form_state['values']['lti_tool_provider_consumer_key'];
  449. $entity->lti_tool_provider_consumer_secret = $form_state['values']['lti_tool_provider_consumer_secret'];
  450. $entity->lti_tool_provider_consumer_consumer = $form_state['values']['lti_tool_provider_consumer_consumer'];
  451. $entity->lti_tool_provider_consumer_domain = $form_state['values']['lti_tool_provider_consumer_domain'];
  452. $entity->lti_tool_provider_consumer_dummy_pref = $form_state['values']['lti_tool_provider_consumer_dummy_pref'];
  453. if ($form_state['values']['lti_tool_provider_consumer_dummy_pref'] && $form['lti_tool_provider_consumer_dummy_pref']['#default_value'] == 0) {
  454. lti_tool_provider_create_dummy_account($form_state['values']['lti_tool_provider_consumer_domain']);
  455. drupal_set_message(t('Dummy user has been created.'));
  456. }
  457. else {
  458. if ($form_state['values']['lti_tool_provider_consumer_id'] != 0 && $form_state['values']['lti_tool_provider_consumer_dummy_pref'] == 0 && $form['lti_tool_provider_consumer_dummy_pref']['#default_value'] == 1) {
  459. lti_tool_provider_remove_dummy_account($form_state['values']['lti_tool_provider_consumer_domain']);
  460. drupal_set_message(t('Dummy user has been removed.'));
  461. }
  462. }
  463. field_attach_submit('lti_tool_provider_consumer', $entity, $form, $form_state);
  464. $entity = lti_tool_provider_consumer_save($entity);
  465. drupal_set_message(t('Configurations saved.'));
  466. $form_state['redirect'] = 'admin/config/lti-tool-provider/lti-tool-consumers';
  467. }
  468. /**
  469. * Button submit function: handle the 'Delete' button on the consumer form.
  470. */
  471. function lti_tool_provider_consumer_form_delete_submit($form, &$form_state) {
  472. $destination = array();
  473. if (isset($_GET['destination'])) {
  474. $destination = drupal_get_destination();
  475. unset($_GET['destination']);
  476. }
  477. $consumer = $form_state['#consumer'];
  478. $form_state['redirect'] = array('admin/config/lti-tool-provider/lti-tool-consumer/' . $consumer->lti_tool_provider_consumer_id . '/delete', array('query' => $destination));
  479. }
  480. /**
  481. * Edit or delete a consumer entity.
  482. *
  483. * @param array $form
  484. * The form.
  485. * @param array $form_state
  486. * The form state.
  487. */
  488. function lti_tool_provider_consumer_edit_delete($form, &$form_state) {
  489. $entity = $form_state['values']['lti_tool_provider_consumer'];
  490. lti_tool_provider_remove_dummy_account($entity->lti_tool_provider_consumer_domain);
  491. lti_tool_provider_consumer_delete($entity);
  492. drupal_set_message(t('The entity %lti_tool_provider_consumer_consumer (ID %lti_tool_provider_consumer_id) has been deleted.', array(
  493. '%lti_tool_provider_consumer_consumer' => $entity->lti_tool_provider_consumer_consumer,
  494. '%lti_tool_provider_consumer_id' => $entity->lti_tool_provider_consumer_id,
  495. )));
  496. $form_state['redirect'] = 'admin/config/lti-tool-provider/lti-tool-consumers';
  497. }
  498. /**
  499. * View a single consumer entity.
  500. *
  501. * @param object $entity
  502. * The consumer to view.
  503. * @param string $view_mode
  504. * The requested view mode.
  505. *
  506. * @return array
  507. * The content array from the entity.
  508. */
  509. function lti_tool_provider_consumer_view($entity, $view_mode = 'tweaky') {
  510. $entity_type = 'lti_tool_provider_consumer';
  511. $entity->content = array(
  512. '#view_mode' => $view_mode,
  513. );
  514. field_attach_prepare_view($entity_type, array($entity->lti_tool_provider_consumer_id => $entity), $view_mode);
  515. entity_prepare_view($entity_type, array($entity->lti_tool_provider_consumer_id => $entity));
  516. $entity->content += field_attach_view($entity_type, $entity, $view_mode);
  517. $entity->content['lti_tool_provider_consumer_consumer'] = array(
  518. '#type' => 'item',
  519. '#title' => t('Consumer'),
  520. '#markup' => $entity->lti_tool_provider_consumer_consumer,
  521. );
  522. $entity->content['lti_tool_provider_consumer_key'] = array(
  523. '#type' => 'item',
  524. '#title' => t('Key'),
  525. '#markup' => $entity->lti_tool_provider_consumer_key,
  526. );
  527. $entity->content['lti_tool_provider_consumer_secret'] = array(
  528. '#type' => 'item',
  529. '#title' => t('Secret'),
  530. '#markup' => $entity->lti_tool_provider_consumer_secret,
  531. );
  532. $entity->content['lti_tool_provider_consumer_domain'] = array(
  533. '#type' => 'item',
  534. '#title' => t('Domain'),
  535. '#markup' => $entity->lti_tool_provider_consumer_domain,
  536. );
  537. $entity->content['lti_tool_provider_consumer_dummy_pref'] = array(
  538. '#type' => 'item',
  539. '#title' => t('Activate Dummy Account'),
  540. '#markup' => lti_tool_provider_trans_bool($entity->lti_tool_provider_consumer_dummy_pref),
  541. );
  542. $entity->content['date_joined'] = array(
  543. '#type' => 'item',
  544. '#title' => t('Date Joined'),
  545. '#markup' => format_date($entity->date_joined),
  546. );
  547. global $language;
  548. $langcode = $language->language;
  549. $entity->content['#language'] = $langcode;
  550. module_invoke_all('entity_view', $entity, $entity_type, $view_mode, $langcode);
  551. drupal_alter(array('lti_tool_provider_consumer_view', 'entity_view'),
  552. $entity->content, $entity_type);
  553. return $entity->content;
  554. }
  555. /**
  556. * Confirms the delete action.
  557. *
  558. * @param array $form_state
  559. * Form state array.
  560. *
  561. * @return array
  562. * Confirm form array.
  563. */
  564. function lti_tool_provider_consumer_confirm_delete_form($form, &$form_state, $consumer) {
  565. $form['consumer_delete'] = array(
  566. '#type' => 'value',
  567. '#value' => $consumer,
  568. );
  569. return confirm_form($form,
  570. t('Are you sure you want to delete the consumer @name?', array('@name' => $consumer->lti_tool_provider_consumer_consumer)),
  571. 'admin/config/lti-tool-provider/lti-tool-consumer/' . $consumer->lti_tool_provider_consumer_id,
  572. t('This action cannot be undone.'),
  573. t('Delete'),
  574. t('Cancel'));
  575. }
  576. /**
  577. * Submit handler for the consumer form delete.
  578. *
  579. * @param array $form
  580. * Form array
  581. * @param array $form_state
  582. * Form state array
  583. */
  584. function lti_tool_provider_consumer_confirm_delete_form_submit($form, &$form_state) {
  585. $consumer = $form['consumer_delete']['#value'];
  586. lti_tool_provider_consumer_delete($consumer);
  587. drupal_set_message(t('The consumer @name has been deleted.', array(
  588. '@name' => $consumer->lti_tool_provider_consumer_consumer,
  589. )));
  590. $form_state['redirect'] = 'admin/config/lti-tool-provider/lti-tool-consumers';
  591. }
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.