public function OpignoModuleManagerController::accessActivityUpdateWeight in Opigno module 8
Same name and namespace in other branches
- 3.x src/Controller/OpignoModuleManagerController.php \Drupal\opigno_module\Controller\OpignoModuleManagerController::accessActivityUpdateWeight()
Checks access for the activity update weight.
Parameters
\Drupal\Core\Session\AccountInterface $account: Current user.
Return value
\Drupal\Core\Access\AccessResult Access result.
1 string reference to 'OpignoModuleManagerController::accessActivityUpdateWeight'
File
- src/
Controller/ OpignoModuleManagerController.php, line 580
Class
- OpignoModuleManagerController
- Controller for all the actions of the Opigno module manager.
Namespace
Drupal\opigno_module\ControllerCode
public function accessActivityUpdateWeight(AccountInterface $account) {
$datas = json_decode(\Drupal::request()
->getContent());
// Check that current user can edit all parent Opigno modules.
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$omr_ids = array_map(function ($value) {
return $value->omr_id;
}, $datas->acitivies_weight);
$module_ids = $db_connection
->select('opigno_module_relationship', 'omr')
->fields('omr', [
'parent_id',
])
->condition('omr_id', $omr_ids, 'IN')
->groupBy('parent_id')
->execute()
->fetchCol();
$modules = OpignoModule::loadMultiple($module_ids);
foreach ($modules as $module) {
/** @var \Drupal\opigno_module\Entity\OpignoModule $module */
if (!$module
->access('update')) {
return AccessResult::forbidden();
}
}
return AccessResult::allowed();
}