diff --git a/include/class-Mailfoward.php b/include/class-Mailfoward.php index 90c21c8..c82c078 100644 --- a/include/class-Mailfoward.php +++ b/include/class-Mailfoward.php @@ -1,82 +1,92 @@ . /** * An e-mail fowarding */ class Mailfoward extends Domain { const T = 'mailfoward'; /** * Get the mailfoward address * * @return string E-mail */ public function getMailfowardAddress() { - return sprintf( "%s@%s", - $this->get( 'mailfoward_source' ), - $this->get( 'domain_name' ) + return sprintf( '%s@%s', + $this->getMailfowardSource(), + $this->getDomainName() ); } + /** + * Get the mailfoward source (just username) + * + * @return string + */ + public function getMailfowardSource() { + return $this->get( 'mailfoward_source' ); + } + /** * Get the mailfoward destination * * @return string */ public function getMailfowardDestination() { return $this->get( 'mailfoward_destination' ); } /** * Get the mailfoward permalink * + * @param $absolute boolean * @return string */ public function getMailfowardPermalink( $absolute = false ) { return Mailfoward::permalink( - $this->get( 'domain_name' ), - $this->get( 'mailfoward_source' ) + $this->getDomainName(), + $this->getMailfowardSource(), + $absolute ); } /** * Update the related database row */ public function update( $columns ) { query_update( self::T, $columns, sprintf( "domain_ID = %d AND mailfoward_source = '%s'", $this->getDomainID(), - esc_sql( $this->get( 'mailfoward_source' ) ) + esc_sql( $this->getMailfowardSource() ) ) ); } /** * Get the mailfoward permalink * * @return string */ - public static function permalink( $domain, $mailfoward ) { - return sprintf( - '%s/%s/%s', - ROOT . '/mailfoward.php', - $domain, - $mailfoward - ); + public static function permalink( $domain, $mailfoward = false, $absolute = false ) { + $part = site_page( 'mailfoward.php', $absolute ) . _ . $domain; + if( $mailfoward ) { + $part .= _ . $mailfoward; + } + return $part; } }