Changeset 25872 for extensions
- Timestamp:
- Dec 9, 2013, 5:34:37 PM (11 years ago)
- Location:
- extensions/ContactForm
- Files:
-
- 5 added
- 5 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ContactForm/admin.php
r23207 r25872 7 7 8 8 // tabsheet 9 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 9 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 10 10 $tabsheet = new tabsheet(); 11 11 $tabsheet->add('config', l10n('Configuration'), CONTACT_FORM_ADMIN . '-config'); … … 17 17 include(CONTACT_FORM_PATH . 'admin/' . $page['tab'] . '.php'); 18 18 19 if (!$conf['ContactForm ']['cf_ready'])19 if (!$conf['ContactForm_ready']) 20 20 { 21 array_push($page['errors'], l10n('No active email address'));21 $page['errors'][] = l10n('No active email address'); 22 22 } 23 23 … … 29 29 30 30 $template->assign_var_from_handle('ADMIN_CONTENT', 'contact_form'); 31 32 ?> -
extensions/ContactForm/admin/config.php
r24348 r25872 5 5 if (isset($_POST['save_config'])) 6 6 { 7 $was_ready = $conf['ContactForm']['cf_ready']; 8 7 if ($_POST['cf_redirect_url']=='http://') 8 { 9 $_POST['cf_redirect_url'] = null; 10 } 11 else if (!empty($_POST['cf_redirect_url'])) 12 { 13 if (strpos($_POST['cf_redirect_url'], 'http') !== 0) 14 { 15 $_POST['cf_redirect_url'] = 'http://' . $_POST['cf_redirect_url']; 16 } 17 if (!url_check_format($_POST['cf_redirect_url'])) 18 { 19 $page['errors'][] = l10n('Invalid redirect URL'); 20 $_POST['cf_redirect_url'] = $conf['ContactForm']['cf_redirect_url']; 21 } 22 } 23 9 24 $conf['ContactForm'] = array( 10 25 'cf_must_initialize' => false, … … 16 31 'cf_mandatory_name' => isset($_POST['cf_mandatory_name']), 17 32 'cf_mail_type' => $_POST['cf_mail_type'], 18 'cf_redirect_url' => ($_POST['cf_redirect_url']!='http://') ? $_POST['cf_redirect_url'] : null, 19 'cf_theme' => $_POST['cf_theme'], 33 'cf_redirect_url' => $_POST['cf_redirect_url'], 20 34 ); 21 35 $conf['ContactForm_before'] = $_POST['cf_before']; 22 36 $conf['ContactForm_after'] = $_POST['cf_after']; 23 37 24 38 conf_update_param('ContactForm', serialize($conf['ContactForm'])); 25 39 conf_update_param('ContactForm_before', $conf['ContactForm_before']); 26 40 conf_update_param('ContactForm_after', $conf['ContactForm_after']); 27 28 $conf['ContactForm']['cf_ready'] = $was_ready; 29 30 array_push($page['infos'], l10n('Information data registered in database')); 41 42 $page['infos'][] = l10n('Information data registered in database'); 31 43 } 32 44 … … 40 52 41 53 $template->set_filename('contact_form', realpath(CONTACT_FORM_PATH . 'admin/template/config.tpl')); 42 43 ?> -
extensions/ContactForm/admin/emails.php
r23207 r25872 9 9 { 10 10 if (isset($entry['delete'])) continue; 11 12 if ( empty($entry['email']) or ! check_email_validity($entry['email']) )11 12 if ( empty($entry['email']) or !email_check_format($entry['email']) ) 13 13 { 14 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));14 $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 15 15 } 16 16 else 17 17 { 18 if (empty($entry['name'])) $entry['name'] = $entry['email']; 18 19 if ($entry['group_name'] == -1) $entry['group_name'] = null; 19 20 array_push($emails,array(20 21 $emails[] = array( 21 22 'name' => $entry['name'], 22 23 'email' => $entry['email'], 23 24 'group_name' => $entry['group_name'], 24 25 'active' => boolean_to_string(isset($entry['active'])), 25 ) );26 ); 26 27 } 27 28 } 28 29 29 30 pwg_query('TRUNCATE TABLE `'. CONTACT_FORM_TABLE. '`;'); 30 31 31 32 mass_inserts( 32 33 CONTACT_FORM_TABLE, … … 34 35 $emails 35 36 ); 36 37 $conf['ContactForm ']['cf_ready'] = count($emails);38 39 array_push($page['infos'], l10n('Information data registered in database'));37 38 $conf['ContactForm_ready'] = count($emails); 39 40 $page['infos'][] = l10n('Information data registered in database'); 40 41 } 41 42 … … 55 56 { 56 57 $data['active'] = get_boolean($data['active']); 57 array_push($emails, $data);58 $emails[] = $data; 58 59 if (!empty($data['group_name'])) 59 60 { 60 array_push($groups, $data['group_name']);61 $groups[] = $data['group_name']; 61 62 } 62 63 } … … 68 69 69 70 $template->set_filename('contact_form', realpath(CONTACT_FORM_PATH . 'admin/template/emails.tpl')); 70 71 ?> -
extensions/ContactForm/admin/template/config.tpl
r23205 r25872 1 {combine_css path=$CONTACT_FORM_PATH|@cat:"admin/template/style.css"} 2 {include file='include/colorbox.inc.tpl'} 3 4 {footer_script}{literal} 5 jQuery("a.preview-box").colorbox(); 6 7 jQuery("input[name='cf_theme']").change(function() { 8 jQuery("input[name='cf_theme']").parents(".themeBox").removeClass("themeDefault"); 9 jQuery(this).parents(".themeBox").addClass("themeDefault"); 10 }); 11 {/literal}{/footer_script} 1 {combine_css path=$CONTACT_FORM_PATH|cat:"admin/template/style.css"} 12 2 13 3 <div class="titrePage"> … … 17 7 <form method="post" action="{$CONTACT_FORM_ADMIN}-config" class="properties"> 18 8 <fieldset> 19 <legend>{'General configuration'| @translate}</legend>9 <legend>{'General configuration'|translate}</legend> 20 10 <ul> 21 11 <li> 22 12 <label> 23 13 <input type="checkbox" name="cf_menu_link" value="1" {if $cf_menu_link}checked="checked"{/if}> 24 {'Add link in menu'| @translate}14 {'Add link in menu'|translate} 25 15 </label> 26 16 </li> … … 28 18 <label> 29 19 <input type="checkbox" name="cf_allow_guest" value="1" {if $cf_allow_guest}checked="checked"{/if}> 30 {'Allow guests to see the form'| @translate}20 {'Allow guests to see the form'|translate} 31 21 </label> 32 22 </li> … … 34 24 <label> 35 25 <input type="checkbox" name="cf_mandatory_mail" value="1" {if $cf_mandatory_mail}checked="checked"{/if}> 36 {'E-mail address is mandatory'| @translate}26 {'E-mail address is mandatory'|translate} 37 27 </label> 38 28 </li> … … 40 30 <label> 41 31 <input type="checkbox" name="cf_mandatory_name" value="1" {if $cf_mandatory_name}checked="checked"{/if}> 42 {'Name is mandatory'| @translate}32 {'Name is mandatory'|translate} 43 33 </label> 44 34 </li> … … 46 36 <label> 47 37 <input type="text" name="cf_redirect_url" value="{if $cf_redirect_url}{$cf_redirect_url}{else}http://{/if}" size="50"> 48 {'Redirect after sending email (optional)'| @translate}38 {'Redirect after sending email (optional)'|translate} 49 39 </label> 50 40 </li> 51 41 </ul> 52 42 </fieldset> 53 43 54 44 <fieldset> 55 <legend>{'E-mail configuration'| @translate}</legend>45 <legend>{'E-mail configuration'|translate}</legend> 56 46 <ul> 57 47 <li> 58 {'E-mail format :'| @translate}48 {'E-mail format :'|translate} 59 49 <label> 60 50 <input type="radio" name="cf_mail_type" value="text/html" {if $cf_mail_type == 'text/html'}checked="checked"{/if}> … … 63 53 <label> 64 54 <input type="radio" name="cf_mail_type" value="text/plain" {if $cf_mail_type == 'text/plain'}checked="checked"{/if}> 65 {'Plain text'| @translate}55 {'Plain text'|translate} 66 56 </label> 67 57 </li> … … 69 59 <label> 70 60 <input type="text" name="cf_default_subject" value="{$cf_default_subject}" size="50"> 71 {'Default e-mail subject'| @translate} ({'can be translated with LocalFiles Editor plugin'|@translate})61 {'Default e-mail subject'|translate} ({'can be translated with LocalFiles Editor plugin'|translate}) 72 62 </label> 73 63 </li> … … 75 65 <label> 76 66 <input type="text" name="cf_subject_prefix" value="{$cf_subject_prefix}" size="50"> 77 {'Prefix of the sent e-mail subject'| @translate} ({'you can use "%gallery_title%"'|@translate})67 {'Prefix of the sent e-mail subject'|translate} ({'you can use "%gallery_title%"'|translate}) 78 68 </label> 79 69 </li> 80 70 </ul> 81 71 </fieldset> 82 72 83 73 <fieldset> 84 <legend>{'Theme'|@translate}</legend> 85 86 <div class="themeBoxes"> 87 <div class="themeBox {if $cf_theme=='clear'}themeDefault{/if}"> 88 <div class="themeName"><label> 89 <input type="radio" name="cf_theme" value="clear" {if $cf_theme=='clear'}checked{/if}> 90 Clear 91 </label></div> 92 <div class="themeShot"> 93 <a href="{$CONTACT_FORM_PATH}admin/template/prev-clear.jpg" class="preview-box"><img src="{$CONTACT_FORM_PATH}admin/template/prev-clear.jpg" width="150"/></a> 94 </div> 95 </div> 96 <div class="themeBox {if $cf_theme=='dark'}themeDefault{/if}"> 97 <div class="themeName"><label> 98 <input type="radio" name="cf_theme" value="dark" {if $cf_theme=='dark'}checked{/if}> 99 Dark 100 </label></div> 101 <div class="themeShot"> 102 <a href="{$CONTACT_FORM_PATH}admin/template/prev-dark.jpg" class="preview-box"><img src="{$CONTACT_FORM_PATH}admin/template/prev-dark.jpg" width="150"/></a> 103 </div> 104 </div> 105 </div> 106 </fieldset> 107 108 <fieldset> 109 <legend>{'Text before the contact form'|@translate}</legend> 74 <legend>{'Text before the contact form'|translate}</legend> 110 75 <textarea rows="4" cols="80" class="description" name="cf_before">{$cf_before}</textarea> 111 76 </fieldset> 112 77 113 78 <fieldset> 114 <legend>{'Text after the contact form'| @translate}</legend>79 <legend>{'Text after the contact form'|translate}</legend> 115 80 <textarea rows="4" cols="80" class="description" name="cf_after">{$cf_after}</textarea> 116 81 </fieldset> 117 82 118 <p style="text-align:left;"><input type="submit" name="save_config" value="{'Submit'| @translate}" class="submit"></p>83 <p style="text-align:left;"><input type="submit" name="save_config" value="{'Submit'|translate}" class="submit"></p> 119 84 </form> -
extensions/ContactForm/admin/template/emails.tpl
r18407 r25872 1 {combine_css path=$CONTACT_FORM_PATH|@cat:"admin/template/style.css"} 2 1 {combine_css path=$CONTACT_FORM_PATH|cat:"admin/template/style.css"} 3 2 4 3 <div class="titrePage"> … … 6 5 </div> 7 6 8 9 7 <form method="post" action="{$CONTACT_FORM_ADMIN}-emails" class="properties"> 10 8 <table class="table2" id="emails"> 11 9 <tr class="throw"> 12 <th>{'Name'| @translate}</th>13 <th>{'Email address'| @translate}</th>14 <th>{'Category'| @translate}</th>15 <th>{'Active'| @translate}</th>16 <th>{'Delete'| @translate}</th>10 <th>{'Name'|translate}</th> 11 <th>{'Email address'|translate}</th> 12 <th>{'Category'|translate}</th> 13 <th>{'Active'|translate}</th> 14 <th>{'Delete'|translate}</th> 17 15 </tr> 18 16 {counter start=0 assign=i} … … 42 40 <tr class="{if $i is odd}row1{else}row2{/if}" id="addEntryContainer"> 43 41 <td colspan="2" style="text-align:center;"> 44 <a id="addEntry">{'+ Add an email'| @translate}</a>42 <a id="addEntry">{'+ Add an email'|translate}</a> 45 43 </td> 46 44 <td> 47 <a id="addGroup">{'+ Add a category'| @translate}</a>45 <a id="addGroup">{'+ Add a category'|translate}</a> 48 46 </td> 49 47 <td colspan="2" style="text-align:center;"> 50 <input type="submit" name="save_emails" value="{'Submit'| @translate}" class="submit">48 <input type="submit" name="save_emails" value="{'Submit'|translate}" class="submit"> 51 49 </td> 52 50 </tr> … … 56 54 57 55 <div class="infos tip"> 58 <b>{'Tip'| @translate}:</b>59 {'Each category is displayed as a distinct "service" on the contact form (example: "Technical", "Commercial", "General question"). Using categories is not mandatory.'| @translate}56 <b>{'Tip'|translate}:</b> 57 {'Each category is displayed as a distinct "service" on the contact form (example: "Technical", "Commercial", "General question"). Using categories is not mandatory.'|translate} 60 58 </div> 61 62 59 63 60 … … 68 65 {/foreach} 69 66 70 {literal} 71 var doBlink = function(obj,start,finish) { jQuery(obj).fadeOut(300).fadeIn(300); if(start!=finish) { start=start+1; doBlink(obj,start,finish); } }; 72 jQuery.fn.blink = function(start,finish) { return this.each(function() { doBlink(this,start,finish) }); }; 67 var doBlink = function(obj,start,finish) { 68 jQuery(obj).fadeOut(300).fadeIn(300); 69 if(start!=finish) { 70 start=start+1; doBlink(obj,start,finish); 71 } 72 }; 73 jQuery.fn.blink = function(start,finish) { 74 return this.each(function() { 75 doBlink(this,start,finish); 76 }); 77 }; 73 78 74 79 jQuery(document).on('change', '.delete', function() { 75 80 if ($(this).is(':checked')) { 76 81 $(this).parents('tr').addClass('delete'); 77 } else { 82 } 83 else { 78 84 $(this).parents('tr').removeClass('delete'); 79 85 } … … 83 89 entry++; 84 90 i = entry; 85 91 86 92 content = 87 93 '<tr class="row'+ (i%2+1) +'">'+ … … 108 114 '</tr>' 109 115 $('#emails').append(content); 110 116 111 117 $('#addEntryContainer') 112 118 .removeClass('row1 row2') … … 116 122 117 123 jQuery('#addGroup').click(function() { 118 name = prompt("{ /literal}{'Name'|@translate}{literal}:");124 name = prompt("{'Name'|translate}:"); 119 125 if (name != null && name != "") { 120 126 name = name.replace(new RegExp('"','g'),"'"); … … 124 130 } 125 131 }); 126 {/ literal}{/footer_script}132 {/footer_script} -
extensions/ContactForm/admin/template/style.css
r23205 r25872 26 26 border-radius:5px; 27 27 } 28 29 .themeBox {30 height:auto;31 padding-bottom:5px;32 } -
extensions/ContactForm/include/contact_form.inc.php
r23207 r25872 4 4 global $template, $user, $conf, $page, $pwg_loaded_plugins; 5 5 6 if ( (!is_classic_user() and !$conf['ContactForm']['cf_allow_guest']) or !$conf['ContactForm ']['cf_ready'] )6 if ( (!is_classic_user() and !$conf['ContactForm']['cf_allow_guest']) or !$conf['ContactForm_ready'] ) 7 7 { 8 8 redirect(get_absolute_root_url()); … … 22 22 'send_copy' => isset($_POST['send_copy']), 23 23 ); 24 24 25 25 $comment_action = send_contact_form($contact, @$_POST['key']); 26 26 … … 105 105 )); 106 106 107 $template->set_filename('index', realpath(CONTACT_FORM_PATH . 'template/contact_form.tpl')); 108 109 ?> 107 $template->set_filename('contactform', realpath(CONTACT_FORM_PATH . 'template/contact_form.tpl')); 108 $template->assign_var_from_handle('CONTENT', 'contactform'); -
extensions/ContactForm/include/functions.inc.php
r24347 r25872 8 8 { 9 9 global $tokens, $page, $conf; 10 10 11 11 if ($tokens[0] == 'contact') 12 12 { 13 add_event_handler('loc_begin_page_header', 'contact_form_header');14 15 13 $page['section'] = 'contact'; 14 $page['title'] = l10n('Contact'); 15 $page['body_id'] = 'theContactPage'; 16 $page['is_external'] = true; 16 17 $page['is_homepage'] = false; 17 18 $page['title'] = l10n('Contact'); 19 $page['section_title'] = $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].'<a href="'.CONTACT_FORM_PUBLIC.'">'.l10n('Contact').'</a>'; 20 } 21 } 22 function contact_form_header() 18 19 $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].'<a href="'.CONTACT_FORM_PUBLIC.'">'.l10n('Contact').'</a>'; 20 } 21 } 22 23 /** 24 * contact page 25 */ 26 function contact_form_page() 23 27 { 24 28 global $page; 25 $page['body_id'] = 'theContactPage';26 }27 28 /**29 * contact page30 */31 function contact_form_page()32 {33 global $page;34 29 35 30 if (isset($page['section']) and $page['section'] == 'contact') 36 31 { 37 include(CONTACT_FORM_PATH . ' /include/contact_form.inc.php');38 } 39 } 40 41 /** 42 * public menu link 32 include(CONTACT_FORM_PATH . 'include/contact_form.inc.php'); 33 } 34 } 35 36 /** 37 * public menu link 43 38 */ 44 39 function contact_form_applymenu($menu_ref_arr) 45 40 { 46 41 global $conf; 47 48 if ( !$conf['ContactForm']['cf_menu_link']) return;49 if ( !is_classic_user() and !$conf['ContactForm']['cf_allow_guest']) return;50 if ( !$conf['ContactForm']['cf_ready']) return;42 43 if (!$conf['ContactForm']['cf_menu_link']) return; 44 if (!is_classic_user() and !$conf['ContactForm']['cf_allow_guest']) return; 45 if (!$conf['ContactForm_ready']) return; 51 46 52 47 $menu = &$menu_ref_arr[0]; 53 48 if (($block = $menu->get_block('mbMenu')) != null) 54 49 { 55 array_push($block->data,array(50 $block->data[] = array( 56 51 'URL' => CONTACT_FORM_PUBLIC, 57 52 'NAME' => l10n('Contact'), 58 ));59 } 60 } 61 62 /** 63 * change contact on link on footer53 ); 54 } 55 } 56 57 /** 58 * change contact link in footer 64 59 */ 65 60 function contact_form_footer_link($content, &$smarty) 66 61 { 67 62 $search = '<a href="mailto:{$CONTACT_MAIL}?subject={\'A comment on your site\'|@translate|@escape:url}">'; 68 $replace = '<a href=" '.CONTACT_FORM_PUBLIC.'">';63 $replace = '<a href="{$CONTACT_FORM_PUBLIC}">'; 69 64 return str_replace($search, $replace, $content); 70 65 } 71 66 72 67 /** 68 * change contact link in mail footer 69 */ 70 function contact_form_mail_template($cache_key, $content_type) 71 { 72 global $conf_mail; 73 74 $template = &$conf_mail[$cache_key]['theme']; 75 $template->assign('CONTACT_FORM_PUBLIC', CONTACT_FORM_PUBLIC); 76 77 if ($content_type == 'text/html') 78 { 79 $template->set_prefilter('mail_footer', 'contact_form_mail_template_html'); 80 } 81 else 82 { 83 $template->set_prefilter('mail_footer', 'contact_form_mail_template_plain'); 84 } 85 } 86 function contact_form_mail_template_html($content) 87 { 88 return str_replace( 89 'mailto:{$CONTACT_MAIL}?subject={\'A comment on your site\'|translate|escape:url}', 90 '{$CONTACT_FORM_PUBLIC}', 91 $content 92 ); 93 } 94 function contact_form_mail_template_plain($content) 95 { 96 return str_replace( 97 '{$CONTACT_MAIL}', 98 '{$CONTACT_FORM_PUBLIC}', 99 $content 100 ); 101 } 102 103 /** 73 104 * init emails list 74 105 */ … … 76 107 { 77 108 global $conf; 78 109 79 110 $query = ' 80 111 SELECT … … 89 120 ;'; 90 121 $result = pwg_query($query); 91 122 92 123 $emails = array(); 93 124 while ($row = pwg_db_fetch_assoc($result)) 94 125 { 95 array_push($emails,array(126 $emails[] = array( 96 127 'name' => $row['username'], 97 128 'email' => $row['email'], 98 129 'active' => 'true', 99 ) );100 } 101 130 ); 131 } 132 102 133 mass_inserts( 103 134 CONTACT_FORM_TABLE, … … 105 136 $emails 106 137 ); 107 138 108 139 $conf['ContactForm']['cf_must_initialize'] = false; 109 140 conf_update_param('ContactForm', serialize($conf['ContactForm'])); … … 116 147 function send_contact_form(&$comm, $key) 117 148 { 118 global $conf, $page, $template, $conf_mail; 119 120 if (!isset($conf_mail)) 121 { 122 $conf_mail = get_mail_configuration(); 123 } 124 149 global $conf, $page, $template; 150 125 151 $query = ' 126 152 SELECT DISTINCT group_name … … 129 155 ;'; 130 156 $groups = array_from_query($query, 'group_name'); 131 157 132 158 $comm = array_merge($comm, 133 159 array( … … 138 164 139 165 $comment_action='validate'; 140 166 141 167 // check key 142 168 if (!verify_ephemeral_key(@$key)) … … 146 172 147 173 // check author 148 if ( $conf['ContactForm']['cf_mandatory_name'] and empty($comm['author']))149 { 150 array_push($page['errors'], l10n('Please enter a name'));151 $comment_action='reject'; 152 } 153 174 if ($conf['ContactForm']['cf_mandatory_name'] and empty($comm['author'])) 175 { 176 $page['errors'][] = l10n('Please enter a name'); 177 $comment_action='reject'; 178 } 179 154 180 // check email 155 if ( $conf['ContactForm']['cf_mandatory_mail'] and empty($comm['email']))156 { 157 array_push($page['errors'], l10n('Please enter an e-mail'));158 $comment_action='reject'; 159 } 160 else if ( !empty($comm['email']) and !check_email_validity($comm['email']))161 { 162 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));181 if ($conf['ContactForm']['cf_mandatory_mail'] and empty($comm['email'])) 182 { 183 $page['errors'][] = l10n('Please enter an e-mail'); 184 $comment_action='reject'; 185 } 186 else if (!empty($comm['email']) and !email_check_format($comm['email'])) 187 { 188 $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 163 189 $comment_action='reject'; 164 190 } … … 167 193 if (empty($comm['subject'])) 168 194 { 169 array_push($page['errors'], l10n('Please enter a subject'));195 $page['errors'][] = l10n('Please enter a subject'); 170 196 $comment_action='reject'; 171 197 } 172 198 else if (strlen($comm['subject']) > 100) 173 199 { 174 array_push($page['errors'], sprintf(l10n('%s must not be more than %d characters long'), l10n('Subject'), 100));175 $comment_action='reject'; 176 } 177 200 $page['errors'][] = sprintf(l10n('%s must not be more than %d characters long'), l10n('Subject'), 100); 201 $comment_action='reject'; 202 } 203 178 204 // check group 179 if ( count($groups) > 1 and $comm['group'] == -1)205 if (count($groups) > 1 and $comm['group'] == -1) 180 206 { 181 207 $comm['group'] = true; 182 array_push($page['errors'], l10n('Please choose a category'));183 $comment_action='reject'; 184 } 185 208 $page['errors'][] = l10n('Please choose a category'); 209 $comment_action='reject'; 210 } 211 186 212 // check content 187 213 if (empty($comm['content'])) 188 214 { 189 array_push($page['errors'], l10n('Please enter a message'));215 $page['errors'][] = l10n('Please enter a message'); 190 216 $comment_action='reject'; 191 217 } 192 218 else if (strlen($comm['subject']) > 2000) 193 219 { 194 array_push($page['errors'], sprintf(l10n('%s must not be more than %d characters long'), l10n('Message'), 2000));195 $comment_action='reject'; 196 } 197 220 $page['errors'][] = sprintf(l10n('%s must not be more than %d characters long'), l10n('Message'), 2000); 221 $comment_action='reject'; 222 } 223 198 224 include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); 199 225 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 200 226 201 227 add_event_handler('contact_form_check', 'user_comment_check', 202 228 EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 203 229 204 230 // perform more spam check 205 231 $comment_action = trigger_event('contact_form_check', $comment_action, $comm); 206 232 207 233 // get admin emails 208 234 $emails = get_contact_emails($comm['group']); 209 235 if (!count($emails)) 210 236 { 211 array_push($page['errors'], l10n('Error while sending e-mail'));237 $page['errors'][] = l10n('Error while sending e-mail'); 212 238 $comment_action='reject'; 213 239 } … … 215 241 if ($comment_action == 'validate') 216 242 { 217 // format subject218 243 $prefix = str_replace('%gallery_title%', $conf['gallery_title'], $conf['ContactForm']['cf_subject_prefix']); 219 $subject = '['.$prefix.'] '.$comm['subject']; 220 $subject = trim(preg_replace('#[\n\r]+#s', '', $subject)); 221 $subject = encode_mime_header($subject); 222 223 // format content 224 $comm['content'] = trigger_event('render_contact_content', $comm['content']); 225 if ($conf['ContactForm']['cf_mail_type'] == 'text/html') 244 245 $from = $Cc = null; 246 if (!empty($comm['email'])) 226 247 { 227 $comm['content'] = nl2br($comm['content']); 248 $from = array( 249 'name' => $comm['author'], 250 'email' => $comm['email'], 251 ); 252 if ($comm['send_copy']) 253 { 254 $Cc = $from; 255 } 228 256 } 229 230 // format expeditor 231 if (empty($comm['email'])) 232 { 233 $args['from'] = $conf_mail['formated_email_webmaster']; 234 } 235 else 236 { 237 $args['from'] = format_email($comm['author'], $comm['email']); 238 } 239 240 // hearders 241 $headers = 'From: '.$args['from']."\n"; 242 $headers.= 'MIME-Version: 1.0'."\n"; 243 $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 244 $headers.= 'Content-Transfer-Encoding: 8bit'."\n"; 245 $headers.= 'Content-Type: '.$conf['ContactForm']['cf_mail_type'].'; charset="'.get_pwg_charset().'";'."\n"; 246 247 set_make_full_url(); 257 248 258 switch_lang_to(get_default_language()); 249 259 load_language('plugin.lang', CONTACT_FORM_PATH); 250 251 // template 252 if ($conf['ContactForm']['cf_mail_type'] == 'text/html') 253 { 254 $mail_css = file_get_contents(dirname(__FILE__).'/../template/mail/style-'.$conf['ContactForm']['cf_theme'].'.css'); 255 $template->set_filename('contact_mail', dirname(__FILE__).'/../template/mail/content_html.tpl'); 256 } 257 else 258 { 259 $mail_css = null; 260 $template->set_filename('contact_mail', dirname(__FILE__).'/../template/mail/content_plain.tpl'); 261 } 262 263 $comm['show_ip'] = isset($conf['contact_form_show_ip']) ? $conf['contact_form_show_ip'] : false; 264 265 $template->assign(array( 266 'cf_prefix' => $prefix, 267 'contact' => $comm, 268 'GALLERY_URL' => get_gallery_home_url(), 269 'PHPWG_URL' => PHPWG_URL, 270 'CONTACT_MAIL_CSS' => $mail_css, 271 )); 272 273 // mail content 274 $content = $template->parse('contact_mail', true); 275 $content = wordwrap($content, 70, "\n", true); 276 277 // send mail 278 $result = 279 trigger_event('send_mail', 280 false, /* Result */ 281 trigger_event('send_mail_to', implode(',', $emails)), 282 trigger_event('send_mail_subject', $subject), 283 trigger_event('send_mail_content', $content), 284 trigger_event('send_mail_headers', $headers), 285 $args 260 261 $result = pwg_mail( 262 $emails, 263 array( 264 'subject' => '['.$prefix.'] '.$comm['subject'], 265 'mail_title' => $prefix, 266 'mail_subtitle' => $comm['subject'], 267 'content_format' => 'text/html', 268 'from' => $from, 269 'Cc' => $Cc, 270 ), 271 array( 272 'filename' => 'mail', 273 'dirname' => realpath(CONTACT_FORM_PATH . 'template'), 274 'assign' => array( 275 'CONTACT' => $comm, 276 ), 277 ) 286 278 ); 287 288 if ( $comm['send_copy'] and !empty($comm['email']) ) 289 { 290 trigger_event('send_mail', 291 false, /* Result */ 292 trigger_event('send_mail_to', $args['from']), 293 trigger_event('send_mail_subject', $subject), 294 trigger_event('send_mail_content', $content), 295 trigger_event('send_mail_headers', $headers), 296 $args 297 ); 298 } 299 300 unset_make_full_url(); 279 301 280 switch_lang_back(); 302 281 load_language('plugin.lang', CONTACT_FORM_PATH); 303 282 304 283 if ($result == false) 305 284 { 306 array_push($page['errors'], l10n('Error while sending e-mail'));285 $page['errors'][] = l10n('Error while sending e-mail'); 307 286 $comment_action='reject'; 308 287 } 309 288 } 310 289 311 290 return $comment_action; 312 291 } … … 322 301 { 323 302 global $conf; 324 303 325 304 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 326 305 327 306 $where = '1=1'; 328 307 if ($group!==true) … … 337 316 } 338 317 } 339 318 340 319 $query = ' 341 SELECT *320 SELECT name, email 342 321 FROM '. CONTACT_FORM_TABLE .' 343 WHERE 322 WHERE 344 323 '.$where.' 345 324 AND active = "true" 346 325 ORDER BY name ASC 347 326 '; 348 $result = pwg_query($query); 349 350 $emails = array(); 351 while ($data = pwg_db_fetch_assoc($result)) 352 { 353 array_push($emails, format_email($data['name'], $data['email'])); 354 } 355 327 $emails = array_from_query($query); 328 356 329 return $emails; 357 330 } 358 359 360 /**361 * check if email is valid362 */363 function check_email_validity($mail_address)364 {365 if (function_exists('email_check_format'))366 {367 return email_check_format($mail_address); // Piwigo 2.5368 }369 else if (version_compare(PHP_VERSION, '5.2.0') >= 0)370 {371 return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;372 }373 else374 {375 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase376 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name377 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';378 379 return (bool)preg_match($regex, $mail_address);380 }381 }382 383 ?> -
extensions/ContactForm/language/en_UK/plugin.lang.php
r19180 r25872 59 59 $lang['Send'] = 'Send'; 60 60 $lang['Send copy to my email'] = 'Send copy to my email'; 61 $lang['Invalid redirect URL'] = 'Invalid redirect URL'; 62 $lang['Name'] = 'Name'; 61 63 62 64 ?> -
extensions/ContactForm/language/fr_FR/plugin.lang.php
r19180 r25872 60 60 $lang['Send'] = 'Envoyer'; 61 61 $lang['Send copy to my email'] = 'Envoyer une copie à mon email'; 62 $lang['Invalid redirect URL'] = 'URL de redirection invalide'; 63 $lang['Name'] = 'Nom'; 62 64 63 65 ?> -
extensions/ContactForm/main.inc.php
r24347 r25872 31 31 add_event_handler('loc_end_section_init', 'contact_form_section_init'); 32 32 add_event_handler('loc_end_index', 'contact_form_page'); 33 add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10);34 33 } 34 35 add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10); 36 add_event_handler('before_parse_mail_template', 'contact_form_mail_template', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 35 37 36 38 include(CONTACT_FORM_PATH . 'include/functions.inc.php'); … … 43 45 { 44 46 global $conf, $template, $pwg_loaded_plugins; 45 46 if ( 47 CONTACT_FORM_VERSION == 'auto' or 48 $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] == 'auto' or 49 version_compare($pwg_loaded_plugins[CONTACT_FORM_ID]['version'], CONTACT_FORM_VERSION, '<') 50 ) 51 { 52 include_once(CONTACT_FORM_PATH . 'include/install.inc.php'); 53 contact_form_install(); 54 55 if ( $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] != 'auto' and CONTACT_FORM_VERSION != 'auto' ) 56 { 57 $query = ' 58 UPDATE '. PLUGINS_TABLE .' 59 SET version = "'. CONTACT_FORM_VERSION .'" 60 WHERE id = "'. CONTACT_FORM_ID .'"'; 61 pwg_query($query); 62 63 $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] = CONTACT_FORM_VERSION; 64 65 if (defined('IN_ADMIN')) 66 { 67 $_SESSION['page_infos'][] = 'ContactForm updated to version '. CONTACT_FORM_VERSION; 68 } 69 } 70 } 71 47 48 include_once(CONTACT_FORM_PATH . 'maintain.inc.php'); 49 $maintain = new ContactForm_maintain(CONTACT_FORM_ID); 50 $maintain->autoUpdate(CONTACT_FORM_VERSION, 'install'); 51 72 52 $conf['ContactForm'] = unserialize($conf['ContactForm']); 73 53 load_language('plugin.lang', CONTACT_FORM_PATH); 74 54 load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true)); 75 55 76 56 if ($conf['ContactForm']['cf_must_initialize']) 77 57 { 78 58 contact_form_initialize_emails(); 79 59 } 80 81 $conf['ContactForm ']['cf_ready'] = count(get_contact_emails());82 83 if ($conf['ContactForm ']['cf_ready'] && (!is_a_guest() || $conf['ContactForm']['cf_allow_guest']))60 61 $conf['ContactForm_ready'] = count(get_contact_emails()); 62 63 if ($conf['ContactForm_ready'] && (!is_a_guest() || $conf['ContactForm']['cf_allow_guest'])) 84 64 { 85 $template->assign('CONTACT_MAIL', true); 65 $template->assign(array( 66 'CONTACT_MAIL' => true, 67 'CONTACT_FORM_PUBLIC' => CONTACT_FORM_PUBLIC, 68 )); 86 69 $template->set_prefilter('tail', 'contact_form_footer_link'); 87 70 } … … 89 72 90 73 /** 91 * admin plugins menu link 74 * admin plugins menu link 92 75 */ 93 function contact_form_admin_menu($menu) 76 function contact_form_admin_menu($menu) 94 77 { 95 array_push($menu,array(78 $menu[] = array( 96 79 'URL' => CONTACT_FORM_ADMIN, 97 80 'NAME' => 'Contact Form', 98 ) );81 ); 99 82 return $menu; 100 83 } 101 102 ?> -
extensions/ContactForm/maintain.inc.php
r24348 r25872 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 defined('CONTACT_FORM_ID') or define('CONTACT_FORM_ID', basename(dirname(__FILE__))); 5 include_once(PHPWG_PLUGINS_PATH . CONTACT_FORM_ID . '/include/install.inc.php'); 4 class ContactForm_maintain extends PluginMaintain 5 { 6 private $installed = false; 6 7 7 function plugin_install() 8 { 9 contact_form_install(); 10 define('contact_form_installed', true); 11 } 8 function install($plugin_version, &$errors=array()) 9 { 10 global $conf, $prefixeTable; 12 11 13 function plugin_activate() 14 { 15 if (!defined('contact_form_installed')) 12 // email table 13 $query = ' 14 CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'contact_form` ( 15 `id` smallint(5) NOT NULL AUTO_INCREMENT, 16 `name` varchar(128) NOT NULL, 17 `email` varchar(128) NOT NULL, 18 `active` enum("true","false") NOT NULL DEFAULT "true", 19 `group_name` varchar(128) DEFAULT NULL, 20 PRIMARY KEY (`id`), 21 UNIQUE KEY `UNIQUE` (`email`,`group_name`) 22 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;'; 23 pwg_query($query); 24 25 // configuration 26 if (empty($conf['ContactForm'])) 27 { 28 $conf['ContactForm'] = serialize(array( 29 'cf_must_initialize' => true, 30 'cf_menu_link' => true, 31 'cf_subject_prefix' => '%gallery_title%', 32 'cf_default_subject' => 'A comment on your site', 33 'cf_allow_guest' => true, 34 'cf_mandatory_mail' => true, 35 'cf_mandatory_name' => true, 36 'cf_mail_type' => 'text/html', 37 'cf_redirect_url' => null, 38 )); 39 40 $conf['ContactForm_before'] = null; 41 $conf['ContactForm_after'] = null; 42 43 conf_update_param('ContactForm', $conf['ContactForm']); 44 conf_update_param('ContactForm_before', $conf['ContactForm_before']); 45 conf_update_param('ContactForm_after', $conf['ContactForm_after']); 46 } 47 else 48 { 49 $new_conf = is_string($conf['ContactForm']) ? unserialize($conf['ContactForm']) : $conf['ContactForm']; 50 51 // migration 2.4 -> 2.5 52 if (!isset($new_conf['cf_must_initialize'])) 53 { 54 // new params 55 $new_conf['cf_default_subject'] = 'A comment on your site'; 56 $new_conf['cf_mail_type'] = 'text/html'; 57 $new_conf['cf_redirect_url'] = null; 58 59 // move emails to database 60 $emails = array(); 61 foreach ($new_conf['cf_admin_mails'] as $email => $data) 62 { 63 $emails[] = array( 64 'email' => $email, 65 'name' => $data['NAME'], 66 'active' => boolean_to_string($data['ACTIVE']), 67 ); 68 } 69 70 $new_conf['cf_must_initialize'] = empty($emails); 71 72 mass_inserts( 73 $prefixeTable .'contact_form', 74 array('name','email','active'), 75 $emails 76 ); 77 78 // old params 79 unset( 80 $new_conf['comment'], $new_conf['cf_redirect_delay'], 81 $new_conf['cf_separator'], $new_conf['cf_separator_length'], 82 $new_conf['cf_admin_mails'] 83 ); 84 85 // save config 86 $conf['ContactForm_before'] = stripslashes(@$conf['persoformtop']); 87 $conf['ContactForm_after'] = stripslashes(@$conf['persoformbottom']); 88 89 conf_update_param('ContactForm_before', $conf['ContactForm_before']); 90 conf_update_param('ContactForm_after', $conf['ContactForm_after']); 91 92 conf_delete_param(array('persoformtop','persoformbottom')); 93 } 94 95 // save config 96 $conf['ContactForm'] = serialize($new_conf); 97 conf_update_param('ContactForm', $conf['ContactForm']); 98 } 99 100 // just in case something went wrong in a previous version 101 if (empty($conf['ContactForm_before'])) 102 { 103 $conf['ContactForm_before'] = null; 104 conf_update_param('ContactForm_before', $conf['ContactForm_before']); 105 } 106 107 if (empty($conf['ContactForm_after'])) 108 { 109 $conf['ContactForm_after'] = null; 110 conf_update_param('ContactForm_after', $conf['ContactForm_after']); 111 } 112 } 113 114 function activate($plugin_version, &$errors=array()) 16 115 { 17 contact_form_install(); 116 if (!$this->installed) 117 { 118 $this->install($plugin_version, $errors); 119 } 120 } 121 122 function deactivate() 123 { 124 } 125 126 127 function uninstall() 128 { 129 global $prefixeTable; 130 131 pwg_query('DROP TABLE IF EXISTS `'. $prefixeTable .'contact_form`;'); 132 133 conf_delete_param(array('ContactForm','ContactForm_before','ContactForm_after')); 18 134 } 19 135 } 20 21 function plugin_uninstall()22 {23 global $prefixeTable, $conf;24 25 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param LIKE "ContactForm%";');26 pwg_query('DROP TABLE IF EXISTS `'. $prefixeTable .'contact_form`;');27 28 unset($conf['ContactForm'], $conf['ContactForm_before'], $conf['ContactForm_after']);29 }30 31 ?> -
extensions/ContactForm/template/contact_form.tpl
r19180 r25872 1 {combine_css path=$CONTACT_FORM_PATH| @cat:"template/style.css"}2 {combine_script id="livevalidation" load="footer" path=$CONTACT_FORM_PATH| @cat:"template/livevalidation.min.js"}1 {combine_css path=$CONTACT_FORM_PATH|cat:"template/style.css"} 2 {combine_script id="livevalidation" load="footer" path=$CONTACT_FORM_PATH|cat:"template/livevalidation.min.js"} 3 3 4 4 {footer_script require='livevalidation'} 5 5 {if $contact.mandatory_name and !$contact.is_logged} 6 6 var author = new LiveValidation('author', {ldelim} onlyOnSubmit: true }); 7 author.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a name'| @translate}" });7 author.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a name'|translate}" }); 8 8 {/if} 9 9 10 10 {if $contact.mandatory_mail and (!$contact.is_logged or empty($contact.email))} 11 11 var email = new LiveValidation('email', {ldelim} onlyOnSubmit: true }); 12 email.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter an e-mail'| @translate}" });13 email.add(Validate.Email, {ldelim} failureMessage: "{'mail address must be like xxx@yyy.eee (example : jack@altern.org)'| @translate}" });12 email.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter an e-mail'|translate}" }); 13 email.add(Validate.Email, {ldelim} failureMessage: "{'mail address must be like xxx@yyy.eee (example : jack@altern.org)'|translate}" }); 14 14 {/if} 15 15 16 16 {if $GROUPS} 17 17 var group = new LiveValidation('group', {ldelim} onlyOnSubmit: true }) 18 group.add(Validate.Exclusion, {ldelim} within: ['-1'], failureMessage: "{'Please choose a category'| @translate}" });18 group.add(Validate.Exclusion, {ldelim} within: ['-1'], failureMessage: "{'Please choose a category'|translate}" }); 19 19 {/if} 20 20 21 21 var subject = new LiveValidation('subject', {ldelim} onlyOnSubmit: true }); 22 subject.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a subject'| @translate}" });22 subject.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a subject'|translate}" }); 23 23 subject.add(Validate.Length, {ldelim} maximum: 100, 24 tooLongMessage: "{'%s must not be more than %d characters long'| @translate|@sprintf:'':100}"24 tooLongMessage: "{'%s must not be more than %d characters long'|translate:'':100}" 25 25 }); 26 26 27 27 var content = new LiveValidation('cf_content', {ldelim} onlyOnSubmit: true }); 28 content.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a message'| @translate}" });28 content.add(Validate.Presence, {ldelim} failureMessage: "{'Please enter a message'|translate}" }); 29 29 content.add(Validate.Length, {ldelim} maximum: 2000, 30 tooLongMessage: "{'%s must not be more %d characters long'|@translate|@sprintf:'':2000}",30 tooLongMessage: "{'%s must not be more than %d characters long'|translate:'':2000}", 31 31 }); 32 32 {/footer_script} 33 33 34 35 {* <!-- Menubar & titrePage --> *}36 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}37 {include file=$CONTACT_FORM_ABS_PATH|@cat:'template/themes/stripped.tpl'}38 {assign var="clear" value="true"}39 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}40 {include file=$CONTACT_FORM_ABS_PATH|@cat:'template/themes/simple.tpl'}41 {assign var="clear" value="true"}42 {else}43 {include file=$CONTACT_FORM_ABS_PATH|@cat:'template/themes/default.tpl'}44 {/if}45 46 47 {if isset($errors) or not empty($infos)}48 {include file='infos_errors.tpl'}49 {/if}50 34 51 35 {if $ContactForm_before} … … 57 41 <table> 58 42 <tr> 59 <td class="title"><label for="author">{'Your name'| @translate}</label></td>43 <td class="title"><label for="author">{'Your name'|translate}</label></td> 60 44 <td> 61 45 {if $contact.is_logged} … … 68 52 </tr> 69 53 <tr> 70 <td class="title"><label for="email">{'Your e-mail'| @translate}</label></td>54 <td class="title"><label for="email">{'Your e-mail'|translate}</label></td> 71 55 <td> 72 56 {if $contact.is_logged and !empty($contact.email)} … … 80 64 {if $GROUPS} 81 65 <tr> 82 <td class="title"><label for="group">{'Category'| @translate}</label></td>66 <td class="title"><label for="group">{'Category'|translate}</label></td> 83 67 <td> 84 68 <select name="group" id="group"> … … 90 74 {/if} 91 75 <tr> 92 <td class="title"><label for="subject">{'Subject'| @translate}</label></td>76 <td class="title"><label for="subject">{'Subject'|translate}</label></td> 93 77 <td><input type="text" name="subject" id="subject" style="width:400px;" value="{$contact.subject}"></td> 94 78 </tr> 95 79 <tr> 96 <td class="title"><label for="cf_content">{'Message'| @translate}</label></td>80 <td class="title"><label for="cf_content">{'Message'|translate}</label></td> 97 81 <td><textarea name="content" id="cf_content" rows="10" style="width:400px;">{$contact.content}</textarea></td> 98 82 </tr> … … 100 84 <td class="title"> </td> 101 85 <td> 102 <input class="submit" type="submit" name="send_mail" value="{'Send'| @translate}">103 <label><input type="checkbox" name="send_copy"> {'Send copy to my email'| @translate}</label>86 <input class="submit" type="submit" name="send_mail" value="{'Send'|translate}"> 87 <label><input type="checkbox" name="send_copy"> {'Send copy to my email'|translate}</label> 104 88 </td> 105 89 </tr> 106 90 </table> 107 91 108 92 <input type="hidden" name="key" value="{$KEY}" /> 109 93 </form> … … 113 97 <div class="contact desc">{$ContactForm_after}</div> 114 98 {/if} 115 116 {if $clear}<div style="clear: both;"></div>117 </div>{/if}118 </div>{* <!-- content --> *} -
extensions/ContactForm/template/style.css
r17945 r25872 37 37 color:#cc0000; 38 38 } 39 .LV_invalid_field, 40 input.LV_invalid_field:hover, 39 .LV_invalid_field, 40 input.LV_invalid_field:hover, 41 41 input.LV_invalid_field:active, 42 textarea.LV_invalid_field:hover, 42 textarea.LV_invalid_field:hover, 43 43 textarea.LV_invalid_field:active { 44 44 border: 1px solid #cc0000;
Note: See TracChangeset
for help on using the changeset viewer.