Skip to content

Commit a502dfe

Browse files
committed
Folder delimiter check added #137
1 parent faaee5d commit a502dfe

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## [UNRELEASED]
88
### Fixed
9-
- NaN
9+
- Folder delimiter check added #137
1010

1111
### Added
1212
- NaN
1313

1414
### Affected Classes
15-
- NaN
15+
- [Folder::class](src/IMAP/Folder.php)
1616

1717
## 0.0.1 - 2018-08-13
1818
### Added

src/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ public function deleteFolder($name, $expunge = true) {
383383
*
384384
* @return MessageCollection
385385
* @throws ConnectionFailedException
386+
* @throws Exceptions\InvalidWhereQueryCriteriaException
386387
* @throws GetMessagesFailedException
387-
* @throws MessageSearchValidationException
388388
*
389389
* @deprecated 1.0.5.2:2.0.0 No longer needed. Use Folder::getMessages() instead
390390
* @see Folder::getMessages()
@@ -404,8 +404,8 @@ public function getMessages(Folder $folder, $criteria = 'ALL', $fetch_options =
404404
*
405405
* @return MessageCollection
406406
* @throws ConnectionFailedException
407+
* @throws Exceptions\InvalidWhereQueryCriteriaException
407408
* @throws GetMessagesFailedException
408-
* @throws MessageSearchValidationException
409409
*
410410
* @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::getMessages('UNSEEN') instead
411411
* @see Folder::getMessages()
@@ -426,8 +426,8 @@ public function getUnseenMessages(Folder $folder, $criteria = 'UNSEEN', $fetch_o
426426
*
427427
* @return MessageCollection
428428
* @throws ConnectionFailedException
429+
* @throws Exceptions\InvalidWhereQueryCriteriaException
429430
* @throws GetMessagesFailedException
430-
* @throws MessageSearchValidationException
431431
*
432432
* @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::searchMessages() instead
433433
* @see Folder::searchMessages()

src/Folder.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ class Folder {
111111
*
112112
* @param \Webklex\PHPIMAP\Client $client
113113
*
114-
* @param object $folder
114+
* @param object structure
115115
*/
116-
public function __construct(Client $client, $folder) {
116+
public function __construct(Client $client, $structure) {
117117
$this->client = $client;
118118

119-
$this->delimiter = $folder->delimiter;
120-
$this->path = $folder->name;
121-
$this->fullName = $this->decodeName($folder->name);
119+
$this->setDelimiter($structure->delimiter);
120+
$this->path = $structure->name;
121+
$this->fullName = $this->decodeName($structure->name);
122122
$this->name = $this->getSimpleName($this->delimiter, $this->fullName);
123123

124-
$this->parseAttributes($folder->attributes);
124+
$this->parseAttributes($structure->attributes);
125125
}
126126

127127
/**
@@ -187,6 +187,7 @@ public function setChildren($children = []) {
187187
* @param boolean $fetch_flags
188188
*
189189
* @return Message|null
190+
* @throws Exceptions\ConnectionFailedException
190191
*/
191192
public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = true) {
192193
if (imap_msgno($this->getClient()->getConnection(), $uid) > 0) {
@@ -210,8 +211,8 @@ public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_
210211
*
211212
* @return MessageCollection
212213
* @throws Exceptions\ConnectionFailedException
214+
* @throws Exceptions\InvalidWhereQueryCriteriaException
213215
* @throws GetMessagesFailedException
214-
* @throws MessageSearchValidationException
215216
*/
216217
public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") {
217218

@@ -234,8 +235,8 @@ public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_bod
234235
*
235236
* @return MessageCollection
236237
* @throws Exceptions\ConnectionFailedException
238+
* @throws Exceptions\InvalidWhereQueryCriteriaException
237239
* @throws GetMessagesFailedException
238-
* @throws MessageSearchValidationException
239240
*
240241
* @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::getMessages('UNSEEN') instead
241242
* @see Folder::getMessages()
@@ -270,8 +271,8 @@ public function getUnseenMessages($criteria = 'UNSEEN', $fetch_options = null, $
270271
* @return MessageCollection
271272
*
272273
* @throws Exceptions\ConnectionFailedException
274+
* @throws Exceptions\InvalidWhereQueryCriteriaException
273275
* @throws GetMessagesFailedException
274-
* @throws MessageSearchValidationException
275276
*
276277
* @doc http://php.net/manual/en/function.imap-search.php
277278
* imap_search() only supports IMAP2 search criterias, because the function mail_criteria() (from c-client lib)
@@ -404,6 +405,7 @@ public function move($target_mailbox, $expunge = true) {
404405
* SA_ALL - set all of the above
405406
*
406407
* @return object
408+
* @throws Exceptions\ConnectionFailedException
407409
*/
408410
public function getStatus($options) {
409411
return imap_status($this->client->getConnection(), $this->path, $options);
@@ -417,6 +419,7 @@ public function getStatus($options) {
417419
* @param string $internal_date
418420
*
419421
* @return bool
422+
* @throws Exceptions\ConnectionFailedException
420423
*/
421424
public function appendMessage($message, $options = null, $internal_date = null) {
422425
return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
@@ -430,4 +433,16 @@ public function appendMessage($message, $options = null, $internal_date = null)
430433
public function getClient() {
431434
return $this->client;
432435
}
436+
437+
438+
/**
439+
* @param $delimiter
440+
*/
441+
public function setDelimiter($delimiter){
442+
if(in_array($delimiter, [null, '', ' ', false]) === true) {
443+
$delimiter = ClientManager::$config['options']['delimiter'];
444+
}
445+
446+
$this->delimiter = $delimiter;
447+
}
433448
}

0 commit comments

Comments
 (0)