Jump to content

Download: (caps) Email Post Notification


capbiker

Recommended Posts

File Name: (caps) Email Post Notification
File Submitter: capbiker
File Submitted: 20 Jan 2010
File Updated: 29 Jan 2010
File Category: Hooks and Plugins

This hook will enable you to decide on which members on your board will be able to receive emails about new topics being created and new replies to topics.

You can select which forums you get these messages from.

With in the emails as default you will receive a notification telling you the posters name and IP address, the topic title, the forum where the topic/post is located and the actual content of the post and a direct link for you to go and deal with it as necessary.

I would recommend not to use this hook on a high posting board because you will be in undated with emails and also it could course problems on your server in the long run.

1.0.1 as a fix to a bug where with the right configuration within the settings pages all members on the board could receive email notifications. This as now been fixed.

To upgrade the hook login to ACP->Manage Hooks->caps Email Post Notifications and select the down arrow next to the title and click on uninstall. Now you will just re-install it as the instructions states. You will need to check the Disabled Hook section because it might appear in there, if it does just click on the arrow next to it and select enable.

Click here to download this file

Link to comment

Hi,

Further to http://community.invisionpower.com/topic/302060-can-admin-receive-an-email-notification-after-every-post/page__pid__1905519__st__20&#entry1905519

I have removed and reinstalled but the same thing i'm afraid.

IP.Board Version v3.0.5 (ID:30012)

Only other hook installed was added after this one was first tested.

Edit: Infact, the reason i'm getting two is I have two forum profiles. However, EVERYONE on the forum is getting one instead of just the UID i entered.

Matt

Link to comment

Matt

I have sent you a PM about this with an edited version of the hook to help me to hopefully diagnosed the problems that you are.

I have just read the edited part, and somebody else today as reported the same thing and sent them the same edited version of the hook. Hopefully with two different boards it will help me work out where the problems are and correct it.

cap

Link to comment
  • 3 weeks later...
  • 10 months later...
  • 1 month later...

Gentlemen and Ladies

The comments here only relate to the implementation of this hook and does not talk about the hooks functionality.

[*]This is an "action overload hook"


overloading means that the original IPB action (load) is replaced but the original action (load) can still be executed if desired ie Overloaded It is inadvisable to completely replace IPB action because IPB revision uplevels may add functionality This "(caps) Email Post Notification" hook does a complete replacement

The hook replaces the original class public_forums_post_post (we did a line difference comparison) This won't work at IPB 3.1.4 because the IPB 3.1.4 class public_forums_post_post now contains the following additional code"


						$permissions['softDelete']    = $this->registry->getClass('class_forums')->canSoftDeletePosts( $topic['forum_id'], $topic );

						$permissions['softDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts( $topic['forum_id'] );

and


						if ( $permissions['softDelete'] AND $permissions['softDeleteSee'] )

						{

							$posts += $topic['topic_deleted_posts'];

						}

Therefore installing this hook the functionality at IPB 3.1.4 will be lost!!!!


parent::saveForm($type);

[*] and the possibly correct implementation (to overload but not replace) and to make compatiable with IPB 3.1.4 and possible future revisions to the "class public_forums_post_post" "public function saveForm( $type )" would be as below


  public function saveForm($type) {

    $forums = array();

    $email_forum = false;

    $email_member = false;

    $forum = 0;

    $post = false;

    $members = array();

    $member = 0;

    $email_member = array();

    $counter = 0;

    $select_members = "";

    if ($this->settings['email_notification_on'] == false)

    {

      parent :: saveForm($type);

    }

    if ($type != 'new' AND $type != 'reply')

    {

      parent :: saveForm($type);

    }

    if ($this->settings['email_notification_forums'] != '*')

    {

      $forums = explode(",", $this->settings['email_notification_forums']);

      if (count($forums) > 0) {

        foreach ($forums as $forum) {

          if ($topic['forum_id'] == $forum)

          {

            $email = true;

          }

        }

      }

    }

    else {

      $email_forum = true;

    }

    if (preg_match("/,/i", $this->settings['email_notification_members']))

    {

      $members = explode(",", $this->settings['email_notification_members']);

    }

    else {

      if ($this->settings['email_notification_members'] != $this->memberData['member_id'])

      {

        $select_members = "member_id = " . $this->settings['email_notification_members'];

        $email_member = true;

      }

    }

    if (count($members) > 0)

    {

      foreach ($members as $member)

      {

        if ($member != "" AND $member > 0)

        {

          if ($member != $this->memberData['member_id']) {

            $select_members .= ($select_members != "") ? " OR member_id = $member" : "member_id = " . $member;

            $email_member = true;

          }

        }

      }

    }

    if ($email_forum == false OR $email_member == false)

    {

      parent :: saveForm($type);

    }


    $topic = $this->_postClass->getTopicData();

    $post = $this->_postClass->getPostData();


    switch ($type) {

      case 'reply' :

        try {

          if (!$this->_postClass->addReply() === FALSE)

          {

            if (!$topic['_returnToMove'] AND !$this->settings['post_order_sort'] == 'desc')

            {

              $this->email_notification($topic, $post, $type, $select_members);

              parent :: saveForm($type);

            }

          }

        }

        catch (Exception $error)

        {

            parent :: saveForm($type);

        }

        break;

      case 'new' :

        try

        {

          if (!$this->_postClass->addTopic() === FALSE)

          {

            $this->email_notification($topic, $post, $type, $select_members);

            parent :: saveForm($type);

          }

        }

        catch (Exception $error)

        {

            parent :: saveForm($type);

        }

        break;

    }

  }

[*]I took the liberty to rearrange the code for clarity and code reduction. [*]In regards to exceptions arising from "addTopic()" and "addReply()" and since "email_notification" does not have any new exceptions coded at this time, we merely call the parent and the exceptions will get handled and the appropriate redirect will be done. [*]This implementation has not been tested. [*]If I need the functionality of this hook I will debug and post any corrections here. [*]NOTE: The functionality of this hook would be better implemented as "Data Hook" in the Location "postFirstPost" which would require a rewrite of above implementation but would make all the exception handling go away [*]Thank you for the education. NOTE: I recommend that IPB implement a "postFirstPost" data hook point which passes both Topic and Post data. As it is the developer has to horse around with the DB or implement two hooks to get all the data needed to do what is being attempted with the "(caps) Email Post Notification"




[*]Therefore This "(caps) Email Post Notification" appears to be not compatible with IPB 3.1.4 [*]Specifically looking at this "hooks.xml" code [*]and comparing it with the "post.php" at "class public_forums_post_post" "public function saveForm( $type ) " which this hook replaces [*]We note: [*]Now the "hook.xml" did illustrate how the overloading can work while preserving the original load [*] Reviewing the code ( and this ) we note that original "class public_forums_post_post" "public function saveForm( $type ) "can be executed with
Link to comment
  • 1 month later...

I cannot get this to work on my forum! I use 3.1.4

I have no idea what the previous poster is going on about..totally over my head.

Simple question then..Does this work on 3.1.4? If so WHO has it operating properly. As I received NO emails after implementing and setting it up.

Link to comment
  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...