| [ Index ] |
PHP Cross Reference of zeList |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 function notification_deny($link_id,$old_status) { 5 if($old_status == 'deny') return; 6 zelist_notify('deny',$link_id); 7 } 8 add_action('deny_link','notification_deny',10,2); 9 10 function notification_publish($link_id,$old_status) { 11 if($old_status == 'publish') return; 12 zelist_notify('publish',$link_id); 13 } 14 add_action('publish_link','notification_publish',10,2); 15 16 function notification_pending($link_id,$old_status = '') { 17 if($old_status == 'pending') return; 18 zelist_notify('pending',$link_id); 19 } 20 add_action('pending_link','notification_pending',10,2); 21 add_action('add_link','notification_pending',10,1); 22 23 function zelist_notify($action,$link_id) { 24 $link = get_bookmark($link_id); 25 if(!$link) return false; 26 $webmaster = new WP_User($link->link_owner); 27 if(!$webmaster) return false; 28 29 switch ($action) { 30 case 'deny' : 31 $notify_message = sprintf( __('Your site "%s" has been denied','zelist'), $link->link_url) . "\r\n"; 32 // @TODO ban reasons 33 if($reason = get_link_meta($link_id, 'ban_reason',1)) { 34 $ban_reasons = get_option('zelist_banreasons'); 35 if($label = $ban_reasons[$reason]) 36 $notify_message .= sprintf(__('The editor of the directory has flagged your site as %s','zelist'),$label). "\r\n"; 37 //$notify_message .= sprintf(__('You may submit your site again : %s','zelist'),get_edit_bookmark_link($link->link_id)) . "\r\n"; 38 } 39 $notify_message .= "\r\n" . "\r\n" . get_option('blogname') . "\r\n" . get_option('home'); 40 $subject = sprintf( __('[%s] Site denied : "%s"','zelist'), get_option('blogname'), $link->link_url ); 41 $email = $webmaster->user_email; 42 break; 43 44 case 'publish' : 45 $notify_message = sprintf( __('Your site "%s" has been published on %s','zelist'), $link->link_name, get_permalink(get_option('zelist_root'))) . "\r\n\r\n"; 46 $notify_message .= __('You can view your site on:','zelist')."\r\n"; 47 $notify_message .= get_link_permalink($link->link_id). "\r\n"; 48 $notify_message .= __('You can edit your site on:','zelist')."\r\n"; 49 $notify_message .= get_edit_bookmark_link($link->link_id). "\r\n"; 50 $notify_message .= "\r\n" . "\r\n" . get_option('blogname') . "\r\n" . get_option('home'); 51 52 $subject = sprintf( __('[%1$s] Site accepted : "%2$s"','zelist'), get_option('blogname'), $link->link_url ); 53 $email = $webmaster->user_email; 54 break; 55 case 'pending' : 56 $notify_message = sprintf( __('A new link #%1$s "%2$s" is waiting for your approval','zelist'), $link->link_id, $link->link_name) . "\r\n"; 57 //$notify_message .= get_link_permalink($link->link_id) . "\r\n\r\n"; @TODO admin preview page for pending links 58 $notify_message .= sprintf(__('Please edit this link on: %s','zelist'),get_edit_bookmark_link($link->link_id)). "\r\n\r\n"; 59 $notify_message .= sprintf( __('Webmaster : %s','zelist'), $webmaster->user_name) . "\r\n"; 60 $notify_message .= sprintf( __('E-mail : %s','zelist'), $webmaster->user_email) . "\r\n"; 61 $host = parse_url($link->link_url); 62 $host = $host['host']; 63 if ( substr( $host, 0, 4 ) == 'www.' ) $host = substr( $host, 4 ); 64 $notify_message .= sprintf( __('Whois : http://whois.domaintools.com/%s','zelist'), $host ) . "\r\n"; 65 $notify_message .= sprintf(__('Description: %s','zelist'), "\r\n" . $link->link_description) . "\r\n\r\n"; 66 67 $notify_message .= "\r\n" . "\r\n" . get_option('blogname') . "\r\n" . get_option('home'); 68 69 $subject = sprintf( __('[%1$s] Please moderate: "%2$s"','zelist'), get_option('blogname'), $link->link_url); 70 $email = get_option('admin_email'); 71 break; 72 default : 73 break; 74 } 75 76 77 78 79 $headers = "From: ".get_option('blogname').' <'.get_option('admin_email').">\n"; 80 if(get_option('zelist_cc_admin') && $email != get_option('admin_email')) $headers .= "To: ".get_option('admin_email')."\n"; 81 @wp_mail($email, $subject, $notify_message,$headers); 82 return true; 83 } 84 85 /** 86 * Filters the from email to admin email 87 * @param $mail 88 * @return unknown_type 89 */ 90 function notifications_mail_from($mail) { 91 $sitename = strtolower( $_SERVER['SERVER_NAME'] ); 92 if ( substr( $sitename, 0, 4 ) == 'www.' ) { 93 $sitename = substr( $sitename, 4 ); 94 } 95 96 $from_email = 'wordpress@' . $sitename; 97 if($mail == $from_email) $mail = get_option('admin_email'); 98 return $mail; 99 } 100 add_filter('wp_mail_from', 'notifications_mail_from');
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat May 30 23:51:06 2009 | Cross-referenced by PHPXref 0.7 |