displayRightsChoiceMatrix() public method

Display rights choice matrix
public displayRightsChoiceMatrix ( array $rights, array $options = [] ) : random
$rights array array possible: 'itemtype' => the type of the item to check (as passed to self::getRightsFor()) 'rights' => when use of self::getRightsFor() is impossible 'label' => the label for the right 'field' => the name of the field inside the DB and HTML form (prefixed by '_') 'html_field' => when $html_field != '_'.$field
$options array array possible: 'title' the title of the matrix 'canedit' 'default_class' the default CSS class used for the row
return random value used to generate the ids
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = array(array('itemtype' => 'PluginAddressingAddressing', 'label' => __('Generate reports', 'addressing'), 'field' => 'plugin_addressing'));
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_addressing_use_ping_in_equipment'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Use ping on equipment form', 'addressing') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_addressing_use_ping_in_equipment[1_0]', 'checked' => $effective_rights['plugin_addressing_use_ping_in_equipment']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
Exemplo n.º 2
0
 function showForm($ID, $options = array())
 {
     global $LANG;
     if (!Profile::canView()) {
         return false;
     }
     $canedit = self::canUpdate();
     $profile = new Profile();
     if ($ID) {
         //$this->getFromDBByProfile($ID);
         $profile->getFromDB($ID);
     }
     if ($canedit) {
         echo "<form action='" . $profile->getFormURL() . "' method='post'>";
     }
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2'));
     if ($canedit) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value=" . $ID . ">";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>";
     }
     Html::closeForm();
     $this->showLegend();
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     if ($profile->getField('interface') == 'central') {
         $rights = $this->getAllRights();
         $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Helpdesk') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_racks_open_ticket'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Associable items to a ticket') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_racks_open_ticket', 'checked' => $effective_rights['plugin_racks_open_ticket']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * @param $prof   Profile object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB;
     $canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE));
     if ($canedit) {
         echo "<form method='post' action='" . $prof->getFormURL() . "'>";
     }
     $rights = self::getAllRights();
     $prof->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Rights management by profil', 'reports')));
     if ($canedit) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $prof->getField('id')));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     $profile = new Profile();
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile->getFromDB($profiles_id);
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Reforme', 'reforme')));
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         echo Html::closeForm(false);
     }
     echo "</div>";
 }
Exemplo n.º 6
0
 function showForm($ID, $options = array())
 {
     global $DB;
     $profile = new Profile();
     if ($ID) {
         $this->getFromDB($ID);
         $profile->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     if ($canedit = self::canUpdate()) {
         $options['colspan'] = 1;
         $options['target'] = $profile->getFormURL();
         $this->fields["id"] = $ID;
         $this->showFormHeader($options);
     }
     $rights = $this->getGeneralRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2'));
     if ($canedit) {
         $options['candel'] = false;
         $this->showFormButtons($options);
     }
 }
Exemplo n.º 7
0
 function showForm($profiles_id, $options = array())
 {
     if (!Session::haveRight("profile", READ)) {
         return false;
     }
     $canedit = Session::haveRight("profile", UPDATE);
     //if ($id) {
     //   $this->getProfilesFromDB($id);
     //}
     //Ensure rights are defined in database
     self::installRights();
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     echo "<form action='" . Profile::getFormUrl() . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     $general_rights = self::getGeneralRights();
     $profile->displayRightsChoiceMatrix($general_rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General', 'genericobject')));
     $types_rights = self::getTypesRights();
     $title = __('Objects', 'genericobject');
     if (count($types_rights) == 0) {
         $title .= __(" (No types defined yet)", "genericobject");
     }
     $profile->displayRightsChoiceMatrix($types_rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => $title));
     $profile->showLegend();
     if ($canedit) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = $this->getRightsGeneral();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General', 'fusioninventory')));
     $rights = $this->getRightsRules();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => _n('Rule', 'Rules', 2)));
     $rights = $this->getRightsInventory();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Inventory', 'fusioninventory')));
     $rights = $this->getRightsDeploy();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('Software deployment', 'fusioninventory')));
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
     $this->showLegend();
 }
Exemplo n.º 9
0
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $options = array())
 {
     echo "<div class='firstbloc'>";
     $profile = new Profile();
     if ($profiles_id > 0) {
         $profile->check($profiles_id, READ);
     } else {
         // Create item
         $profile->check(-1, CREATE);
     }
     $profile->showFormHeader($options);
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Advanced', 'consumables') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_consumables_user', 'plugin_consumables_group', 'plugin_consumables_validation', 'plugin_consumables_request'));
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Consumable validation', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_validation[1_0]', 'checked' => $effective_rights['plugin_consumables_validation']));
     echo "<td>" . __('Make a consumable request', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_request[1_0]', 'checked' => $effective_rights['plugin_consumables_request']));
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Make a consumable request for all users', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_user[1_0]', 'checked' => $effective_rights['plugin_consumables_user']));
     echo "</td>";
     echo "<td>" . __('Make a consumable request for my groups', 'consumables') . "</td>";
     echo "<td>";
     Html::showCheckbox(array('name' => '_plugin_consumables_group[1_0]', 'checked' => $effective_rights['plugin_consumables_group']));
     echo "</td>";
     echo "</tr>\n";
     $profile->showFormButtons($options);
     echo "</div>";
 }
 public function showForm($profiles_id, $options = array())
 {
     global $LANG;
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     if ($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) {
         echo "<form action='" . $profile->getFormURL() . "' method='post'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => $LANG['plugin_news']['title']));
     if ($canedit) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     HTML::closeForm();
 }
Exemplo n.º 11
0
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     global $DB, $CFG_GLPI;
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form action='" . $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/profile.form.php' method='post'>";
     }
     //Delegating
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_ocsinventoryng'));
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='4' class='center b'>" . sprintf(__('%1$s - %2$s'), 'OcsinventoryNG', $profile->fields["name"]) . "</th>";
     echo "</tr>";
     $used = array();
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s : %2$s'), _n('Allowed OCSNG server', 'Allowed OCSNG servers', 2, 'ocsinventoryng'), "&nbsp;");
     //$profile = $this->fields['id'];
     $crit = array('profiles_id' => $profiles_id);
     foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers_profiles", $crit) as $data) {
         $used[$data['plugin_ocsinventoryng_ocsservers_id']] = $data['plugin_ocsinventoryng_ocsservers_id'];
         $configid[$data['plugin_ocsinventoryng_ocsservers_id']] = $data['id'];
     }
     if (Session::haveRight("profile", UPDATE)) {
         Dropdown::show('PluginOcsinventoryngOcsServer', array('width' => '50%', 'used' => $used, 'value' => '', 'condition' => "is_active = 1"));
         echo "&nbsp;&nbsp;<input type='hidden' name='profile' value='{$profiles_id}'>";
         echo "&nbsp;&nbsp;<input type='submit' name='addocsserver' value=\"" . _sx('button', 'Add') . "\" class='submit' >";
     }
     echo "</td><td>";
     echo "<table width='100%'><tr class='tab_bg_1'><td>";
     $nbservers = countElementsInTable('glpi_plugin_ocsinventoryng_ocsservers_profiles', "`profiles_id` = " . $profiles_id);
     $query = "SELECT `glpi_plugin_ocsinventoryng_ocsservers`.`id`,\n                       `glpi_plugin_ocsinventoryng_ocsservers`.`name`\n                FROM `glpi_plugin_ocsinventoryng_ocsservers_profiles`\n                LEFT JOIN `glpi_plugin_ocsinventoryng_ocsservers`\n                   ON `glpi_plugin_ocsinventoryng_ocsservers_profiles`.`plugin_ocsinventoryng_ocsservers_id` = `glpi_plugin_ocsinventoryng_ocsservers`.`id`\n                WHERE `profiles_id`= " . $_SESSION["glpiactiveprofile"]['id'] . "\n                ORDER BY `name` ASC";
     $result = $DB->query($query);
     if ($data = $DB->fetch_assoc($result)) {
         $ocsserver = new PluginOcsinventoryngOcsServer();
         foreach ($used as $id) {
             if ($ocsserver->getFromDB($id)) {
                 echo "<br>";
                 if (Session::haveRight("profile", UPDATE)) {
                     echo "<input type='checkbox' name='item[" . $configid[$id] . "]' value='1'>";
                 }
                 if ($data['id'] == $id) {
                     echo $ocsserver->getLink();
                 } else {
                     echo $ocsserver->getName();
                 }
             }
         }
     }
     if (!$nbservers) {
         _e('None');
     }
     echo "</td></tr>";
     if ($nbservers && Session::haveRight("profile", UPDATE)) {
         echo "<tr class='tab_bg_1 center'><td>";
         echo "<input type='submit' name='delete' value='Supprimer' class='submit' >";
         echo "</td></tr>";
     }
     echo "</table>";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }