Jake Vanderwerf
3 days ago ba1e1ccf869b818f7a7a897264dfea05563a7796
inc/managers/InvitationsManager.php
@@ -5,7 +5,7 @@
use JVBase\managers\queue\executors\InvitationExecutor;
use JVBase\managers\queue\TypeConfig;
use JVBase\registrar\Registrar;
use JVBase\utility\Features;
use JVBase\base\Site;
use WP_Error;
if (!defined('ABSPATH')) {
@@ -25,7 +25,7 @@
         return;
      }
      $this->setInviteConfig();
      $this->cache = Cache::for('invitations');
      $this->cache = Cache::for('invitations')->user();
      add_action('init', [$this, 'registerInvitationExecutors'], 5);
      add_action('user_register', [$this, 'checkInvitation']);
@@ -36,8 +36,9 @@
   public function defineTable():void
   {
      $terms = Registrar::getFeatured('invitable', 'term');
      $roles = Features::forMembership()->get('can_invite');
      $terms = Registrar::withFeature('invitable', 'term');
      $membership = Site::membership();
      $roles = ($membership) ? Site::membership()->has('can_invite') :[];
      if (empty($terms) && empty($roles)) {
         return;
      }
@@ -48,9 +49,9 @@
         'name'            => 'varchar(255) NOT NULL',
         'email'           => 'varchar(255) NOT NULL',
         'invitation_token'   => 'varchar(255) NOT NULL',
         'invited_role'    => 'varchar(50) NOT NULL COMMENT \'Role being invited to\'',
         'status'       => 'ENUM(\'pending\',\'accepted\',\'rejected\',\'expired\',\'revoked\') DEFAULT \'pending\'',
         'inviters'        => 'JSON NOT NULL COMMENT \'Array of {user_id, invited_at}\'',
         'invited_role'    => 'varchar(50) NOT NULL',    //Role being invited to
         'status'       => "ENUM('pending','accepted','rejected','expired','revoked') DEFAULT 'pending'",
         'inviters'        => 'JSON NOT NULL',        // Array of {user_id, invited_at}
         'new_user_id'     => $table->getUserIDType().' DEFAULT NULL',
         'expires_at'      => 'datetime NOT NULL',
         'accepted_at'     => 'datetime DEFAULT NULL',
@@ -66,7 +67,7 @@
      $table->setKeys([
         ['key' => 'PRIMARY', 'value' => '(`id`)'],
         ['key' => 'UNIQUE KEY', 'value' => '`unique_email_role` (`email`, `invited_role`)'],
         ['key' => 'UNIQUE', 'value' => '`unique_email_role` (`email`, `invited_role`)'],
         '`token_lookup` (`invitation_token`)',
         '`status_expiry` (`status`, `expires_at`)',
         '`role_status` (`invited_role`, `status`)',
@@ -162,9 +163,9 @@
            }
            // Term invitations from invitable content taxonomies
            $invitable = Registrar::getFeatured('invitable', 'term');
            $content = Registrar::getFeatured('is_content', 'term');
            $ownable = Registrar::getFeatured('is_ownable', 'term');
            $invitable = Registrar::withFeature('invitable', 'term');
            $content = Registrar::withFeature('is_content', 'term');
            $ownable = Registrar::withFeature('is_ownable', 'term');
            $taxonomies = array_intersect($invitable, $content, $ownable);
            if (!empty($taxonomies)) {
               $users = Registrar::getRegistered('user');