1 | <?php |
||
26 | class ItemService extends Service { |
||
27 | |||
28 | private $statusFlag; |
||
29 | private $config; |
||
30 | private $timeFactory; |
||
31 | private $itemMapper; |
||
32 | private $systemConfig; |
||
33 | |||
34 | public function __construct(ItemMapper $itemMapper, |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Returns all new items |
||
50 | * @param int $id the id of the feed, 0 for starred or all items |
||
51 | * @param int $type the type of the feed |
||
52 | * @param int $updatedSince a timestamp with the last modification date |
||
53 | * returns only items with a >= modified timestamp |
||
54 | * @param boolean $showAll if unread items should also be returned |
||
55 | * @param string $userId the name of the user |
||
56 | * @return array of items |
||
57 | */ |
||
58 | public function findAllNew($id, $type, $updatedSince, $showAll, $userId){ |
||
76 | |||
77 | |||
78 | /** |
||
79 | * Returns all items |
||
80 | * @param int $id the id of the feed, 0 for starred or all items |
||
81 | * @param int $type the type of the feed |
||
82 | * @param int $limit how many items should be returned |
||
83 | * @param int $offset the offset |
||
84 | * @param boolean $showAll if unread items should also be returned |
||
85 | * @param boolean $oldestFirst if it should be ordered by oldest first |
||
86 | * @param string $userId the name of the user |
||
87 | * @param string[] $search an array of keywords that the result should |
||
88 | * contain in either the author, title, link or body |
||
89 | * @return array of items |
||
90 | */ |
||
91 | public function findAll($id, $type, $limit, $offset, $showAll, $oldestFirst, |
||
112 | |||
113 | |||
114 | /** |
||
115 | * Star or unstar an item |
||
116 | * @param int $feedId the id of the item's feed that should be starred |
||
117 | * @param string $guidHash the guidHash of the item that should be starred |
||
118 | * @param boolean $isStarred if true the item will be marked as starred, |
||
119 | * if false unstar |
||
120 | * @param string $userId the name of the user for security reasons |
||
121 | * @throws ServiceNotFoundException if the item does not exist |
||
122 | */ |
||
123 | public function star($feedId, $guidHash, $isStarred, $userId){ |
||
140 | |||
141 | |||
142 | /** |
||
143 | * Read or unread an item |
||
144 | * @param int $itemId the id of the item that should be read |
||
145 | * @param boolean $isRead if true the item will be marked as read, |
||
146 | * if false unread |
||
147 | * @param string $userId the name of the user for security reasons |
||
148 | * @throws ServiceNotFoundException if the item does not exist |
||
149 | */ |
||
150 | public function read($itemId, $isRead, $userId){ |
||
151 | $lastModified = $this->timeFactory->getTime(); |
||
152 | $this->itemMapper->readItem($itemId, $isRead, $lastModified, $userId); |
||
153 | } |
||
154 | |||
155 | |||
156 | /** |
||
157 | * Set all items read |
||
158 | * @param int $highestItemId all items below that are marked read. This is |
||
159 | * used to prevent marking items as read that the users hasn't seen yet |
||
160 | * @param string $userId the name of the user |
||
161 | */ |
||
162 | public function readAll($highestItemId, $userId){ |
||
166 | |||
167 | |||
168 | /** |
||
169 | * Set a folder read |
||
170 | * @param int $folderId the id of the folder that should be marked read |
||
171 | * @param int $highestItemId all items below that are marked read. This is |
||
172 | * used to prevent marking items as read that the users hasn't seen yet |
||
173 | * @param string $userId the name of the user |
||
174 | */ |
||
175 | public function readFolder($folderId, $highestItemId, $userId){ |
||
181 | |||
182 | |||
183 | /** |
||
184 | * Set a feed read |
||
185 | * @param int $feedId the id of the feed that should be marked read |
||
186 | * @param int $highestItemId all items below that are marked read. This is |
||
187 | * used to prevent marking items as read that the users hasn't seen yet |
||
188 | * @param string $userId the name of the user |
||
189 | */ |
||
190 | public function readFeed($feedId, $highestItemId, $userId){ |
||
194 | |||
195 | |||
196 | /** |
||
197 | * This method deletes all unread feeds that are not starred and over the |
||
198 | * count of $this->autoPurgeCount starting by the oldest. This is to clean |
||
199 | * up the database so that old entries don't spam your db. As criteria for |
||
200 | * old, the id is taken |
||
201 | */ |
||
202 | public function autoPurgeOld(){ |
||
208 | |||
209 | |||
210 | /** |
||
211 | * Returns the newest item id, use this for marking feeds read |
||
212 | * @param string $userId the name of the user |
||
213 | * @throws ServiceNotFoundException if there is no newest item |
||
214 | * @return int |
||
215 | */ |
||
216 | public function getNewestItemId($userId) { |
||
223 | |||
224 | |||
225 | /** |
||
226 | * Returns the starred count |
||
227 | * @param string $userId the name of the user |
||
228 | * @return int the count |
||
229 | */ |
||
230 | public function starredCount($userId){ |
||
233 | |||
234 | |||
235 | /** |
||
236 | * @param string $userId from which user the items should be taken |
||
237 | * @return array of items which are starred or unread |
||
238 | */ |
||
239 | public function getUnreadOrStarred($userId) { |
||
242 | |||
243 | |||
244 | /** |
||
245 | * Deletes all items of a user |
||
246 | * @param string $userId the name of the user |
||
247 | */ |
||
248 | public function deleteUser($userId) { |
||
251 | |||
252 | |||
253 | /** |
||
254 | * Regenerates the search index for all items |
||
255 | */ |
||
256 | public function generateSearchIndices() { |
||
259 | |||
260 | } |
||
261 |