Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Enable subscription option for already subscribed "virtual" folders,

small code improvements
  • Loading branch information...
commit ab08544520cc47b8a63be1737d5d6edb02c511b4 1 parent a370a70
Aleksander Machniak alecpl authored

Showing 1 changed file with 32 additions and 28 deletions. Show diff stats Hide diff stats

  1. +32 28 program/steps/settings/folders.inc
60 program/steps/settings/folders.inc
@@ -299,40 +299,44 @@ function rcube_subscription_form($attrib)
299 299
300 300 $disabled = (($protected && $subscribed) || $noselect);
301 301
302   - // check if the folder is a namespace prefix, then disable subscription option on it
303   - if (!$disabled && $folder['virtual'] && $folder['level'] == 0 && !empty($namespace)) {
304   - $fname = $folder['id'] . $delimiter;
305   - foreach ($namespace as $ns) {
306   - if (is_array($ns)) {
307   - foreach ($ns as $item) {
308   - if ($item[0] === $fname) {
309   - $disabled = true;
310   - break 2;
  302 + // Below we will disable subscription option for "virtual" folders
  303 + // according to namespaces, but only if they aren't already subscribed.
  304 + // User should be able to unsubscribe from the folder
  305 + // even if it doesn't exists or is not accessible (OTRS:1000059)
  306 + if (!$subscribed && !$disabled && !empty($namespace) && $folder['virtual']) {
  307 + // check if the folder is a namespace prefix, then disable subscription option on it
  308 + if (!$disabled && $folder['level'] == 0) {
  309 + $fname = $folder['id'] . $delimiter;
  310 + foreach ($namespace as $ns) {
  311 + if (is_array($ns)) {
  312 + foreach ($ns as $item) {
  313 + if ($item[0] === $fname) {
  314 + $disabled = true;
  315 + break 2;
  316 + }
311 317 }
312 318 }
313 319 }
314 320 }
315   - }
316   - // check if the folder is an other users virtual-root folder, then disable subscription option on it
317   - if (!$disabled && $folder['virtual'] && $folder['level'] == 1
318   - && !empty($namespace) && !empty($namespace['other'])
319   - ) {
320   - $parts = explode($delimiter, $folder['id']);
321   - $fname = $parts[0] . $delimiter;
322   - foreach ($namespace['other'] as $item) {
323   - if ($item[0] === $fname) {
324   - $disabled = true;
325   - break;
  321 + // check if the folder is an other users virtual-root folder, then disable subscription option on it
  322 + if (!$disabled && $folder['level'] == 1 && !empty($namespace['other'])) {
  323 + $parts = explode($delimiter, $folder['id']);
  324 + $fname = $parts[0] . $delimiter;
  325 + foreach ($namespace['other'] as $item) {
  326 + if ($item[0] === $fname) {
  327 + $disabled = true;
  328 + break;
  329 + }
326 330 }
327 331 }
328   - }
329   - // check if the folder is shared, then disable subscription option on it (if not subscribed already)
330   - if (!$disabled && !$subscribed && $folder['virtual'] && !empty($namespace)) {
331   - $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
332   - foreach ($tmp_ns as $item) {
333   - if (strpos($folder['id'], $item[0]) === 0) {
334   - $disabled = true;
335   - break;
  332 + // check if the folder is shared, then disable subscription option on it (if not subscribed already)
  333 + if (!$disabled) {
  334 + $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
  335 + foreach ($tmp_ns as $item) {
  336 + if (strpos($folder['id'], $item[0]) === 0) {
  337 + $disabled = true;
  338 + break;
  339 + }
336 340 }
337 341 }
338 342 }

0 comments on commit ab08544

Please sign in to comment.
Something went wrong with that request. Please try again.