tbrehm
2007-08-21 aa17242faa4cf067731444cda26e0456de23870f
Added ISPConfig help module and a the first parts of a basic trouble ticket system.
12 files added
1 files modified
482 ■■■■■ changed files
install/sql/ispconfig3.sql 21 ●●●●● patch | view | raw | blame | history
interface/web/help/form/support_message.tform.php 120 ●●●●● patch | view | raw | blame | history
interface/web/help/lib/admin.conf.php 8 ●●●●● patch | view | raw | blame | history
interface/web/help/lib/lang/en_support_message.lng 9 ●●●●● patch | view | raw | blame | history
interface/web/help/lib/lang/en_support_message_list.lng 11 ●●●●● patch | view | raw | blame | history
interface/web/help/lib/module.conf.php 43 ●●●●● patch | view | raw | blame | history
interface/web/help/list/support_message.list.php 62 ●●●●● patch | view | raw | blame | history
interface/web/help/support_message_del.php 51 ●●●●● patch | view | raw | blame | history
interface/web/help/support_message_edit.php 63 ●●●●● patch | view | raw | blame | history
interface/web/help/support_message_list.php 23 ●●●●● patch | view | raw | blame | history
interface/web/help/templates/support_message_edit.htm 32 ●●●●● patch | view | raw | blame | history
interface/web/help/templates/support_message_list.htm 25 ●●●●● patch | view | raw | blame | history
interface/web/help/templates/support_message_view.htm 14 ●●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql
@@ -593,6 +593,27 @@
-- --------------------------------------------------------
-- 
-- Tabellenstruktur für Tabelle `support_message`
--
CREATE TABLE `support_message` (
  `support_message_id` bigint(20) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `recipient_id` int(11) NOT NULL default '0',
  `sender_id` int(11) NOT NULL default '0',
  `subject` varchar(255) default NULL,
  `message` varchar(255) default NULL,
  `tstamp` int(11) NOT NULL default '1187707778',
  PRIMARY KEY  (`support_message_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sys_datalog`
-- 
interface/web/help/form/support_message.tform.php
New file
@@ -0,0 +1,120 @@
<?php
//* Title of the form
$form["title"]             = "Support Message";
//* Description of the form (optional)
$form["description"]     = "";
//* Name of the form. The name shall not contain spaces or foreign characters
$form["name"]             = "support_message";
//* The file that is used to call the form in the browser
$form["action"]            = "support_message_edit.php";
//* The name of the database table that shall be used to store the data
$form["db_table"]        = "support_message";
//* The name of the database table index field, this field must be a numeric auto increment column
$form["db_table_idx"]    = "support_message_id";
//* Shall changes to this table be stored in the database history (sys_datalog) table.
//* This should be set to "yes" for all tables that store configuration information.
$form["db_history"]        = "no"; // yes / no
//* The name of the tab that is shown when the form is opened
$form["tab_default"]    = "message";
//* The name of the default list file of this form
$form["list_default"]    = "support_message_list.php";
//* Use the internal authentication system for this table. This should
//* be set to yes in most cases
$form["auth"]            = 'yes'; // yes / no
//* Authentocation presets. The defaults below does not need to be changed in most cases.
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Begin of the form definition of the first tab. The name of the tab is called "message". We refer
//* to this name in the $form["tab_default"] setting above.
$form["tabs"]['message'] = array (
    'title'     => "Message", // Title of the Tab
    'width'     => 100, // Tab width
    'template'     => "templates/support_message_edit.htm", // Template file name
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'recipient_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'            => 'SQL',
                                        'querystring'     => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username',
                                        'keyfield'        => 'userid',
                                        'valuefield'    => 'username'
                                     ),
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'recipient_id_is_not_integer'),
                                    ),
            'value'        => ''
        ),
        'sender_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'            => 'SQL',
                                        'querystring'     => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username',
                                        'keyfield'        => 'userid',
                                        'valuefield'    => 'username'
                                     ),
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'recipient_id_is_not_integer'),
                                    ),
            'value'        => ''
        ),
        'subject' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'subject_is_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'message' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXTAREA',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'message_is_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'cols'        => '30',
            'rows'        => '10',
            'maxlength'    => '255'
        ),
        'tstamp' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => time(),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '30'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/help/lib/admin.conf.php
New file
@@ -0,0 +1,8 @@
<?php
/*
    The admin.conf.php file contains menu definitions to be displayed in the administration modile.
*/
?>
interface/web/help/lib/lang/en_support_message.lng
New file
@@ -0,0 +1,9 @@
<?php
$wb["recipient_id_txt"] = 'recipient_id';
$wb["sender_id_txt"] = 'sender_id';
$wb["subject_txt"] = 'subject';
$wb["message_txt"] = 'message';
$wb["tstamp_txt"] = 'tstamp';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
?>
interface/web/help/lib/lang/en_support_message_list.lng
New file
@@ -0,0 +1,11 @@
<?php
$wb["list_head_txt"] = 'support_message';
$wb["sender_id_txt"] = 'sender_id';
$wb["subject_txt"] = 'subject';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
?>
interface/web/help/lib/module.conf.php
New file
@@ -0,0 +1,43 @@
<?php
//* Name of the module. The module name must match the name of the module directory. The module name may not contain spaces.
$module["name"]      = "help";
//* Title of the module. The title is dispalayed in the top navigation.
$module["title"]     = "Help";
//* The template file of the module. This is always module.tpl.htm if you do not have any special requirements like a 3 column layout.
$module["template"]  = "module.tpl.htm";
//* The page that is displayed when the module is loaded. the path must is relative to the web directory
$module["startpage"] = "help/index.php";
//* The width of the tab. Normally you should leave this empty and let the browser define the width automatically.
$module["tab_width"] = '';
/*
------------------------------------------
- Menu Definition
------------------------------------------
*/
//* make sure that the items array is empty
$items = array();
//* Add a menu item with the label "Send message"
$items[] = array( 'title'   => 'Send message',
                  'target'  => 'content',
                  'link'    => 'help/support_message_edit.php');
//* Add a menu item with the label "View messages"
$items[] = array( 'title'   => 'View messages',
                  'target'  => 'content',
                  'link'    => 'help/support_message_list.php');
//* Add the menu items defined above to a menu section labeled 'Support'
$module["nav"][] = array( 'title' => 'Support',
                          'open'  => 1,
                          'items'    => $items);
?>
interface/web/help/list/support_message.list.php
New file
@@ -0,0 +1,62 @@
<?php
//* Name of the list
$liste["name"]                 = "support_message";
//* Database table
$liste["table"]             = "support_message";
//* Index index field of the database table
$liste["table_idx"]            = "support_message_id";
//* Search Field Prefix
$liste["search_prefix"]     = "search_";
//* Records per page
$liste["records_per_page"]     = 15;
//* Script File of the list
$liste["file"]                = "support_message_list.php";
//* Script file of the edit form
$liste["edit_file"]            = "support_message_edit.php";
//* Script File of the delete script
$liste["delete_file"]        = "support_message_del.php";
//* Paging Template
$liste["paging_tpl"]        = "templates/paging.tpl.htm";
//* Enable auth
$liste["auth"]                = "yes";
/*****************************************************
* Search fields
*****************************************************/
$liste["item"][] = array(    'field'        => "sender_id",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "SELECT",
                            'op'        => "=",
                            'prefix'    => "",
                            'suffix'    => "",
                            'width'        => "",
                            'datasource'=> array (     'type' => 'SQL',
                                        'querystring'     => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username',
                                        'keyfield'        => 'userid',
                                        'valuefield'    => 'username'
                                     ),
                            'value'        => "");
$liste["item"][] = array(    'field'        => "subject",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'        => "",
                            'value'        => "");
?>
interface/web/help/support_message_del.php
New file
@@ -0,0 +1,51 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//* From and List definition files
$list_def_file = "list/support_message.list.php";
$tform_def_file = "form/support_message.tform.php";
//* Include the base libraries
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Check module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'help')) {
    header("Location: ../index.php");
    exit;
}
//* Load the form
$app->uses("tform_actions");
$app->tform_actions->onDelete();
?>
interface/web/help/support_message_edit.php
New file
@@ -0,0 +1,63 @@
<?php
//* Set the path to the form definition file.
$tform_def_file = "form/support_message.tform.php";
//* include the basic application and configuration files
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Checking module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'help')) {
    header("Location: ../index.php");
    exit;
}
//* Loading the templating and form classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
//* Creating a class page_action that extends the tform_actions base class
class page_action extends tform_actions {
    //* Custom onSubmit Event handler
    function onSubmit() {
        global $app, $conf;
        //* If the current user is not the admin user
        if($_SESSION["s"]["user"]["typ"] != 'admin') {
            //* Set the admin as recipient
            $this->dataRecord["recipient_id"] = 1;
        }
        // Set the sender_id field to the ID of the current user
        $this->dataRecord["sender_id"] = $_SESSION["s"]["user"]["userid"];
        //* call the onSubmit function of the parent class
        parent::onSubmit();
    }
    //* Custom onShow Event handler
    function onShow() {
        global $app, $conf;
        //* We do not want that messages get edited, so we switch to a
        //  read only template  if a existing message is loaded
        if($this->id > 0) {
            $app->tform->formDef['tabs']['message']['template'] = 'templates/support_message_view.htm';
        }
        //* call the onShow function of the parent class
        parent::onShow();
    }
}
//* Create the new page object
$page = new page_action();
//* Start the page rendering and action handling
$page->onLoad();
?>
interface/web/help/support_message_list.php
New file
@@ -0,0 +1,23 @@
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Path to the list definition file
$list_def_file = "list/support_message.list.php";
//* Check the module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'help')) {
    header("Location: ../index.php");
    exit;
}
//* Loading the class
$app->uses('listform_actions');
//* Optional limit
// $app->listform_actions->SQLExtWhere = "type = 'alias'";
//* Start the form rendering and action ahndling
$app->listform_actions->onLoad();
?>
interface/web/help/templates/support_message_edit.htm
New file
@@ -0,0 +1,32 @@
<table width="500" border="0" cellspacing="0" cellpadding="2">
  <tmpl_if name="is_admin">
  <tr>
    <td class="frmText11">{tmpl_var name='recipient_id_txt'}:</td>
    <td class="frmText11">
        <select name="recipient_id" class="text">
            {tmpl_var name='recipient_id'}
        </select>
    </td>
  </tr>
  </tmpl_if>
  <tr>
    <td class="frmText11">{tmpl_var name='subject_txt'}:</td>
    <td class="frmText11"><input name="subject" type="text" class="text" value="{tmpl_var name='subject'}" size="30" maxlength="255"></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='message_txt'}:</td>
    <td class="frmText11"><textarea name='message' cols='30' rows='10'>{tmpl_var name='message'}</textarea></td>
  </tr>
  <tr>
    <td class="frmText11">&nbsp;</td>
    <td class="frmText11">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','help/support_message_edit.php');"><div class="buttonEnding"></div>&nbsp;
      <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('help/support_message_list.php');"><div class="buttonEnding"></div>
    </td>
  </tr>
</table>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<input type="hidden" name="tstamp" value="{tmpl_var name='tstamp'}">
interface/web/help/templates/support_message_list.htm
New file
@@ -0,0 +1,25 @@
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<input type="button" value="{tmpl_var name="add_new_record_txt"}" class="button" onClick="loadContent('help/support_message_edit.php');" /><div class="buttonEnding"></div><br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
  <tr>
    <td class="tblHead"><tmpl_var name="sender_id_txt"></td>
    <td class="tblHead"><tmpl_var name="subject_txt"></td>
    <td class="tblHead">&nbsp;</td>
  </tr>
  <tr>
    <td class="frmText11"><select name="search_sender_id" onChange="submitForm('pageForm','help/support_message_list.php');">{tmpl_var name='search_sender_id'}</select></td>
    <td class="frmText11"><input type="text" name="search_subject" value="{tmpl_var name='search_subject'}" class="text" /></td>
    <td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick="submitForm('pageForm','help/support_message_list.php');"><div class="buttonEnding"></div></td>
  </tr>
  <tmpl_loop name="records">
  <tr bgcolor="{tmpl_var name="bgcolor"}">
    <td class="frmText11"><a href="#" onClick="loadContent('help/support_message_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="sender_id"}</a></td>
    <td class="frmText11"><a href="#" onClick="loadContent('help/support_message_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="subject"}</a></td>
    <td class="frmText11" align="right">[<a href="javascript: del_record('help/support_message_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}');" class="frmText11">{tmpl_var name='delete_txt'}</a>]</td>
  </tr>
  </tmpl_loop>
  <tr>
      <td colspan="3" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
  </tr>
</table>
interface/web/help/templates/support_message_view.htm
New file
@@ -0,0 +1,14 @@
<table width="500" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td class="frmText11">{tmpl_var name='subject_txt'}:</td>
    <td class="frmText11">{tmpl_var name='subject'}</td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='message_txt'}:</td>
    <td class="frmText11">{tmpl_var name='message'}</td>
  </tr>
  <tr>
    <td class="frmText11">&nbsp;</td>
    <td class="frmText11">&nbsp;</td>
  </tr>
</table>