Viewing 1 post (of 1 total)
  • Author
    Posts
  • youyou Friend
    #163795

    Hello,

    Here is some corrections I propose for the JA QuickContact module version 1.0.1
    I have modified the version I have download http://www.joomlart.com/forums/downloads.php?do=file&id=2272 the 10 Mai 2011.
    <blockquote>JA Quick Contact module for Joomla 1.6 (7.6 KB) 1.0.1 02-20-2011</blockquote>
    If a new version has been released at the time you are reading this mail, DO NOT USE MY FILE.

    I have corrected some errors and it seems to be working fine now (including famous Error 404).
    You can test it by replacing the two files modified or by installing the module as usual with the file:
    13038

    The corrections are:

    • Correct the subject writted by the user (avoid error 404)
    • Correct sender name in email (use Name writted by the user)
    • Correct display of the input box for the subject writted by the user (Make use of admin field “Email’s subject” on focus/on blur)
    • Correct Message by adding the subject writted by the user and moddifying the title by “Default Subject – Subject writted by User” or “Subject writted by User” if “Default Subject” is empty in admin panel. (You can change this to just “Default Subject” by removing the line: $subject .= ” – $email_subject”; )

    NOTE: “Default Subject” refers to field “Subject” in admin panel

    I hope to have done this propoerly but use it with caution.
    If you have problem, you just have to reinstall the original version and eventually delete the folder “your_website_root/modules/mod_jaquickcontact/modYouyouBackup”.
    You can also read what modifications I have done.

    Modifications are commented and Files modified are:

    • your_website_root/modules/mod_jaquickcontact/mod_jaquickcontact.php
    • your_website_root/modules/mod_jaquickcontact/tmpl/default.php

    Hope this helps 🙂

    PS: If you don’t want to be redirected on the article “Thank you”, The redirect page (in admin panel) must be set to the “page” #contact-us

    Here is the modified files:

    • your_website_root/modules/mod_jaquickcontact/mod_jaquickcontact.php

    <?php
    defined('_JEXEC') or die('Restricted access');

    $mainframe = JFactory::getApplication();

    if (!defined ('_MODE_JAQUICKCONTACT_ASSETS_')) {
    define ('_MODE_JAQUICKCONTACT_ASSETS_', 1);
    JHTML::stylesheet('modules/'.$module->module.'/assets/css/style.css');

    if (is_file(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'css'.DS.$module->module.".css"))
    JHTML::stylesheet('templates/'.$mainframe->getTemplate().'/css/'.$module->module.".css");

    JHTML::_('behavior.mootools');
    JHTML::_('behavior.tooltip');
    }

    $do_submit = isset($_POST['do_submit'])?$_POST['do_submit']:0;
    $status =null;

    $captcha = JPluginHelper::importPlugin('content','captcha');
    $user = JFactory::getUser();
    $name = isset($user->username)?$user->username:'';
    $email = isset($user->email)?$user->email:'';
    $text ='';
    $subject = $params->get('subject');

    /*-- Youyou Modification (add) --*/

    $email_subject='';

    /*-- // Youyou Modification --*/

    $senderlabel =$params->get('sender_label',JText::_( 'ENTER_YOUR_NAME' ));
    $email_label =$params->get('email_label',JText::_( 'EMAIL_ADDRESS' ));
    $subject_label =$params->get('subject_label',JText::_( 'ENTER_YOUR_SUBJECT') );
    $message_label =$params->get('message_label',JText::_( 'ENTER_YOUR_MESSAGE' ));
    $error = array();
    if($do_submit)
    {
    $name = stripslashes(JRequest::getVar('name',$name));
    $email = stripslashes(JRequest::getVar('email',$email));

    /*-- Youyou Modification --*/

    /* $subject = stripslashes(JRequest::getVar('subject',$subject)); */

    $email_subject = stripslashes(JRequest::getVar('email_subject',$email_subject));

    /*-- // Youyou Modification --*/

    $text = JRequest::getString('text');
    if(!eregi("^([_a-z0-9-]+)(.[_a-z0-9-]+)*@(+)(.+)*(.{2,4})$", $email) )
    {
    $error['email'] = JText::_("EMAIL_REQUIRE");
    }
    if(!$name)
    {
    $error['name']= JText::_("NAME_REQUIRE");
    }

    /*-- Youyou Modification --*/

    /* if(!$subject)
    {
    $error['subject']= JText::_("SUBJECT_REQUIRE");
    } */

    if(!$email_subject)
    {
    $error['email_subject']= JText::_("SUBJECT_REQUIRE");
    }

    /*-- // Youyou Modification --*/

    if (strlen($text)>$params->get('max_chars',1000) ||strlen($text)<5)
    {
    $error['text'] =JText::_('MESSAGE_REQUIRE');
    }
    if ($captcha==true)
    {
    $ccheck = $mainframe->triggerEvent('onValidateForm');

    if (!$ccheck ||(isset($ccheck)&&!$ccheck[0]))
    {
    $error['captcha_code'] = JText::_('CAPTCHA_REQUIRE');
    }
    }
    if(count($error)==0)
    {

    /*-- Youyou Modification (add) --*/

    if($subject=='')
    {
    $subject=$email_subject; /* Email Subject of the user */
    }
    else
    {
    $subject .= " - $email_subject"; /* Fied Subject in the backend of the module + Email Subjexct of the user */
    }

    /*-- // Youyou Modification --*/

    $header = "From: $email";

    /*-- Youyou Modification --*/

    /* $message = "
    Name: $name <br/>
    Email: $email <br/> "; */

    $message = "
    Name: $name <br/>
    Email: $email <br/>
    Subject: $email_subject <br/> ";

    /*-- // Youyou Modification --*/

    $message .=
    "<br/>
    $text
    ";
    $email_copy =(JRequest::getVar('email_copy',0)==1)?1:0;
    $adminemail = $mainframe->getCfg( 'mailfrom' );
    $recipient =$params->get('recipient',$adminemail);
    $mail = JFactory::getMailer();

    $mail->addRecipient( $recipient );
    if ($params->get('show_email_copy',0)&&($email_copy==1))
    {
    $mail->addRecipient( $email);
    }
    $mail->IsHTML(true);

    /*-- Youyou Modification --*/

    /* $mail->setSender( array( $email, $subject ) ); */

    $mail->setSender( array( $email, $name ) );

    /*-- // Youyou Modification --*/

    $mail->setSubject( $subject );
    $mail->setBody( $message );

    $success = $mail->Send();
    if($success===true)
    {
    $thanks = $params->get('thank_msg','Thank you!') ;
    $url_redirect =$params->get('redirect_url','index.php');
    return $mainframe->redirect($url_redirect,$thanks);
    }
    else
    {
    if (strtolower(get_class($success)) == 'jexception')
    {
    $status = $success->getMessage();
    }
    else $status = JText::_('Error send mail');
    }

    }
    unset($_POST["do_submit"]);
    unset($do_submit);

    }

    $templatename = $mainframe->getTemplate();
    if (file_exists(JPATH_THEMES.DS.$templatename.DS.'css'.DS.'mod_jaquickcontact.css'))
    {
    JHTML::stylesheet('templates/'.$mainframe->getTemplate().'/css/'.$module->module.".css");

    }
    require(JModuleHelper::getLayoutPath('mod_jaquickcontact'));

    • your_website_root/modules/mod_jaquickcontact/tmpl/default.php

    <?php
    defined('_JEXEC') or die('Restricted access');
    ?>
    <?php if ($status!=''):?>
    <script type="text/javascript">
    alert('<?php echo $status;?>');
    </script>
    <?php endif;?>
    <div id="<?php echo $params->get('class_suffix','')?>ja-form">
    <div class="<?php echo $params->get('class_suffix','')?>form-info">
    <h3><?php echo $params->get('intro_text','Contact Us')?></h3>
    </div>
    <form action="#" name="contact" method="post" id="contact" class="form-validate">
    <ul class="<?php echo $params->get('class_suffix','')?>form-list">
    <li class="<?php echo $params->get('class_suffix','')?>wide clearfix" id="row_name">
    <label for="contact_name" class="required">
     <?php echo $senderlabel;?>:
    </label>
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <div id="error_name" class="<?php echo $params->get('class_suffix','')?>jl_error"><?php if(isset($error['name']))echo $error['name'] ?></div>
    <input id="contact_name" type="text" name="name" value="<?php if ($name!='')echo $name; else echo $senderlabel; ?>" maxlength="60" size="40" onblur="if(this.value=='')this.value='<?php echo $senderlabel?>';" onfocus="if(this.value=='<?php echo $senderlabel?>')this.value='';" />
    </div>
    </li>
    <li class="<?php echo $params->get('class_suffix','')?>wide clearfix" id="row_email">
    <label id="contact_emailmsg" for="contact_email">
     <?php echo $email_label?>:
    </label>
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <div id="error_email" class="<?php echo $params->get('class_suffix','')?>jl_error"><?php if(isset($error['email']))echo $error['email'] ?></div>
    <input class="input-text" id="contact_email" type="text" name="email" value="<?php if ($email!='')echo $email; else echo $email_label; ?>" maxlength="64" size="40" onblur="if(this.value=='')this.value='<?php echo $email_label ?>';" onfocus="if(this.value=='<?php echo $email_label?>')this.value='';" />
    <div class="<?php echo $params->get('class_suffix','')?>small"><?php echo JText::_('NOTICE_REQUEST_USER_REAL_EMAIL');?> </div>
    </div>
    </li>

    <!--Youyou Modification -->

    <!--
    <li class="<?php echo $params->get('class_suffix','')?>wide clearfix" id="row_subject">
    <label id="contact_textmsg" class="required" for="contact_subject">
     <?php echo $subject_label?>:
    </label>
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <div id="error_subject" class="<?php echo $params->get('class_suffix','')?>jl_error"><?php if(isset($error['error_subject']))echo $error['error_subject'] ?></div>
    <input class="input-text" id="contact_subject" name="subject" value="<?php echo @$subject?>" size="40"/>
    </div>
    </li>
    -->

    <li class="<?php echo $params->get('class_suffix','')?>wide clearfix" id="row_subject">
    <label id="contact_subjectmsg" class="required" for="contact_subject">
     <?php echo $subject_label?>:
    </label>
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <div id="error_subject" class="<?php echo $params->get('class_suffix','')?>jl_error"><?php if(isset($error['error_subject']))echo $error['error_subject'] ?></div>
    <input class="input-text" id="contact_subject" type="text" name="email_subject" size="40"
    onblur="if(this.value=='')this.value='<?php echo $subject_label?>';"
    onfocus="if(this.value=='<?php echo $subject_label;?>')this.value='';"
    value="<?php if($email_subject!='') echo $email_subject; else echo $subject_label;?>"
    />
    </div>
    </li>

    <!--// Youyou Modification -->

    <li class="<?php echo $params->get('class_suffix','')?>wide clearfix" id="row_text">
    <label id="contact_textmsg" class="required" for="contact_text">
     <?php echo $message_label?>:
    </label>
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <div id="error_text" class="<?php echo $params->get('class_suffix','')?>jl_error"><?php if(isset($error['error_text']))echo $error['error_text'] ?></div>
    <textarea class="textarea" id="contact_text" name="text" rows="10" cols="40" onblur="if(this.value=='')this.value='<?php echo $message_label?>';" onfocus="if(this.value=='<?php echo $message_label;?>')this.value='';"><?php if($text!='') echo $text; else echo $message_label?></textarea>
    </div>
    </li>
    <?php if ($params->get( 'show_email_copy' ,0)) : ?>
    <li class="<?php echo $params->get('class_suffix','')?>wide">
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <input type="checkbox" name="email_copy" id="contact_email_copy" value="1" />
    <label for="contact_email_copy">
    <?php echo JText::_( 'SEND_ME_A_COPIED_EMAIL' ); ?>
    </label>
    </div>
    </li>
    <?php endif; ?>
    <?php if ($captcha):?>
    <li class="<?php echo $params->get('class_suffix','')?>wide">
    <div class="<?php echo $params->get('class_suffix','')?>input-box">
    <div id="error_captcha_code" class="<?php echo $params->get('class_suffix','')?>jl_error"><?php if(isset($error['captcha_code']))echo $error['captcha_code'] ?></div>
    <?php

    $mainframe->triggerEvent('onAfterDisplayForm');
    ?>
    </div>
    </li>
    <?php endif;?>
    <li>
    <div style="padding-top: 10px;">
    <a href="javascript:void(0)" id="ac-submit" class="button-img but-orange"><span class="icon icon-submit"> </span><span><?php echo JText::_("SEND_EMAIL"); ?></span></a>
    </div>
    </li>
    </ul>
    <input type="hidden" name="subject" id="subject" value="<?php echo $params->get('subject','Error 404')?>" />
    <input type="hidden" name="category" value="Error/Problems using site" />
    <input type="hidden" name="do_submit" value="1">
    <?php echo JHTML::_( 'form.token' ); ?>
    </form>
    </div>
    <script type="text/javascript">
    /* <!+@(+.)+{2,4}$/;
    if(!regex.test(email))
    {
    if((email=='')||(email==emailabel))
    {
    $('error_email').innerHTML ='<?php echo JText::_('ERROR_EMAIL_EMPTY')?>';
    }
    else
    {
    $('error_email').innerHTML ="<?php echo JText::_('ERROR_EMAIL_INVALID')?>";
    }
    $('row_email').addClass('error');
    ck=false;
    }
    else
    {
    $('error_email').innerHTML ='';
    }
    var name = $('contact_name').value;
    if((name=='')||(name==senderlabel))
    {
    $('error_name').innerHTML ='<?php echo JText::_("ERROR_NAME_INVALID")?>';
    $('row_name').addClass('error');
    ck = false;
    }
    else
    {
    $('error_name').innerHTML ='';
    }

    /*--// Youyou Modification --*/

    /* var subject = $('contact_subject').value;
    if(subject=='') */

    var email_subject = $('contact_subject').value;
    if(email_subject=='' || email_subject=='<?php echo $subject_label?>')

    /*--// Youyou Modification --*/

    {
    $('error_subject').innerHTML ="<?php echo JText::_("SUBJECT_REQUIRE")?>";
    $('row_subject').addClass('error');
    ck = false;
    }
    else
    {
    $('error_subject').innerHTML ='';
    }
    var message = $('contact_text').value;
    if((message.length>maxchars) ||(message.length<5)||(message==messagelabel))
    {

    $('error_text').innerHTML ='<?php $error_message = JText::_('ERROR_MESSAGE_INVALID'); echo addslashes($error_message);?>';
    $('row_text').addClass('error');
    ck = false;
    }
    else
    {
    $('error_text').innerHTML ='';
    }
    if(captcha)
    {
    var captcha_code = $('captcha_code').value;
    if((captcha_code=='')||(captcha_code=='Type the code shown'))
    {
    $('error_captcha_code').innerHTML = "<?php echo JText::_('EMPTY_CAPTCHA')?>";
    ck = false;
    }
    else $('error_captcha_code').innerHTML = "";
    }
    if(ck)
    {
    $("contact").submit();
    }
    return ck;
    };
    });
    /* ]]> */
    </script>


Viewing 1 post (of 1 total)

This topic contains 1 reply, has 1 voice, and was last updated by  youyou 8 years, 5 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum