NotificationTemplateTranslation::showForm PHP Method

showForm() public method

public showForm ( $ID, $options )
    function showForm($ID, $options)
    {
        global $DB, $CFG_GLPI;
        if (!Config::canUpdate()) {
            return false;
        }
        $notificationtemplates_id = -1;
        if (isset($options['notificationtemplates_id'])) {
            $notificationtemplates_id = $options['notificationtemplates_id'];
        }
        if ($this->getFromDB($ID)) {
            $notificationtemplates_id = $this->getField('notificationtemplates_id');
        }
        $this->initForm($ID, $options);
        $template = new NotificationTemplate();
        $template->getFromDB($notificationtemplates_id);
        Html::initEditorSystem('content_html');
        $this->showFormHeader($options);
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . NotificationTemplate::getTypeName() . "</td>";
        echo "<td colspan='2'><a href='" . Toolbox::getItemTypeFormURL('NotificationTemplate') . "?id=" . $notificationtemplates_id . "'>" . $template->getField('name') . "</a>";
        echo "</td><td>";
        $rand = mt_rand();
        Ajax::createIframeModalWindow("tags" . $rand, $CFG_GLPI['root_doc'] . "/front/notification.tags.php?sub_type=" . $template->getField('itemtype'));
        echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID("tags" . $rand) . ".dialog('open');\">" . __('Show list of available tags') . "</a>";
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Language') . "</td><td colspan='3'>";
        //Get all used languages
        $used = self::getAllUsedLanguages($notificationtemplates_id);
        if ($ID > 0) {
            if (isset($used[$this->getField('language')])) {
                unset($used[$this->getField('language')]);
            }
        }
        Dropdown::showLanguages("language", array('display_emptychoice' => true, 'value' => $this->fields['language'], 'used' => $used));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Subject') . "</td>";
        echo "<td colspan='3'>";
        Html::autocompletionTextField($this, 'subject', array('size' => 100));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>";
        _e('Email text body');
        echo "<br>" . __('(leave the field empty for a generation from HTML)');
        echo "</td><td colspan='3'>";
        echo "<textarea cols='100' rows='15' name='content_text' >" . $this->fields["content_text"];
        echo "</textarea></td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>";
        _e('Email HTML body');
        echo "</td><td colspan='3'>";
        echo "<textarea cols='100' rows='15' name='content_html'>" . $this->fields["content_html"];
        echo "</textarea>";
        echo "<input type='hidden' name='notificationtemplates_id' value='" . $template->getField('id') . "'>";
        echo "</td></tr>";
        $this->showFormButtons($options);
        return true;
    }

Usage Example

コード例 #1
0
}
$language = new NotificationTemplateTranslation();
if (isset($_POST["add"])) {
    $language->check(-1, 'w', $_POST);
    $newID = $language->add($_POST);
    Event::log($newID, "notificationtemplates", 4, "notification", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " : " . $_POST["language"] . ".");
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $language->check($_POST["id"], 'd');
        $language->delete($_POST);
        Event::log($_POST["id"], "notificationtemplates", 4, "notification", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
        $language->redirectToList();
    } else {
        if (isset($_POST["update"])) {
            $language->check($_POST["id"], 'w');
            $language->update($_POST);
            Event::log($_POST["id"], "notificationtemplates", 4, "notification", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
            glpi_header($_SERVER['HTTP_REFERER']);
        } else {
            commonHeader($LANG['mailing'][113], $_SERVER['PHP_SELF'], "config", "mailing", "notificationtemplate");
            if ($_GET["id"] == '') {
                $options = array("notificationtemplates_id" => $_GET["notificationtemplates_id"]);
            } else {
                $options = array();
            }
            $language->showForm($_GET["id"], $options);
            commonFooter();
        }
    }
}