public function OpignoModuleManagerController::ajaxCheckedActivities in Opigno module 8
Same name and namespace in other branches
- 3.x src/Controller/OpignoModuleManagerController.php \Drupal\opigno_module\Controller\OpignoModuleManagerController::ajaxCheckedActivities()
Ajax callback.
1 string reference to 'OpignoModuleManagerController::ajaxCheckedActivities'
File
- src/
Controller/ OpignoModuleManagerController.php, line 120
Class
- OpignoModuleManagerController
- Controller for all the actions of the Opigno module manager.
Namespace
Drupal\opigno_module\ControllerCode
public function ajaxCheckedActivities() {
if (!empty($_POST['data'])) {
$data = json_decode($_POST['data']);
$checkboxes_ids = !empty($_SESSION['activities_bank']['checkboxes_ids']) ? $_SESSION['activities_bank']['checkboxes_ids'] : [];
$activities_ids = !empty($_SESSION['activities_bank']['activities_ids']) ? $_SESSION['activities_bank']['activities_ids'] : [];
if (!empty($data->checked) && array_search($data->checked, $checkboxes_ids) === FALSE) {
$checkboxes_ids[] = $data->checked;
$activities_ids[] = $data->activityID;
}
elseif (!empty($data->unchecked)) {
$key = array_search($data->unchecked, $checkboxes_ids);
if ($key !== FALSE) {
unset($checkboxes_ids[$key]);
}
$key = array_search($data->activityID, $activities_ids);
if ($key !== FALSE) {
unset($activities_ids[$key]);
}
}
$_SESSION['activities_bank'] = [
'checkboxes_ids' => $checkboxes_ids,
'activities_ids' => $activities_ids,
];
}
die;
}