src/Service/Emailer.php
public function trackLink($sRef, $iLinkId)
    {
        $oEmail = $this->getByRef($sRef);

        if ($oEmail) {

            //  Get the link which was clicked
            $oDb = Factory::service('Database');
            $oDb->select('id, url');
            $oDb->where('email_id', $oEmail->id);
            $oDb->where('id', $iLinkId);
            $oLink = $oDb->get(NAILS_DB_PREFIX . 'email_archive_link')->row();

            if ($oLink) {

                //  Update the read count and a add a track data point
                $oDb->set('link_click_count', 'link_click_count+1', false);
                $oDb->where('id', $oEmail->id);
                $oDb->update($this->sTable);

                //  Add a link trackback
                $oDb->set('created', 'NOW()', false);
                $oDb->set('email_id', $oEmail->id);
                $oDb->set('link_id', $oLink->id);

                if (activeUser('id')) {
                    $oDb->set('user_id', activeUser('id'));
                }

                $oDb->insert(NAILS_DB_PREFIX . 'email_archive_track_link');

                //  Return the URL to go to
                return $oLink->url;

            } else {
                return false;
            }
        }

        return false;
    }
public function trackLink($sRef, $iLinkId)
    {
        $oEmail = $this->getByRef($sRef);

        if ($oEmail) {

            //  Get the link which was clicked
            $oDb = Factory::service('Database');
            $oDb->select('id, url');
            $oDb->where('email_id', $oEmail->id);
            $oDb->where('id', $iLinkId);
            $oLink = $oDb->get(NAILS_DB_PREFIX . 'email_archive_link')->row();

            if ($oLink) {

                //  Update the read count and a add a track data point
                $oDb->set('link_click_count', 'link_click_count+1', false);
                $oDb->where('id', $oEmail->id);
                $oDb->update($this->sTable);

                //  Add a link trackback
                $oDb->set('created', 'NOW()', false);
                $oDb->set('email_id', $oEmail->id);
                $oDb->set('link_id', $oLink->id);

                if (activeUser('id')) {
                    $oDb->set('user_id', activeUser('id'));
                }

                $oDb->insert(NAILS_DB_PREFIX . 'email_archive_track_link');

                //  Return the URL to go to
                return $oLink->url;

            } else {
                return false;
            }
        }

        return false;
    }
public function trackLink ( $ sRef , $ iLinkId ) { $ oEmail = $ this -> getByRef ( $ sRef ) ; if ( $ oEmail ) { //  Get the link which was clicked $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( 'id, url' ) ; $ oDb -> where ( 'email_id' , $ oEmail -> id ) ; $ oDb -> where ( 'id' , $ iLinkId ) ; $ oLink = $ oDb -> get ( NAILS_DB_PREFIX . 'email_archive_link' ) -> row ( ) ; if ( $ oLink ) { //  Update the read count and a add a track data point $ oDb -> set ( 'link_click_count' , 'link_click_count+1' , false ) ; $ oDb -> where ( 'id' , $ oEmail -> id ) ; $ oDb -> update ( $ this -> sTable ) ; //  Add a link trackback $ oDb -> set ( 'created' , 'NOW()' , false ) ; $ oDb -> set ( 'email_id' , $ oEmail -> id ) ; $ oDb -> set ( 'link_id' , $ oLink -> id ) ; if ( activeUser ( 'id' ) ) { $ oDb -> set ( 'user_id' , activeUser ( 'id' ) ) ; } $ oDb -> insert ( NAILS_DB_PREFIX . 'email_archive_track_link' ) ; //  Return the URL to go to return $ oLink -> url ; } else { return false ; } } return false ; }
Increments a link's open count and adds a tracking note

@param  string  $sRef    The email's reference
@param  integer $iLinkId The link's ID

@return string
@throws \Nails\Common\Exception\FactoryException
Increments a link s open count and adds a tracking note