Skip to content

Commit

Permalink
Use Horde_Imap_Client_Namespace_List object return
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed May 27, 2014
1 parent 44aec3e commit 37a91d8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
10 changes: 5 additions & 5 deletions imp/lib/Ftree/Account/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public function getList($query = null)
foreach ($ns as $val) {
$type = null;

switch ($val['type']) {
case Horde_Imap_Client::NS_OTHER:
switch ($val->type) {
case $val::NS_OTHER:
$attr = IMP_Ftree::ELT_NAMESPACE_OTHER;
$type = self::OTHER_KEY;
break;

case Horde_Imap_Client::NS_SHARED:
case $val::NS_SHARED:
$attr = IMP_Ftree::ELT_NAMESPACE_SHARED;
$type = self::SHARED_KEY;
break;
Expand All @@ -83,8 +83,8 @@ public function getList($query = null)
$unsub = true;
}

foreach (array_keys($ns) as $val) {
$searches[] = $val . '*';
foreach ($ns as $val) {
$searches[] = strval($val) . '*';
}
} else {
$searches[] = $query;
Expand Down
36 changes: 13 additions & 23 deletions imp/lib/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,16 @@ public function accessCompose($right, $data)
/**
* Get the namespace list.
*
* @return array See Horde_Imap_Client_Base#getNamespaces().
* @return Horde_Imap_Client_Namespace_List Namespace list.
*/
public function getNamespaces()
{
if (!isset($this->_temp['ns'])) {
try {
$nsconfig = $this->config->namespace;
$this->_temp['ns'] = $this->__call('getNamespaces', array(
is_null($nsconfig) ? array() : $nsconfig
is_null($nsconfig) ? array() : $nsconfig,
array('ob_return' => true)
));
} catch (Horde_Imap_Client_Exception $e) {
return array();
Expand All @@ -486,7 +487,8 @@ public function getNamespaces()
/**
* Get namespace info for a full mailbox path.
*
* @param string $mailbox The mailbox path.
* @param string $mailbox The mailbox path. (self:NS_DEFAULT will
* return the default personal namespace.)
* @param boolean $personal If true, will return empty namespace only
* if it is a personal namespace.
*
Expand All @@ -495,32 +497,20 @@ public function getNamespaces()
*/
public function getNamespace($mailbox, $personal = false)
{
if (!$this->isImap()) {
return null;
}

$ns = $this->getNamespaces();

if (isset($ns[$mailbox])) {
return $ns[$mailbox];
}
if ($this->isImap()) {
$ns = $this->getNamespaces();
if ($mailbox !== self::NS_DEFAULT) {
return $ns->getNamespace($mailbox, $personal);
}

foreach ($ns as $key => $val) {
if ($mailbox === self::NS_DEFAULT) {
if ($val['type'] === Horde_Imap_Client::NS_PERSONAL) {
return $val;
}
} else {
$mbox = $mailbox . $val['delimiter'];
if (strlen($key) && (strpos($mbox, $key) === 0)) {
foreach ($ns as $val) {
if ($val->type === $val::NS_PERSONAL) {
return $val;
}
}
}

return (isset($ns['']) && (!$personal || ($val['type'] == Horde_Imap_Client::NS_PERSONAL)))
? $ns['']
: null;
return null;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions imp/lib/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,22 @@ protected function _doConnectionTest($vars)
try {
$namespaces = $imap_client->getNamespaces();
foreach ($namespaces as $val) {
switch ($val['type']) {
case Horde_Imap_Client::NS_PERSONAL:
switch ($val->type) {
case $val::NS_PERSONAL:
$type = 'Personal';
break;

case Horde_Imap_Client::NS_OTHER:
case $val::NS_OTHER:
$type = 'Other Users\'';
break;

case Horde_Imap_Client::NS_SHARED:
case $val::NS_SHARED:
$type = 'Shared';
break;
}

$ret .= 'NAMESPACE: "' . htmlspecialchars($val['name']) . "\"\n" .
'DELIMITER: ' . htmlspecialchars($val['delimiter']) . "\n" .
$ret .= 'NAMESPACE: "' . htmlspecialchars($val->name) . "\"\n" .
'DELIMITER: ' . htmlspecialchars($val->delimiter) . "\n" .
'TYPE: ' . htmlspecialchars($type) . "\n\n";
}
} catch (Horde_Imap_Client_Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion imp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@
<package>
<name>Horde_Imap_Client</name>
<channel>pear.horde.org</channel>
<min>2.18.4</min>
<min>2.21.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down

0 comments on commit 37a91d8

Please sign in to comment.