Enable subscription option for already subscribed "virtual" folders,

small code improvements
pull/32/merge
Aleksander Machniak 12 years ago
parent a370a702ca
commit ab08544520

@ -299,40 +299,44 @@ function rcube_subscription_form($attrib)
$disabled = (($protected && $subscribed) || $noselect); $disabled = (($protected && $subscribed) || $noselect);
// check if the folder is a namespace prefix, then disable subscription option on it // Below we will disable subscription option for "virtual" folders
if (!$disabled && $folder['virtual'] && $folder['level'] == 0 && !empty($namespace)) { // according to namespaces, but only if they aren't already subscribed.
$fname = $folder['id'] . $delimiter; // User should be able to unsubscribe from the folder
foreach ($namespace as $ns) { // even if it doesn't exists or is not accessible (OTRS:1000059)
if (is_array($ns)) { if (!$subscribed && !$disabled && !empty($namespace) && $folder['virtual']) {
foreach ($ns as $item) { // check if the folder is a namespace prefix, then disable subscription option on it
if ($item[0] === $fname) { if (!$disabled && $folder['level'] == 0) {
$disabled = true; $fname = $folder['id'] . $delimiter;
break 2; foreach ($namespace as $ns) {
if (is_array($ns)) {
foreach ($ns as $item) {
if ($item[0] === $fname) {
$disabled = true;
break 2;
}
} }
} }
} }
} }
} // check if the folder is an other users virtual-root folder, then disable subscription option on it
// check if the folder is an other users virtual-root folder, then disable subscription option on it if (!$disabled && $folder['level'] == 1 && !empty($namespace['other'])) {
if (!$disabled && $folder['virtual'] && $folder['level'] == 1 $parts = explode($delimiter, $folder['id']);
&& !empty($namespace) && !empty($namespace['other']) $fname = $parts[0] . $delimiter;
) { foreach ($namespace['other'] as $item) {
$parts = explode($delimiter, $folder['id']); if ($item[0] === $fname) {
$fname = $parts[0] . $delimiter; $disabled = true;
foreach ($namespace['other'] as $item) { break;
if ($item[0] === $fname) { }
$disabled = true;
break;
} }
} }
} // check if the folder is shared, then disable subscription option on it (if not subscribed already)
// check if the folder is shared, then disable subscription option on it (if not subscribed already) if (!$disabled) {
if (!$disabled && !$subscribed && $folder['virtual'] && !empty($namespace)) { $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
$tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']); foreach ($tmp_ns as $item) {
foreach ($tmp_ns as $item) { if (strpos($folder['id'], $item[0]) === 0) {
if (strpos($folder['id'], $item[0]) === 0) { $disabled = true;
$disabled = true; break;
break; }
} }
} }
} }

Loading…
Cancel
Save