Changeset 1809
- Timestamp:
- Feb 13, 2007, 12:21:23 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_notification_by_mail.inc.php
r1806 r1809 258 258 * Return none 259 259 */ 260 function set_user_on_env_nbm( $user_id, $is_action_send)260 function set_user_on_env_nbm(&$nbm_user, $is_action_send) 261 261 { 262 262 global $user, $lang, $lang_info, $env_nbm; 263 263 264 264 $user = array(); 265 $user['id'] = $ user_id;265 $user['id'] = $nbm_user['user_id']; 266 266 $user = array_merge($user, getuserdata($user['id'], true)); 267 267 … … 287 287 if ($is_action_send) 288 288 { 289 $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']); 289 $nbm_user['template'] = $user['template']; 290 $nbm_user['theme'] = $user['theme']; 291 $env_nbm['mail_template'] = 292 get_mail_template($env_nbm['email_format'], 293 array('template' => $nbm_user['template'], 'theme' => $nbm_user['theme'])); 290 294 $env_nbm['mail_template']->set_filename('notification_by_mail', 'admin/notification_by_mail.tpl'); 291 295 } … … 432 436 { 433 437 // set env nbm user 434 set_user_on_env_nbm($nbm_user ['user_id'], true);438 set_user_on_env_nbm($nbm_user, true); 435 439 436 440 $subject = '['.$conf['gallery_title'].']: '.($is_subscribe ? l10n('nbm_object_subscribe'): l10n('nbm_object_unsubscribe')); … … 446 450 ); 447 451 448 if (pwg_mail( 452 if (pwg_mail 453 ( 449 454 format_email($nbm_user['username'], $nbm_user['mail_address']), 450 $env_nbm['send_as_mail_formated'], 451 $subject, 452 $env_nbm['mail_template']->parse('notification_by_mail', true), 453 $env_nbm['email_format'], $env_nbm['email_format'] 454 )) 455 array 456 ( 457 'from' => $env_nbm['send_as_mail_formated'], 458 'subject' => $subject, 459 'email_format' => $env_nbm['email_format'], 460 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 461 'content_format' => $env_nbm['email_format'], 462 'template' => $nbm_user['template'], 463 'theme' => $nbm_user['theme'] 464 ) 465 )) 455 466 { 456 467 inc_mail_sent_success($nbm_user); -
trunk/admin/notification_by_mail.php
r1806 r1809 274 274 275 275 // set env nbm user 276 set_user_on_env_nbm($nbm_user ['user_id'], $is_action_send);276 set_user_on_env_nbm($nbm_user, $is_action_send); 277 277 278 278 if ($is_action_send) … … 378 378 ); 379 379 380 if (pwg_mail( 380 if (pwg_mail 381 ( 381 382 format_email($nbm_user['username'], $nbm_user['mail_address']), 382 $env_nbm['send_as_mail_formated'], 383 $subject, 384 $env_nbm['mail_template']->parse('notification_by_mail', true), 385 $env_nbm['email_format'], $env_nbm['email_format'] 386 )) 383 array 384 ( 385 'from' => $env_nbm['send_as_mail_formated'], 386 'subject' => $subject, 387 'email_format' => $env_nbm['email_format'], 388 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 389 'content_format' => $env_nbm['email_format'], 390 'template' => $nbm_user['template'], 391 'theme' => $nbm_user['theme'] 392 ) 393 )) 387 394 { 388 395 inc_mail_sent_success($nbm_user); -
trunk/include/functions_mail.inc.php
r1808 r1809 65 65 format_email($conf['gallery_title'], $conf_mail['email_webmaster']); 66 66 67 $conf_mail['boundary_key'] = generate_key(32); 68 67 69 return $conf_mail; 68 70 } … … 98 100 99 101 /** 100 * Returns an new mail template 101 * 102 * @param none 103 */ 104 function get_mail_template($email_format) 105 { 106 global $user; 107 108 $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template'], $user['theme']); 109 $mail_template->set_rootdir(PHPWG_ROOT_PATH.'template/'.$user['template'].'/mail/'.$email_format); 102 * Return an completed array template/theme 103 * completed with $conf['default_template'] 104 * 105 * @params: 106 * - args: incompleted array of template/theme 107 * o template: template to use [default $conf['default_template']] 108 * o theme: template to use [default $conf['default_template']] 109 */ 110 function get_array_template_theme($args = array()) 111 { 112 global $conf; 113 114 $res = array(); 115 116 if (empty($args['template']) or empty($args['theme'])) 117 { 118 list($res['template'], $res['theme']) = explode('/', $conf['default_template']); 119 } 120 121 if (!empty($args['template'])) 122 { 123 $res['template'] = $args['template']; 124 } 125 126 if (!empty($args['theme'])) 127 { 128 $res['theme'] = $args['theme']; 129 } 130 131 return $res; 132 } 133 134 /** 135 * Return an new mail template 136 * 137 * @params: 138 * - email_format: mail format 139 * - args: function params of mail function: 140 * o template: template to use [default $conf['default_template']] 141 * o theme: template to use [default $conf['default_template']] 142 */ 143 function get_mail_template($email_format, $args = array()) 144 { 145 $args = get_array_template_theme($args); 146 147 $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']); 148 $mail_template->set_rootdir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format); 110 149 111 150 return $mail_template; … … 124 163 /** 125 164 * sends an email, using PhpWebGallery specific informations 126 */ 127 function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $format_infos = 'text/plain', $email_format = null) 128 { 129 global $conf, $conf_mail, $lang_info, $page, $user; 130 131 $cvt7b_subject = str_translate_to_ascii7bits($subject); 165 * 166 * @param: 167 * - to: Receiver, or receivers of the mail. 168 * - args: function params of mail function: 169 * o from: sender [default value webmaster email] 170 * o subject [default value 'PhpWebGallery'] 171 * o content: content of mail [default value ''] 172 * o content_format: format of mail content [default value 'text/plain'] 173 * o email_format: global mail format [default value $conf_mail['default_email_format']] 174 * o template: template to use [default $conf['default_template']] 175 * o theme: template to use [default $conf['default_template']] 176 */ 177 //function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $infos_format = 'text/plain', $email_format = null) 178 function pwg_mail($to, $args = array()) 179 { 180 global $conf, $conf_mail, $lang_info, $page; 132 181 133 182 if (!isset($conf_mail)) … … 136 185 } 137 186 138 if (is_null($email_format)) 139 { 140 $email_format = $conf_mail['default_email_format']; 141 } 142 143 if (($format_infos == 'text/html') and ($email_format == 'text/plain')) 187 if (empty($args['email_format'])) 188 { 189 $args['email_format'] = $conf_mail['default_email_format']; 190 } 191 192 // Compute root_path in order have complete path 193 if ($args['email_format'] == 'text/html') 194 { 195 set_make_full_url(); 196 } 197 198 $to = format_email('', $to); 199 200 if (empty($args['from'])) 201 { 202 $args['from'] = $conf_mail['formated_email_webmaster']; 203 } 204 else 205 { 206 $args['from'] = format_email('', $args['from']); 207 } 208 209 if (empty($args['subject'])) 210 { 211 $args['subject'] = 'PhpWebGallery'; 212 } 213 $cvt7b_subject = str_translate_to_ascii7bits($args['subject']); 214 215 if (!isset($args['content'])) 216 { 217 $args['content'] = ''; 218 } 219 220 if (empty($args['content_format'])) 221 { 222 $args['content_format'] = 'text/plain'; 223 } 224 225 if (($args['content_format'] == 'text/html') and ($args['email_format'] == 'text/plain')) 144 226 { 145 227 // Todo find function to convert html text to plain text … … 147 229 } 148 230 149 // Compute root_path in order have complete path 150 if ($email_format == 'text/html') 151 { 152 set_make_full_url(); 153 } 154 155 $to = format_email('', $to); 156 157 if ($from == '') 158 { 159 $from = $conf_mail['formated_email_webmaster']; 160 } 161 else 162 { 163 $from = format_email('', $from); 164 } 165 166 $headers = 'From: '.$from."\n"; 167 $headers.= 'Reply-To: '.$from."\n"; 168 $headers.= 'Content-Type: '.$email_format.';format=flowed;charset="'.$lang_info['charset'].'";'; 169 $headers.= 'reply-type=original'."\n"; 231 $args = array_merge($args, get_array_template_theme($args)); 232 233 $headers = 'From: '.$args['from']."\n"; 234 $headers.= 'Reply-To: '.$args['from']."\n"; 235 $headers.= 'Content-Type: multipart/alternative;'."\n"; 236 $headers.= ' boundary="---='.$conf_mail['boundary_key'].'";'."\n"; 237 $headers.= ' reply-type=original'."\n"; 170 238 $headers.= 'MIME-Version: 1.0'."\n"; 171 239 … … 177 245 $content = ''; 178 246 179 if (!isset($conf_mail[$ email_format][$lang_info['charset']][$user['template']][$user['theme']]))247 if (!isset($conf_mail[$args['email_format']][$lang_info['charset']][$args['template']][$args['theme']])) 180 248 { 181 249 if (!isset($mail_template)) 182 250 { 183 $mail_template = get_mail_template($ email_format);251 $mail_template = get_mail_template($args['email_format']); 184 252 } 185 253 … … 190 258 array( 191 259 //Header 260 'BOUNDARY_KEY' => $conf_mail['boundary_key'], 261 'CONTENT_TYPE' => $args['email_format'], 192 262 'CONTENT_ENCODING' => $lang_info['charset'], 193 263 'LANG' => $lang_info['code'], … … 208 278 )); 209 279 210 if ($ email_format== 'text/html')280 if ($args['email_format'] == 'text/html') 211 281 { 212 282 $old_root = $mail_template->root; … … 218 288 } 219 289 220 $mail_template->root = PHPWG_ROOT_PATH.'template/'.$ user['template'].'/theme/'.$user['theme'];290 $mail_template->root = PHPWG_ROOT_PATH.'template/'.$args['template'].'/theme/'.$args['theme']; 221 291 if (is_file($mail_template->root.'/mail-css.tpl')) 222 292 { … … 236 306 237 307 // what are displayed on the header of each mail ? 238 $conf_mail[$ email_format]308 $conf_mail[$args['email_format']] 239 309 [$lang_info['charset']] 240 [$ user['template']][$user['theme']]['header'] =310 [$args['template']][$args['theme']]['header'] = 241 311 $mail_template->parse('mail_header', true); 242 312 243 313 // what are displayed on the footer of each mail ? 244 $conf_mail[$ email_format]314 $conf_mail[$args['email_format']] 245 315 [$lang_info['charset']] 246 [$ user['template']][$user['theme']]['footer'] =316 [$args['template']][$args['theme']]['footer'] = 247 317 $mail_template->parse('mail_footer', true); 248 318 } 249 319 250 $content.= $conf_mail[$email_format] 320 // Header 321 $content.= $conf_mail[$args['email_format']] 251 322 [$lang_info['charset']] 252 [$user['template']][$user['theme']]['header']; 253 254 if (($format_infos == 'text/plain') and ($email_format == 'text/html')) 255 { 256 $content.= '<pre>'.htmlentities($infos).'</pre>'; 323 [$args['template']][$args['theme']]['header']; 324 325 // Content 326 if (($args['content_format'] == 'text/plain') and ($args['email_format'] == 'text/html')) 327 { 328 $content.= '<p>'.nl2br(htmlentities($args['content'])).'</p>'; 257 329 } 258 330 else 259 331 { 260 $content.= $infos; 261 } 262 263 $content.= $conf_mail[$email_format] 332 $content.= $args['content']; 333 } 334 335 // Footer 336 $content.= $conf_mail[$args['email_format']] 264 337 [$lang_info['charset']] 265 [$user['template']][$user['theme']]['footer']; 266 338 [$args['template']][$args['theme']]['footer']; 339 340 // Close boundary 341 $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; 342 267 343 // Undo Compute root_path in order have complete path 268 if ($ email_format== 'text/html')344 if ($args['email_format'] == 'text/html') 269 345 { 270 346 unset_make_full_url(); … … 276 352 @mkdir(PHPWG_ROOT_PATH.'testmail'); 277 353 $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username']; 278 if ($ format_infos== 'text/plain')354 if ($args['content_format'] == 'text/plain') 279 355 { 280 356 $filename .= '.txt'; -
trunk/include/picture_comment.inc.php
r1750 r1809 224 224 .'comments.php?validate='.$comm['id']; 225 225 } 226 pwg_mail( get_webmaster_mail_address(), '', 227 'PWG comment by '.$comm['author'], 228 $content 229 ); 226 pwg_mail(get_webmaster_mail_address(), 227 array('subject' => 'PWG comment by '.$comm['author'], 'content' => $content)); 230 228 } 231 229 } -
trunk/password.php
r1531 r1809 85 85 ; 86 86 87 if (pwg_mail($row['email'], '', l10n('password updated'), $infos)) 87 if (pwg_mail($row['email'], 88 array('subject' => l10n('password updated'), 'content' => $infos))) 88 89 { 89 90 $data = -
trunk/register.php
r1753 r1809 71 71 .l10n('admin').': '.$admin_url; 72 72 73 pwg_mail( get_webmaster_mail_address(), '', 74 'PWG '.l10n('register_title').' '.$username, 75 $content 76 ); 73 pwg_mail(get_webmaster_mail_address(), 74 array 75 ( 76 'subject' => 'PWG '.l10n('register_title').' '.$username, 77 'content' => $content 78 ) 79 ); 77 80 } 78 81 redirect(make_index_url()); -
trunk/template/yoga/mail/text/html/header.tpl
r1807 r1809 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 1 -----={BOUNDARY_KEY} 2 Content-Type: {CONTENT_TYPE}; charset={CONTENT_ENCODING}; 3 Content-Transfer-Encoding: 8bit 4 5 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 3 6 <html lang="{LANG}" dir="{DIR}"> 4 7 <head> -
trunk/template/yoga/mail/text/plain/header.tpl
r1784 r1809 1 {FAKE_SIMULATE_EMPTY_FILE} 1 -----={BOUNDARY_KEY} 2 Content-Type: {CONTENT_TYPE}; charset={CONTENT_ENCODING}; format=flowed; 3 Content-Transfer-Encoding: 8bit
Note: See TracChangeset
for help on using the changeset viewer.