require_once('edit.inc.php');
foreach ($cols as $col => &$colconf) {
+ if (isset($colconf['visible'])) {
+ if ($colconf['visible'] == 'admin' and empty($User['admin'])) {
+ $colconf['visible'] = FALSE;
+ continue;
+ }
+ }
+ else {
+ $colconf['visible'] = TRUE;
+ }
+
if (!isset($colconf['filename'])) {
continue; # exceptional storage
}
if (isset($colconf['values'])) {
if (!file_exists($colconf['filename'])) {
+ $colconf['visible'] = FALSE;
continue;
- #TODO: drop key
}
$tags = [];
foreach (glob($colconf['filename'] . '/*') as $tag) {
$tagname = pathinfo($tag, PATHINFO_BASENAME);
$target = "$tag/{$user['name']}";
$val = file_exists($target);
- $tags[$tagname] = ['value' => $val];
- if (empty($User['admin'])) {
- continue; # forbidden
- }
+ $tagopt = &$colconf['values'][$tagname];
+ $tagopt = ['value' => $val];
if (!is_writable($tag)) {
continue; # locked tag directory
}
if ($val and !is_writable($target)) {
continue; # existing file locked
}
- $tags[$tagname]['target'] = $target;
+ $tagopt['target'] = $target;
}
}
}
try {
require_once('upload.inc.php');
- $target = userupload($val, $cols[$col]['target']);
+ $target = userupload($val, NULL, $cols[$col]['target']);
if (!$target) continue;
$cols[$col]['value'] = '';
}
catch (Exception $e) {
- $colwarn[$col] = $e->getMessage();
+ $colwarn[$col] = ucfirst($e->getMessage()).'.';
}
}
<ul class="grid">
<?php
foreach ($cols as $col => &$colconf) {
+ if (!$colconf['visible']) {
+ continue;
+ }
+
print "\t";
printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
else {
if (isset($cols[$col]['filter'])) {
list ($targetstr, $inputstr) = $cols[$col]['filter'];
- $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']);
+ $colconf['value'] = str_replace($targetstr, $inputstr, @$colconf['value']);
}
$attrs = [