WordPress.org

Ready to get started?Download WordPress

Forums

WP Post Notifier For All
French translated (traduit en français) (3 posts)

  1. jauphrwa
    Member
    Posted 3 years ago #

    Hi guys,

    I quickly translated the "gui" in French.
    J'ai traduit vite fait l'interface utilisateur et admin en français.

    <?php
    /*
    Plugin Name: WP Post Notifier For All
    Description: Notify all WordPress users (and not only the admin) on post publishing. The notification is sent only one time after the first post publishing(not on every update).
    Version: 1.0
    Author: Fayçal Tirich
    Translate FR: jauphrwa (20110221)
    */
    
    $pnfa_from_tpl = "Nom <adresse@email.com>";
    
    $pnfa_subject_tpl = "[BLOG_NAME] - Nouvel article par [AUTHOR]: [TITLE]";
    
    $pnfa_body_tpl = <<<EOD
    <center>[LOGO]http://www.example.org/logo.png[/LOGO]</center><br />
    Un nouvel article vient d'être publié par [AUTHOR]!<br /><br />
    <h3>[TITLE]</h3>
    [LINK]<br /><br />
    Bonne lecture !<br /><br />
    EOD;
    
    $pnfa_otions_msg = '';
    
    function pnfa_get_users () {
        $blog_users = array();
        global $wpdb;
        $users = $wpdb->get_results("SELECT ID, user_login, display_name, user_email  FROM $wpdb->users");
        foreach($users as $user) {
            $object = new stdClass();
            $object->ID = $user->ID;
            $object->user_login = $user->user_login;
            $object->display_name = $user->display_name;
            $object->user_email = $user->user_email;
            $blog_users[$user->ID]=$object;
        }
        return $blog_users;
    }
    
    if ( isset($_POST['pnfa_submit']) ) {
        update_option('fay-post-notifier-for-all_from-tpl', stripslashes_deep(trim($_POST['pnfa_from'])));
        update_option('fay-post-notifier-for-all_subject-tpl', stripslashes_deep(trim($_POST['pnfa_subject'])));
        update_option('fay-post-notifier-for-all_body-tpl', stripslashes_deep(trim($_POST['pnfa_body'])));
        $pnfa_otions_msg = '<span style="color:green">'.__('Options sauvegardées').'</span><br />';
    }
    
    $pnfa_from = get_option('fay-post-notifier-for-all_from-tpl');
    if (!isset($pnfa_from)  || empty($pnfa_from)) {
            $pnfa_from = $pnfa_from_tpl ;
    }
    
    $pnfa_subject = get_option('fay-post-notifier-for-all_subject-tpl');
    if (!isset($pnfa_subject)  || empty($pnfa_subject)) {
            $pnfa_subject = $pnfa_subject_tpl ;
    }
    
    $pnfa_body = get_option('fay-post-notifier-for-all_body-tpl');
    if (!isset($pnfa_body)  || empty($pnfa_body)) {
        $pnfa_body = $pnfa_body_tpl ;
    }
    
    function pnfa_notify_users($post_ID) {
    
        global $pnfa_from, $pnfa_subject, $pnfa_body;
        $process = 0;
        $post = get_post($post_ID);
    
        //check if the post was already notified
        $options =  get_option('fay-notifay-all_notified-posts');
        if (!is_array($options)) {
            $options = array ();
            update_option('fay-notifay-all_notified-posts', $options);
            $process = 1;
        } else {
            if (in_array($post_ID, $options)) {
                $process = 0;
            } else {
                $process = 1;
            }
        }
        if ($process==1)
        {
            //only notify for new posts
            $activation_date = get_option('fay-post-notifier_first-activation-date');
            if(strtotime($post->post_date)<strtotime($activation_date)) {
                $process = 0;
            }
        }
    
        $author = get_the_author_meta('display_name',$post->post_author);
    
        if ($process == 1) {
            global $wpdb;
            $users = $wpdb->get_results("SELECT ID, user_email FROM $wpdb->users");
            $emails = '';
            foreach($users as $user) {
                if (get_usermeta($user->ID,'pnfa_exclude')!='true') {
                    $emails = $user->user_email.', '.$emails ;
                }
            }
    
            $pnfa_subject = str_replace('[AUTHOR]', htmlspecialchars_decode($author), $pnfa_subject);
            $pnfa_subject = str_replace('[BLOG_NAME]',html_entity_decode(get_bloginfo('name'), ENT_QUOTES), $pnfa_subject);
            $pnfa_subject = str_replace('[TITLE]',  htmlspecialchars_decode($post->post_title), $pnfa_subject);
    
            $pattern = '/(\[LOGO\])(.*)(\[\/LOGO\])/';
            $replacement = '<img src="${2}" alt="'. htmlspecialchars_decode(get_bloginfo('name')).'"/>';
            $pnfa_body = preg_replace($pattern, $replacement, $pnfa_body);
    
            $pnfa_body = str_replace('[AUTHOR]', htmlspecialchars_decode($author), $pnfa_body);
    
            $link = '<a style="color: #2D83D5" href="'.get_permalink($post_ID).'">'.get_permalink($post_ID).'</a>';
            $pnfa_body = str_replace('[LINK]', $link, $pnfa_body);
    
    	$pnfa_body = str_replace('[TITLE]', htmlspecialchars_decode($post->post_title), $pnfa_body);
    
            $mailTo = "";
    
            $headers = "From: $pnfa_from\n";
    	$headers .= "Bcc: $emails\n";
            $headers .= "X-Mailer: Devoteam Blog\n";
            $headers .= "MIME-Version: 1.0\n";
            $rand = md5(time());
            $mime_boundary = "----.fay----".$rand;
            $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
    
            $message .= "--$mime_boundary\n";
            $message .= "Content-Type: text/html; charset=UTF-8\n";
            $message .= "Content-Transfer-Encoding: 8bit\n\n";
            $message .= "<html>\n";
            $message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
            $message .= $pnfa_body;
            $message .= "\n\n";
            $message .= "</body>\n";
            $message .= "</html>\n";
            $message .= "--$mime_boundary--\n\n";
            if (mail($mailTo, $pnfa_subject, $message, $headers)) {
                $options[] = $post_ID;
                sort($options);
                update_option('fay-notifay-all_notified-posts', $options);
            }
        }
        return $post_ID;
    }
    
    // Options page
    function pnfa_options() {
        global $pnfa_from_tpl, $pnfa_from, $pnfa_body_tpl, $pnfa_subject_tpl, $pnfa_body, $pnfa_subject, $pnfa_otions_msg ;
        if ( isset($_POST['pnfa_exclude_submit']) ) {
            $users_to_exclude_array = array();
            if(isset($_POST['pnfa_excluded_users'])) {
                $users_to_exclude_array = $_POST['pnfa_excluded_users'];
            }
            $users = pnfa_get_users();
            $log = '';
            foreach($users as $user) {
                if (in_array($user->ID, $users_to_exclude_array)) {
                    if (get_usermeta($user->ID,'pnfa_exclude')!='true'){
                        update_usermeta($user->ID,'pnfa_exclude','true');
                        $log = $log .'<span style="color:green">'.$user->display_name.' exclu</span><br />';
                    }
                } else {
                    if (get_usermeta($user->ID,'pnfa_exclude')!='false'){
                        update_usermeta($user->ID,'pnfa_exclude','false');
                        $log = $log .'<span style="color:green">'.$user->display_name.' sera notifié</span><br />';
                    }
                }
            }
            if ($log!=''){
                $pnfa_otions_msg = $log;
            }
        }
        if(!empty($pnfa_otions_msg)) {
    ?>
        <!-- Last Action --><div id="message" class="updated fade"><p><?php echo $pnfa_otions_msg; ?></p></div>
    <?php
    }
    ?>
    <div class="wrap">
        <?php screen_icon(); ?>
        <h2>Post Notifier For All (fr)</h2>
        <br />
        <form method="post" action="">
            <div>
                <div>
                    <label for="pnfa_from"><strong>Expéditeur de l'email</strong></label>
                    <br />
                    <input type="text" size="150" id="pnfa_from" name="pnfa_from" value="<?php echo $pnfa_from; ?>" />
                    <p>
                        Expéditeur par défaut:<br />
                        <?php
                            $temp = $pnfa_from_tpl ;
                            $temp = str_replace("<","<",$temp);
                            $temp = str_replace(">",">",$temp);
                            echo nl2br($temp);
                        ?>
                    </p>
                </div>
                <div>
                    <label for="pnfa_subject"><strong>Sujet de l'email</strong></label>
                    <br />
                    <input type="text" size="150" id="pnfa_subject" name="pnfa_subject" value="<?php echo $pnfa_subject; ?>" />
                    <p>
                        Sujet par défaut:<br />
                        <?php echo $pnfa_subject_tpl; ?>
                    </p>
                </div>
                <div>
                    <label for="pnfa_body"><strong>Corps de l'email</strong></label>
                    <br />
                    <textarea style="width: 90%; font-size: 12px;" rows="8" cols="60" id="pnfa_body" name="pnfa_body"><?php echo $pnfa_body; ?></textarea>
                    <p>
                        Corps par défaut:<br />
                        <?php
                            $temp = $pnfa_body_tpl ;
                            $temp = str_replace("<","<",$temp);
                            $temp = str_replace(">",">",$temp);
                            echo nl2br($temp);
                        ?>
                    </p>
                </div>
                <p class="submit">
                    <input class="button-primary" type="submit" name="pnfa_submit" class="button" value="<?php _e('Enregistrer le modèle d\'email'); ?>" />
                </p>
            </div>
        </form>
        <br />
        <h2>Exclure des abonnés</h2>
        <form method="post" action="">
                <table class="widefat fixed" cellspacing="0">
                <thead>
                <tr class="thead">
                    <th id="cb" class="manage-column column-cb column-exclude" style="" scope="col">
                        <?php echo __('Exclure'); ?>?
                    </th>
                    <th id="username" class="manage-column column-username" style="" scope="col">
                       <?php echo __('Username'); ?>
                    </th>
                    <th id="email" class="manage-column column-email" style="" scope="col">
                        <?php echo __('Email'); ?>
                    </th>
                </tr>
                </thead>
    
                <tfoot>
                <tr class="thead">
                    <th id="cb" class="manage-column column-cb column-exclude" style="" scope="col">
                        <?php echo __('Exclure'); ?>?
                    </th>
                    <th id="username" class="manage-column column-username" style="" scope="col">
                       <?php echo __('Username'); ?>
                    </th>
                    <th id="email" class="manage-column column-email" style="" scope="col">
                        <?php echo __('Email'); ?>
                    </th>
                </tr>
                </tfoot>
    
                <tbody id="users" class="list:user user-list">
                <?php
                $style = '';
                $users = pnfa_get_users();
                foreach($users as $user) {
                    $is_checked = false ;
                    if (get_usermeta($user->ID,'pnfa_exclude')=='true') {
                        $is_checked = true;
                    }
                    $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
                    ?>
                    <tr id='user-<?php echo $user->ID; ?>' <?php echo $style; ?> <?php echo ($is_checked)?'style="background-color: rgb(255, 153, 153);"':''; ?>>
                    <th scope='row' class='check-column'><input type='checkbox'  name='pnfa_excluded_users[]' id='user_<?php echo $user->ID; ?>' <?php echo ($is_checked)?"checked":""; ?>  value='<?php echo $user->ID; ?>' /></th>
                    <td><?php echo $user->user_login; ?></td>
                    <td><?php echo $user->user_email; ?></td>
                    </tr>
                    <?php
                }
                ?>
                </tbody>
                </table>
                <p class="submit">
                    <input class="button-primary" type="submit" name="pnfa_exclude_submit" class="button" value="<?php _e('Enregistrer les exclusions'); ?>" />
                </p>
            </form>
    </div>
    <?php
    }
    
    function pnfa_user_options() {
            $text = '';
            global $user_ID;
            get_currentuserinfo();
            if ( isset($_POST['pnfa_user_submit']) ) {
                    if(isset($_POST['pnfa_user_active']) && $_POST['pnfa_user_active']=='true') {
                        if (get_usermeta($user_ID,'pnfa_exclude')!='true'){
                            update_usermeta($user_ID,'pnfa_exclude','true');
                        }
                    } else {
                        if (get_usermeta($user_ID,'pnfa_exclude')!='false'){
                            update_usermeta($user_ID,'pnfa_exclude','false');
                        }
                    }
                    $text = '<span style="color:green">'.__('Option updated').'</span><br />';
            }
            if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; }
            ?>
            <div class="wrap">
            <?php screen_icon(); ?>
            <h2>Notification de nouvel article</h2>
            <br /><br />
            <form method="post" action="">
                <table class="widefat">
                    <thead>
                        <tr>
                            <th>Désactiver la notification d'un nouvel article</th>
                        </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>
                            <input type="checkbox" name="pnfa_user_active" value="true" <?php if(get_usermeta($user_ID,'pnfa_exclude')=='true') echo ' checked="checked"'; ?> /> <?php _e('Cocher pour désactiver les notifications à l\'avenir'); ?>
                            <p class="submit">
                                    <input class="button-primary" type="submit" name="pnfa_user_submit" class="button" value="<?php _e('Enregistrer'); ?>" />
                            </p>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
            </div>
        <?php
        }
    
    function pnfa_activation() {
    	$first_date = get_option('fay-post-notifier_first-activation-date');
    	if (!isset($first_date) || empty($first_date))
    	{
    		update_option('fay-post-notifier_first-activation-date', date("Y-m-d H:m:s"));
    	}
    }
    register_activation_hook( __FILE__, 'pnfa_activation' );
    
    function pnfa_menu() {
        if (function_exists('add_options_page')) {
            if( current_user_can('manage_options') ) {
                add_options_page(__('Notifications'), __('Notifications'), 'manage_options', __FILE__, 'pnfa_options') ;
            }
        }
         if (function_exists('add_submenu_page')) {
            add_submenu_page('users.php', __('Notifications'), __('Notifications'), 'read', __FILE__, pnfa_user_options);
         }
    }
    
    add_action('admin_menu', 'pnfa_menu');
    
    add_action('publish_post', 'pnfa_notify_users' );
    
    ?>

    http://wordpress.org/extend/plugins/wp-post-notifier-for-all/

  2. JoeALVES
    Member
    Posted 3 years ago #

    Nice JOB SIR !!!

    Beau travail super ! ca va m'éviter de la faire !

    Je me permets également une petite question ....

    Absolument aucun mail ne part lors de mes posts (d'autres partes d'autres modules, mais pas de celui la) !

    N'etant pas un grand spécialiste de WordPress, il y a peut être une option "générale" à activer ?

    Merci pour ton Aide.

    Joe

  3. jauphrwa
    Member
    Posted 2 years ago #

    Version 2.3

    <?php
    /*
    Plugin Name: WP Post Notifier For All
    Plugin URI: http://faycaltirich.blogspot.com/1979/01/wp-post-notifier-for-all.html
    Description: Notify all WordPress users (and not only the admin) on post publishing. The notification is sent only one time after the first post publishing(not on every update).
    Version: 2.3
    Author: Fayçal Tirich
    Author URI: http://faycaltirich.blogspot.com
    Translate fr : jauphrwa
    */
    
    define("WPNFA_ACTIVATION-DATE", "wp-post-notifier-for-all_first-activation-date");
    define("WPNFA_NOTIFIED-POSTS", "wp-post-notifier-for-all_notified-posts");
    define("WPNFA_EXCLUDE", "wp-post-notifier-for-all_exclude");
    define("WPNFA_FROM-TPL", "wp-post-notifier-for-all_from-tpl");
    define("WPNFA_SUBJECT-TPL", "wp-post-notifier-for-all_subject-tpl");
    define("WPNFA_BODY-TPL", "wp-post-notifier-for-all_body-tpl");
    
    $pnfa_from_tpl = "Nom <adresse@email.com>";
    $pnfa_subject_tpl = "[BLOG_NAME] - [AUTHOR] a publié un nouvel article: [TITLE]";
    $pnfa_body_tpl=<<<EOD
    [AUTHOR] a publié un nouvel article !<br /><br />
    <h3>[TITLE]</h3>
    In: [CATEGORIES]<br /><br />
    [EXCERPT]<br /><br />
    [LINK]<br /><br />
    Bonne lecture !<br /><br />
    EOD;
    
    function pnfa_get_users() {
        global $wpdb;
        $blog_users = array();
        $users = get_users();
        foreach($users as $user) {
            $object = new stdClass();
            $object->ID = $user->ID;
            $object->user_login = $user->user_login;
            $object->display_name = $user->display_name;
            $object->user_email = $user->user_email;
            $blog_users[$user->ID]=$object;
            $isExcluded = 0;
            $savedIsExcluded = get_user_meta($user->ID, constant("WPNFA_EXCLUDE"), true);
            if(!empty($savedIsExcluded) && $savedIsExcluded==1){
                $isExcluded = 1;
            }
            $object->isExcluded = $isExcluded;
        }
        return $blog_users;
    }
    
    $pnfa_otions_msg = '';
    if ( isset($_POST['pnfa_submit']) ) {
        update_option(constant("WPNFA_FROM-TPL"), htmlentities(stripslashes_deep(trim($_POST['pnfa_from'])),ENT_QUOTES, "UTF-8"));
        update_option(constant("WPNFA_SUBJECT-TPL"), htmlentities(stripslashes_deep(trim($_POST['pnfa_subject'])),ENT_QUOTES, "UTF-8"));
        update_option(constant("WPNFA_BODY-TPL"), htmlentities(stripslashes_deep(trim($_POST['pnfa_body'])),ENT_QUOTES, "UTF-8"));
        $pnfa_otions_msg = '<span style="color:green">'.__('Options updated').'</span><br />';
    }
    
    $pnfa_from = get_option(constant("WPNFA_FROM-TPL"), $pnfa_from_tpl);
    $pnfa_subject = get_option(constant("WPNFA_SUBJECT-TPL"), $pnfa_subject_tpl);
    $pnfa_body = get_option(constant("WPNFA_BODY-TPL"), $pnfa_body_tpl);
    
    function pnfa_notify_users($post_ID) {
        global $pnfa_from, $pnfa_subject, $pnfa_body;
        $process = 0;
        $post = get_post($post_ID);
        //check if the post was already notified
        $notified_posts = get_option(constant("WPNFA_NOTIFIED-POSTS"));
        if (!is_array($notified_posts)){
            $notified_posts = array();
            update_option(constant("WPNFA_NOTIFIED-POSTS"), $notified_posts);
            $process = 1;
        } else {
            if (in_array($post_ID, $notified_posts)) {
                $process = 0;
            } else {
                $process = 1;
            }
        }
        if ($process==1){
            //only notify for new posts
            $activation_date = get_option(constant("WPNFA_ACTIVATION-DATE"));
            if(strtotime($post->post_date)<strtotime($activation_date)) {
                $process = 0;
            }
        }
    
        if ($process == 1){
            $users = pnfa_get_users();
            foreach($users as $user) {
                if (!$user->isExcluded) {
                    $emails[] = $user->user_email;
                }
            }
    
            $author = get_the_author_meta('display_name',$post->post_author);
    
            $email_pnfa_subject = str_replace('[AUTHOR]', htmlspecialchars_decode($author), $pnfa_subject);
            $email_pnfa_subject = str_replace('[BLOG_NAME]',html_entity_decode(get_bloginfo('name'), ENT_QUOTES), $email_pnfa_subject);
            $email_pnfa_subject = str_replace('[TITLE]', htmlspecialchars_decode($post->post_title), $email_pnfa_subject);
    
            $email_pnfa_body = str_replace('[AUTHOR]', htmlspecialchars_decode($author), $pnfa_body);
    
            $link = '<a style="color: #2D83D5" href="'.get_permalink($post_ID).'">'.get_permalink($post_ID).'</a>';
            $email_pnfa_body = str_replace('[LINK]', $link, $email_pnfa_body);
    
            $email_pnfa_body = str_replace('[TITLE]', htmlspecialchars_decode($post->post_title), $email_pnfa_body);
            $email_pnfa_body = str_replace('[EXCERPT]', htmlspecialchars_decode($post->post_excerpt), $email_pnfa_body);
            $email_pnfa_body = str_replace('[BLOG_NAME]',html_entity_decode(get_bloginfo('name'), ENT_QUOTES), $email_pnfa_body);
    
            $post_categories = wp_get_post_categories( $post_ID , array('fields' => 'all'));
            $cats = '';
            foreach ($post_categories as $cat){
            	$cats .= $cat->name.', ';
            }
            $cats = substr($cats,0,-2);
            $email_pnfa_body = str_replace('[CATEGORIES]', htmlspecialchars_decode($cats), $email_pnfa_body);
    
            //
            $email_pnfa_from = html_entity_decode($pnfa_from, ENT_QUOTES, "UTF-8");
            $message_headers = "From: ".$email_pnfa_from."\r\n";
            $message_headers .= "MIME-Version: 1.0\n";
            $message_headers .= "Content-type: text/html; charset=UTF-8\r\n"; 
    
            $message .= "<html>\n";
            $message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
            $message .= html_entity_decode($email_pnfa_body);
            $message .= "\n\n";
            $message .= "</body>\n";
            $message .= "</html>\n";
    
            add_filter('wp_mail_charset', 'pnfa_get_mail_charset');
            foreach ( $emails as $email ){
                @wp_mail($email, $email_pnfa_subject, $message, $message_headers );
            }
            remove_filter('wp_mail_charset', 'pnfa_get_mail_charset');
    
            $notified_posts[] = $post_ID;
            sort($notified_posts);
            update_option(constant("WPNFA_NOTIFIED-POSTS"), $notified_posts);
        }
        return $post_ID;
    }
    
    function pnfa_get_mail_charset(){
        return "UTF-8";
    }
    
    // Options page
    function pnfa_options() {
        global $pnfa_from_tpl, $pnfa_from, $pnfa_body_tpl, $pnfa_subject_tpl, $pnfa_body, $pnfa_subject, $pnfa_otions_msg ;
        if ( isset($_POST['pnfa_exclude_submit']) ) {
            $users_to_exclude_array = array();
            if(isset($_POST['pnfa_excluded_users'])) {
                $users_to_exclude_array = $_POST['pnfa_excluded_users'];
            }
            $users = pnfa_get_users();
            $log = '';
            foreach($users as $user) {
                if (in_array($user->ID, $users_to_exclude_array)) {
                    if (!$user->isExcluded){
                        update_user_meta($user->ID,constant("WPNFA_EXCLUDE"),1);
                        $log = $log .'<span style="color:green">'.$user->display_name.' est exclu</span><br />';
                    }
                } else {
                    if ($user->isExcluded){
                        update_user_meta($user->ID,constant("WPNFA_EXCLUDE"),0);
                        $log = $log .'<span style="color:green">'.$user->display_name.' sera notifié</span><br />';
                    }
                }
            }
            if ($log!=''){
                $pnfa_otions_msg = $log;
            }
        }
        if(!empty($pnfa_otions_msg)) {
            ?>
    <!-- Last Action -->
    <div id="message" class="updated fade">
    	<p>
    	<?php echo $pnfa_otions_msg; ?>
    	</p>
    </div>
    	<?php
        }
        ?>
    <style type="text/css">
    .excluded {
    	background-color: #FF9999;
    }
    
    .defaultText {
    	font-size: smaller !important;
    	margin-bottom: 20px !important;
    }
    </style>
    <div class="wrap">
    <?php screen_icon(); ?>
    	<h2>Post Notifier For All (fr)</h2>
    	<form method="post" action="">
    		<table class="widefat">
    			<thead>
    				<tr>
    					<th>Modèle de l'e-mail</th>
    				</tr>
    			</thead>
    			<tbody>
    				<tr>
    					<td>
    						<div>
    							<label for="pnfa_from"><strong>Expéditeur de l'e-mail</strong> </label>
    							<br /> <input type="text" size="150" id="pnfa_from"
    								name="pnfa_from" value="<?php echo $pnfa_from; ?>" />
    							<p class="defaultText">
    								Défaut:<br />
    								<?php
    								$temp = $pnfa_from_tpl ;
    								$temp = str_replace("<","<",$temp);
    								$temp = str_replace(">",">",$temp);
    								echo nl2br($temp);
    								?>
    							</p>
    						</div>
    						<div>
    							<label for="pnfa_subject"><strong>Sujet de l'e-mail</strong>
    							</label> <br /> <input type="text" size="150" id="pnfa_subject"
    								name="pnfa_subject" value="<?php echo $pnfa_subject; ?>" />
    							<p class="defaultText">
    								Défaut:<br />
    								<?php echo $pnfa_subject_tpl; ?>
    							</p>
    						</div>
    						<div>
    							<label for="pnfa_body"><strong>Corps de l'e-mail</strong> </label>
    							<br />
    							<textarea style="width: 90%; font-size: 12px;" rows="8" cols="60"
    								id="pnfa_body" name="pnfa_body"><?php echo $pnfa_body; ?></textarea>
    							<p class="defaultText">
    								Défaut:<br />
    								<?php
    								$temp = $pnfa_body_tpl ;
    								$temp = str_replace("<","<",$temp);
    								$temp = str_replace(">",">",$temp);
    								echo nl2br($temp);
    								?>
    							</p>
    						</div>
    						<p class="submit">
    							<input class="button-primary" type="submit" name="pnfa_submit"
    								class="button" value="<?php _e('Enregistrer les modifications'); ?>" />
    						</p>
    					</td>
    				</tr>
    			</tbody>
    		</table>
    	</form>
    	<br />
    	<?php include 'donate.php';?>
    	<h2>Exclude users</h2>
    	<form method="post" action="">
    		<table class="widefat fixed" cellspacing="0">
    			<thead>
    				<tr class="thead">
    					<th id="cb" class="manage-column column-cb column-exclude" style=""
    						scope="col"><?php echo __('Exclure'); ?>?</th>
    					<th id="username" class="manage-column column-username" style=""
    						scope="col"><?php echo __('Utilisateur'); ?>
    					</th>
    					<th id="email" class="manage-column column-email" style=""
    						scope="col"><?php echo __('Email'); ?>
    					</th>
    				</tr>
    			</thead>
    
    			<tfoot>
    				<tr class="thead">
    					<th id="cb" class="manage-column column-cb column-exclude" style=""
    						scope="col"><?php echo __('Exclure'); ?>?</th>
    					<th id="username" class="manage-column column-username" style=""
    						scope="col"><?php echo __('Utilisateur'); ?>
    					</th>
    					<th id="email" class="manage-column column-email" style=""
    						scope="col"><?php echo __('Email'); ?>
    					</th>
    				</tr>
    			</tfoot>
    
    			<tbody id="users" class="list:user user-list">
    			<?php
    			$style = '';
    			$users = pnfa_get_users();
    			$normalStyle='';
    			foreach($users as $user) {
    			    $normalStyle = ( ' class="alternate"' == $normalStyle ) ? '' : ' class="alternate"';
    			    $excludedStyle = ' class="alternate excluded" ';
    			    if($normalStyle==''){
    			        $excludedStyle = ' class="excluded" ';
    			    }
    			    ?>
    				<tr id='user-<?php echo $user->ID; ?>'
    				<?php echo ($user->isExcluded)?$excludedStyle:$normalStyle ?>>
    					<th scope='row' class='check-column'><input type='checkbox'
    						name='pnfa_excluded_users[]' id='user_<?php echo $user->ID; ?>'
    						<?php echo ($user->isExcluded)?"checked":""; ?>
    						value='<?php echo $user->ID; ?>' />
    					</th>
    					<td><?php echo $user->user_login; ?></td>
    					<td><?php echo $user->user_email; ?></td>
    				</tr>
    				<?php
    			}
    			?>
    			</tbody>
    		</table>
    		<p class="submit">
    			<input class="button-primary" type="submit"
    				name="pnfa_exclude_submit" class="button"
    				value="<?php _e('Enregistrer les modifications'); ?>" />
    		</p>
    	</form>
    	<script type="text/javascript">
    			jQuery(document).ready(function() {
    				jQuery("[name='pnfa_excluded_users[]']").click(function(){
    					if(jQuery(this).is(":checked")){
    						jQuery(this).parents("tr").addClass("excluded");
    					}else {
    						jQuery(this).parents("tr").removeClass("excluded");
    					}
    				});
    			});
    	</script>
    </div>
    			<?php
    }
    
    function pnfa_user_options() {
        global $user_ID;
        $isExcluded = (bool) get_user_meta($user_ID,constant("WPNFA_EXCLUDE"),true);
        $text = '';
        get_currentuserinfo();
        if ( isset($_POST['pnfa_user_submit']) ) {
            if(isset($_POST['pnfa_user_active']) && $_POST['pnfa_user_active']=='true') {
                if (!$isExcluded){
                    $isExcluded = 1;
                }
            } else {
                if ($isExcluded){
                    $isExcluded = 0;
                }
            }
            update_user_meta($user_ID, constant("WPNFA_EXCLUDE"), $isExcluded);
            $text = '<span style="color:green">'.__('Option updated').'</span><br />';
        }
        if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; }
        ?>
    <div class="wrap">
    <?php screen_icon(); ?>
    	<h2>Notifications</h2>
    	<br /> <br />
    	<form method="post" action="">
    		<table class="widefat">
    			<thead>
    				<tr>
    					<th>Désactiver les notifications</th>
    				</tr>
    			</thead>
    			<tbody>
    				<tr>
    					<td><input type="checkbox" name="pnfa_user_active" value="true"
    					<?php if($isExcluded) echo ' checked="checked"'; ?> />&nbsp;<?php _e('Cocher pour ne plus recevoir de notification par email lors des prochaines publications'); ?>
    						<p class="submit">
    							<input class="button-primary" type="submit"
    								name="pnfa_user_submit" class="button"
    								value="<?php _e('Enregistrer les modifications'); ?>" />
    						</p>
    					</td>
    				</tr>
    			</tbody>
    		</table>
    	</form>
    </div>
    					<?php
    }
    
    function pnfa_activation() {
        $first_date = get_option(constant("WPNFA_ACTIVATION-DATE"));
        if (!isset($first_date) || empty($first_date)){
            update_option(constant("WPNFA_ACTIVATION-DATE"), date("Y-m-d H:m:s"));
        }
    }
    register_activation_hook( __FILE__, 'pnfa_activation' );
    
    function pnfa_menu() {
        if (function_exists('add_options_page')) {
            if( current_user_can('manage_options') ) {
                add_options_page(__('Post Notifier'), __('Post Notifier'), 'manage_options', __FILE__, 'pnfa_options') ;
            }
        }
        if (function_exists('add_submenu_page')) {
            add_submenu_page('users.php', __('Notifications'), __('Notifications'), 'read', __FILE__, 'pnfa_user_options');
        }
    }
    
    add_action('admin_menu', 'pnfa_menu');
    add_action('publish_post', 'pnfa_notify_users' );
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic