Commit 0dc29ff9 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '6180-action-names-with-numbers-breaks-management' into '1.4-dev'

Resolve "Action names with numbers breaks management"

See merge request fusiondirectory/fd!918
Showing with 34 additions and 43 deletions
+34 -43
......@@ -461,72 +461,63 @@ class managementListing
return $result;
}
// Filter GET with "act" attributes
if (isset($_GET['act'])) {
// Filter GET with "act" attributes
$key = validate($_GET['act']);
if (preg_match('/^listing_([a-zA-Z_]+)_([0-9]+)$/', $key, $m)) {
$action = $m[1];
if (preg_match('/^listing_([[:alnum:]_\.]+)_([0-9]+)$/', $key, $m)) {
$target = $m[2];
if (isset($this->entriesIndex[$target])) {
$result['action'] = $action;
$result['action'] = $m[1];
$result['targets'][] = $this->entriesIndex[$target];
}
} elseif (isset($_REQUEST['dn']) && preg_match('/^listing_([a-zA-Z_]+)$/', $key, $m)) {
} elseif (isset($_REQUEST['dn']) && preg_match('/^listing_([[:alnum:]_\.]+)$/', $key, $m)) {
/* Pre-render list to init things if a dn is gonna be opened on first load */
$dn = urldecode($_REQUEST['dn']);
$action = $m[1];
$dn = urldecode($_REQUEST['dn']);
$this->focusDn($dn);
$this->render();
$result['action'] = $action;
$result['action'] = $m[1];
$result['targets'][] = $dn;
// Make sure no other management class intercept the same dn
unset($_REQUEST['dn']);
}
if (preg_match('/^([a-zA-Z]+)_([a-zA-Z_]+)$/', $result['action'], $m)) {
$result['action'] = $m[1];
$result['subaction'] = $m[2];
} else {
// Filter POST with "act" attributes -> posted from action menu
if (isset($_POST['act']) && ($_POST['act'] != '')) {
$result['action'] = validate($_POST['act']);
}
return $result;
}
// Filter POST with "act" attributes -> posted from action menu
if (isset($_POST['act']) && ($_POST['act'] != '')) {
$result['action'] = validate($_POST['act']);
}
// Filter POST with "listing_" attributes
foreach (array_keys($_POST) as $key) {
// Capture selections
if (preg_match('/^listing_selected_[0-9]+$/', $key)) {
$target = preg_replace('/^listing_selected_([0-9]+)$/', '$1', $key);
if (isset($this->entriesIndex[$target])) {
$result['targets'][] = $this->entriesIndex[$target];
// Filter POST with "listing_" attributes
foreach (array_keys($_POST) as $key) {
// Capture selections
if (preg_match('/^listing_selected_([0-9]+)$/', $key, $m)) {
$target = $m[1];
if (isset($this->entriesIndex[$target])) {
$result['targets'][] = $this->entriesIndex[$target];
}
continue;
}
continue;
}
// Capture action with target - this is a one shot
if (preg_match('/^listing_[a-zA-Z_]+_[0-9]+(|_x)$/', $key)) {
$target = preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key);
if (isset($this->entriesIndex[$target])) {
$result['action'] = preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key);
$result['targets'] = [$this->entriesIndex[$target]];
// Capture action with target - this is a one shot
if (preg_match('/^listing_([[:alnum:]_\.]+)_([0-9]+)(|_x)$/', $key, $m)) {
$target = $m[2];
if (isset($this->entriesIndex[$target])) {
$result['action'] = $m[1];
$result['targets'] = [$this->entriesIndex[$target]];
}
break;
}
break;
}
// Capture action without target
if (preg_match('/^listing_[a-zA-Z_]+(|_x)$/', $key)) {
$result['action'] = preg_replace('/^listing_([a-zA-Z_]+)(|_x)$/', '$1', $key);
continue;
// Capture action without target
if (preg_match('/^listing_([[:alnum:]_\.]+)(|_x)$/', $key, $m)) {
$result['action'] = $m[1];
continue;
}
}
}
if (preg_match('/^([a-zA-Z\.]+)_([a-zA-Z_\.]+)$/', $result['action'], $m)) {
$result['action'] = $m[1];
$result['subaction'] = $m[2];
if (strpos($result['action'], '_') !== FALSE) {
list($result['action'], $result['subaction']) = explode('_', $result['action'], 2);
}
return $result;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment