Skip to content

Commit

Permalink
Folder delimiter check added #137
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Aug 14, 2018
1 parent faaee5d commit a502dfe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [UNRELEASED]
### Fixed
- NaN
- Folder delimiter check added #137

### Added
- NaN

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

## 0.0.1 - 2018-08-13
### Added
Expand Down
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ public function deleteFolder($name, $expunge = true) {
*
* @return MessageCollection
* @throws ConnectionFailedException
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
* @throws MessageSearchValidationException
*
* @deprecated 1.0.5.2:2.0.0 No longer needed. Use Folder::getMessages() instead
* @see Folder::getMessages()
Expand All @@ -404,8 +404,8 @@ public function getMessages(Folder $folder, $criteria = 'ALL', $fetch_options =
*
* @return MessageCollection
* @throws ConnectionFailedException
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
* @throws MessageSearchValidationException
*
* @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::getMessages('UNSEEN') instead
* @see Folder::getMessages()
Expand All @@ -426,8 +426,8 @@ public function getUnseenMessages(Folder $folder, $criteria = 'UNSEEN', $fetch_o
*
* @return MessageCollection
* @throws ConnectionFailedException
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
* @throws MessageSearchValidationException
*
* @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::searchMessages() instead
* @see Folder::searchMessages()
Expand Down
33 changes: 24 additions & 9 deletions src/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ class Folder {
*
* @param \Webklex\PHPIMAP\Client $client
*
* @param object $folder
* @param object structure
*/
public function __construct(Client $client, $folder) {
public function __construct(Client $client, $structure) {
$this->client = $client;

$this->delimiter = $folder->delimiter;
$this->path = $folder->name;
$this->fullName = $this->decodeName($folder->name);
$this->setDelimiter($structure->delimiter);
$this->path = $structure->name;
$this->fullName = $this->decodeName($structure->name);
$this->name = $this->getSimpleName($this->delimiter, $this->fullName);

$this->parseAttributes($folder->attributes);
$this->parseAttributes($structure->attributes);
}

/**
Expand Down Expand Up @@ -187,6 +187,7 @@ public function setChildren($children = []) {
* @param boolean $fetch_flags
*
* @return Message|null
* @throws Exceptions\ConnectionFailedException
*/
public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = true) {
if (imap_msgno($this->getClient()->getConnection(), $uid) > 0) {
Expand All @@ -210,8 +211,8 @@ public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_
*
* @return MessageCollection
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
* @throws MessageSearchValidationException
*/
public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") {

Expand All @@ -234,8 +235,8 @@ public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_bod
*
* @return MessageCollection
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
* @throws MessageSearchValidationException
*
* @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::getMessages('UNSEEN') instead
* @see Folder::getMessages()
Expand Down Expand Up @@ -270,8 +271,8 @@ public function getUnseenMessages($criteria = 'UNSEEN', $fetch_options = null, $
* @return MessageCollection
*
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
* @throws MessageSearchValidationException
*
* @doc http://php.net/manual/en/function.imap-search.php
* imap_search() only supports IMAP2 search criterias, because the function mail_criteria() (from c-client lib)
Expand Down Expand Up @@ -404,6 +405,7 @@ public function move($target_mailbox, $expunge = true) {
* SA_ALL - set all of the above
*
* @return object
* @throws Exceptions\ConnectionFailedException
*/
public function getStatus($options) {
return imap_status($this->client->getConnection(), $this->path, $options);
Expand All @@ -417,6 +419,7 @@ public function getStatus($options) {
* @param string $internal_date
*
* @return bool
* @throws Exceptions\ConnectionFailedException
*/
public function appendMessage($message, $options = null, $internal_date = null) {
return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
Expand All @@ -430,4 +433,16 @@ public function appendMessage($message, $options = null, $internal_date = null)
public function getClient() {
return $this->client;
}


/**
* @param $delimiter
*/
public function setDelimiter($delimiter){
if(in_array($delimiter, [null, '', ' ', false]) === true) {
$delimiter = ClientManager::$config['options']['delimiter'];
}

$this->delimiter = $delimiter;
}
}

0 comments on commit a502dfe

Please sign in to comment.