Skip to content

Commit 04e09af

Browse files
author
filip
committed
Implemented new FAQ functionality in help module
1 parent fb33392 commit 04e09af

25 files changed

+662
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- --------------------------------------------------------
2+
-- tables for the FAQ module
3+
4+
CREATE TABLE `help_faq_sections` (
5+
`hfs_id` int(11) NOT NULL AUTO_INCREMENT,
6+
`hfs_name` varchar(255) DEFAULT NULL,
7+
`hfs_order` int(11) DEFAULT '0',
8+
`sys_userid` int(11) DEFAULT NULL,
9+
`sys_groupid` int(11) DEFAULT NULL,
10+
`sys_perm_user` varchar(5) DEFAULT NULL,
11+
`sys_perm_group` varchar(5) DEFAULT NULL,
12+
`sys_perm_other` varchar(5) DEFAULT NULL,
13+
PRIMARY KEY (`hfs_id`)
14+
) ENGINE=MyISAM AUTO_INCREMENT=1;
15+
16+
INSERT INTO `help_faq_sections` VALUES (1,'General',0,NULL,NULL,NULL,NULL,NULL);
17+
18+
CREATE TABLE `help_faq` (
19+
`hf_id` int(11) NOT NULL AUTO_INCREMENT,
20+
`hf_section` int(11) DEFAULT NULL,
21+
`hf_order` int(11) DEFAULT '0',
22+
`hf_question` text,
23+
`hf_answer` text,
24+
`sys_userid` int(11) DEFAULT NULL,
25+
`sys_groupid` int(11) DEFAULT NULL,
26+
`sys_perm_user` varchar(5) DEFAULT NULL,
27+
`sys_perm_group` varchar(5) DEFAULT NULL,
28+
`sys_perm_other` varchar(5) DEFAULT NULL,
29+
PRIMARY KEY (`hf_id`)
30+
) ENGINE=MyISAM AUTO_INCREMENT=1;
31+
32+
INSERT INTO `help_faq` VALUES (1,1,0,'I\'d like to know ...','Yes, of course.',1,1,'riud','riud','r');
33+

install/sql/ispconfig3.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,38 @@ INSERT INTO `country` (`iso`, `name`, `printable_name`, `iso3`, `numcode`) VALUE
16171617
('ZW', 'ZIMBABWE', 'Zimbabwe', 'ZWE', 716);
16181618

16191619
-- --------------------------------------------------------
1620+
-- tables for the FAQ module
1621+
1622+
CREATE TABLE `help_faq_sections` (
1623+
`hfs_id` int(11) NOT NULL AUTO_INCREMENT,
1624+
`hfs_name` varchar(255) DEFAULT NULL,
1625+
`hfs_order` int(11) DEFAULT '0',
1626+
`sys_userid` int(11) DEFAULT NULL,
1627+
`sys_groupid` int(11) DEFAULT NULL,
1628+
`sys_perm_user` varchar(5) DEFAULT NULL,
1629+
`sys_perm_group` varchar(5) DEFAULT NULL,
1630+
`sys_perm_other` varchar(5) DEFAULT NULL,
1631+
PRIMARY KEY (`hfs_id`)
1632+
) ENGINE=MyISAM AUTO_INCREMENT=1;
1633+
1634+
INSERT INTO `help_faq_sections` VALUES (1,'General',0,NULL,NULL,NULL,NULL,NULL);
1635+
1636+
CREATE TABLE `help_faq` (
1637+
`hf_id` int(11) NOT NULL AUTO_INCREMENT,
1638+
`hf_section` int(11) DEFAULT NULL,
1639+
`hf_order` int(11) DEFAULT '0',
1640+
`hf_question` text,
1641+
`hf_answer` text,
1642+
`sys_userid` int(11) DEFAULT NULL,
1643+
`sys_groupid` int(11) DEFAULT NULL,
1644+
`sys_perm_user` varchar(5) DEFAULT NULL,
1645+
`sys_perm_group` varchar(5) DEFAULT NULL,
1646+
`sys_perm_other` varchar(5) DEFAULT NULL,
1647+
PRIMARY KEY (`hf_id`)
1648+
) ENGINE=MyISAM AUTO_INCREMENT=1;
1649+
1650+
INSERT INTO `help_faq` VALUES (1,1,0,'I\'d like to know ...','Yes, of course.',1,1,'riud','riud','r');
1651+
16201652
-- --------------------------------------------------------
16211653

16221654
SET FOREIGN_KEY_CHECKS = 1;

interface/web/help/faq_delete.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
// From and List definition files
4+
$list_def_file = 'list/faq_list.php';
5+
$tform_def_file = 'form/faq.tform.php';
6+
7+
// Include the base libraries
8+
require_once('../../lib/config.inc.php');
9+
require_once('../../lib/app.inc.php');
10+
11+
// Check module permissions
12+
if(!stristr($_SESSION['s']['user']['modules'],'help')) {
13+
header('Location: ../index.php');
14+
die;
15+
}
16+
17+
// Load the form
18+
$app->uses('tform_actions');
19+
$app->tform_actions->onDelete();
20+
21+
?>

interface/web/help/faq_edit.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
// Set the path to the form definition file.
4+
$tform_def_file = 'form/faq.tform.php';
5+
6+
// include the core configuration and application classes
7+
require_once('../../lib/config.inc.php');
8+
require_once('../../lib/app.inc.php');
9+
10+
// Check the module permissions and redirect if not allowed.
11+
if(!stristr($_SESSION['s']['user']['modules'],'help')) {
12+
header('Location: ../index.php');
13+
die;
14+
}
15+
16+
// Load the templating and form classes
17+
$app->uses('tpl,tform,tform_actions');
18+
$app->load('tform_actions');
19+
20+
// Create a class page_action that extends the tform_actions base class
21+
class page_action extends tform_actions {
22+
23+
//* Customisations for the page actions will be defined here
24+
25+
}
26+
27+
// Create the new page object
28+
$page = new page_action();
29+
30+
// Start the page rendering and action handling
31+
$page->onLoad();
32+
33+
?>

interface/web/help/faq_list.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
require_once('../../lib/config.inc.php');
4+
require_once('../../lib/app.inc.php');
5+
6+
// Path to the list definition file
7+
$list_def_file = 'list/faq_list.php';
8+
9+
// Check the module permissions
10+
if(!stristr($_SESSION['s']['user']['modules'],'help')) {
11+
header('Location: ../index.php');
12+
die();
13+
}
14+
15+
// Loading the class
16+
$app->uses('listform_actions');
17+
18+
// Optional limit
19+
$hf_section = 0;
20+
if(isset($_GET['hfs_id']))
21+
$hf_section = preg_replace("/[^0-9]/","",$_GET['hfs_id']);
22+
23+
// if section id is not specified in the url, choose the first existing section
24+
if(!$hf_section)
25+
{
26+
$res = $app->db->queryOneRecord("SELECT MIN(hfs_id) AS min_id FROM help_faq_sections");
27+
$hf_section = $res['min_id'];
28+
}
29+
$app->listform_actions->SQLExtWhere = "hf_section = $hf_section";
30+
31+
32+
$res = $app->db->queryOneRecord("SELECT hfs_name FROM help_faq_sections WHERE hfs_id=$hf_section");
33+
// Start the form rendering and action ahndling
34+
echo "<h2>FAQ: ".$res['hfs_name']."</h2>";
35+
$app->listform_actions->onLoad();
36+
37+
?>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
// From and List definition files
4+
$list_def_file = 'list/faq_sections_list.php';
5+
$tform_def_file = 'form/faq_sections.tform.php';
6+
7+
// Include the base libraries
8+
require_once('../../lib/config.inc.php');
9+
require_once('../../lib/app.inc.php');
10+
11+
// Check module permissions
12+
if(!stristr($_SESSION['s']['user']['modules'],'help')) {
13+
header('Location: ../index.php');
14+
die;
15+
}
16+
17+
// Load the form
18+
$app->uses('tform_actions');
19+
$app->tform_actions->onDelete();
20+
21+
?>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
// Set the path to the form definition file.
4+
$tform_def_file = 'form/faq_sections.tform.php';
5+
6+
// include the core configuration and application classes
7+
require_once('../../lib/config.inc.php');
8+
require_once('../../lib/app.inc.php');
9+
10+
// Check the module permissions and redirect if not allowed.
11+
if(!stristr($_SESSION['s']['user']['modules'],'help')) {
12+
header('Location: ../index.php');
13+
die;
14+
}
15+
16+
// Load the templating and form classes
17+
$app->uses('tpl,tform,tform_actions');
18+
$app->load('tform_actions');
19+
20+
// Create a class page_action that extends the tform_actions base class
21+
class page_action extends tform_actions {
22+
23+
//* Customisations for the page actions will be defined here
24+
25+
}
26+
27+
// Create the new page object
28+
$page = new page_action();
29+
30+
// Start the page rendering and action handling
31+
$page->onLoad();
32+
33+
?>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
require_once('../../lib/config.inc.php');
4+
require_once('../../lib/app.inc.php');
5+
6+
// Path to the list definition file
7+
$list_def_file = 'list/faq_sections_list.php';
8+
9+
// Check the module permissions
10+
if(!stristr($_SESSION['s']['user']['modules'],'help')) {
11+
header('Location: ../index.php');
12+
die();
13+
}
14+
15+
// Loading the class
16+
$app->uses('listform_actions');
17+
18+
// Start the form rendering and action ahndling
19+
$app->listform_actions->onLoad();
20+
21+
?>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
// Title of the form.
4+
$form['title'] = 'Frequently Asked Questions';
5+
6+
// Optional description of the form.
7+
$form['description'] = '';
8+
9+
// Name of the form which cannot contain spaces or foreign characters.
10+
$form['name'] = 'faq_form';
11+
12+
// The file that is used to call the form in the browser.
13+
$form['action'] = 'faq_edit.php';
14+
15+
// The name of the database table used to store the data
16+
$form['db_table'] = 'help_faq';
17+
18+
// The name of the database table index field.
19+
// This field must be a numeric auto increment column.
20+
$form['db_table_idx'] = 'hf_id';
21+
22+
// Should changes to this table be stored in the database history (sys_datalog) table.
23+
// This should be set to 'yes' for all tables that store configuration information.
24+
$form['db_history'] = 'no';
25+
26+
// The name of the tab that is shown when the form is opened
27+
$form['tab_default'] = 'message';
28+
29+
// The name of the default list file of this form
30+
$form['list_default'] = 'faq_list.php';
31+
32+
// Use the internal authentication system for this table. This should
33+
// be set to 'yes' in most cases, otherwise 'no'.
34+
$form['auth'] = 'yes';
35+
36+
//** Authentication presets. The defaults below does not need to be changed in most cases.
37+
38+
// 0 = id of the user, > 0 id must match with id of current user
39+
$form['auth_preset']['userid'] = 0;
40+
41+
// 0 = default groupid of the user, > 0 id must match with groupid of current
42+
$form['auth_preset']['groupid'] = 0;
43+
44+
// Permissions with the following codes: r = read, i = insert, u = update, d = delete
45+
$form['auth_preset']['perm_user'] = 'riud';
46+
$form['auth_preset']['perm_group'] = 'riud';
47+
$form['auth_preset']['perm_other'] = 'r';
48+
49+
// The form definition of the first tab. The name of the tab is called 'message'. We refer
50+
// to this name in the $form['tab_default'] setting above.
51+
$form['tabs']['message'] = array(
52+
'title' => 'FAQ', // Title of the Tab
53+
'width' => 100, // Tab width
54+
'template' => 'templates/faq_edit.htm', // Template file name
55+
'fields' => array(
56+
57+
//*** BEGIN Datatable columns **********************************
58+
59+
'hf_section' => array (
60+
'datatype' => 'INTEGER',
61+
'formtype' => 'SELECT',
62+
'default' => '',
63+
'datasource' => array ( 'type' => 'SQL',
64+
'querystring' => 'SELECT hfs_id,hfs_name FROM help_faq_sections',
65+
'keyfield' => 'hfs_id',
66+
'valuefield' => 'hfs_name'
67+
),
68+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
69+
'errmsg'=> 'recipient_id_is_not_integer'),
70+
),
71+
'value' => ($_SESSION['s']['user']['typ'] != 'admin')?array(1 => 'Administrator'):''
72+
),
73+
74+
'hf_question' => array(
75+
'datatype' => 'VARCHAR',
76+
'formtype' => 'TEXT',
77+
'validators' => array( 0 => array( 'type' => 'NOTEMPTY',
78+
'errmsg'=> 'subject_is_empty'
79+
),
80+
),
81+
'default' => '',
82+
'value' => '',
83+
'width' => '30',
84+
'maxlength' => '255'
85+
),
86+
87+
'hf_answer' => array(
88+
'datatype' => 'TEXT',
89+
'formtype' => 'TEXTAREA',
90+
'validators' => array( 0 => array( 'type' => 'NOTEMPTY',
91+
'errmsg'=> 'message_is_empty'
92+
),
93+
),
94+
'default' => '',
95+
'value' => '',
96+
'cols' => '30',
97+
'rows' => '10',
98+
'maxlength' => '255'
99+
),
100+
101+
//*** END Datatable columns **********************************
102+
)
103+
);
104+
?>

0 commit comments

Comments
 (0)