Changeset 17945 for extensions/ContactForm/include
- Timestamp:
- Sep 16, 2012, 5:20:39 PM (12 years ago)
- Location:
- extensions/ContactForm/include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ContactForm/include/contact_form.inc.php
r17483 r17945 15 15 { 16 16 $contact = array( 17 'author' => trim($_POST['author']), 18 'email' => trim($_POST['email']), 19 'subject' => trim($_POST['subject']), 20 'content' => $_POST['content'], 17 'author' => trim($_POST['author']), 18 'email' => trim($_POST['email']), 19 'group' => @$_POST['group'], 20 'subject' => trim($_POST['subject']), 21 'content' => $_POST['content'], 21 22 ); 22 23 … … 47 48 'author' => $user['username'], 48 49 'email' => $user['email'], 50 'group' => null, 49 51 'subject' => l10n($conf['ContactForm']['cf_default_subject']), 50 52 'content' => null, … … 67 69 } 68 70 71 $query = ' 72 SELECT DISTINCT group_name 73 FROM '. CONTACT_FORM_TABLE .' 74 ORDER BY group_name 75 ;'; 76 $result = pwg_query($query); 77 78 $groups = array(); 79 while ($data = pwg_db_fetch_assoc($result)) 80 { 81 $groups[ $data['group_name'] ] = !empty($data['group_name']) ? l10n($data['group_name']) : l10n('Default'); 82 } 83 84 if (count($groups) > 1) 85 { 86 $template->assign('GROUPS', $groups); 87 } 88 69 89 $template->assign(array( 70 90 'contact' => $contact, … … 77 97 )); 78 98 79 $template->set_filename('index', dirname(__FILE__).'/../template/contact_form.tpl');99 $template->set_filename('index', realpath(CONTACT_FORM_PATH . 'template/contact_form.tpl')); 80 100 81 101 ?> -
extensions/ContactForm/include/functions.inc.php
r17662 r17945 86 86 'name' => $row['username'], 87 87 'email' => $row['email'], 88 'active' => true,88 'active' => 'true', 89 89 )); 90 90 } 91 91 92 $conf['ContactForm']['cf_admin_mails'] = $emails; 92 mass_inserts( 93 CONTACT_FORM_TABLE, 94 array('name','email','active'), 95 $email 96 ); 97 93 98 $conf['ContactForm']['cf_must_initialize'] = false; 94 99 conf_update_param('ContactForm', serialize($conf['ContactForm'])); … … 107 112 $conf_mail = get_mail_configuration(); 108 113 } 114 115 $query = ' 116 SELECT DISTINCT group_name 117 FROM '. CONTACT_FORM_TABLE .' 118 ORDER BY group_name 119 ;'; 120 $groups = array_from_query($query, 'group_name'); 109 121 110 122 $comm = array_merge($comm, … … 159 171 } 160 172 173 // check group 174 if ( count($groups) > 1 and $comm['group'] == -1 ) 175 { 176 $comm['group'] = true; 177 array_push($page['errors'], l10n('Please choose a category')); 178 $comment_action='reject'; 179 } 180 161 181 // check content 162 182 if (empty($comm['content'])) … … 186 206 187 207 // get admin emails 188 $emails = get_contact_emails( );208 $emails = get_contact_emails($comm['group']); 189 209 if (!count($emails)) 190 210 { … … 281 301 /** 282 302 * get contact emails 283 */ 284 function get_contact_emails() 303 * @param mixed group: 304 * - bool true: all emails 305 * - empty string: emails without group 306 * - string: emails with the specified group 307 */ 308 function get_contact_emails($group=true) 285 309 { 286 310 global $conf; … … 288 312 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 289 313 314 $where = '1=1'; 315 if ($group!==true) 316 { 317 if (empty($group)) 318 { 319 $where = 'group_name IS NULL'; 320 } 321 else 322 { 323 $where = 'group_name="'.$group.'"'; 324 } 325 } 326 327 $query = ' 328 SELECT * 329 FROM '. CONTACT_FORM_TABLE .' 330 WHERE 331 '.$where.' 332 AND active = "true" 333 ORDER BY name ASC 334 '; 335 $result = pwg_query($query); 336 290 337 $emails = array(); 291 foreach ($conf['ContactForm']['cf_admin_mails'] as $data) 292 { 293 if ($data['active']) 294 { 295 array_push($emails, format_email($data['name'], $data['email'])); 296 } 338 while ($data = pwg_db_fetch_assoc($result)) 339 { 340 array_push($emails, format_email($data['name'], $data['email'])); 297 341 } 298 342 -
extensions/ContactForm/include/install.inc.php
r17658 r17945 4 4 function contact_form_install() 5 5 { 6 global $conf; 6 global $conf, $prefixeTable; 7 8 // email table 9 $query = ' 10 CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'contact_form` ( 11 `id` smallint(5) NOT NULL AUTO_INCREMENT, 12 `name` varchar(128) NOT NULL, 13 `email` varchar(128) NOT NULL, 14 `active` enum("true","false") NOT NULL DEFAULT "true", 15 `group_name` varchar(128) DEFAULT NULL, 16 PRIMARY KEY (`id`), 17 UNIQUE KEY `UNIQUE` (`email`,`group_name`) 18 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;'; 19 pwg_query($query); 7 20 8 21 // configuration … … 19 32 'cf_redirect_delay' => 5, 20 33 'cf_mail_type' => 'text/html', 21 'cf_admin_mails' => array(),22 34 )); 23 35 … … 37 49 if (!isset($new_conf['cf_must_initialize'])) 38 50 { 51 // new params 39 52 $new_conf['cf_must_initialize'] = false; 40 53 $new_conf['cf_default_subject'] = 'A comment on your site'; 41 54 $new_conf['cf_mail_type'] = 'text/html'; 42 unset($new_conf['comment'], $new_conf['cf_redirect_delay'], $new_conf['cf_separator'], $new_conf['cf_separator_length']);43 55 56 // move emails to database 57 $email = array(); 44 58 foreach ($new_conf['cf_admin_mails'] as $email => $data) 45 59 { 46 $new_conf['cf_admin_mails'][] =array(60 array_push($emails, array( 47 61 'email' => $email, 48 62 'name' => $data['NAME'], 49 'active' => $data['ACTIVE'], 50 ); 51 unset($new_conf['cf_admin_mails'][ $email ]); 63 'active' => boolean_to_string($data['ACTIVE']), 64 )); 52 65 } 53 66 67 mass_inserts( 68 $prefixeTable .'contact_form', 69 array('name','email','active'), 70 $emails 71 ); 72 73 // old params 74 unset( 75 $new_conf['comment'], $new_conf['cf_redirect_delay'], 76 $new_conf['cf_separator'], $new_conf['cf_separator_length'], 77 $new_conf['cf_admin_mails'] 78 ); 79 80 // save config 54 81 $conf['ContactForm'] = serialize($new_conf); 55 82 $conf['ContactForm_before'] = stripslashes($conf['persoformtop']);
Note: See TracChangeset
for help on using the changeset viewer.