diff --git a/include/class-DomainUser.php b/include/class-DomainUser.php index 29ff517..4985b2d 100644 --- a/include/class-DomainUser.php +++ b/include/class-DomainUser.php @@ -1,60 +1,65 @@ . // assure load of dependent traits class_exists( 'Domain' ); class_exists( 'User' ); /** * Trait for a DomainUser class */ trait DomainUserTrait { use DomainTrait; use UserTrait; + public function getDomainUserCreationDate() { + return $this->get('domain_user_creation_date'); + } + /** * Normalize a DomainUser object after being retrieved from database */ protected function normalizeDomainUser() { $this->normalizeDomain(); $this->normalizeUser(); } } /** * Describe the 'domain_user' table */ class DomainUser extends Queried { use DomainUserTrait; /** * Database table */ const T = 'domain_user'; /** * Constructor */ public function __construct() { $this->normalizeDomainUser(); + $this->datetimes('domain_user_creation_date'); } } diff --git a/include/class-UserAPI.php b/include/class-UserAPI.php index 3fcd1e5..0b6c464 100644 --- a/include/class-UserAPI.php +++ b/include/class-UserAPI.php @@ -1,117 +1,139 @@ . /** * Methods for an UserAPI class */ trait UserAPITrait { /** * Filter to a certain User UID * * @param string $uid User UID * @return self */ public function whereUserUID( $uid ) { return $this->whereStr( 'user_uid', $uid ); } /** * Filter to a certain User E-mail * * @param string $email User E-mail * @return self */ public function whereUserEmail( $email ) { return $this->whereStr( 'user_email', $email ); } /** * Filter to a certain User ID * * @param string $uid User ID * @return self */ public function whereUserID( $id ) { return $this->whereInt( static::USER_ID, $id ); } /** * Filter to myself * * @return self */ public function whereUserIsMe() { $id = get_user()->getUserID(); return $this->whereUserID( $id ); } /** * WHere the User(s) is editable * * @return Query */ public function whereUserIsEditable() { // if I can't see everyone, just see myself if( !has_permission( 'edit-user-all' ) ) { $this->whereUserIsMe(); } return $this; } /** * Limit to a specific User * * @param object $user User * @return self */ public function whereUser( $user ) { $id = $user->getSessionuserID(); return $this->whereUserID( $id ); } + /** + * Join whatever table with the domain table + * + * @return self + */ + public function joinUser() { + return $this->joinOn( 'INNER', 'user', self::USER_ID, 'user.user_ID'); + } + + /** + * Order elements by the User's signature. + */ + public function orderByUserFirm() { + return $this->orderByUserUID(); + } + + /** + * Order elements by the field "User UID". + */ + public function orderByUserUID() { + return $this->orderBy('user_uid'); + } } /** * Query the 'user' database table */ class UserAPI extends Query { use UserAPITrait; /** * Univoque column name of the User ID */ const USER_ID = 'user.user_ID'; /** * Constructor * * @param object $db Database (or NULL for the current one) */ public function __construct( $db = null ) { // set database and class name parent::__construct( $db, User::class ); // set database table $this->from( User::T ); } } diff --git a/template/domain-users.php b/template/domain-users.php new file mode 100644 index 0000000..5211091 --- /dev/null +++ b/template/domain-users.php @@ -0,0 +1,72 @@ +. + +/* + * This is the template for the Domain Activity + * + * Called from: + * template/domain.php + * + * Available variables: + * $domain object|null + */ + +$domain_users = (new DomainUserAPI()) + ->whereDomain($domain) + ->joinUser() + ->orderByUserFirm() + ->queryResults(); + +$admins = (new UserAPI()) + ->whereStr('user_role', 'admin') + ->orderByUserFirm() + ->queryResults(); + +?> + + + +
+

+

+ + + +

+ + + +
+ + diff --git a/template/domain.php b/template/domain.php index 421f8c3..38143b4 100644 --- a/template/domain.php +++ b/template/domain.php @@ -1,57 +1,60 @@ . /* * This is the template for the website domain dashboard page * * Called from: * domain.php * * Available variables: * $domain object Domain * $plan object Plan */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; // pass the same arguments to the sub-templates $args = [ 'domain' => $domain, 'plan' => $plan, ]; // spawn the mailboxes list template( 'mailboxes', $args ); // spawn the mail forwardings list template( 'mailforwards', $args ); // spawn the ftp list template( 'ftp-users', $args ); // show some links to the plan template( 'domain-plan-section', $args ); if( has_permission( 'edit-mta-all' ) ) { // show a link to the Domain-MTA page template( 'domain-mta-link', $args ); } +// show some links to the plan +template( 'domain-users', $args ); + // show Domain activity template( 'domain-activity', $args );