| | |
| | | use Exception; |
| | | use JVBase\managers\CustomTable; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\utility\Features; |
| | | use JVBase\base\Site; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; // Exit if accessed directly |
| | |
| | | 'icon' => 'info', |
| | | 'digest'=> true |
| | | ]]; |
| | | if (Features::forSite()->has('favourites')) { |
| | | if (Site::has('favourites')) { |
| | | $types = array_merge($types, [ |
| | | 'new_favourite' => [ |
| | | 'icon' => 'heart', |
| | |
| | | ] |
| | | ]); |
| | | } |
| | | $contentTax = Registrar::getFeatured('is_content', 'term'); |
| | | $verifyEntry = Registrar::getFeatured('verify_entry', 'term'); |
| | | $contentTax = Registrar::withFeature('is_content', 'term'); |
| | | $verifyEntry = Registrar::withFeature('verify_entry', 'term'); |
| | | if (!empty(array_intersect($contentTax, $verifyEntry))) { |
| | | $types = array_merge($types, [ |
| | | 'entry_requested' => [ |
| | |
| | | ] |
| | | ]); |
| | | } |
| | | $invitable = Registrar::getFeatured('invitable'); |
| | | $invitable = Registrar::withFeature('invitable'); |
| | | if (!empty($invitable)) { |
| | | $types = array_merge($types, [ |
| | | 'invitation_requested' => [ |
| | |
| | | ]); |
| | | } |
| | | |
| | | $approvals = Registrar::getFeatured('approve_new'); |
| | | $approvals = Registrar::withFeature('approve_new'); |
| | | if (!empty($approvals)) { |
| | | $tmp = ['user', 'term', 'post']; |
| | | $app = []; |
| | | foreach ($tmp as $t) { |
| | | $approvals = Registrar::getFeatured('approve_new', $t); |
| | | $approvals = Registrar::withFeature('approve_new', $t); |
| | | if (!empty($approvals)) { |
| | | $app = array_merge($app, [ |
| | | $t.'_new' => [ |
| | |
| | | $this->types = $types; |
| | | } |
| | | |
| | | public function getNotificationTypes(bool $all = false):array |
| | | { |
| | | return ($all) ? $this->types : array_keys($this->types); |
| | | } |
| | | |
| | | private function defineTable():void |
| | | { |
| | | $table = CustomTable::for('notifications_main'); |
| | | |
| | | $typeEnum = implode(',',array_map(function($type) { return '`'.$type.'`';}, array_keys($this->types))); |
| | | $typeEnum = implode(',',array_map(function($type) { return "'{$type}'";}, array_keys($this->types))); |
| | | |
| | | $table->setColumns([ |
| | | 'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT', |
| | |
| | | '`user_status` (`for_user`, `status`)', |
| | | '`target_lookup` (`target_id`, `target_type`)', |
| | | '`unread_notifications` (`for_user`, `status`, `created_at`)', |
| | | '`requires_action` (`for_user`, `requires_action`, `action_taken`)', |
| | | '`requires_action` (`for_user`, `action_taken`)', |
| | | '`from_user_lookup` (`for_user`, `from_user`, `target_id`, `target_type`, `type`)' |
| | | ]); |
| | | |