diff --git a/include/class-Domain.php b/include/class-Domain.php index 086de37..fbe3b4c 100644 --- a/include/class-Domain.php +++ b/include/class-Domain.php @@ -1,77 +1,77 @@ . /** * A domain handled by the user */ class Domain extends Queried { const T = 'domain'; const UID = 'domain_name'; public function __construct() { $this->integers( 'domain_ID' ); $this->booleans( 'domain_active' ); $this->dates( 'domain_born', 'domain_expiration' ); } /** * Get domain ID * * @return int */ public function getDomainID() { return $this->get( 'domain_ID' ); } /** * Get domain name * * @return string */ public function getDomainName() { return $this->get( 'domain_name' ); } /** * Get the domain edit URl * * @return string */ public function getDomainPermalink( $absolute = false ) { return ROOT . '/domain.php/' . $this->get( 'domain_name' ); } /** * Factory mailbox from this domain * * @return MailboxFullAPI */ public function factoryMailbox() { return ( new MailboxFullAPI() )->whereDomain( $this ); } /** - * Factory e-mail foward from this domain + * Factory e-mail forward from this domain * - * @return MailfowardFullAPI + * @return MailforwardFullAPI */ - public function factoryMailfoward() { - return ( new MailfowardFullAPI() )->whereDomain( $this ); + public function factoryMailforward() { + return ( new MailforwardFullAPI() )->whereDomain( $this ); } } diff --git a/include/class-Mailfoward.php b/include/class-Mailforward.php similarity index 62% rename from include/class-Mailfoward.php rename to include/class-Mailforward.php index c82c078..e214034 100644 --- a/include/class-Mailfoward.php +++ b/include/class-Mailforward.php @@ -1,92 +1,92 @@ . /** - * An e-mail fowarding + * An e-mail forwarding */ -class Mailfoward extends Domain { +class Mailforward extends Domain { const T = 'mailfoward'; /** - * Get the mailfoward address + * Get the mailforward address * * @return string E-mail */ - public function getMailfowardAddress() { + public function getMailforwardAddress() { return sprintf( '%s@%s', - $this->getMailfowardSource(), + $this->getMailforwardSource(), $this->getDomainName() ); } /** - * Get the mailfoward source (just username) + * Get the mailforward source (just username) * * @return string */ - public function getMailfowardSource() { + public function getMailforwardSource() { return $this->get( 'mailfoward_source' ); } /** - * Get the mailfoward destination + * Get the mailforward destination * * @return string */ - public function getMailfowardDestination() { + public function getMailforwardDestination() { return $this->get( 'mailfoward_destination' ); } /** - * Get the mailfoward permalink + * Get the mailforward permalink * * @param $absolute boolean * @return string */ - public function getMailfowardPermalink( $absolute = false ) { - return Mailfoward::permalink( + public function getMailforwardPermalink( $absolute = false ) { + return Mailforward::permalink( $this->getDomainName(), - $this->getMailfowardSource(), + $this->getMailforwardSource(), $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->getMailfowardSource() ) + esc_sql( $this->getMailforwardSource() ) ) ); } /** - * Get the mailfoward permalink + * Get the mailforward permalink * * @return string */ - public static function permalink( $domain, $mailfoward = false, $absolute = false ) { - $part = site_page( 'mailfoward.php', $absolute ) . _ . $domain; - if( $mailfoward ) { - $part .= _ . $mailfoward; + public static function permalink( $domain, $mailforward = false, $absolute = false ) { + $part = site_page( 'mailforward.php', $absolute ) . _ . $domain; + if( $mailforward ) { + $part .= _ . $mailforward; } return $part; } } diff --git a/include/class-MailfowardAPI.php b/include/class-MailforwardAPI.php similarity index 66% rename from include/class-MailfowardAPI.php rename to include/class-MailforwardAPI.php index 1491087..5c3c053 100644 --- a/include/class-MailfowardAPI.php +++ b/include/class-MailforwardAPI.php @@ -1,64 +1,64 @@ . /** - * E-mail fowarding API + * E-mail forwarding API */ -class MailfowardAPI extends DomainAPI { +class MailforwardAPI extends DomainAPI { public function __construct() { Query::__construct(); - $this->from( Mailfoward::T ); - $this->defaultClass( 'Mailfoward' ); + $this->from( Mailforward::T ); + $this->defaultClass( 'Mailforward' ); } /** - * Join mailfowardes and domain (once) + * Join mailforwardes and domain (once) * * @return self */ - public function joinMailfowardDomain() { - if( empty( $this->joinedMailfowardDomain ) ) { - $this->joinedMailfowardDomain = true; + public function joinMailforwardDomain() { + if( empty( $this->joinedMailforwardDomain ) ) { + $this->joinedMailforwardDomain = true; $this->from( 'domain' ); $this->equals( 'domain.domain_ID', 'mailfoward.domain_ID' ); } return $this; } /** - * Filter to a certain mail fowarding source + * Filter to a certain mail forwarding source * - * @param mailfoward_source string + * @param mailforward_source string * @return self */ - public function whereMailfowardSource( $mailfoward_source ) { - return $this->whereStr( 'mailfoward_source', $mailfoward_source ); + public function whereMailforwardSource( $mailforward_source ) { + return $this->whereStr( 'mailfoward_source', $mailforward_source ); } /** * Filter to a certain domain ID * * @param $domain_ID int * @return self * @override */ public function whereDomainID( $domain_ID ) { return $this->whereInt( 'mailfoward.domain_ID', $domain_ID ); } } diff --git a/include/class-MailfowardFullAPI.php b/include/class-MailforwardFullAPI.php similarity index 86% rename from include/class-MailfowardFullAPI.php rename to include/class-MailforwardFullAPI.php index 1522268..bafad36 100644 --- a/include/class-MailfowardFullAPI.php +++ b/include/class-MailforwardFullAPI.php @@ -1,28 +1,28 @@ . /** * Mailbox API (a full mailbox address) */ -class MailfowardFullAPI extends MailfowardAPI { +class MailforwardFullAPI extends MailforwardAPI { public function __construct() { parent::__construct(); - $this->joinMailfowardDomain(); + $this->joinMailforwardDomain(); } } diff --git a/mailfoward.php b/mailforward.php similarity index 66% rename from mailfoward.php rename to mailforward.php index 6f2af19..5812f1a 100644 --- a/mailfoward.php +++ b/mailforward.php @@ -1,170 +1,170 @@ . /* - * This is the single e-mail fowarding edit page + * This is the single e-mail forwarding edit page */ // load framework require 'load.php'; // wanted informations $domain = null; -$mailfoward = null; +$mailforward = null; -// URL paramenters (maximum both domain and mailfoward source, minimum just domain) -list( $domain_name, $mailfoward_source ) = url_parts( 2, 1 ); +// URL paramenters (maximum both domain and mailforward source, minimum just domain) +list( $domain_name, $mailforward_source ) = url_parts( 2, 1 ); -// eventually retrieve mailfoward from database -if( $mailfoward_source ) { - $mailfoward = ( new MailfowardFullAPI ) +// eventually retrieve mailforward from database +if( $mailforward_source ) { + $mailforward = ( new MailforwardFullAPI ) ->select( [ 'domain.domain_ID', 'domain.domain_name', 'mailfoward_source', 'mailfoward_destination', ] ) ->whereDomainName( $domain_name ) - ->whereMailfowardSource( $mailfoward_source ) + ->whereMailforwardSource( $mailforward_source ) ->whereDomainIsEditable() ->queryRow(); // 404 - $mailfoward or PageNotFound::spawn(); + $mailforward or PageNotFound::spawn(); - // recycle the mailfoward object that has domain informations - $domain = $mailfoward; + // recycle the mailforward object that has domain informations + $domain = $mailforward; } // eventually retrieve domain from database if( ! $domain ) { $domain = ( new DomainAPI() ) ->select( [ 'domain.domain_ID', 'domain.domain_name', ] ) ->whereDomainName( $domain_name ) ->whereDomainIsEditable() ->queryRow(); // 404 $domain or PageNotFound::spawn(); } // save destination action -if( is_action( 'mailfoward-save' ) ) { +if( is_action( 'mailforward-save' ) ) { // columns to be saved $changes = []; // always require destination - if( empty( $_POST[ 'mailfoward_destination' ] ) ) { + if( empty( $_POST[ 'mailforward_destination' ] ) ) { BadRequest::spawn( __( "missing parameter" ) ); } // validate destination - $destination = luser_input( $_POST[ 'mailfoward_destination' ], 128 ); + $destination = luser_input( $_POST[ 'mailforward_destination' ], 128 ); if( filter_var( $destination, FILTER_VALIDATE_EMAIL ) ) { $changes[] = new DBCol( 'mailfoward_destination', $destination, 's' ); } else { BadRequest::spawn( __( "fail e-mail validation" ) ); } // save source only during creation - if( ! $mailfoward ) { + if( ! $mailforward ) { // require source (can be empty) - if( ! isset( $_POST[ 'mailfoward_source' ] ) ) { + if( ! isset( $_POST[ 'mailforward_source' ] ) ) { BadRequest::spawn( __( "missing parameter" ) ); } - $source = luser_input( $_POST[ 'mailfoward_source' ], 128 ); + $source = luser_input( $_POST[ 'mailforward_source' ], 128 ); if( ! empty( $source ) && ! validate_mailbox_username( $source ) ) { BadRequest::spawn( __( "invalid mailbox name" ) ); } $changes[] = new DBCol( 'mailfoward_source', $source, 's' ); } if( $changes ) { - if( $mailfoward ) { + if( $mailforward ) { // update existing - $mailfoward->update( $changes ); + $mailforward->update( $changes ); // POST/redirect/GET - http_redirect( $mailfoward->getMailfowardPermalink( true ), 303 ); + http_redirect( $mailforward->getMailforwardPermalink( true ), 303 ); } else { // insert as new // check existence - $mailfoward_exists = ( new MailfowardAPI ) + $mailforward_exists = ( new MailforwardAPI ) ->select( 1 ) ->whereDomain( $domain ) - ->whereMailfowardSource( $source ) + ->whereMailforwardSource( $source ) ->queryRow(); // die if exists - if( $mailfoward_exists ) { - BadRequest::spawn( __( "e-mail fowarding already existing" ) ); + if( $mailforward_exists ) { + BadRequest::spawn( __( "e-mail forwarding already existing" ) ); } // insert as new row insert_row( 'mailfoward', array_merge( $changes, [ new DBCol( 'domain_ID', $domain->getDomainID(), 'd' ), ] ) ); // POST/redirect/GET - http_redirect( Mailfoward::permalink( + http_redirect( Mailforward::permalink( $domain->getDomainName(), $source, true ), 303 ); } } } // delete action -if( $mailfoward && is_action( 'mailfoward-delete' ) ) { +if( $mailforward && is_action( 'mailforward-delete' ) ) { query( sprintf( "DELETE FROM %s WHERE domain_ID = %d AND mailfoward_source = '%s'", T( 'mailfoward' ), - $mailfoward->getDomainID(), - esc_html( $mailfoward->getMailfowardSource() ) + $mailforward->getDomainID(), + esc_html( $mailforward->getMailforwardSource() ) ) ); // POST/redirect/GET http_redirect( $domain->getDomainPermalink( true ), 303 ); } // spawn header Header::spawn( [ - 'title-prefix' => __( "E-mail fowarding" ), - 'title' => $mailfoward - ? $mailfoward->getMailfowardAddress() + 'title-prefix' => __( "E-mail forwarding" ), + 'title' => $mailforward + ? $mailforward->getMailforwardAddress() : __( "create" ), 'breadcrumb' => [ new MenuEntry( null, $domain->getDomainPermalink(), $domain->getDomainName() ), ], ] ); // spawn the page content -template( 'mailfoward', [ +template( 'mailforward', [ 'domain' => $domain, - 'mailfoward' => $mailfoward, + 'mailforward' => $mailforward, ] ); // spawn the footer Footer::spawn(); diff --git a/template/domain.php b/template/domain.php index 5b80c6d..95259f3 100644 --- a/template/domain.php +++ b/template/domain.php @@ -1,32 +1,32 @@ . /* * This is the template for the website domain dashboard page * * Called from: * domain.php */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; // spawn the mailboxes list template( 'mailboxes', [ 'domain' => $domain ] ); -// spawn the mail fowardings list -template( 'mailfowards', [ 'domain' => $domain ] ); +// spawn the mail forwardings list +template( 'mailforwards', [ 'domain' => $domain ] ); diff --git a/template/mailbox-description.php b/template/mailbox-description.php index 139d699..9480e91 100644 --- a/template/mailbox-description.php +++ b/template/mailbox-description.php @@ -1,29 +1,29 @@ . /* - * This is the template for a single e-mail fowarding + * This is the template for a single e-mail forwarding * * Called from: * template/mailbox.php */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; ?>

diff --git a/template/mailfoward-description.php b/template/mailforward-description.php similarity index 76% rename from template/mailfoward-description.php rename to template/mailforward-description.php index 1c11fc4..5144ddd 100644 --- a/template/mailfoward-description.php +++ b/template/mailforward-description.php @@ -1,29 +1,29 @@ . /* - * This is the template for a single e-mail fowarding + * This is the template for a single e-mail forwarding * * Called from: - * template/mailfoward.php + * template/mailforward.php */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; ?> -

+

diff --git a/template/mailfoward.php b/template/mailforward.php similarity index 55% rename from template/mailfoward.php rename to template/mailforward.php index 688ae02..46eeefa 100644 --- a/template/mailfoward.php +++ b/template/mailforward.php @@ -1,64 +1,64 @@ . /* - * This is the template for a single e-mail fowarding + * This is the template for a single e-mail forwarding * * Called from: - * mailfoward.php + * mailforward.php * * Available variables: * $domain Domain object - * $mailfoward Mailfoward object + * $mailforward Mailforward object */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; ?> - +

-
- - getMailfowardAddress() ) ?> /> +
+ + getMailforwardAddress() ) ?> /> - getMailfowardSource() ); + getMailforwardSource() ); } ?> /> @getDomainName() ) ?>

-
- getMailfowardDestination() ); +
+ getMailforwardDestination() ); } ?> />

- - - + + +

diff --git a/template/mailfowards.php b/template/mailforwards.php similarity index 73% rename from template/mailfowards.php rename to template/mailforwards.php index 8d13086..365a7de 100644 --- a/template/mailfowards.php +++ b/template/mailforwards.php @@ -1,64 +1,64 @@ . /* * This is the template for the mailboxes list * * Called from: * template/domain.php */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; -// domain mail fowardings -$mailfowards = $domain->factoryMailfoward() +// domain mail forwardings +$mailforwards = $domain->factoryMailforward() ->select( [ 'domain_name', 'mailfoward_source', 'mailfoward_destination', ] ) ->queryGenerator(); ?> - +

- valid() ): ?> + valid() ): ?> - +

getDomainName() ), + Mailforward::permalink( $domain->getDomainName() ), __( "Create" ) ) ?>

- +