diff --git a/include/class-Mailforwardfrom.php b/include/class-Mailforwardfrom.php index 89b597b..8fd7d52 100644 --- a/include/class-Mailforwardfrom.php +++ b/include/class-Mailforwardfrom.php @@ -1,153 +1,156 @@ . +// load DomainTrait +class_exists( 'Domain' ); + /** * Methods for a Mailforwardfrom class */ trait MailforwardfromTrait { /** * Get the mailforward from ID * * @return int */ public function getMailforwardfromID() { return $this->get( 'mailforwardfrom_ID' ); } /** * Get the mailforward from address * * @return string E-mail */ public function getMailforwardfromAddress() { return Mailbox::address( $this->getDomainName(), $this->getMailforwardfromUsername() ); } /** * Get the Mailforwardfrom printable firm * * @return self */ public function getMailforwardfromFirm() { return Mailforwardfrom::firm( $this->getDomainName(), $this->getMailforwardfromUsername() ); } /** * Get the mailforward from username * * @return string */ public function getMailforwardfromUsername() { return $this->get( 'mailforwardfrom_username' ); } /** * Get the mailforward permalink * * @param $absolute boolean * @return string */ public function getMailforwardfromPermalink( $absolute = false ) { return Mailforwardfrom::permalink( $this->getDomainName(), $this->getMailforwardfromUsername(), $absolute ); } /** * Normalize a Mailforwardfrom object after being retrieved from database */ protected function normalizeMailforwardfrom() { $this->integers( 'mailforwardfrom_ID' ); } } /** * An e-mail forwarding */ class Mailforwardfrom extends Queried { use MailforwardfromTrait; use DomainTrait; /** * Constructor */ public function __constructor() { $this->normalizeMailforwardfrom(); $this->normalizeDomain(); } /** * Database table name */ const T = 'mailforwardfrom'; /** * Update the related database row */ public function update( $columns ) { query_update( self::T, $columns, sprintf( "mailforwardfrom_ID = %d", $this->getMailforwardfromID() ) ); } /** * Get the mailforward permalink * * @return string */ public static function permalink( $domain, $mailforward = false, $absolute = false ) { $part = site_page( 'mailforward.php', $absolute ) . _ . $domain; if( $mailforward ) { $part .= _ . $mailforward; } return $part; } /** * Get a printable Mailbox firm * * @param string $domain_name Domain name * @param string $mailforward_username Mailforward username without domain name * @return string */ public static function firm( $domain_name, $mailforward_username ) { return HTML::a( self::permalink( $domain_name, $mailforward_username ), esc_html( Mailbox::address( $domain_name, $mailforward_username ) ) ); } /** * Force to get a Mailforwardfrom ID, whatever is passed * * @param mixed $mailforward Mailforwardfrom object or its ID * @return int */ public static function getID( $mailforward ) { return is_object( $mailforward ) ? $mailforward->getMailforwardfromID() : (int)$mailforward; } }