Neue Spalte in Tabelle faqdata

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
mueller71
Posts: 6
Joined: Thu Jul 07, 2011 12:53 pm

Neue Spalte in Tabelle faqdata

Post by mueller71 »

Hallo zusammen,

für unser FAQ System muss ich verschiedene Service Level erstellen, welche die FAQ von der Erstellung bis zur Freigabe für den öffentlichen Bereich durchlauft.

Ich habe daher eine neue Spalte in der Tabelle faqdata erstellt und würde gerne die jeweilige Gruppe aus dem Auswahlfeld dort hinterlegen. Leider bekomme ich es mit dem Abspeichern nicht hin.

Das Eingabe format sieht wie folgt aus (record.edit):

echo "<select id=\"restricted_groupsfaq\" name=\"restricted_groupsfaq\">";
while ($daten = mysql_fetch_array($sql_result)){
?>
<option value="<?php print $daten['group_id']?>" <?php if($faqdatagroupID==$daten['group_id']){echo"selected";}?>><?php print $daten['description']?></option>
<?php
}
echo "</select><br />";

In der record.save habe ich folgendes hinzugefügt:

$restricted_groupfaq = PMF_Filter::filterInput(INPUT_POST, 'restricted_groupsfaq', FILTER_VALIDATE_INT);

$recordData = array(
'group_id' => $restricted_groupfaq,
'date_SLA' => '2011-07-30'


In der Function addRecord:

$query = sprintf(
"INSERT INTO
%sfaqdata
VALUES
(%d, '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s','%s')",
SQLPREFIX,
$record_id,
$data['lang'],
$this->getSolutionId(),
0,
$data['active'],
$data['sticky'],
$data['group_id'],
$this->db->escape_string($data['keywords']),
$this->db->escape_string($data['thema']),
$this->db->escape_string($data['content']),
$this->db->escape_string($data['author']),
$data['email'],
$data['comment'],
$data['date'],
$data['linkState'],
$data['linkDateCheck'],
$data['dateStart'],
$data['dateEnd'],
$data['date_SLA']);

Wenn ich mir den query ausgeben lasse, sind die werte für $data['group_id'] und $data['date_SLA'] immer leer.

Woran kann das liegen bzw. was muss ich noch ändern um einen neuen Eintrag zu erstellen bzw. einen bestehenden abzuspeichern.

Vielen Dank für Eure Hifle im vorraus!!

Beste Grüße
Mark
mueller71
Posts: 6
Joined: Thu Jul 07, 2011 12:53 pm

Re: Neue Spalte in Tabelle faqdata

Post by mueller71 »

Hi Thorsten,

hast du evtl. eine Info für mich bzgl. des o.g. Problems?

Würdest mir sehr sehr helfen.

Danke.

Gruß
Mark
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Neue Spalte in Tabelle faqdata

Post by Thorsten »

Hi,

aus den Codefragmenten sehe ich das nicht auf Anhieb... kannst du mir deine Änderungen zusenden?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
mueller71
Posts: 6
Joined: Thu Jul 07, 2011 12:53 pm

Re: Neue Spalte in Tabelle faqdata

Post by mueller71 »

Hallo Thorsten,

in der record.edit.php habe ich Zeile 90 sowie Zeile 331 bis 347 hinzugefügt.

Code: Select all

<?php
/**
 * The FAQ record editor.
 * 
 * PHP Version 5.2
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * @category  phpMyFAQ
 * @package   Administration
 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
 * @copyright 2003-2010 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
 * @link      http://www.phpmyfaq.de
 * @since     2003-02-23
 */

if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

// Re-evaluate $user
$user = PMF_User_CurrentUser::getFromSession($faqconfig->get('main.ipCheck'));

if ($permission["editbt"] && !PMF_Db::checkOnEmptyTable('faqcategories')) {

    $category = new PMF_Category($current_admin_user, $current_admin_groups, false);
    $category->buildTree();
    
    $helper = PMF_Helper_Category::getInstance();
    $helper->setCategory($category);

    $current_category = '';
    $categories       = array();
    $faqData          = array(
        'id'          => 0,
        'lang'        => $LANGCODE,
        'revision_id' => 0,
        'title'       => '',
        'dateStart'   => '',
        'dateEnd'     => '');

    $tagging = new PMF_Tags();

    if ($action == 'takequestion') {
        $question_id      = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
        $question         = $faq->getQuestion($question_id);
        $current_category = $question['category'];
        $faqData['title'] = $question['question'];
        $categories       = array(
            'category_id'   => $current_category,
            'category_lang' => $faqData['lang']);
    }

    if ($action == 'editpreview') {

    	$faqData['id'] = PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT);
        if (!is_null($faqData['id'])) {
            $url_variables = 'saveentry&id='.$faqData['id'];
        } else {
            $url_variables = 'insertentry';
        }
        
        $faqData['lang']  = PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING);
        $current_category = isset($_POST['rubrik']) ? $_POST['rubrik'] : null;
        if (is_array($current_category)) {
            foreach ($current_category as $cats) {
                $categories[] = array('category_id' => $cats, 'category_lang' => $faqData['lang']);
            }
        }
        $faqData['active']      = PMF_Filter::filterInput(INPUT_POST, 'active', FILTER_SANITIZE_STRING);
        $faqData['keywords']    = PMF_Filter::filterInput(INPUT_POST, 'keywords', FILTER_SANITIZE_STRING);
        $faqData['title']       = PMF_Filter::filterInput(INPUT_POST, 'thema', FILTER_SANITIZE_STRING);
        $faqData['content']     = PMF_Filter::filterInput(INPUT_POST, 'content', FILTER_SANITIZE_SPECIAL_CHARS);
        $faqData['author']      = PMF_Filter::filterInput(INPUT_POST, 'author', FILTER_SANITIZE_STRING);
        $faqData['email']       = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
        $faqData['comment']     = PMF_Filter::filterInput(INPUT_POST, 'comment', FILTER_SANITIZE_STRING);
        $faqData['solution_id'] = PMF_Filter::filterInput(INPUT_POST, 'solution_id', FILTER_VALIDATE_INT);
        $faqData['revision_id'] = PMF_Filter::filterInput(INPUT_POST, 'revision_id', FILTER_VALIDATE_INT, 0);
        $faqData['sticky']      = PMF_Filter::filterInput(INPUT_POST, 'sticky', FILTER_VALIDATE_INT);
		$faqData['group_id'] 	= PMF_Filter::filterInput(INPUT_POST, 'restricted_groupsfaq', FILTER_VALIDATE_INT);
        $tags                   = PMF_Filter::filterInput(INPUT_POST, 'tags', FILTER_SANITIZE_STRING);
        $changed                = PMF_Filter::filterInput(INPUT_POST, 'changed', FILTER_SANITIZE_STRING);
        $faqData['dateStart']   = PMF_Filter::filterInput(INPUT_POST, 'dateStart', FILTER_SANITIZE_STRING);
        $faqData['dateEnd']     = PMF_Filter::filterInput(INPUT_POST, 'dateEnd', FILTER_SANITIZE_STRING);
        $faqData['content']     = html_entity_decode($faqData['content']);
        
    } elseif ($action == 'editentry') {

        $id   = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
        $lang = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
        if ((!isset($current_category) && !isset($faqData['title'])) || !is_null($id)) {
            $logging = new PMF_Logging();
            $logging->logAdmin($user, 'Beitragedit, ' . $id);
            $faqData['id']   = $id;
            $faqData['lang'] = $lang;
            
            $faq->setLanguage($faqData['lang']);
            $categories = $category->getCategoryRelationsFromArticle($faqData['id'], $faqData['lang']);

            $faq->getRecord($faqData['id'], null, true);
            $faqData       = $faq->faqRecord;
            $tags          = implode(',', $tagging->getAllTagsById($faqData['id']));
            $url_variables = 'saveentry&id='.$faqData['id'];
        } else {
            $url_variables = 'insertentry';
        }

    } elseif ($action == 'copyentry') {

        $faqData['id']   = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
        $faqData['lang'] = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
        $faq->language   = $faqData['lang'];
        $categories      = $category->getCategoryRelationsFromArticle($faqData['id'], $faqData['lang']);

        $faq->getRecord($faqData['id'], null, true);

        $faqData       = $faq->faqRecord;
        $url_variables = 'insertentry';

    } else {
        $logging = new PMF_Logging();
        $logging->logAdmin($user, 'Beitragcreate');
        $url_variables = 'insertentry';
        if (!is_array($categories)) {
            $categories = array();
        }
    }
    
    // Revisions
    $revisionid_selected = PMF_Filter::filterInput(INPUT_POST, 'revisionid_selected', FILTER_VALIDATE_INT);
    if (is_null($revisionid_selected)) {
        $revisionid_selected = $faqData['revision_id'];
    }

    // Permissions
    $user_permission = $faq->getPermission('user', $faqData['id']);
    if (count($user_permission) == 0 || $user_permission[0] == -1) {
        $all_users          = true;
        $restricted_users   = false;
        $user_permission[0] = -1;
    } else {
        $all_users        = false;
        $restricted_users = true;
    }

    $group_permission = $faq->getPermission('group', $faqData['id']);
    if (count($group_permission) == 0 || $group_permission[0] == -1) {
        $all_groups          = true;
        $restricted_groups   = false;
        $group_permission[0] = -1;
    } else {
        $all_groups        = false;
        $restricted_groups = true;
    }

    print '<h2>'.$PMF_LANG["ad_entry_edit_1"];
    if ($faqData['id'] != 0 && $action != 'copyentry') {
        printf(' <span style="color: Red;">%d (%s 1.%d) </span> ',
            $faqData['id'],
            $PMF_LANG['ad_entry_revision'],
            $revisionid_selected);
    }
    print ' '.$PMF_LANG["ad_entry_edit_2"].'</h2>';

    if ($permission["changebtrevs"]){

        $revisions = $faq->getRevisionIds($faqData['id'], $faqData['lang']);
        if (count($revisions)) {
?>

    <form id="selectRevision" name="selectRevision" action="?action=editentry&id=<?php print $faqData['id']; ?>&lang=<?php print $faqData['lang']; ?>" method="post">
    <fieldset>
    <legend><?php print $PMF_LANG['ad_changerev']; ?></legend>
        <select name="revisionid_selected" onchange="selectRevision.submit();">
            <option value="<?php print $faqData['revision_id']; ?>"><?php print $PMF_LANG['ad_changerev']; ?></option>
<?php foreach ($revisions as $_revision_id => $_revision_data) { ?>
            <option value="<?php print $_revision_data['revision_id']; ?>" <?php if ($revisionid_selected == $_revision_data['revision_id']) { print 'selected="selected"'; } ?> ><?php print $PMF_LANG['ad_entry_revision'].' 1.'.$_revision_data['revision_id'].': '.PMF_Date::createIsoDate($_revision_data['datum'])." - ".$_revision_data['author']; ?></option>
<?php } ?>
        </select>
    </fieldset>
    </form>
    <br />
<?php
        }

        if (isset($revisionid_selected) &&
            isset($faqData['revision_id']) &&
            $revisionid_selected != $faqData['revision_id']) {

            $faq->language = $faqData['lang'];
            $faq->getRecord($faqData['id'], $revisionid_selected, true);
            $faqData = $faq->faqRecord;
            $tags    = implode(',', $tagging->getAllTagsById($faqData['id']));
        }
    }
?>

    <form id="faqEditor" style="float: left;" action="?action=<?php print $url_variables; ?>" method="post">
    <input type="hidden" name="revision_id" id="revision_id" value="<?php print $faqData['revision_id']; ?>" />
    <input type="hidden" name="record_id" id="record_id" value="<?php print $faqData['id']; ?>" />
    <input type="hidden" name="csrf" value="<?php print $user->getCsrfTokenFromSession(); ?>" />

    <fieldset class="fullwidth">
    <legend><?php print $PMF_LANG['ad_entry_faq_record']; ?></legend>

    <label class="lefteditor" for="rubrik"><b><?php print $PMF_LANG["ad_entry_category"]; ?></b></label><br>
    <select name="rubrik[]" id="rubrik" size="10" multiple="multiple" style="width: 720px;">
    <?php print $helper->renderCategoryOptions($categories); ?>
    </select><br><br />

    <label for="thema"><b><?php print $PMF_LANG["ad_entry_theme"]; ?></b></label><br>
    <input name="thema" id="thema" style="width: 720px; height: 30px; font-size: 16px;" value="<?php if (isset($faqData['title'])) { print PMF_String::htmlspecialchars($faqData['title']); } ?>" maxlength="255" /><br><br />

    <label for="content"><b><?php print $PMF_LANG["ad_entry_content"]; ?></b></label><br>
    <noscript>Please enable JavaScript to use the WYSIWYG editor!</noscript>
    <textarea id="content" name="content" cols="84" rows="16" style="width: 720px; height: 480px;">
    <?php if (isset($faqData['content'])) { print trim(PMF_String::htmlentities($faqData['content'])); } ?>
    </textarea><br />

<?php
    if ($action == 'copyentry') {
        $faqData['lang'] = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
    }

    if ($permission["addatt"]) {
        if (isset($faqData['id']) && $faqData['id'] != "") {
            $attList = PMF_Attachment_Factory::fetchByRecordId($faqData['id']);
            while (list(,$att) = each($attList)) {
                print "<a href=\"../" . $att->buildUrl() . "\">" . $att->getFilename() . "</a>";
                if ($permission["delatt"]) {
                    print "&nbsp;[&nbsp;<a href=\"?action=delatt&" . "record_id=" . $faqData['id'] . "&id=" . 
                        $att->getId() . "&lang=" . $faqData['lang'] . "\">" . $PMF_LANG["ad_att_del"] . "</a>&nbsp;]";
                }
                print "<br />\n";
            }
            print "<a href=\"#\" onclick=\"Picture('attachment.php?record_id=".$faqData['id']."&record_lang=".$faqData['lang']."&rubrik=".$current_category."', 'Attachment', 400,80)\">".$PMF_LANG["ad_att_add"]."</a>";
        } else {
            print "&nbsp;".$PMF_LANG["ad_att_nope"];
        }
?><br />

<?php
    }
?>

    <label class="lefteditor" for="keywords"><?php print $PMF_LANG["ad_entry_keywords"]; ?></label>
    <input name="keywords" id="keywords" style="width: 390px;" value="<?php if (isset($faqData['keywords'])) { print PMF_String::htmlspecialchars($faqData['keywords']); } ?>" maxlength="255" /> <span id="keywordsHelp"></span><br />

    <label class="lefteditor" for="tags"><?php print $PMF_LANG['ad_entry_tags']; ?>:</label>
    <input name="tags" id="tags" style="width: 390px;" value="<?php if (isset($tags)) { print PMF_String::htmlspecialchars($tags); } ?>" maxlength="255" /><img style="display: none; margin-bottom: -5px;" id="tags_autocomplete_wait" src="images/indicator.gif" alt="waiting..."></img>
    <script type="text/javascript">
        $('#tags').autocomplete("index.php?action=ajax&ajax=tags_list", { width: 260, selectFirst: false, multiple: true } );
    </script><span id="tagsHelp"></span><br />

    <label class="lefteditor" for="author"><?php print $PMF_LANG["ad_entry_author"]; ?></label>
    <input name="author" id="author" style="width: 390px;" value="<?php if (isset($faqData['author'])) { print PMF_String::htmlspecialchars($faqData['author']); } else { print $user->getUserData('display_name'); } ?>" /><br />

    <label class="lefteditor" for="email"><?php print $PMF_LANG["ad_entry_email"]; ?></label>
    <input name="email" id="email" style="width: 390px;" value="<?php if (isset($faqData['email'])) { print PMF_String::htmlspecialchars($faqData['email']); } else { print $user->getUserData('email'); } ?>" /><br />

    </fieldset>

    <fieldset class="fullwidth">
    <legend><?php print $PMF_LANG['ad_entry_record_administration']; ?></legend>

    <label class="left" for="language"><?php print $PMF_LANG["ad_entry_locale"]; ?>:</label>
    <?php print PMF_Language::selectLanguages($faqData['lang']); ?><br />

    <label class="left" for="solution_id"><?php print $PMF_LANG['ad_entry_solution_id']; ?>:</label>
    <input name="solution_id" id="solution_id" style="width: 50px; text-align: right;" value="<?php print (isset($faqData['solution_id']) ? $faqData['solution_id'] : $faq->getSolutionId()); ?>" size="5" readonly="readonly" /><br />

    <label class="left" for="active"><?php print $PMF_LANG["ad_entry_active"]; ?></label>
<?php
if($permission['approverec']):
    if (isset($faqData['active']) && $faqData['active'] == 'yes') {
        $suf = ' checked="checked"';
        $sul = null;
    } elseif ($faqconfig->get('records.defaultActivation')) {
        $suf = ' checked="checked"';
        $sul = null;
    } else {
        $suf = null;
        $sul = ' checked="checked"';
    }
?>
    <input type="radio" id="active" name="active" class="active" value="yes"<?php if (isset($suf)) { print $suf; } ?> /> <?php print $PMF_LANG['ad_gen_yes']; ?> <input type="radio" name="active" class="active" value="no"<?php if (isset($sul)) { print $sul; } ?> /> <?php print $PMF_LANG['ad_gen_no']; ?><br />
<?php else: ?>
    <input type="radio" name="active" class="active" value="no" checked="checked" /> <?php print $PMF_LANG['ad_gen_no']; ?><br />
<?php endif; ?>

	<label class="left" for="sticky"><?php print $PMF_LANG['ad_entry_sticky']; ?>:</label>
	<input type="checkbox" id="sticky" name="sticky" <?php print (isset($faqData['sticky']) && $faqData['sticky'] ? 'checked="checked"' : '') ?> /><br />

<?php
    if (isset($faqData['comment']) && $faqData['comment'] == 'y') {
        $suf = ' checked="checked"';
    } elseif ($faqconfig->get('records.defaultAllowComments')) {
        $suf = ' checked="checked"';
    } else {
        $suf = null;
    }
?>
    <label class="left" for="comment"><?php print $PMF_LANG["ad_entry_allowComments"]; ?></label>
    <input type="checkbox" name="comment" id="comment" value="y"<?php if (isset($suf)) { print $suf; } ?> /> <?php print $PMF_LANG['ad_gen_yes']; ?><br />
<?php
    if ($url_variables != 'insertentry') {
        $rev_yes = ' checked="checked"';
        $rev_no  = null;
    }
    if (isset($faqData['active']) && $faqData['active'] == 'no') {
        $rev_no  = ' checked="checked"';
        $rev_yes = null;
    }
    if ($url_variables != 'insertentry') {
?>
    <label class="left" for="revision"><?php print $PMF_LANG['ad_entry_new_revision']; ?></label>
    <input type="radio" name="revision" class="active" value="yes"<?php print isset($rev_yes) ? $rev_yes : ''; ?>/> <?php print $PMF_LANG["ad_gen_yes"]; ?> <input type="radio" name="revision" class="active" value="no"<?php print isset($rev_no) ? $rev_no : ''; ?>/> <?php print $PMF_LANG["ad_gen_no"]; ?><br />
<?php
    }
?>
    <label class="left" for="grouppermission"><?php print $PMF_LANG['ad_entry_grouppermissionFAQ']; ?></label>
    <!--<select name="restricted_groupsfaq" size="1"><?php print $user->perm->getAllGroupsOptionsFAQ($group_permission[0]); ?></select><br />
	-->
<?php
	$sql = "SELECT * FROM tbl_faqgroup";
	$sql_result = mysql_query($sql);
	$sqlgroupID=getSqlRow("SELECT group_id FROM tbl_faqdata WHERE id='".$faqData['id']."'");	
	$faqdatagroupID=$sqlgroupID['group_id'];
	//print "FAQ GroupID: ".$faqData['group_id']."<br>";
	echo "<select id=\"restricted_groupsfaq\" name=\"restricted_groupsfaq\">";
	while ($daten = mysql_fetch_array($sql_result)){
	?>
	<option value="<?php print $daten['group_id']?>" <?php if($faqdatagroupID==$daten['group_id']){echo"selected";}?>><?php print $daten['description']?></option>
	<?php					
		//echo "<option value='".$daten['group_id']."' if($faqData['group_id']=='".$daten['group_id']."'){echo"selected";}".$daten['description']."</option>\n";
	}
	echo "</select><br />";
?>
<?php
	if ($faqconfig->get('main.permLevel') != 'basic') {
?>
    <label class="left" for="grouppermission"><?php print $PMF_LANG['ad_entry_grouppermission']; ?></label>
    <input type="radio" id="grouppermission" name="grouppermission" class="active" value="all" <?php print ($all_groups ? 'checked="checked"' : ''); ?>/> <?php print $PMF_LANG['ad_entry_all_groups']; ?> <input type="radio" name="grouppermission" class="active" value="restricted" <?php print ($restricted_groups ? 'checked="checked"' : ''); ?>/> <?php print $PMF_LANG['ad_entry_restricted_groups']; ?> <select name="restricted_groups" size="1"><?php print $user->perm->getAllGroupsOptions($group_permission[0]); ?></select><br />
<?php
    } else {
?>
    <input type="hidden" name="grouppermission" class="active" value="all" />
<?php   
    }
    
    if ('00000000000000' == $faqData['dateStart']) {
        $dateStart = '';
    } else {
        $dateStart = preg_replace("/(\d{4})(\d{2})(\d{2}).*/", "$1-$2-$3", $faqData['dateStart']);
    }
    
    if ('99991231235959' == $faqData['dateEnd']) {
        $dateEnd = '';
    } else {
        $dateEnd = preg_replace("/(\d{4})(\d{2})(\d{2}).*/", "$1-$2-$3", $faqData['dateEnd']);
    }
    
    if (!isset($faqData['date'])) { 
    	$faqData['date'] = PMF_Date::createIsoDate(date('YmdHis'));
    }
?>
    <label class="left" for="userpermission"><?php print $PMF_LANG['ad_entry_userpermission']; ?></label>
    <input type="radio" id="userpermission" name="userpermission" class="active" value="all" <?php print ($all_users ? 'checked="checked"' : ''); ?>/> <?php print $PMF_LANG['ad_entry_all_users']; ?> <input type="radio" name="userpermission" class="active" value="restricted" <?php print ($restricted_users ? 'checked="checked"' : ''); ?>/> <?php print $PMF_LANG['ad_entry_restricted_users']; ?> <select name="restricted_users" size="1"><?php print $user->getAllUserOptions($user_permission[0]); ?></select><br />
    
	<label class="left" for="dateActualize"><?php echo $PMF_LANG["ad_entry_date"]; ?></label>
    <input type="radio" id="dateActualize" checked="checked" name="recordDateHandling" onchange="setRecordDate(this.id);" /> <?php print $PMF_LANG['msgUpdateFaqDate']; ?>
    <input type="radio" id="dateKeep" name="recordDateHandling" onchange="setRecordDate(this.id);" /> <?php print $PMF_LANG['msgKeepFaqDate']; ?>
    <input type="radio" id="dateCustomize" name="recordDateHandling" onchange="setRecordDate(this.id);" /> <?php print $PMF_LANG['msgEditFaqDat']; ?>
    <div id="recordDateInputContainer" style="display: none;"></span><label class="left" for="date">&nbsp;</label>
    <input type="text" name="date" id="date" maxlength="16" value="" /></div>
    </fieldset>

    <fieldset class="fullwidth">
    <legend><a href="javascript:void(0);" onclick="javascript:toggleFieldset('Expiration');"><?php print $PMF_LANG['ad_record_expiration_window']; ?></a></legend>
    
    <div id="editExpiration" style="display: none;">
        <label class="lefteditor" for="dateStart"><?php print $PMF_LANG['ad_news_from']; ?></label>
        <input name="dateStart" id="dateStart" class="date-pick" value="<?php print $dateStart; ?>" maxlength="10" />
        <br />
        <label class="lefteditor" for="dateEnd"><?php print $PMF_LANG['ad_news_to']; ?></label>
        <input name="dateEnd" id="dateEnd" class="date-pick" value="<?php print $dateEnd; ?>" maxlength="10" />
    </div>
    
    </fieldset>

    <fieldset class="fullwidth">
    <legend><a href="javascript:void(0);" onclick="javascript:toggleFieldset('Changelog');"><?php print $PMF_LANG['ad_entry_changelog']; ?></a></legend>

    <div id="editChangelog" style="display: none;">
        <label class="lefteditor"><?php print $PMF_LANG["ad_entry_date"]; ?></label>
        <?php if (isset($faqData['date'])) { print $faqData['date']; } else { print PMF_Date::createIsoDate(date("YmdHis")); } ?><br />

        <label class="lefteditor" for="changed"><?php print $PMF_LANG["ad_entry_changed"]; ?></label>
        <textarea name="changed" id="changed" style="width: 390px; height: 50px;" cols="40" rows="4"><?php if (isset($changed)) { print $changed; } ?></textarea><br />
    </div>

    </fieldset><br />

    <p align="center">
<?php
    if ($revisionid_selected == $faqData['revision_id']) {
?>
    <input class="submit" type="submit" value="<?php print $PMF_LANG["ad_entry_save"]; ?>" name="submit[1]" />
    <input class="submit" type="reset" value="<?php print $PMF_LANG["ad_gen_reset"]; ?>" />
<?php
    }
    if ($url_variables != "insertentry") {
?>
    <input class="submit" type="submit" value="<?php print $PMF_LANG["ad_entry_delete"]; ?>" name="submit[0]" />
<?php
    }
?>
    </p>
<?php
    if (is_numeric($faqData['id'])) {
?>
    <fieldset class="fullwidth">
    <legend><a href="javascript:void(0);" onclick="javascript:toggleFieldset('ChangelogHistory');"><?php print $PMF_LANG["ad_entry_changelog"]; ?></a></legend>
    <div id="editChangelogHistory" style="display: none;">
<?php
        $changeEntries = $faq->getChangeEntries($faqData['id']);
        foreach ($changeEntries as $entry) {
            $user->getUserById($entry['user']);
?>
        <p style="font-size: 10px;">
            <strong><?php print $PMF_LANG['ad_entry_revision'].' 1.'.$entry['revision_id'] . ' / ' . date("Y-m-d H:i:s", $entry['date']).": ".$user->getUserData('display_name'); ?></strong><br />
            <?php print $entry['changelog']; ?>
        </p>
<?php
        }
?>
    </div>
    </fieldset>
    
    </form>
    
    <script type="text/javascript">
    /* <![CDATA[ */

    $(function()
    {
        $('.date-pick').datePicker();

        $('#date').datePicker({startDate: '1900-01-01'});
        $('#date').bind('dateSelected', function (e, date, $td, status)
        {
            if(status) {
                var dt = new Date();

                var hours   = dt.getHours();
                var minutes = dt.getMinutes();
                
                $('#date').val(date.asString() +
                               ' ' + (hours < 10 ? '0' : '') + hours +
                               ':' + (minutes < 10 ? '0' : '') + minutes);
            }
        });

        $('#keywords').focus(function() { showHelp('keywords'); });
        $('#tags').focus(function() { showHelp('tags'); });
        
    });

    /**
     * Toggle fieldsets
     *
     * @param string fieldset ID of the fieldset
     *
     * @return void
     */
    function toggleFieldset(fieldset)
    {
        if ($('#edit' + fieldset).css('display') == 'none') {
            $('#edit' + fieldset).fadeIn('fast');
        } else {
            $('#edit' + fieldset).fadeOut('fast');
        }
    }
    
    /**
     * Toggle input date container show
     *
     * @param boolean show show or hide (optional)
     *
     * @return void
     */
    function showIDContainer()
    {
        var display = 0 == arguments.length || !!arguments[0] ? 'block' : 'none';
        
        $('#recordDateInputContainer').attr('style', 'display: ' + display);
    }


    function setRecordDate(how)
    {
        if('dateActualize' == how) {
            showIDContainer(false);
            $('#date').val('');
        } else if ('dateKeep' == how) {
            showIDContainer(false);
            $('#date').val('<?php print $faqData['date']; ?>');
        } else if('dateCustomize' == how) {
            showIDContainer(true);
            $('#date').val('');
        }
    }
        
    /**
     * Shows help for keywords and tags input fields
     * 
     * @param string 
     * 
     * @return void
     */
    function showHelp(option)
    {
        $('#' + option + 'Help').prepend('<?php print $PMF_LANG['msgShowHelp']; ?>').fadeIn(500);
        $('#' + option + 'Help').fadeOut(5000);
    }
    
    /* ]]> */
    </script>
<?php
    }
} elseif ($permission["editbt"] != 1 && !PMF_Db::checkOnEmptyTable('faqcategories')) {
    print $PMF_LANG["err_NotAuth"];
} elseif ($permission["editbt"] && PMF_Db::checkOnEmptyTable('faqcategories')) {
    print $PMF_LANG["no_cats"];
}

In der record.save.php habe ich Zeile 50, 89 und 101 hinzugefügt.

Code: Select all

<?php
/**
 * Save an existing FAQ record.
 * 
 * PHP Version 5.2
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * @category  phpMyFAQ
 * @package   Administration
 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
 * @copyright 2003-2010 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1
 * @link      http://www.phpmyfaq.de
 * @since     2003-02-23
 */

if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

// Re-evaluate $user
$user     = PMF_User_CurrentUser::getFromSession($faqconfig->get('main.ipCheck'));
$category = new PMF_Category($current_admin_user, $current_admin_groups, false);    

if ($permission['editbt']) {
    
    // Get submit action
    $submit        = PMF_Filter::filterInputArray(INPUT_POST, array('submit' => array('filter' => FILTER_VALIDATE_INT,
                                                                                      'flags'  => FILTER_REQUIRE_ARRAY)));
    // FAQ data
    $dateStart     = PMF_Filter::filterInput(INPUT_POST, 'dateStart', FILTER_SANITIZE_STRING);
    $dateEnd       = PMF_Filter::filterInput(INPUT_POST, 'dateEnd', FILTER_SANITIZE_STRING);
    $question      = PMF_Filter::filterInput(INPUT_POST, 'thema', FILTER_SANITIZE_STRING);
    $categories    = PMF_Filter::filterInputArray(INPUT_POST, array('rubrik' => array('filter' => FILTER_VALIDATE_INT,
                                                                                      'flags'  => FILTER_REQUIRE_ARRAY)));
    $record_lang   = PMF_Filter::filterInput(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
    $tags          = PMF_Filter::filterInput(INPUT_POST, 'tags', FILTER_SANITIZE_STRING);
    $active        = 'yes' == PMF_Filter::filterInput(INPUT_POST, 'active', FILTER_SANITIZE_STRING) && $permission['approverec'] ? 'yes' : 'no';
    $sticky        = PMF_Filter::filterInput(INPUT_POST, 'sticky', FILTER_SANITIZE_STRING);
	$restricted_groupfaq = PMF_Filter::filterInput(INPUT_POST, 'restricted_groupsfaq', FILTER_VALIDATE_INT);
    $content       = PMF_Filter::filterInput(INPUT_POST, 'content', FILTER_SANITIZE_SPECIAL_CHARS);
    $keywords      = PMF_Filter::filterInput(INPUT_POST, 'keywords', FILTER_SANITIZE_STRING);
    $author        = PMF_Filter::filterInput(INPUT_POST, 'author', FILTER_SANITIZE_STRING);
    $email         = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
    $comment       = PMF_Filter::filterInput(INPUT_POST, 'comment', FILTER_SANITIZE_STRING);
    $record_id     = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT);
    $solution_id   = PMF_Filter::filterInput(INPUT_POST, 'solution_id', FILTER_VALIDATE_INT);
    $revision      = PMF_Filter::filterInput(INPUT_POST, 'revision', FILTER_SANITIZE_STRING);
    $revision_id   = PMF_Filter::filterInput(INPUT_POST, 'revision_id', FILTER_VALIDATE_INT);
    $changed       = PMF_Filter::filterInput(INPUT_POST, 'changed', FILTER_SANITIZE_STRING);
    $date          = PMF_Filter::filterInput(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
    
    // Permissions
    $user_permission   = PMF_Filter::filterInput(INPUT_POST, 'userpermission', FILTER_SANITIZE_STRING);
    $restricted_users  = ('all' == $user_permission) ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_users', FILTER_VALIDATE_INT);
    $group_permission  = PMF_Filter::filterInput(INPUT_POST, 'grouppermission', FILTER_SANITIZE_STRING);
    $restricted_groups = ('all' == $group_permission) ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_groups', FILTER_VALIDATE_INT);
    
    if (isset($submit['submit'][1]) && !is_null($question) && !is_null($categories)) {
        // Save entry
        $logging = new PMF_Logging();
        $logging->logAdmin($user, 'Beitragsave ' . $record_id);
        print "<h2>".$PMF_LANG["ad_entry_aor"]."</h2>\n";

        $tagging = new PMF_Tags();
        
        if ('yes' == $revision) {
            // Add current version into revision table
            $faq->addNewRevision($record_id, $record_lang);
            $revision_id++;
        }

        $recordData = array(
            'id'            => $record_id,
            'lang'          => $record_lang,
            'revision_id'   => $revision_id,
            'active'        => $active,
            'sticky'        => (!is_null($sticky) ? 1 : 0),
			'group_id'      => $restricted_groupfaq,
            'thema'         => html_entity_decode($question),
            'content'       => html_entity_decode($content),
            'keywords'      => $keywords,
            'author'        => $author,
            'email'         => $email,
            'comment'       => (!is_null($comment) ? 'y' : 'n'),
            'date'          => empty($date) ? date('YmdHis') : str_replace(array('-', ':', ' '), '', $date),
            'dateStart'     => (empty($dateStart) ? '00000000000000' : str_replace('-', '', $dateStart) . '000000'),
            'dateEnd'       => (empty($dateEnd) ? '99991231235959' : str_replace('-', '', $dateEnd) . '235959'),
            'linkState'     => '',
            'linkDateCheck' => 0,
			'date_SLA' 		=> '2011-07-30');

        // Create ChangeLog entry
        $faq->createChangeEntry($record_id, $user->getUserId(), nl2br($changed), $record_lang, $revision_id);

        // save or update the FAQ record
        if ($faq->isAlreadyTranslated($record_id, $record_lang)) {
            $faq->updateRecord($recordData);
        } else {
            $record_id = $faq->addRecord($recordData, false);
        }

        if ($record_id) {
            print $PMF_LANG['ad_entry_savedsuc'];
            link_ondemand_javascript($record_id, $record_lang);
?>
    <script type="text/javascript">
    <!--
    $(document).ready(function(){
        setTimeout(function() {
            window.location = "index.php?action=view";
            }, 5000);
        });
    //-->
    </script>       
<?php
        } else {
            print $PMF_LANG['ad_entry_savedfail'].$db->error();
        }
        
        if (!isset($categories['rubrik'])) {
            $categories['rubrik'] = array();
        }
        
        // delete category relations
        $faq->deleteCategoryRelations($record_id, $record_lang);
        // save or update the category relations
        $faq->addCategoryRelations($categories['rubrik'], $record_id, $record_lang);

        // Insert the tags
        if ($tags != '') {
            $tagging->saveTags($record_id, explode(',', $tags));
        } else {
            $tagging->deleteTagsFromRecordId($record_id);
        }

        // Add user permissions
        $faq->deletePermission('user', $record_id);
        $faq->addPermission('user', $record_id, $restricted_users);
        $category->deletePermission('user', $categories['rubrik']);
        $category->addPermission('user', $categories['rubrik'], $restricted_users);
        // Add group permission
        if ($faqconfig->get('main.permLevel') != 'basic') {
            $faq->deletePermission('group', $record_id);
            $faq->addPermission('group', $record_id, $restricted_groups);
            $category->deletePermission('group', $categories['rubrik']);
            $category->addPermission('group', $categories['rubrik'], $restricted_groups);
        }
    } elseif (isset($submit['submit'][0])) {
        
        $logging = new PMF_Logging();
        $logging->logAdmin($user, 'Beitragdel, ' . $record_id);

        $path = PMF_ROOT_DIR . DIRECTORY_SEPARATOR . PMF_ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . $record_id . '/';
        if (@is_dir($path)) {
            $do = dir($path);
            while ($dat = $do->read()) {
                if ($dat != "." && $dat != "..") {
                    unlink($path . $dat);
                }
            }
            rmdir($path);
        }
        
        $faq->deleteRecord($record_id, $record_lang);
        print $PMF_LANG['ad_entry_delsuc'];
    }
} else {
    print $PMF_LANG['err_NotAuth'];
}
Die Funktion addRecord sieht wie folgt aus:

Code: Select all

public function addRecord(Array $data, $new_record = true)
    {
        if ($new_record) {
            $record_id = $this->db->nextID(SQLPREFIX.'faqdata', 'id');
        } else {
            $record_id = $data['id'];
        }

        // Add new entry
        $query = sprintf(
            "INSERT INTO
                %sfaqdata
            VALUES
                (%d, '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s','%s')",
            SQLPREFIX,
            $record_id,
            $data['lang'],
            $this->getSolutionId(),
            0,
            $data['active'],
            $data['sticky'],
			$data['group_id'],
            $this->db->escape_string($data['keywords']),
            $this->db->escape_string($data['thema']),
            $this->db->escape_string($data['content']),
            $this->db->escape_string($data['author']),
            $data['email'],
            $data['comment'],
            $data['date'],
            $data['linkState'],
            $data['linkDateCheck'],
            $data['dateStart'],
            $data['dateEnd'],
			$data['date_SLA']);
		print $query;
        $this->db->query($query);
        return $record_id;
    }
Was mache ich falsch bzw. wie kann ich es dann auch hinbekommen, dass das ganze auch beim bearbeiten eines FAQ funktioniert.

Darüber hinaus hab ich in der Tabelle faqdata und faqdata_revision die spalten group_id und date_SLA (0000-00-00) hinzugefügt.

Würdest mir wirklich sehr damit helfen, wenn du eine Lösung für mich hättest.

Besten Dank.
Mark
mueller71
Posts: 6
Joined: Thu Jul 07, 2011 12:53 pm

Re: Neue Spalte in Tabelle faqdata

Post by mueller71 »

Hallo Thorsten,

hat sich erledigt.

Wer lesen kann ist im Vorteil.

Ich habe die ganze Zeit in der falschen Datei gearbeitet. Bei einem neuen Eintrag greift die record.add.php und nicht die record.save.php.

Danke nochmals für die Unterstützung.

Beste Grüße
Mark
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Neue Spalte in Tabelle faqdata

Post by Thorsten »

Hi,

perfekt! :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply