getDropdownArrayNames() статический публичный Метод

Get values of a dropdown for a list of item
static public getDropdownArrayNames ( $table, $ids ) : array
$table the dropdown table from witch we want values on the select
$ids array containing the ids to get
Результат array containing the value of the dropdown or   if not exists
Пример #1
0
 /**
  * Print the user preference form
  *
  * @param $target          form target
  * @param $ID     integer  Id of the user
  *
  * @return boolean : user found
  **/
 function showMyForm($target, $ID)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) {
         return false;
     }
     if ($this->getFromDB($ID)) {
         $authtype = $this->getAuthMethodsByID();
         $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
         // No autocopletion :
         $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"];
         $CFG_GLPI["use_ajax_autocompletion"] = false;
         echo "<div class='center'>";
         echo "<form method='post' name='user_manager' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Login'), $this->fields["name"]);
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
         if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) {
             echo $this->fields["realname"];
         } else {
             Html::autocompletionTextField($this, "realname");
         }
         echo "</td>";
         //do some rights verification
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<td>" . __('Password') . "</td>";
             echo "<td><input id='password' type='password' name='password' value='' size='30' autocomplete='off' onkeyup=\"return passwordCheck();\">";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'></tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
         if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
             echo $this->fields["firstname"];
         } else {
             Html::autocompletionTextField($this, "firstname");
         }
         echo "</td>";
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<td>" . __('Password confirmation') . "</td>";
             echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'></tr>";
         }
         echo "<tr class='tab_bg_1'><td class='top'>" . _n('Email', 'Emails', 2);
         UserEmail::showAddEmailButton($this);
         echo "</td><td>";
         UserEmail::showForUser($this);
         echo "</td>";
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<td>" . __('Password security policy') . "</td>";
             echo "<td>";
             Config::displayPasswordSecurityChecks();
             echo "</td>";
         } else {
             echo "<td colspan='2'>";
         }
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
             echo $this->fields["mobile"];
         } else {
             Html::autocompletionTextField($this, "mobile");
         }
         echo "</td>";
         if (!GLPI_DEMO_MODE) {
             echo "<td>" . __('Language') . "</td><td>";
             // Use session variable because field in table may be null if same of the global config
             Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>";
         if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
             echo $this->fields["phone"];
         } else {
             Html::autocompletionTextField($this, "phone");
         }
         echo "</td>";
         if (count($_SESSION['glpiprofiles']) > 1) {
             echo "<td>" . __('Default profile') . "</td><td>";
             $options = array(0 => Dropdown::EMPTY_VALUE);
             $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>";
         if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
             echo $this->fields["phone2"];
         } else {
             Html::autocompletionTextField($this, "phone2");
         }
         echo "</td>";
         $entities = Profile_User::getUserEntities($this->fields['id'], 1);
         if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
             echo "<td>" . __('Default entity') . "</td><td>";
             Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
         $entities = Profile_User::getUserEntities($ID, true);
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities));
         if (Session::haveRight("config", "w")) {
             echo "<td>" . __('Use GLPI in mode') . "</td><td>";
             $modes[Session::NORMAL_MODE] = __('Normal');
             //$modes[Session::TRANSLATION_MODE] = __('Translation');
             $modes[Session::DEBUG_MODE] = __('Debug');
             Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * Print the user preference form
  *
  * @param $target form target
  * @param $ID Integer : Id of the user
  *
  * @return boolean : user found
  **/
 function showMyForm($target, $ID)
 {
     global $CFG_GLPI, $LANG, $PLUGIN_HOOKS;
     // Affiche un formulaire User
     if ($ID != getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) {
         return false;
     }
     if ($this->getFromDB($ID)) {
         $authtype = $this->getAuthMethodsByID();
         $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
         // No autocopletion :
         $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"];
         $CFG_GLPI["use_ajax_autocompletion"] = false;
         echo "<div class='center'>";
         echo "<form method='post' name='user_manager' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . $LANG['setup'][18] . "&nbsp;: " . $this->fields["name"];
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . $LANG['common'][48] . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) {
             echo $this->fields["realname"];
         } else {
             autocompletionTextField($this, "realname");
         }
         echo "</td>";
         //do some rights verification
         if (!$extauth && haveRight("password_update", "1")) {
             echo "<td>" . $LANG['setup'][19] . "&nbsp;:</td>";
             echo "<td><input type='password' name='password' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'></tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . $LANG['common'][43] . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
             echo $this->fields["firstname"];
         } else {
             autocompletionTextField($this, "firstname");
         }
         echo "</td>";
         if (!$extauth && haveRight("password_update", "1")) {
             echo "<td>" . $LANG['setup'][20] . "&nbsp;:</td>";
             echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'></tr>";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][14] . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['email_field']) && !empty($authtype['email_field'])) {
             echo $this->fields["email"];
         } else {
             autocompletionTextField($this, "email", array('name' => "email_form"));
             if (!NotificationMail::isUserAddressValid($this->fields["email"])) {
                 echo "<br><span class='red'>" . $LANG['mailing'][110] . "</span>";
             }
         }
         echo "</td>";
         if (!GLPI_DEMO_MODE) {
             echo "<td>" . $LANG['setup'][41] . "&nbsp;:</td><td>";
             /// Use sesion variable because field in table may be null if same of the global config
             Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . $LANG['common'][42] . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
             echo $this->fields["mobile"];
         } else {
             autocompletionTextField($this, "mobile");
         }
         echo "</td>";
         if (count($_SESSION['glpiprofiles']) > 1) {
             echo "<td>" . $LANG['profiles'][13] . "&nbsp;:</td><td>";
             $options = array(0 => DROPDOWN_EMPTY_VALUE);
             $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
             echo $this->fields["phone"];
         } else {
             autocompletionTextField($this, "phone");
         }
         echo "</td>";
         if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
             $entities = Profile_User::getUserEntities($this->fields['id'], 1);
             echo "<td>" . $LANG['profiles'][37] . "&nbsp;:</td><td>";
             Dropdown::show('Entity', array('value' => $this->fields['entities_id'], 'entity' => $entities));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . " 2 : </td><td>";
         if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
             echo $this->fields["phone2"];
         } else {
             autocompletionTextField($this, "phone2");
         }
         echo "</td>";
         if (haveRight("config", "w")) {
             echo "<td>" . $LANG['setup'][138] . "&nbsp;:</td><td>";
             $modes[NORMAL_MODE] = $LANG['setup'][135];
             $modes[TRANSLATION_MODE] = $LANG['setup'][136];
             $modes[DEBUG_MODE] = $LANG['setup'][137];
             Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></form></div>";
         $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
         return true;
     }
     return false;
 }