示例#1
0
 /**
  * Print the user form
  *
  * @param $ID        integer : Id of the user
  * @param $options   array
  *     - target form target
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean : user found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !self::canView()) {
         return false;
     }
     $this->initForm($ID, $options);
     if ($ID) {
         $caneditpassword = $this->currentUserHaveMoreRightThan($ID);
     } else {
         // can edit on creation form
         $caneditpassword = true;
     }
     $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
     $options['formoptions'] = " enctype='multipart/form-data'";
     $this->showFormHeader($options);
     $rand = mt_rand();
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Login') . "</td>";
     // si on est dans le cas d'un ajout , cet input ne doit plus etre hidden
     if ($this->fields["name"] == "") {
         echo "<td><input name='name' value=\"" . $this->fields["name"] . "\"></td>";
         // si on est dans le cas d'un modif on affiche la modif du login si ce n'est pas une auth externe
     } else {
         if (!empty($this->fields["password"]) || $this->fields["authtype"] == Auth::DB_GLPI) {
             echo "<td>";
             echo "<input name='name' value=\"" . $this->fields["name"] . "\"></td>";
         } else {
             echo "<td class='b'>" . $this->fields["name"];
             echo "<input type='hidden' name='name' value=\"" . $this->fields["name"] . "\"></td>";
         }
     }
     if (!empty($this->fields["name"])) {
         echo "<td rowspan='3'>" . __('Picture') . "</td>";
         echo "<td rowspan='3'>";
         echo "<div class='user_picture_border_small' id='picture{$rand}'>";
         echo "<img class='user_picture_small' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($this->fields['picture']) . "'>";
         //         echo "<img src='".self::getURLForPicture($this->fields["picture"])."' class='user_picture'/>";
         echo "</div>";
         $full_picture = "<div class='user_picture_border'>";
         $full_picture .= "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getURLForPicture($this->fields['picture']) . "'>";
         $full_picture .= "</div>";
         Html::showTooltip($full_picture, array('applyto' => "picture{$rand}"));
         echo "<input type='file' name='picture' accept='image/*'>";
         echo "<input type='checkbox' name='_blank_picture'>&nbsp;" . __('Clear');
         echo "</td>";
     } else {
         echo "<td rowspan='3'></td>";
         echo "<td rowspan='3'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
     Html::autocompletionTextField($this, "realname");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
     Html::autocompletionTextField($this, "firstname");
     echo "</td></tr>";
     //do some rights verification
     if (self::canUpdate() && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Password') . "</td>";
         echo "<td><input id='password' type='password' name='password' value='' size='20'\n                    autocomplete='off' onkeyup=\"return passwordCheck();\"></td>";
         echo "<td rowspan='2'>" . __('Password security policy') . "</td>";
         echo "<td rowspan='2'>";
         Config::displayPasswordSecurityChecks();
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Password confirmation') . "</td>";
         echo "<td><input type='password' name='password2' value='' size='20' autocomplete='off'>";
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1'>";
     if (!GLPI_DEMO_MODE) {
         echo "<td>" . __('Active') . "</td><td>";
         Dropdown::showYesNo('is_active', $this->fields['is_active']);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "<td>" . _n('Email', 'Emails', Session::getPluralNumber());
     UserEmail::showAddEmailButton($this);
     echo "</td><td>";
     UserEmail::showForUser($this);
     echo "</td>";
     echo "</tr>";
     if (!GLPI_DEMO_MODE) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Valid since') . "</td><td>";
         Html::showDateTimeField("begin_date", array('value' => $this->fields["begin_date"], 'timestep' => 1, 'maybeempty' => true));
         echo "</td>";
         echo "<td>" . __('Valid until') . "</td><td>";
         Html::showDateTimeField("end_date", array('value' => $this->fields["end_date"], 'timestep' => 1, 'maybeempty' => true));
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone') . "</td><td>";
     Html::autocompletionTextField($this, "phone");
     echo "</td>";
     //Authentications information : auth method used and server used
     //don't display is creation of a new user'
     if (!empty($ID)) {
         if (Session::haveRight(self::$rightname, self::READAUTHENT)) {
             echo "<td>" . __('Authentication') . "</td><td>";
             echo Auth::getMethodName($this->fields["authtype"], $this->fields["auths_id"]);
             if (!empty($this->fields["date_sync"])) {
                 //TRANS: %s is the date of last sync
                 echo '<br>' . sprintf(__('Last synchronization on %s'), HTML::convDateTime($this->fields["date_sync"]));
             }
             if (!empty($this->fields["user_dn"])) {
                 //TRANS: %s is the user dn
                 echo '<br>' . sprintf(__('%1$s: %2$s'), __('User DN'), $this->fields["user_dn"]);
             }
             if ($this->fields['is_deleted_ldap']) {
                 echo '<br>' . __('User missing in LDAP directory');
             }
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
     } else {
         echo "<td colspan='2'><input type='hidden' name='authtype' value='1'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Mobile phone') . "</td><td>";
     Html::autocompletionTextField($this, "mobile");
     echo "</td>";
     echo "<td>" . __('Category') . "</td><td>";
     UserCategory::dropdown(array('value' => $this->fields["usercategories_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone 2') . "</td><td>";
     Html::autocompletionTextField($this, "phone2");
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='6' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Administrative number') . "</td><td>";
     Html::autocompletionTextField($this, "registration_number");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . _x('person', 'Title') . "&nbsp;:</td><td>";
     UserTitle::dropdown(array('value' => $this->fields["usertitles_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     if (!empty($ID)) {
         echo "<td>" . __('Location') . "</td><td>";
         $entities = Profile_User::getUserEntities($ID, true);
         if (count($entities) <= 0) {
             $entities = -1;
         }
         Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $entities));
         echo "</td>";
     }
     echo "</tr>";
     if (empty($ID)) {
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='2'>" . _n('Authorization', 'Authorizations', 1) . "</th>";
         echo "<td>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("_is_recursive", 0);
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Profile') . "</td><td>";
         Profile::dropdownUnder(array('name' => '_profiles_id', 'value' => Profile::getDefault()));
         echo "</td><td>" . __('Entity') . "</td><td>";
         Entity::dropdown(array('name' => '_entities_id', 'display_emptychoice' => false, 'entity' => $_SESSION['glpiactiveentities']));
         echo "</td></tr>";
     } else {
         if ($caneditpassword) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Default profile') . "</td><td>";
             $options = Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"], 'display_emptychoice' => true));
             echo "</td><td>" . __('Default entity') . "</td><td>";
             $entities = Profile_User::getUserEntities($this->fields['id'], 1);
             Entity::dropdown(array('value' => $this->fields["entities_id"], 'entity' => $entities));
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         //TRANS: %s is the date
         printf(__('Last update on %s'), HTML::convDateTime($this->fields["date_mod"]));
         echo "<br>";
         printf(__('Last login on %s'), HTML::convDateTime($this->fields["last_login"]));
         echo "</td><td colspan='2'class='center'>";
         if ($ID > 0) {
             echo "<a target='_blank' href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?getvcard=1&amp;id={$ID}'>" . __('Vcard') . "</a>";
         }
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
示例#2
0
 /**
  * Print the user form
  *
  * @param $ID        integer : Id of the user
  * @param $options   array
  *     - target form target
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean : user found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !Session::haveRight("user", "r")) {
         return false;
     }
     $this->initForm($ID, $options);
     if ($ID) {
         $caneditpassword = $this->currentUserHaveMoreRightThan($ID);
     } else {
         // can edit on creation form
         $caneditpassword = true;
     }
     $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Login') . "</td>";
     // si on est dans le cas d'un ajout , cet input ne doit plus etre hidden
     if ($this->fields["name"] == "") {
         echo "<td><input name='name' value=\"" . $this->fields["name"] . "\"></td>";
         // si on est dans le cas d'un modif on affiche la modif du login si ce n'est pas une auth externe
     } else {
         if (!empty($this->fields["password"]) || $this->fields["authtype"] == Auth::DB_GLPI) {
             echo "<td>";
             echo "<input name='name' value=\"" . $this->fields["name"] . "\">";
         } else {
             echo "<td class='b'>" . $this->fields["name"];
             echo "<input type='hidden' name='name' value=\"" . $this->fields["name"] . "\">";
         }
         echo "</td>";
     }
     //do some rights verification
     if (Session::haveRight("user", "w") && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<td>" . __('Password') . "</td>";
         echo "<td><input id='password' type='password' name='password' value='' size='20'\n                    autocomplete='off' onkeyup=\"return passwordCheck();\">";
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
     Html::autocompletionTextField($this, "realname");
     echo "</td>";
     //do some rights verification
     if (Session::haveRight("user", "w") && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<td>" . __('Password confirmation') . "</td>";
         echo "<td><input type='password' name='password2' value='' size='20' autocomplete='off'>";
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
     Html::autocompletionTextField($this, "firstname");
     echo "</td>";
     if (Session::haveRight("user", "w") && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<td>" . __('Password security policy') . "</td>";
         echo "<td>";
         Config::displayPasswordSecurityChecks();
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Email', 'Emails', 2);
     UserEmail::showAddEmailButton($this);
     echo "</td><td>";
     UserEmail::showForUser($this);
     echo "</td>";
     //Authentications information : auth method used and server used
     //don't display is creation of a new user'
     if (!empty($ID)) {
         if (Session::haveRight("user_authtype", "r")) {
             echo "<td>" . __('Authentication') . "</td><td>";
             echo Auth::getMethodName($this->fields["authtype"], $this->fields["auths_id"]);
             if (!empty($this->fields["date_sync"])) {
                 //TRANS: %s is the date of last sync
                 echo '<br>' . sprintf(__('Last synchronization on %s'), HTML::convDateTime($this->fields["date_sync"]));
             }
             if (!empty($this->fields["user_dn"])) {
                 //TRANS: %s is the user dn
                 echo '<br>' . sprintf(__('%1$s: %2$s'), __('User DN'), $this->fields["user_dn"]);
             }
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
     } else {
         echo "<td colspan='2'><input type='hidden' name='authtype' value='1'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone') . "</td><td>";
     Html::autocompletionTextField($this, "phone");
     echo "</td>";
     echo "<td>" . __('Active') . "</td><td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Mobile phone') . "</td><td>";
     Html::autocompletionTextField($this, "mobile");
     echo "</td>";
     echo "<td>" . __('Category') . "</td><td>";
     UserCategory::dropdown(array('value' => $this->fields["usercategories_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone 2') . "</td><td>";
     Html::autocompletionTextField($this, "phone2");
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='6' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Administrative number') . "</td><td>";
     Html::autocompletionTextField($this, "registration_number");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . _x('person', 'Title') . "&nbsp;:</td><td>";
     UserTitle::dropdown(array('value' => $this->fields["usertitles_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
     if (!empty($ID)) {
         $entities = Profile_User::getUserEntities($ID, true);
         if (count($entities) > 0) {
             Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $entities));
         } else {
             echo "&nbsp;";
         }
     } else {
         if (!Session::isMultiEntitiesMode()) {
             // Display all locations : only one entity
             Location::dropdown(array('value' => $this->fields["locations_id"]));
         } else {
             echo "&nbsp;";
         }
     }
     echo "</td></tr>";
     if (empty($ID)) {
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='2'>" . _n('Authorization', 'Authorizations', 1) . "</th>";
         echo "<td>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("_is_recursive", 0);
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Profile') . "</td><td>";
         Profile::dropdownUnder(array('name' => '_profiles_id', 'value' => Profile::getDefault()));
         echo "</td><td>" . __('Entity') . "</td><td>";
         Entity::dropdown(array('name' => '_entities_id', 'display_emptychoice' => false, 'entity' => $_SESSION['glpiactiveentities']));
         echo "</td></tr>";
     } else {
         if ($caneditpassword) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Default profile') . "</td><td>";
             $options[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"]));
             echo "</td><td>" . __('Default entity') . "</td><td>";
             $entities = Profile_User::getUserEntities($this->fields['id'], 1);
             Entity::dropdown(array('value' => $this->fields["entities_id"], 'entity' => $entities));
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         //TRANS: %s is the date
         printf(__('Last update on %s'), HTML::convDateTime($this->fields["date_mod"]));
         echo "<br>";
         printf(__('Last login on %s'), HTML::convDateTime($this->fields["last_login"]));
         echo "</td><td colspan='2'class='center'>";
         if ($ID > 0) {
             echo "<a target='_blank' href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?getvcard=1&amp;id={$ID}'>" . __('Vcard') . "</a>";
         }
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
示例#3
0
 /**
  * Print the contact form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Surname') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='4' class='middle right'>" . __('Comments') . "</td>";
     echo "<td class='middle' rowspan='4'>";
     echo "<textarea cols='45' rows='7' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('First name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "firstname");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "phone");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone 2') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "phone2");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Mobile phone') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "mobile");
     echo "</td>";
     echo "<td class='middle'>" . __('Address') . "</td>";
     echo "<td class='middle'>";
     echo "<textarea cols='37' rows='3' name='address'>" . $this->fields["address"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Fax') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "fax");
     echo "</td>";
     echo "<td>" . __('Postal code') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "postcode", array('size' => 10));
     echo "&nbsp;&nbsp;" . __('City') . "&nbsp;";
     Html::autocompletionTextField($this, "town", array('size' => 23));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Email', 'Emails', 1) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "email");
     echo "</td>";
     echo "<td>" . _x('location', 'State') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "state");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ContactType::dropdown(array('value' => $this->fields["contacttypes_id"]));
     echo "</td>";
     echo "<td>" . __('Country') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "country");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . _x('person', 'Title') . "</td><td>";
     UserTitle::dropdown(array('value' => $this->fields["usertitles_id"]));
     echo "<td>&nbsp;</td><td class='center'>";
     if ($ID > 0) {
         echo "<a target=''_blank' href='" . $this->getFormURL() . "?getvcard=1&amp;id={$ID}'>" . __('Vcard') . "</a>";
     }
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }