showMailServerConfig() static public method

Display a mail server configuration form
static public showMailServerConfig ( $value ) : String
$value String host connect string ex {localhost:993/imap/ssl}INBOX
return String type of the server (imap/pop)
 /**
  * Print the mailgate form
  *
  * @param $ID        integer  Id of the item to print
  * @param $options   array
  *     - target filename : where to go when done.
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $options['colspan'] = 1;
     $this->showFormHeader($options);
     if (!function_exists('mb_list_encodings') || !function_exists('mb_convert_encoding')) {
         echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('mbstring extension not found. Warning with charsets used.') . "</td></tr>";
     }
     echo "<tr class='tab_bg_1'><td>" . sprintf(__('%1$s (%2$s)'), __('Name'), __('Email address')) . "</td><td>";
     Html::autocompletionTextField($this, "name");
     echo "</td></tr>";
     if ($this->fields['errors']) {
         echo "<tr class='tab_bg_1_2'><td>" . __('Connection errors') . "</td>";
         echo "<td>" . $this->fields['errors'] . "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'><td>" . __('Active') . "</td><td>";
     Dropdown::showYesNo("is_active", $this->fields["is_active"]);
     echo "</td></tr>";
     $type = Toolbox::showMailServerConfig($this->fields["host"]);
     echo "<tr class='tab_bg_1'><td>" . __('Login') . "</td><td>";
     Html::autocompletionTextField($this, "login");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Password') . "</td>";
     echo "<td><input type='password' name='passwd' value='' size='20' autocomplete='off'>";
     if ($ID > 0) {
         echo "<input type='checkbox' name='_blank_passwd'>&nbsp;" . __('Clear');
     }
     echo "</td></tr>";
     if (version_compare(PHP_VERSION, '5.3.2', '>=')) {
         echo "<tr class='tab_bg_1'><td>" . __('Use Kerberos authentication') . "</td>";
         echo "<td>";
         Dropdown::showYesNo("use_kerberos", $this->fields["use_kerberos"]);
         echo "</td></tr>\n";
     }
     if ($type != "pop") {
         echo "<tr class='tab_bg_1'><td>" . __('Accepted mail archive folder (optional)') . "</td>";
         echo "<td><input size='30' type='text' name='accepted' value=\"" . $this->fields['accepted'] . "\">";
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'><td>" . __('Refused mail archive folder (optional)') . "</td>";
         echo "<td><input size='30' type='text' name='refused' value=\"" . $this->fields['refused'] . "\">";
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td width='200px'> " . __('Maximum size of each file imported by the mails receiver') . "</td><td>";
     self::showMaxFilesize('filesize_max', $this->fields["filesize_max"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Use mail date, instead of collect one') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("use_mail_date", $this->fields["use_mail_date"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'><td>" . __('Comments') . "</td>";
     echo "<td><textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     if ($ID > 0) {
         echo "<br>";
         //TRANS: %s is the datetime of update
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Beispiel #2
0
 /**
  * Print the auth mail form
  *
  * @param $ID        Integer : ID of the item
  * @param $options   array
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     if (!Config::canUpdate()) {
         return false;
     }
     $spotted = false;
     if (empty($ID)) {
         if ($this->getEmpty()) {
             $spotted = true;
         }
     } else {
         if ($this->getFromDB($ID)) {
             $spotted = true;
         }
     }
     if (Toolbox::canUseImapPop()) {
         $options['colspan'] = 1;
         $this->showFormHeader($options);
         echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
         echo "<td><input size='30' type='text' name='name' value='" . $this->fields["name"] . "'>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Active') . "</td>";
         echo "<td colspan='3'>";
         Dropdown::showYesNo('is_active', $this->fields['is_active']);
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Email domain Name (users email will be login@domain)') . "</td>";
         echo "<td><input size='30' type='text' name='host' value='" . $this->fields["host"] . "'>";
         echo "</td></tr>";
         Toolbox::showMailServerConfig($this->fields["connect_string"]);
         echo "<tr class='tab_bg_1'><td>" . __('Comments') . "</td>";
         echo "<td>";
         echo "<textarea cols='40' rows='4' name='comment'>" . $this->fields["comment"] . "</textarea>";
         if ($ID > 0) {
             echo "<br>";
             //TRANS: %s is the datetime of update
             printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
         }
         echo "</td></tr>";
         $this->showFormButtons($options);
     } else {
         echo "<div class='center'>&nbsp;<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('Email server configuration') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         echo "<p class='red'>" . __('Your PHP parser was compiled without the IMAP functions') . "</p>";
         echo "<p>" . __('Impossible to use email server as external source of connection') . "</p>";
         echo "</td></tr></table></div>";
     }
 }