Resource icon

Daily Digest Email System 0.3

No permission to download
Whoah... I completely forgot about not including forums to which a user doesn't have permissions!!!! That's a scary hole!

However, considering that the email gets sent in aggregate, it should group people into user groups and just send emails by group (or simply ignore staff members' permissions, and only pull public forum posts... mods and admins don't need a digest of what's going on... they should be on the site daily anyway).

kkm - looks like the bug you're having is that I need to add the pear folder to the include path. Simple fix. I can do that ASAP and update this weekend!
 
BamaStang,

Keep in mind that if you have a larger forum, you don't want to use a system like this to send your digest out.

You'll need to proxy it through an ESP so you don't get your website blacklisted by spam filters.

Nevertheless, I agree that adding it to an admin system and adding options would be nice so everyone can use it.

Unfortunately, I'm not the guy to do all that! Hopefully some other developer sees the $ potential and picks up where I left off. :)

Cheers,

Steve
 
BamaStang,

Keep in mind that if you have a larger forum, you don't want to use a system like this to send your digest out.

You'll need to proxy it through an ESP so you don't get your website blacklisted by spam filters.

Nevertheless, I agree that adding it to an admin system and adding options would be nice so everyone can use it.

Unfortunately, I'm not the guy to do all that! Hopefully some other developer sees the $ potential and picks up where I left off. :)

Cheers,

Steve

I send all email via SendGrid
 
Down the road, it would be amazing if members could choose to receive updates on forums A, C, D but not forum B and the like.

YES! That would be very good!

Additionally, I think it would make sense to be able to offer this daily digest only to premium members/specific usergroups. This decrease the amount of emails sent out and is another selling point for additional imcome through premium memberships in forums.

I would be willing to pay for this, if it is made as an addon and includes those 2 features
 
Why not just use the site's default email settings? I've configured it so that I can send several thousand emails / day using Amazon.
 
YES! That would be very good!

Additionally, I think it would make sense to be able to offer this daily digest only to premium members/specific usergroups. This decrease the amount of emails sent out and is another selling point for additional imcome through premium memberships in forums.

I would be willing to pay for this, if it is made as an addon and includes those 2 features

Do you also take payed individual work on this addon?

I need the above mentioned features plus the ability for the admin to decide which usergroup is allowed to get a daily digest. Please PM me with a quote.
 
This needs to be part of XF core... too many factors involved in order for efficient digest system. I like this concept very much.
 
This needs to be part of XF core... too many factors involved in order for effificent digest system. I like this concept very much.
I agree. And prior to switching over to xF, all our users were used to phpbb's Digests addon ( https://phpbbservices.com/digests_wp/#.UW1OwrXR18E ) which is 10,000+ lines of original code. So I'm not even sure how this xF digest add on remotely even comes close. I really hope this project is kept current, cuz it's missing around 10-20 essential features...
 
Ability to just use new thread headlines or updated ones or new posts or just updated ones would be a great feature!
 
We already have ability to establish User Groups, private nodes, email notification of new messages. Rather than reinvent the wheel, lets try and expand on what already exists in the XF core. Maybe a second option to receive daily digest OR the individual messages would allow EVERY message thread to be sending out message digests. The ability to watch the thread would need to be given to wider audience, posters and nonposters alike.

email updates.webp
 
There is ability to set defaults for user registration.. ACP->Options->User Registration

watch threads.webp<==== add additional option to Digest

NOTE - I have found no option anywhere to TURN OFF watched threads. please advise
 
Whoah... I completely forgot about not including forums to which a user doesn't have permissions!!!! That's a scary hole!

However, considering that the email gets sent in aggregate, it should group people into user groups and just send emails by group (or simply ignore staff members' permissions, and only pull public forum posts... mods and admins don't need a digest of what's going on... they should be on the site daily anyway).

kkm - looks like the bug you're having is that I need to add the pear folder to the include path. Simple fix. I can do that ASAP and update this weekend!
I have completely re-vamped your entire code for the purposes of our forum.

My changes are as follows:
  • Completely removed the USELESS PEAR crap... PHP has a built-in mail command that works well with Xenforo, so why bother with gmail and email authentications for?
  • Meticulously coded in crazy sql joins to prevent members from seeing private forums they are not supposed to see, I'll post my sql queries later on in this post.
  • In order to check each user via email, I had to change the way the emails are being sent (individually vs bulk), but it still sends it as undisclosed recipient and the end user as bcc
new function => getAccessGroups
PHP:
    private function getAccessGroups($inEmail) {
        $sql = "    select xu.user_id, xu.username, xu.email, xpc.user_group_list
                      from xf_user                  as xu
                inner join xf_permission_combination as xpc on xu.permission_combination_id = xpc.permission_combination_id
                    where xu.email = '{$inEmail}'";
       
        $q = $this->conn->prepare($sql);
 
        if (($res = $q->execute()) === FALSE) { return false; }
 
        $user_groups = $q->fetchColumn(3);
 
        return $user_groups;
    }

new function => canAccessForum
PHP:
    private function canAccessForum($node_id, $groups) {
        $sql = "    select xpec.content_id, xpec.user_group_id, xn.node_id, xn.title, xn.parent_node_id, xn.node_type_id
                      from xf_permission_entry_content as xpec
                inner join xf_node                    as xn  on xpec.content_id = xn.parent_node_id
                    where permission_group_id = 'forum'
                      and permission_id      = 'viewContent'
                      and user_group_id      IN ({$groups})
                      and xn.node_id          = {$node_id}";
         
        $string = trim(preg_replace('/\s+/', ' ', $sql));
         
        $q = $this->conn->prepare($sql);
 
        if (($res = $q->execute()) === FALSE) { return false; }
 
        $category_id = $q->fetchColumn();
 
        if (empty($category_id)) { return false; }
   
        return true;
    }

modified existing function => getPosts
PHP:
    private function getPosts($days, $groups) {
        // Get all posts in the given range:
        $end  = (floor(time() / 86400) * 86400); // Previous midnight
        $start = ($end - $days * 86400);
 
        $sql = "    SELECT p.post_id, p.thread_id, t.node_id, p.message, p.user_id, p.username AS poster,
                                        t.title, t.username AS starter, n.title AS forum
                      FROM xf_post  AS p
                INNER JOIN xf_thread AS t ON p.thread_id = t.thread_id
                INNER JOIN xf_node  AS n ON t.node_id  = n.node_id
                    WHERE p.post_date BETWEEN {$start} AND {$end}
                  ORDER BY p.post_date ASC";
     
        $posts = $this->conn->query($sql);
 
        // Group the posts into threads
        $threads = array();
 
        foreach ($posts as $post) {
            $bHasAccess = $this->canAccessForum($post['node_id'], $groups);
 
            if ($bHasAccess) {
                if (!isset($threads[$post['thread_id']])) $threads[$post['thread_id']] = array();
   
                $threads[$post['thread_id']][] = $post;
            } // else {  no access, do nothing }
        }
 
        return $threads;
    }

and to make all that work, you need to re-do the entire go function to handle emails one by one and call the new functions using these commands:

PHP:
$groups  = $this->getAccessGroups($mail); //one email only! not an array of emails, you've been warned!
$posts    = $this->getPosts($days, $groups);

hopefully this helps out some of ya!
 
Indeed. But this isn't even a PLUGIN for Xenforo, this PHP script works completely independently and outside of the Xenforo realm, but it does the do, so what the hey! :)
*whistles* I'll show myself to the door. lol
 
Top Bottom