ZF-9138: Add sort() to Zend_Mail_Storage_Imap

Description

It should be possible to get a list of sequence numbers sorted by a criterion. This is only supported by imap servers that provide the SORT capability.

In Storage_Imap there should be something like this:

/**
 * get sequence ids sorted by a criterion
 *
 * @param string $sortBy
 * @return array
 */
public function listSorted($sortBy = null)
{
    $params = array($sortBy, 'utf-8', 'ALL');
    return $this->_protocol->sort($params);
}

In Protocol_Imap then

/**
 * do a sort request
 *
 * @internal
 * @return array message sequence ids
 */
public function sort(array $params)
{
    $response = $this->requestAndResponse('SORT', $params);
    if (!$response) {
        return $response;
    }
        foreach ($response as $ids) {
        if ($ids[0] == 'SORT') {
            array_shift($ids);
            return $ids;
        }
    }
    return array();
}

This should do the trick.

Comments

No comments to display