diff --git a/emhttp/plugins/dynamix/ShareEdit.page b/emhttp/plugins/dynamix/ShareEdit.page index 097bea59a..093ad9ff6 100644 --- a/emhttp/plugins/dynamix/ShareEdit.page +++ b/emhttp/plugins/dynamix/ShareEdit.page @@ -50,6 +50,12 @@ $pools = array_filter($pools, function($pool) { return !isSubpool($pool); }); +/* Check for cachePool2 only which is a situation where the primary device is the cachePool2 device. */ +if ((! $share['cachePool']) && ($share['cachePool2'])) { + $share['cachePool'] = $share['cachePool2']; + $share['cachePool2'] = ""; +} + /* Check for non existent pool device. */ if ($share['cachePool'] && !in_array($share['cachePool'], $pools)) { $poolDefined = false; @@ -61,16 +67,16 @@ if ($share['cachePool'] && !in_array($share['cachePool'], $pools)) { /* Check for pool 2 (or array) being defined. */ if ((($share['useCache'] == "yes") || ($share['useCache'] == "prefer")) && ($poolsOnly) && (!$share['cachePool2'])) { - $poolDefined2 = false; - $share['useCache'] = "yes"; + $poolDefined2 = true; + $share['useCache'] = "only"; } else if ($share['cachePool2']) { $poolDefined2 = in_array($share['cachePool2'], $pools); } else { $poolDefined2 = true; } -$cachePoolCapitalized = ucfirst($share['cachePool']); -$cachePoolCapitalized2 = $share['cachePool2'] ? ucfirst($share['cachePool2']) : _("Array"); +$cachePoolCapitalized = compress(my_disk($share['cachePool'],$display['raw'])); +$cachePoolCapitalized2 = $share['cachePool2'] ? compress(my_disk($share['cachePool2'],$display['raw'])) : _("Array"); function globalInclude($name) { global $var; diff --git a/emhttp/plugins/dynamix/ShareList.page b/emhttp/plugins/dynamix/ShareList.page index 16d248725..b97e27954 100644 --- a/emhttp/plugins/dynamix/ShareList.page +++ b/emhttp/plugins/dynamix/ShareList.page @@ -18,7 +18,7 @@ Cond="_var($var,'fsState')!='Stopped' && _var($var,'shareUser')=='e'" /* Function to filter out unwanted disks, check if any valid disks exist, and ignore disks with a blank device. */ function checkDisks($disks) { - global $pools, $poolsOnly; + global $pools; $rc = false; @@ -35,9 +35,6 @@ function checkDisks($disks) { return $rc; } -/* If the configuration is pools only, then no array disks are available. */ -$poolsOnly = ((int)$var['SYS_ARRAY_SLOTS'] <= 2) ? true : false; - /* Are there any array disks? */ $disks = parse_ini_file('state/disks.ini',true) ?? []; $nodisks = checkDisks($disks) ? "" : "disabled"; diff --git a/emhttp/plugins/dynamix/include/ShareList.php b/emhttp/plugins/dynamix/include/ShareList.php index 10711adc2..a2c239563 100644 --- a/emhttp/plugins/dynamix/include/ShareList.php +++ b/emhttp/plugins/dynamix/include/ShareList.php @@ -130,7 +130,7 @@ uksort($shares,'strnatcasecmp'); /* Function to filter out unwanted disks, check if any valid disks exist, and ignore disks with a blank device. */ function checkDisks($disks) { - global $pools, $poolsOnly; + global $pools; $rc = false; @@ -149,112 +149,177 @@ function checkDisks($disks) { // Display export settings function user_share_settings($protocol,$share) { - if (empty($share)) return; - if ($protocol!='yes' || $share['export']=='-') return "-"; - return ($share['export']=='e') ? _(ucfirst($share['security'])) : ''._(ucfirst($share['security'])).''; + if (empty($share)) return; + if ($protocol!='yes' || $share['export']=='-') return "-"; + return ($share['export']=='e') ? _(ucfirst($share['security'])) : ''._(ucfirst($share['security'])).''; } function globalInclude($name) { - global $var; - return substr($name,0,4)!='disk' || !$var['shareUserInclude'] || strpos("{$var['shareUserInclude']},","$name,")!==false; + global $var; + return substr($name,0,4)!='disk' || !$var['shareUserInclude'] || strpos("{$var['shareUserInclude']},","$name,")!==false; } function shareInclude($name) { - global $include; - return !$include || substr($name,0,4)!='disk' || strpos("$include,", "$name,")!==false; + global $include; + return !$include || substr($name,0,4)!='disk' || strpos("$include,", "$name,")!==false; } // Compute user shares & check encryption $crypto = false; foreach ($shares as $name => $share) { - if ($all!=0 && (!$compute || $compute==$name)) exec("$docroot/webGui/scripts/share_size ".escapeshellarg($name)." ssz1 ".escapeshellarg($pools)); - $crypto |= _var($share,'luksStatus',0)>0; + if ($all!=0 && (!$compute || $compute==$name)) exec("$docroot/webGui/scripts/share_size ".escapeshellarg($name)." ssz1 ".escapeshellarg($pools)); + $crypto |= _var($share,'luksStatus',0)>0; } // global shares include/exclude $myDisks = array_filter(array_diff(array_keys($disks), explode(',',$var['shareUserExclude'])), 'globalInclude'); // Share size per disk $ssz1 = []; -if ($all==0) - exec("rm -f /var/local/emhttp/*.ssz1"); -else - foreach (glob("state/*.ssz1",GLOB_NOSORT) as $entry) $ssz1[basename($entry,'.ssz1')] = parse_ini_file($entry); +if ($all==0) { + exec("rm -f /var/local/emhttp/*.ssz1"); +} else { + foreach (glob("state/*.ssz1",GLOB_NOSORT) as $entry) $ssz1[basename($entry,'.ssz1')] = parse_ini_file($entry); +} + +/* Define constants for magic strings */ +define('STATUS_GREEN_ON', 'green-on'); +define('STATUS_YELLOW_ON', 'yellow-on'); +define('LUKS_STATUS_UNKNOWN', 0); +define('LUKS_STATUS_ENCRYPTED', 1); +define('LUKS_STATUS_UNENCRYPTED', 2); // Build table $row = 0; foreach ($shares as $name => $share) { - /* Check if poolsOnly is true */ - $array = $share['cachePool2'] ? ucfirst($share['cachePool2']) : ""._('Array'); + /* Is cachePool2 defined? If it is we need to show the cache pool 2 device name instead of 'Array'. */ + if ($share['cachePool2']) { + $array = compress(my_disk($share['cachePool2'],$display['raw'])); + $indicator = ""; + } else { + $array = _('Array'); + $indicator = ""; + } + + /* Check that the share storage assignments are valid. */ + if (($share['cachePool']) && (! in_array($share['cachePool'], $pools_check))) { + $array = compress(my_disk($share['cachePool'],$display['raw'])); + $indicator = ""; + $share_valid = false; + } else if (($share['cachePool2']) && (! in_array($share['cachePool2'], $pools_check))) { + $array = compress(my_disk($share['cachePool2'],$display['raw'])); + $indicator = ""; + $share_valid = false; + } else if (($poolsOnly) && (! $share['cachePool']) && (! $share['cachePool2'])) { + $share_valid = false; + } else { + /* Is the share exclusive? */ + $exclusive = _var($share, 'exclusive') == 'yes' ? " " : ""; + $share_valid = true; + } + + /* Check if poolsOnly is true. */ if ($poolsOnly) { - /* If useCache is set to 'yes', change it to 'no'. */ - if (($share['useCache'] == 'yes') && (!$share['cachePool2'])) { - $share['useCache'] = 'no'; - } - /* If useCache is set to 'prefer', change it to 'only'. */ - if (($share['useCache'] == 'prefer') && (!$share['cachePool2'])) { + /* If useCache is set to 'yes' or 'prefer', change it to 'only'. */ + if ((($share['useCache'] == 'yes') || ($share['useCache'] == 'prefer')) && (!$share['cachePool2'])) { $share['useCache'] = 'only'; } } - $row++; - $color = $share['color']; - switch ($color) { - case 'green-on' : $orb = 'circle'; $color = 'green'; $help = _('All files protected'); break; - case 'yellow-on': $orb = 'warning'; $color = 'yellow'; $help = _('Some or all files unprotected'); break; - } - if ($crypto) switch ($share['luksStatus']) { - case 0: $luks = ""; break; - case 1: $luks = ""._('All files encrypted').""; break; - case 2: $luks = ""._('Some or all files unencrypted').""; break; - default: $luks = ""._('Unknown encryption state').""; break; - } else $luks = ""; - echo "