Skip to content

Commit

Permalink
Evarisk#1963 [Risk] fix: category should be disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-micka committed Apr 12, 2024
1 parent d4a0e05 commit f04d942
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
5 changes: 5 additions & 0 deletions admin/config/riskassessmentdocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
'code' => 'DIGIRISKDOLIBARR_SHOW_SHARED_RISKS',
'disabled' => !$areRisksSharable
],
'CategoryOnRisk' => [
'name' => 'CategoryOnRisk',
'description' => 'CategoryOnRiskDescription',
'code' => 'DIGIRISKDOLIBARR_CATEGORY_ON_RISK',
],
];

require __DIR__ . '/../../../saturne/core/tpl/admin/object/object_const_view.tpl.php';
Expand Down
5 changes: 3 additions & 2 deletions core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ public function __construct($db)
$i++ => ['DIGIRISKDOLIBARR_RISK_LIST_PARENT_VIEW', 'integer', 0, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_SHOW_INHERITED_RISKS_IN_DOCUMENTS', 'integer', 0, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_SHOW_INHERITED_RISKS_IN_LISTINGS', 'integer', 0, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_SHOW_SHARED_RISKS', 'integer', 0, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_SHOW_SHARED_RISKS', 'integer', 0, '', 0, 'current'],
$i++ => ['DIGIRISKDOLIBARR_CATEGORY_ON_RISK', 'integer', 0, '', 0, 'current'],

// CONST RISK ASSESSMENT
$i++ => ['DIGIRISKDOLIBARR_MAIN_AGENDA_ACTIONAUTO_RISKASSESSMENT_CREATE', 'integer', 1, '', 0, 'current'],
Expand Down Expand Up @@ -1399,7 +1400,7 @@ public function __construct($db)
'url' => '/categories/index.php?type=risk',
'langs' => 'digiriskdolibarr@digiriskdolibarr',
'position' => 100 + $r,
'enabled' => '$conf->digiriskdolibarr->enabled && $conf->categorie->enabled && $user->rights->digiriskdolibarr->risk->read',
'enabled' => '$conf->digiriskdolibarr->enabled && $conf->categorie->enabled && $user->rights->digiriskdolibarr->risk->read && $conf->global->DIGIRISKDOLIBARR_CATEGORY_ON_RISK',
'perms' => '$user->rights->digiriskdolibarr->risk->read',
'target' => '',
'user' => 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$result = $risk->create($user);

if ($result > 0) {
if (isModEnabled('categorie')) {
if (isModEnabled('categorie') && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
$categories = $data['categories'];
if (method_exists($risk, 'setCategories')) {
$risk->setCategories($categories);
Expand Down Expand Up @@ -171,7 +171,7 @@
$result = $risk->update($user);

if ($result > 0) {
if (isModEnabled('categorie')) {
if (isModEnabled('categorie') && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
$categories = $data['categories'];
if (method_exists($risk, 'setCategories')) {
$risk->setCategories($categories);
Expand Down
36 changes: 16 additions & 20 deletions core/tpl/riskanalysis/risk/digiriskdolibarr_risklist_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
$sql .= " FROM " . MAIN_DB_PREFIX . $risk->table_element . " as r";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $digiriskelement->table_element . " as e on (r.fk_element = e.rowid)";
if (is_array($extrafields->attributes[$risk->table_element]['label']) && count($extrafields->attributes[$risk->table_element]['label'])) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $risk->table_element . "_extrafields as ef on (r.rowid = ef.fk_object)";
if (!empty($conf->categorie->enabled)) $sql .= Categorie::getFilterJoinQuery('risk', "r.rowid");
if (!empty($conf->categorie->enabled) && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) $sql .= Categorie::getFilterJoinQuery('risk', "r.rowid");
if ($risk->ismultientitymanaged == 1) $sql .= " WHERE r.entity IN (" . getEntity($risk->element) . ")";
else $sql .= " WHERE 1 = 1";

Expand Down Expand Up @@ -393,7 +393,7 @@
}
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
if (!empty($conf->categorie->enabled)) {
if (!empty($conf->categorie->enabled) && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
$sql .= Categorie::getFilterSelectQuery('risk', 'r.rowid', $search_category_array);
}
// Add where from extra fields
Expand Down Expand Up @@ -459,7 +459,7 @@
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $digiriskelement->table_element . " as e on (r.fk_element = e.rowid)";
if (is_array($extrafields->attributes[$evaluation->table_element]['label']) && count($extrafields->attributes[$evaluation->table_element]['label'])) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $evaluation->table_element . "_extrafields as ef on (evaluation.rowid = ef.fk_object)";
if ($sortfield == 'evaluation.has_tasks') $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_task_extrafields as taskextrafields ON (taskextrafields.fk_risk = r.rowid)';
if (!empty($conf->categorie->enabled)) $sql .= Categorie::getFilterJoinQuery('risk', "r.rowid");
if (!empty($conf->categorie->enabled) && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) $sql .= Categorie::getFilterJoinQuery('risk', "r.rowid");
if ($evaluation->ismultientitymanaged == 1) $sql .= " WHERE evaluation.entity IN (" . getEntity($evaluation->element) . ")";
else $sql .= " WHERE 1 = 1";
$sql .= " AND evaluation.status = 1";
Expand Down Expand Up @@ -504,7 +504,7 @@
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);

if (!empty($conf->categorie->enabled)) {
if (!empty($conf->categorie->enabled) && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
$sql .= Categorie::getFilterSelectQuery('risk', 'r.rowid', $search_category_array);
}

Expand Down Expand Up @@ -736,7 +736,7 @@ class="risk-evaluation-cotation cotation"><?php echo $shownCotation; ?></div>
</div>
<?php endif; ?>
<?php
if (!empty($conf->categorie->enabled)) {
if (!empty($conf->categorie->enabled) && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
print '<div class="risk-categories"><span class="title">'.$langs->trans("Categories") . '</span>';
$categoryArborescence = $form->select_all_categories('risk', '', 'parent', 64, 0, 1);
print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $categoryArborescence, GETPOST('categories', 'array'), '', 0, 'maxwidth300');
Expand Down Expand Up @@ -852,15 +852,13 @@ class="risk-evaluation-cotation cotation"><?php echo $shownCotation; ?></div>
<?php endif; ?>
</div>
<?php
if (!empty($conf->categorie->enabled)) {
print '<div class="risk-categories"><span class="title">'.$langs->trans("Categories") . '</span>';
$categoryArborescence = $form->select_all_categories('risk', '', 'parent', 64, 0, 1);
print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $categoryArborescence, GETPOST('categories', 'array'), '', 0, 'maxwidth300');
print '<a class="butActionNew" href="' . DOL_URL_ROOT . '/categories/index.php?type=risk&backtopage=' . urlencode($_SERVER['PHP_SELF'] . '?action=create') . '" target="_blank"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans('AddCategories') . '"></span></a>';
print "</div>";
}
?>
<hr>
if (!empty($conf->categorie->enabled) && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
print '<div class="risk-categories"><span class="title">'.$langs->trans("Categories") . '</span>';
$categoryArborescence = $form->select_all_categories('risk', '', 'parent', 64, 0, 1);
print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $categoryArborescence, GETPOST('categories', 'array'), '', 0, 'maxwidth300');
print '<a class="butActionNew" href="' . DOL_URL_ROOT . '/categories/index.php?type=risk&backtopage=' . urlencode($_SERVER['PHP_SELF'] . '?action=create') . '" target="_blank"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans('AddCategories') . '"></span></a>';
print "</div><hr>";
} ?>
<div class="risk-evaluation-container standard">
<span class="section-title"><?php echo ' ' . $langs->trans('RiskAssessment'); ?></span>
<div class="risk-evaluation-header">
Expand Down Expand Up @@ -1042,7 +1040,7 @@ class="risk-evaluation-cotation cotation"><?php echo $shownCotation; ?></div>
else $moreforfilter = $hookmanager->resPrint;

// Filter on categories
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
$formcategory = new FormCategory($db);
$moreforfilter = $formcategory->getFilterBox('risk', $search_category_array);
}
Expand Down Expand Up @@ -1318,7 +1316,7 @@ class="risk-evaluation-cotation cotation"><?php echo $shownCotation; ?></div>
</div>
<?php
// Tags-Categories
if ($conf->categorie->enabled) {
if ($conf->categorie->enabled && getDolGlobalInt('DIGIRISKDOLIBARR_CATEGORY_ON_RISK') > 0) {
print '<div class="risk-categories"><span class="title">'.$langs->trans("Categories").'</span>';
$categoryArborescence = $form->select_all_categories('risk', '', 'parent', 64, 0, 1);
$c = new Categorie($db);
Expand All @@ -1331,10 +1329,8 @@ class="risk-evaluation-cotation cotation"><?php echo $shownCotation; ?></div>
}
print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories_risk' . $risk->id, $categoryArborescence, $arrayselected, '', 0, 'maxwidth300');
print '<a class="butActionNew" href="' . DOL_URL_ROOT . '/categories/index.php?type=risk&backtopage=' . urlencode($_SERVER['PHP_SELF'] . '?action=create') . '" target="_blank"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans('AddCategories') . '"></span></a>';
print '</div>';
}
?>
<hr>
print '</div><hr>';
} ?>
<div class="move-risk <?php echo $conf->global->DIGIRISKDOLIBARR_MOVE_RISKS ? '' : 'move-disabled'?>">
<span class="title"><?php echo $langs->trans('MoveRisk'); ?></span>
<?php if (is_object($activeDigiriskElementList[$risk->fk_element])) {
Expand Down
2 changes: 2 additions & 0 deletions langs/fr_FR/digiriskdolibarr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@ DefaultProjectContactType = Rôle par défaut attribué au projet
DefaultTaskContactType = Rôle par défaut attribué aux tâches du projet Document Unique
RiskListParentView = Afficher tous les éléments parents
RiskListParentViewDescription = Afficher tous les éléments parents d'un risque dans la liste des risques
CategoryOnRisk = Afficher les tags/catégories sur les risques
CategoryOnRiskDescription = Permet d'attribuer des tags/catégories aux risques et de les afficher - à minipuler avec précaution.

# Stats - Statistiques
GreyRisk = Risque faible
Expand Down

0 comments on commit f04d942

Please sign in to comment.