getField('id'); $canshowentity = Session::haveRight("entity", READ); $canedit = Session::haveRight('plugin_processmaker_config', UPDATE); $rand=mt_rand(); if ($canedit) { echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
".__('Authorizations', 'processmaker')."
"; echo ""; Entity::Dropdown( ['entity' => $_SESSION['glpiactiveentities']]); echo "".Profile::getTypeName(1).""; Profile::dropdownUnder(['value' => Profile::getDefault()]); echo "".__('Recursive').""; Dropdown::showYesNo("is_recursive", 0); echo ""; echo ""; echo "
"; Html::closeForm(); echo "
"; } $res = $DB->request([ 'SELECT' => [ 'gpp.id AS linkID', 'glpi_profiles.id', 'glpi_profiles.name', 'gpp.is_recursive', 'glpi_entities.completename', 'gpp.entities_id' ], 'DISTINCT' => true, 'FROM' => self::getTable() .' AS gpp', 'LEFT JOIN' => [ 'glpi_profiles' => [ 'FKEY' => [ 'glpi_profiles' => 'id', 'gpp' => 'profiles_id' ] ], 'glpi_entities' => [ 'FKEY' => [ 'glpi_entities' => 'id', 'gpp' => 'entities_id' ] ] ], 'WHERE' => [ 'gpp.plugin_processmaker_processes_id' => $ID ], 'ORDER' => [ 'glpi_profiles.name', 'glpi_entities.completename' ] ]); $num = $res->numrows(); echo "
"; Html::openMassiveActionsForm('mass'.__CLASS__.$rand); if ($canedit && $num) { $massiveactionparams = ['num_displayed' => $num, 'container' => 'mass'.__CLASS__.$rand]; Html::showMassiveActions($massiveactionparams); } if ($num > 0) { echo ""; $header_begin = ""; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= ""; } $header_end .= ""; $header_end .= ""; echo $header_begin.$header_top.$header_end; //while ($data = $DB->fetch_assoc($result)) { foreach ($res as $data) { echo ""; if ($canedit) { echo ""; } echo ""; if (Profile::canView()) { $entname = "". $data["name"].""; } else { $entname = $data["name"]; } if ($data["is_recursive"]) { $entname = sprintf('%1$s %2$s', $entname, "("); if ($data["is_recursive"]) { //TRANS: letter 'R' for Recursive $entname = sprintf('%1$s%2$s', $entname, __('R')); } $entname = sprintf('%1$s%2$s', $entname, ")"); } echo ""; echo ""; } echo $header_begin.$header_bottom.$header_end; echo "
"; $header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_end .= ""._n('Entity', 'Entities', Session::getPluralNumber())."".sprintf('%1$s (%2$s)', Profile::getTypeName(Session::getPluralNumber()), __('D=Dynamic, R=Recursive')); $header_end .= "
"; if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) { Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); } else { echo " "; } echo ""; $link = $data["completename"]; if ($_SESSION["glpiis_ids_visible"]) { $link = sprintf('%1$s (%2$s)', $link, $data["entities_id"]); } if ($canshowentity) { echo ""; } echo $link.($canshowentity ? "" : ''); echo "".$entname."
"; } else { echo ""; echo ""; echo "
".__('No item found')."
\n"; } if ($canedit && $num) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); } Html::closeForm(); echo "
"; } /** * Summary of prepareInputForAdd * @param mixed $input * @return mixed */ function prepareInputForAdd($input) { $tmp = new self; $restrict=[ 'WHERE' => [ 'plugin_processmaker_processes_id' => $input['plugin_processmaker_processes_id'], 'entities_id' => $input['entities_id'], 'profiles_id' => $input['profiles_id'] ], ]; if ($tmp->getFromDBByRequest($restrict)) { //// then update existing //$tmp->update(['id' => $tmp->getID(), // 'is_recursive' => $input['is_recursive']]); Session::addMessageAfterRedirect(__('Authorization not added: already existing!', 'processmaker'), true, WARNING); return []; // to cancel add } return $input; } }