package WebGUI::Widget::FAQ;
our $namespace = "FAQ";
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _reorderQuestions {
my ($sth, $i, $qid);
$sth = WebGUI::SQL->read("select questionId from FAQ_question where widgetId=$_[0] order by sequenceNumber",$session{dbh});
while (($qid) = $sth->array) {
WebGUI::SQL->write("update FAQ_question set sequenceNumber='$i' where questionId=$qid",$session{dbh});
$i++;
}
$sth->finish;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from FAQ where widgetId=$_[0]",$_[1]);
WebGUI::SQL->write("delete from FAQ_question where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
}
#-------------------------------------------------------------------
sub widgetName {
return WebGUI::International::get(205);
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '
';
$output = '
'; $output .= '
'; return $output; } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_deleteQuestionConfirm { my ($output); if (WebGUI::Privilege::canEditPage()) { WebGUI::SQL->write("delete from FAQ_question where questionId=$session{form}{qid}",$session{dbh}); _reorderQuestions($session{form}{wid}); return www_edit(); } else { return WebGUI::Privilege::insufficient(); } } #------------------------------------------------------------------- sub www_edit { my ($output, %data, @question, $sth); tie %data, 'Tie::CPHash'; if (WebGUI::Privilege::canEditPage()) { %data = WebGUI::SQL->quickHash("select * from widget where widget.widgetId=$session{form}{wid}",$session{dbh}); $output = '
';
$output = ''.WebGUI::International::get(212).'
'; $output .= '
'; } $sth->finish; $output .= '