diff options
| -rw-r--r-- | contact.php | 62 | ||||
| -rw-r--r-- | messu_lib.php | 10 | ||||
| -rw-r--r-- | templates/contact.tpl | 91 |
3 files changed, 85 insertions, 78 deletions
diff --git a/contact.php b/contact.php index 0b00fa8..987d080 100644 --- a/contact.php +++ b/contact.php @@ -3,7 +3,7 @@ * message package modules * * @author -* @version $Header: /cvsroot/bitweaver/_bit_messages/contact.php,v 1.2 2005/06/28 07:45:52 spiderr Exp $ +* @version $Header: /cvsroot/bitweaver/_bit_messages/contact.php,v 1.3 2005/07/25 20:02:15 squareing Exp $ * @package messages * @subpackage functions */ @@ -17,54 +17,32 @@ */ require_once( '../bit_setup_inc.php' ); -include_once( MESSU_PKG_PATH.'messu_lib.php' ); - -if (!$user) { - $smarty->assign('msg', tra("You are not logged in")); - - $gBitSystem->display( 'error.tpl' ); - die; +if( !$gBitSystem->isFeatureActive( 'feature_contact' ) ) { + $gBitSystem->fatalError( "The Contact feature is disabled." ); } -if ($feature_contact != 'y') { - $smarty->assign('msg', tra("This feature is disabled").": feature_contact"); +include_once( MESSU_PKG_PATH.'messu_lib.php' ); - $gBitSystem->display( 'error.tpl' ); - die; +$userInfo = $gBitUser->getUserInfo( array( 'login' => $gBitSystem->getPreference( 'contact_user' ) ) ); +$email = $userInfo['email']; +if( empty( $email ) ) { + $gBitSystem->fatalError( "This feature is not correctly set up. The email address is missing." ); +} else { + $smarty->assign( 'email', $email ); } -$gBitSystem->display( 'bitpackage:messu/contact.tpl'); - -$email = $userlib->get_user_email($contact_user); -$smarty->assign('email', $email); - -if ($user and $feature_messages == 'y' and $bit_p_messages == 'y') { - $smarty->assign('sent', 0); - - if (isset($_REQUEST['send'])) { - - $smarty->assign('sent', 1); - - $message = ''; - - // Validation: - // must have a subject or body non-empty (or both) - if (empty($_REQUEST['subject']) && empty($_REQUEST['body'])) { - $smarty->assign('message', tra('ERROR: Either the subject or body must be non-empty')); - - die; - } - - $message = tra('Message sent to'). ':' . $contact_user . '<br/>'; - $messulib->post_message($contact_user, $user, $_REQUEST['to'], - '', $_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['priority']); +if( $gBitSystem->isPackageActive( 'quicktags' ) ) { + include_once( QUICKTAGS_PKG_PATH.'quicktags_inc.php' ); +} - $smarty->assign('message', $message); +if (!empty($_REQUEST['send'])) { + if( empty( $_REQUEST['subject'] ) && empty( $_REQUEST['body'] ) ) { + $gBitSystem->fatalError( "Either a subject or a message body is required." ); } + $messulib->post_message( $userInfo['login'], $gBitUser->mUsername, $_REQUEST['to'], '', $_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['priority']); + $feedback['success'] = tra( 'Your message was sent to' ).': '.( !empty( $userInfo['real_name'] ) ? $userInfo['real_name'] : $userInfo['login'] ); + $smarty->assign( 'feedback', $feedback ); } -$smarty->assign('priority', 3); - - - +$gBitSystem->display( 'bitpackage:messu/contact.tpl'); ?> diff --git a/messu_lib.php b/messu_lib.php index dd26ecf..7aa043e 100644 --- a/messu_lib.php +++ b/messu_lib.php @@ -3,7 +3,7 @@ * message package modules * * @author -* @version $Revision: 1.2 $ +* @version $Revision: 1.3 $ * @package messages */ @@ -21,8 +21,14 @@ class Messu extends BitBase { function post_message( $pToLogin, $to, $cc, $bcc, $subject, $body, $priority) { global $smarty, $gBitUser, $gBitSystem; - + $userInfo = $gBitUser->getUserInfo( array('login' => $pToLogin) ); + if (!$userInfo) { + if (is_numeric($pToLogin)) { + $userInfo = $gBitUser->getUserInfo( array('user_id' => $pToLogin) ); + } + } + if( $userInfo ) { if ($gBitUser->getPreference('allowMsgs', 'y', $userInfo['user_id'] )) { $subject = strip_tags($subject); diff --git a/templates/contact.tpl b/templates/contact.tpl index aea863b..3e32921 100644 --- a/templates/contact.tpl +++ b/templates/contact.tpl @@ -1,35 +1,58 @@ -<a class="pagetitle" href="{$gBitLoc.MESSU_PKG_URL}contact.php">{tr}Contact us{/tr}</a><br /><br /> -{if $gBitSystem->isFeatureActive( 'feature_messages' ) and $bit_p_messages eq 'y'} -{if $message} -{$message} -{/if} +{strip} +<div class="display pigeonholes"> + <div class="header"> + <h1>{tr}Contact Us{/tr}</h1> + </div> -<h2>{tr}Send a message to us{/tr}</h2> - <form method="post" action="{$gBitLoc.MESSU_PKG_URL}contact.php"> - <input type="hidden" name="to" value="{$contact_user|escape}" /> - <table class="panel"> - <tr> - <td>{tr}Priority:{/tr}</td><td> - <select name="priority"> - <option value="1" {if $priority eq 1}selected="selected"{/if}>{tr}1 -Lowest-{/tr}</option> - <option value="2" {if $priority eq 2}selected="selected"{/if}>{tr}2 -Low-{/tr}</option> - <option value="3" {if $priority eq 3}selected="selected"{/if}>{tr}3 -Normal-{/tr}</option> - <option value="4" {if $priority eq 4}selected="selected"{/if}>{tr}4 -High-{/tr}</option> - <option value="5" {if $priority eq 5}selected="selected"{/if}>{tr}5 -Very High-{/tr}</option> - </select> - <input type="submit" name="send" value="{tr}send{/tr}" /> - </td> - </tr> - <tr> - <td>{tr}Subject{/tr}:</td><td><input type="text" name="subject" value="" size="50" maxlength="255" /></td> - </tr> - <tr><td> </td> - <td><textarea rows="20" cols="80" name="body"></textarea></td> - </tr> -</table> -</form> -{/if} -{if strlen($email)>0} -<h2>{tr}Contact us via email{/tr}</h2> -{mailto address="$email" encode="javascript" text="click here to send us an email"} -{/if} + <div class="body"> + {formfeedback hash=$feedback} + + {form legend="Send us a message"} + <input type="hidden" name="to" value="{$contact_user|escape}" /> + + <div class="row"> + {formlabel label="Priority" for="priority"} + {forminput} + <select name="priority" id="priority"> + <option value="1" {if $priority eq 1}selected="selected"{/if}>{tr}1 -Lowest-{/tr}</option> + <option value="2" {if $priority eq 2}selected="selected"{/if}>{tr}2 -Low-{/tr}</option> + <option value="3" {if $priority eq 3 or !$priority}selected="selected"{/if}>{tr}3 -Normal-{/tr}</option> + <option value="4" {if $priority eq 4}selected="selected"{/if}>{tr}4 -High-{/tr}</option> + <option value="5" {if $priority eq 5}selected="selected"{/if}>{tr}5 -Very High-{/tr}</option> + </select> + {formhelp note=""} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Subject" for="subject"} + {forminput} + <input type="text" name="subject" id="subject" size="50" maxlength="255" /> + {formhelp note=""} + {/forminput} + </div> + + {* only display quicktags if tikiwiki quicktags are available *} + {if $gBitSystem->isPackageActive( 'quicktags' ) and $gLibertySystem->mPlugins.tikiwiki.is_active eq 'y'} + {include file="bitpackage:quicktags/quicktags_full.tpl" textarea_id=message_body default_format=tikiwiki} + {/if} + + {* only display smileys if tikiwiki quicktags are available *} + {if $gBitSystem->isPackageActive( 'smileys' ) and $gLibertySystem->mPlugins.tikiwiki.is_active eq 'y'} + {include file="bitpackage:smileys/smileys_full.tpl" textarea_id=message_body default_format=tikiwiki} + {/if} + + <div class="row"> + {forminput} + <textarea rows="20" cols="80" name="body" id="message_body"></textarea> + {formhelp note=""} + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="send" value="{tr}Send Message{/tr}" /> + </div> + {/form} + </div><!-- end .body --> +</div><!-- end .liberty --> +{/strip} |
