| | |
| | | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\CustomTable; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\rest\PermissionHandler; |
| | | use JVBase\rest\Response; |
| | | use JVBase\rest\Rest; |
| | |
| | | $this->sharedListsCache = Cache::for('sharedLists')->connect('favourites', true); |
| | | $this->favouritesCache = Cache::for('allFavourites')->connect('favourites', true); |
| | | |
| | | $this->valid_types = array_keys(array_merge(JVB_CONTENT, JVB_TAXONOMY)); |
| | | $this->valid_types = array_merge(Registrar::getRegistered('post'), Registrar::getRegistered('term')); |
| | | |
| | | // Initialize CustomTable instances |
| | | $this->favourites = CustomTable::for('favourites'); |
| | |
| | | 'target_id' => $target_id |
| | | ]); |
| | | |
| | | if ($result['created']) { |
| | | if ((bool)$result) { |
| | | $this->updateFavouriteCount($type, $target_id); |
| | | $this->maybeNotifyOwner($type, $target_id, $user_id); |
| | | } |
| | |
| | | 'type' => $type, |
| | | 'target_id' => $target_id |
| | | ]); |
| | | if ($result['created']) $results['added']++; |
| | | if ((bool) $result) $results['added']++; |
| | | } else { |
| | | $deleted = $table->where([ |
| | | $deleted = $table->delete([ |
| | | 'user_id' => $user_id, |
| | | 'type' => $type, |
| | | 'target_id' => $target_id |
| | | ])->deleteResults(); |
| | | ]); |
| | | if ($deleted) $results['removed']++; |
| | | } |
| | | |
| | |
| | | |
| | | $args = array_merge($args, [ |
| | | 'page' => max(1, absint($data['page'] ?? 1)), |
| | | 'content' => $this->checkContent($data['content'] ?? 'all') |
| | | 'content' => Registrar::getInstance($data['content']) ? $data['content'] : 'all', |
| | | ]); |
| | | |
| | | return $this->applyOrderFilters($args, $data); |