[21040] Feature: add request for support form 4746:4909

Sigurd Nes <[email protected]> Wed, 24 Feb 2010 21:46:56 +0000
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 21040
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=21040
Author:   sigurdne
Date:     2010-02-24 21:46:56 +0000 (Wed, 24 Feb 2010)
Log Message:
-----------
Feature: add request for support form 4746:4909

Modified Paths:
--------------
    people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php
    people/sigurdne/modules/manual/trunk/templates/base/help.tpl

Added Paths:
-----------
    people/sigurdne/modules/manual/trunk/inc/class.uisupport.inc.php
    people/sigurdne/modules/manual/trunk/setup/phpgw_no.lang
    people/sigurdne/modules/manual/trunk/templates/base/support.xsl

Modified: people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php
===================================================================
--- people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php	2010-02-24 21:45:25 UTC (rev 21039)
+++ people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php	2010-02-24 21:46:56 UTC (rev 21040)
@@ -3,7 +3,7 @@
 	* phpGroupWare - Manual
 	*
 	* @author Sigurd Nes <[email protected]>
-	* @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc. http://www.fsf.org/
+	* @copyright Copyright (C) 2003-2010 Free Software Foundation, Inc. http://www.fsf.org/
 	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
 	* @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
 	* @package manual
@@ -146,11 +146,21 @@
 
 			$attrib_data 	= $GLOBALS['phpgw']->custom_fields->get($appname, $location, $id);
 
+			$helpmsg = nl2br(str_replace(array
+						(
+							'[',
+							']'
+						),array
+						(
+							'<',
+							'>'
+						),$attrib_data['helpmsg']));
+
 			$function_msg	= lang('Help');
 
 			$t->set_file('help', 'help.tpl');
 			$t->set_var('title', lang('Help') . " - \"{$attrib_data['input_text']}\"");
-			$t->set_var('help_msg', $attrib_data['helpmsg'] );
+			$t->set_var('help_msg', $helpmsg );
 			$t->set_var('lang_close', lang('close'));
 											
 			$GLOBALS['phpgw']->common->phpgw_header();

Added: people/sigurdne/modules/manual/trunk/inc/class.uisupport.inc.php
===================================================================
--- people/sigurdne/modules/manual/trunk/inc/class.uisupport.inc.php	                        (rev 0)
+++ people/sigurdne/modules/manual/trunk/inc/class.uisupport.inc.php	2010-02-24 21:46:56 UTC (rev 21040)
@@ -0,0 +1,146 @@
+<?php
+	/**
+	 * Frontend : a simplified tool for end users.
+	 *
+	 * @author Sigurd Nes <[email protected]>
+	 * @copyright Copyright (C) 2010 Free Software Foundation, Inc. http://www.fsf.org/
+	 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
+	 * @package Frontend
+	 * @version $Id$
+	 */
+
+	/*
+	   This program is free software: you can redistribute it and/or modify
+	   it under the terms of the GNU General Public License as published by
+	   the Free Software Foundation, either version 2 of the License, or
+	   (at your option) any later version.
+
+	   This program is distributed in the hope that it will be useful,
+	   but WITHOUT ANY WARRANTY; without even the implied warranty of
+	   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	   GNU General Public License for more details.
+
+	   You should have received a copy of the GNU General Public License
+	   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+	 */
+
+
+	/**
+	 * Manual
+	 *
+	 * @package Manual
+	 */
+
+	class manual_uisupport
+	{
+
+		public $public_functions = array
+		(
+			'send'				=> true,
+		);
+
+		public function __construct()
+		{
+			$GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+			$GLOBALS['phpgw_info']['flags']['noframework'] =  true;
+		}
+
+
+		public function send()
+		{
+			$values	= phpgw::get_var('values');
+
+			$receipt = array();
+			if (isset($values['save']))
+			{
+				if($GLOBALS['phpgw']->session->is_repost())
+				{
+					$receipt['error'][]=array('msg'=>lang('repost'));
+				}
+
+				if(!isset($values['address']) || !$values['address'])
+				{
+					$receipt['error'][]=array('msg'=>lang('Missing address'));
+				}
+
+				if(!isset($values['details']) || !$values['details'])
+				{
+					$receipt['error'][]=array('msg'=>lang('Please give som details'));
+				}
+
+				$attachments = array();
+				
+				if(isset($_FILES['file']['name']) && $_FILES['file']['name'])
+				{
+					$file_name	= str_replace(' ','_',$_FILES['file']['name']);
+					$mime_magic = createObject('phpgwapi.mime_magic');
+					$mime       = $mime_magic->filename2mime($file_name);
+
+					$attachments[] = array
+					(
+						'file' => $_FILES['file']['tmp_name'],
+						'name' => $file_name,
+						'type' => $mime
+					);
+				}
+
+				if (!$receipt['error'])
+				{
+					if (isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server'] )
+					{
+						if (!is_object($GLOBALS['phpgw']->send))
+						{
+							$GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+						}
+					
+						$from = "{$GLOBALS['phpgw_info']['user']['fullname']}<{$values['from_address']}>";
+
+						$receive_notification = true;
+						$rcpt = $GLOBALS['phpgw']->send->msg('email', $values['address'],'Support',
+							 stripslashes(nl2br($values['details'])), '', '', '',
+							 $from , $GLOBALS['phpgw_info']['user']['fullname'],
+							 'html', '', $attachments , $receive_notification);
+
+						if($rcpt)
+						{
+							$receipt['message'][]=array('msg'=>lang('message sent'));
+						}
+					}
+					else
+					{
+						$receipt['error'][]=array('msg'=>lang('SMTP server is not set! (admin section)'));
+					}
+				}
+			}
+
+			$data = array
+			(
+				'msgbox_data'	=> $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($receipt)),
+				'from_name'		=> $GLOBALS['phpgw_info']['user']['fullname'],
+				'from_address'	=> $GLOBALS['phpgw_info']['user']['preferences']['property']['email'],
+				'form_action'		=> $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'manual.uisupport.send')),
+				'support_address'	=> $GLOBALS['phpgw_info']['server']['support_address'],
+			);
+
+            $GLOBALS['phpgw']->xslttpl->add_file('support');
+			$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('send' => $data));
+		}
+
+		public function drawings()
+		{
+			$receipt = array();
+
+			$receipt['error'][]=array('msg'=>'Eksempel på feilmelding');
+			$receipt['message'][]=array('msg'=>'Eksempel på gladmelding');
+
+			$data = array
+			(
+				'msgbox_data'	=> $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($receipt)),
+				'tabs'			=> $this->tabs,
+				'date_start'	=> $GLOBALS['phpgw']->yuical->add_listener('date_start', $date_start),
+				'date_end'		=> $GLOBALS['phpgw']->yuical->add_listener('date_end', $date_end),
+			);
+			self::render_template(array('frontend'), array('demo_2' => $data));
+		}
+
+	}

Added: people/sigurdne/modules/manual/trunk/setup/phpgw_no.lang
===================================================================
--- people/sigurdne/modules/manual/trunk/setup/phpgw_no.lang	                        (rev 0)
+++ people/sigurdne/modules/manual/trunk/setup/phpgw_no.lang	2010-02-24 21:46:56 UTC (rev 21040)
@@ -0,0 +1,13 @@
+address	manual	no	Adresse
+description	manual	no	Beskrivelse
+details	manual	no	Detaljer
+file	manual	no	Fil
+from	manual	no	Fra
+from adress	manual	no	Avsender adresse
+message sent	manual	no	Melding er sendt
+missing address	manual	no	Mangler adresse
+repost	manual	no	Melding er allerede sendt
+Please give som details	manual	no	Angi beskrivelse
+send	manual	no	Send
+support	common	no	Support
+

Modified: people/sigurdne/modules/manual/trunk/templates/base/help.tpl
===================================================================
--- people/sigurdne/modules/manual/trunk/templates/base/help.tpl	2010-02-24 21:45:25 UTC (rev 21039)
+++ people/sigurdne/modules/manual/trunk/templates/base/help.tpl	2010-02-24 21:46:56 UTC (rev 21040)
@@ -8,7 +8,7 @@
 <h2>{title}</h2>
 <table>
 	<tr>
-		<td>
+		<td align = 'left'>
 			{help_msg}
 		</td>
 	</tr>

Added: people/sigurdne/modules/manual/trunk/templates/base/support.xsl
===================================================================
--- people/sigurdne/modules/manual/trunk/templates/base/support.xsl	                        (rev 0)
+++ people/sigurdne/modules/manual/trunk/templates/base/support.xsl	2010-02-24 21:46:56 UTC (rev 21040)
@@ -0,0 +1,91 @@
+<!-- $Id$ -->
+
+	<xsl:template match="send" xmlns:php="http://php.net/xsl">
+		<form ENCTYPE="multipart/form-data" name="form" method="post" action="{form_action}">
+		<table cellpadding="0" cellspacing="0" width="100%">
+ 			<xsl:choose>
+				<xsl:when test="msgbox_data != ''">
+					<tr>
+						<td align="left" colspan="2">
+							<xsl:call-template name="msgbox"/>
+						</td>
+					</tr>
+				</xsl:when>
+			</xsl:choose>
+
+ 			<tr class="th">
+				<td class="th_text" valign="top">
+					<xsl:value-of select="php:function('lang', 'address')" />
+				</td>
+				<td class="th_text" valign="top">
+					<input type="text" name="values[address]" value="{support_address}">
+						<xsl:attribute name="size">
+							<xsl:text>60</xsl:text>
+						</xsl:attribute>
+						<xsl:attribute name="title">
+							<xsl:value-of select="php:function('lang', 'address')" />
+						</xsl:attribute>
+					</input>
+				</td>
+			</tr>
+			<tr>
+				<td class="th_text" valign="top">
+					<xsl:value-of select="php:function('lang', 'from')" />
+				</td>
+				<td class="th_text" valign="top">
+					<xsl:value-of select="from_name"/>
+				</td>
+			</tr>
+			<tr>
+				<td class="th_text" valign="top">
+					<xsl:value-of select="php:function('lang', 'from adress')" />
+				</td>
+				<td class="th_text" valign="top">
+					<input type="text" name="values[from_address]" value="{from_address}">
+						<xsl:attribute name="size">
+							<xsl:text>60</xsl:text>
+						</xsl:attribute>
+						<xsl:attribute name="title">
+							<xsl:value-of select="php:function('lang', 'address')" />
+						</xsl:attribute>
+					</input>
+				</td>
+			</tr>
+			<tr>
+				<td valign="top">
+					<xsl:value-of select="php:function('lang', 'description')" />
+				</td>
+				<td>
+					<textarea cols="60" rows="10" name="values[details]" wrap="virtual" onMouseout="window.status='';return true;">
+						<xsl:attribute name="title">
+							<xsl:value-of select="php:function('lang', 'details')" />
+						</xsl:attribute>
+						<xsl:value-of select="value_details"/>		
+					</textarea>
+				</td>
+			</tr>
+			<tr>
+				<td valign="top">
+					<xsl:value-of select="php:function('lang', 'file')" />
+				</td>
+				<td>
+					<input type="file" name="file" size="50">
+						<xsl:attribute name="title">
+							<xsl:value-of select="php:function('lang', 'file')" />
+						</xsl:attribute>
+					</input>
+				</td>
+			</tr>
+
+			<tr height="50">
+				<td>
+					<xsl:variable name="lang_send"><xsl:value-of select="php:function('lang', 'send')" /></xsl:variable>					
+					<input type="submit" name="values[save]" value="{$lang_send}" title='{$lang_send}'>
+					</input>
+				</td>
+			</tr>
+
+ 		</table>
+ 		</form>
+	</xsl:template>
+