showForUser() static public method

Show emails of a user
static public showForUser ( User $user ) : nothing
$user User User object
return nothing
Example #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;
 }