Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory
Commits
0eba01e8
Commit
0eba01e8
authored
8 years ago
by
Côme Chilliet
Browse files
Options
Download
Patches
Plain Diff
Caching filters once parsed to save a bit of time. Removed filterRowLink
parent
1a5e6954
dev
6342-update-the-locales-for-1-5
6344-template-issue-when-creating-a-template-with-empty-password-error-message-should-not-be-seen
6365-core-locking-mechanism-is-not-changing-the-mail-ressource-it-does-lock-the-mail-account
6365-core-when-lock-mechanism-is-trigger-the-user-should-not-be-editable-if-not-unlock
6378-orcid-test-method-is-wrong-and-break-orcid-saving
core-php8
master
fusiondirectory-1.5
fusiondirectory-1.4
fusiondirectory-1.3.1
fusiondirectory-1.3
fusiondirectory-1.2.3
fusiondirectory-1.2.2
fusiondirectory-1.2.1
fusiondirectory-1.2
fusiondirectory-1.1.1
fusiondirectory-1.1
fusiondirectory-1.0.20
fusiondirectory-1.0.19
fusiondirectory-1.0.18
fusiondirectory-1.0.17
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/class_listing.inc
+84
-79
include/class_listing.inc
include/simpleplugin/class_simpleManagement.inc
+0
-16
include/simpleplugin/class_simpleManagement.inc
plugins/admin/users/user-list.xml
+1
-2
plugins/admin/users/user-list.xml
with
85 additions
and
97 deletions
+85
-97
include/class_listing.inc
+
84
−
79
View file @
0eba01e8
...
...
@@ -63,6 +63,7 @@ class listing
var
$height
=
0
;
var
$scrollPosition
=
0
;
var
$baseSelector
;
protected
$filterCache
=
array
();
/*!
* \brief Create a listing
...
...
@@ -207,6 +208,8 @@ class listing
$this
->
xmlData
=
xml
::
xml2array
(
$contents
,
1
);
}
$this
->
filterCache
=
array
();
if
(
!
isset
(
$this
->
xmlData
[
'list'
]))
{
return
FALSE
;
}
...
...
@@ -393,11 +396,11 @@ class listing
// Fill with department browser if configured this way
$departmentIterator
=
new
departmentSortIterator
(
$this
->
departments
,
$this
->
sortDirection
[
$this
->
sortColumn
]);
foreach
(
$departmentIterator
as
$row
=>
$entry
)
{
$result
.
=
"
<tr>
"
;
$result
.
=
'
<tr>
'
;
// Render multi select if needed
if
(
$this
->
multiSelect
)
{
$result
.
=
"
<td
style='text-align:center;padding:0;'
> </td>
"
;
$result
.
=
'
<td> </td>
'
;
}
// Render defined department columns, fill the rest with some stuff
...
...
@@ -408,16 +411,16 @@ class listing
$colspan
=
$cfg
[
'span'
];
$this
->
useSpan
=
TRUE
;
}
$result
.
=
"
<td colspan=
'
$colspan
' "
.
$this
->
colprops
[
$index
]
.
">"
.
$this
->
renderCell
(
$cfg
[
'value'
],
$entry
,
$row
)
.
"
</td>
"
;
$result
.
=
'
<td colspan=
"'
.
$colspan
.
'" '
.
$this
->
colprops
[
$index
]
.
'>'
.
$this
->
renderCell
(
'department'
,
$index
,
$cfg
[
'value'
],
$entry
,
$row
)
.
'
</td>
'
;
$rest
-=
$colspan
;
}
// Fill remaining cols with nothing
$last
=
$this
->
numColumns
-
$rest
;
for
(
$i
=
0
;
$i
<
$rest
;
$i
++
)
{
$result
.
=
"
<td
"
.
$this
->
colprops
[
$last
+
$i
-
1
]
.
"
> </td>
"
;
$result
.
=
'
<td
'
.
$this
->
colprops
[
$last
+
$i
-
1
]
.
'
> </td>
'
;
}
$result
.
=
"
</tr>
"
;
$result
.
=
'
</tr>
'
;
$alt
++
;
}
...
...
@@ -426,24 +429,24 @@ class listing
// Fill with contents, sort as configured
foreach
(
$this
->
entries
as
$row
=>
$entry
)
{
$trow
=
""
;
$trow
=
''
;
// Render multi select if needed
if
(
$this
->
multiSelect
)
{
$trow
.
=
"
<td style=
'
text-align:center;width:20px;
'
><input type=
'
checkbox
'
id=
'
listing_selected_
$row
'
name=
'
listing_selected_
$row
'
></td>
\n
"
;
$trow
.
=
'
<td style=
"
text-align:center;width:20px;
"
><input type=
"
checkbox
"
id=
"
listing_selected_
'
.
$row
.
'"
name=
"
listing_selected_
'
.
$row
.
'"/
></td>
'
.
"
\n
"
;
}
foreach
(
$this
->
xmlData
[
'table'
][
'column'
]
as
$index
=>
$cfg
)
{
$renderedCell
=
$this
->
renderCell
(
$cfg
[
'value'
],
$entry
,
$row
);
$trow
.
=
"
<td
"
.
$this
->
colprops
[
$index
]
.
">"
.
$renderedCell
.
"
</td>
\n
"
;
$renderedCell
=
$this
->
renderCell
(
'column'
,
$index
,
$cfg
[
'value'
],
$entry
,
$row
);
$trow
.
=
'
<td
'
.
$this
->
colprops
[
$index
]
.
'>'
.
$renderedCell
.
'
</td>
'
.
"
\n
"
;
// Save rendered column
$sort
=
preg_replace
(
'/.*>([^<]+)<.*$/'
,
'$1'
,
$renderedCell
);
$sort
=
preg_replace
(
'/ /'
,
''
,
$sort
);
if
(
preg_match
(
'/</'
,
$sort
))
{
$sort
=
""
;
$sort
=
''
;
}
$this
->
entries
[
$row
][
"
_sort
$index
"
]
=
$sort
;
$this
->
entries
[
$row
][
'
_sort
'
.
$index
]
=
$sort
;
}
// Save rendered entry
...
...
@@ -761,7 +764,7 @@ class listing
}
function
renderCell
(
$data
,
$cfg
,
$row
)
function
renderCell
(
$table
,
$index
,
$data
,
$cfg
,
$row
)
{
// Replace flat attributes in data string
$offset
=
0
;
...
...
@@ -781,7 +784,7 @@ class listing
}
// Watch out for filters and prepare to execute them
$data
=
$this
->
processElementFilter
(
$data
,
$cfg
,
$row
);
$data
=
$this
->
processElementFilter
(
$table
,
$index
,
$data
,
$cfg
,
$row
);
// Replace all non replaced %{...} instances because they
// are non resolved attributes or filters
...
...
@@ -801,79 +804,77 @@ class listing
}
function
processElementFilter
(
$data
,
$cfg
,
$row
)
function
processElementFilter
(
$type
,
$index
,
$data
,
$cfg
,
$row
)
{
preg_match_all
(
"/%\{filter:([^(]+)\((.*)\)\}/"
,
$data
,
$matches
,
PREG_SET_ORDER
);
foreach
(
$matches
as
$match
)
{
$cl
=
""
;
$method
=
""
;
if
(
preg_match
(
'/::/'
,
$match
[
1
]))
{
$cl
=
preg_replace
(
'/::.*$/'
,
''
,
$match
[
1
]);
$method
=
preg_replace
(
'/^.*::/'
,
''
,
$match
[
1
]);
}
else
{
if
(
!
isset
(
$this
->
filters
[
$match
[
1
]]))
{
continue
;
}
$cl
=
preg_replace
(
'/::.*$/'
,
''
,
$this
->
filters
[
$match
[
1
]]);
$method
=
preg_replace
(
'/^.*::/'
,
''
,
$this
->
filters
[
$match
[
1
]]);
}
// Prepare params for function call
$params
=
array
();
preg_match_all
(
'/"[^"]+"|[^,]+/'
,
$match
[
2
],
$parts
);
foreach
(
$parts
[
0
]
as
$param
)
{
// Row is replaced by the row number
if
(
$param
==
"row"
)
{
$params
[]
=
$row
;
continue
;
}
// pid is replaced by the current PID
if
(
$param
==
"pid"
)
{
$params
[]
=
$this
->
pid
;
continue
;
if
(
isset
(
$this
->
filterCache
[
$type
.
$index
]))
{
$filters
=
$this
->
filterCache
[
$type
.
$index
];
}
else
{
preg_match_all
(
'/%{filter:([^(]+)\((.*)\)}/'
,
$data
,
$matches
,
PREG_SET_ORDER
);
$filters
=
array
();
foreach
(
$matches
as
$match
)
{
$cl
=
''
;
$method
=
''
;
if
(
!
preg_match
(
'/^(.*)::(.*)$/'
,
$match
[
1
],
$m
))
{
if
(
!
isset
(
$this
->
filters
[
$match
[
1
]])
||
!
preg_match
(
'/^(.*)::(.*)$/'
,
$this
->
filters
[
$match
[
1
]],
$m
))
{
trigger_error
(
'Unknown filter '
.
$match
[
1
]);
continue
;
}
}
$cl
=
$m
[
1
];
$method
=
$m
[
2
];
// base is replaced by the current base
if
(
$param
==
"base"
)
{
$params
[]
=
$this
->
getBase
();
continue
;
}
// Prepare params for function call
preg_match_all
(
'/"[^"]+"|[^,]+/'
,
$match
[
2
],
$parts
);
// Fixie with "" is passed directly
if
(
preg_match
(
'/^".*"$/'
,
$param
))
{
$params
[]
=
preg_replace
(
'/"/'
,
''
,
$param
);
continue
;
}
$filters
[
$match
[
0
]]
=
array
(
$cl
,
$method
,
$parts
[
0
]);
}
// Move dn if needed
if
(
$param
==
"dn"
)
{
$params
[]
=
LDAP
::
fix
(
$cfg
[
"dn"
]);
continue
;
}
$this
->
filterCache
[
$type
.
$index
]
=
$filters
;
}
// LDAP variables get replaced by their objects
for
(
$i
=
0
;
$i
<
$cfg
[
'count'
];
$i
++
)
{
if
(
$param
==
$cfg
[
$i
])
{
$values
=
$cfg
[
$cfg
[
$i
]];
if
(
is_array
(
$values
))
{
unset
(
$values
[
'count'
]);
foreach
(
$filters
as
$filterstring
=>
$filter
)
{
list
(
$cl
,
$method
,
$parts
)
=
$filter
;
$params
=
array
();
foreach
(
$parts
as
$param
)
{
switch
(
$param
)
{
case
'row'
:
$params
[]
=
$row
;
break
;
case
'pid'
:
$params
[]
=
$this
->
pid
;
break
;
case
'base'
:
$params
[]
=
$this
->
getBase
();
break
;
case
'dn'
:
$params
[]
=
LDAP
::
fix
(
$cfg
[
'dn'
]);
break
;
default
:
if
(
preg_match
(
'/^"(.*)"$/'
,
$param
,
$m
))
{
// Fixie with "" is passed directly
$params
[]
=
$m
[
1
];
}
elseif
(
isset
(
$cfg
[
$param
]))
{
// LDAP variables get replaced by their objects
$values
=
$cfg
[
$param
];
if
(
is_array
(
$values
))
{
unset
(
$values
[
'count'
]);
}
$params
[]
=
$values
;
}
else
{
$params
[]
=
''
;
}
$params
[]
=
$values
;
break
;
}
}
}
// Replace information
if
(
$cl
==
"
listing
"
)
{
// Non static call
- seems to result in errors
$data
=
@
preg_replace
(
'/'
.
preg_quote
(
$
match
[
0
]
)
.
'/'
,
call_user_func_array
(
array
(
$this
,
"
$method
"
),
$params
),
$data
);
if
(
$cl
==
'
listing
'
)
{
// Non static call
$data
=
preg_replace
(
'/'
.
preg_quote
(
$
filterstring
)
.
'/'
,
call_user_func_array
(
array
(
$this
,
$method
),
$params
),
$data
);
}
else
{
// Static call
$data
=
preg_replace
(
'/'
.
preg_quote
(
$
match
[
0
]
)
.
'/'
,
call_user_func_array
(
array
(
$cl
,
$method
),
$params
),
$data
);
$data
=
preg_replace
(
'/'
.
preg_quote
(
$
filterstring
)
.
'/'
,
call_user_func_array
(
array
(
$cl
,
$method
),
$params
),
$data
);
}
}
...
...
@@ -1063,8 +1064,8 @@ class listing
// Render normal entries as usual
if
(
$action
[
'type'
]
==
'entry'
)
{
$label
=
$this
->
processElementFilter
(
$action
[
'label'
],
$this
->
entries
[
$row
],
$row
);
$image
=
$this
->
processElementFilter
(
$action
[
'image'
],
$this
->
entries
[
$row
],
$row
);
$label
=
$this
->
processElementFilter
(
'label'
,
$action
[
'name'
],
$action
[
'label'
],
$this
->
entries
[
$row
],
$row
);
$image
=
$this
->
processElementFilter
(
'image'
,
$action
[
'name'
],
$action
[
'image'
],
$this
->
entries
[
$row
],
$row
);
$result
.
=
'<input class="center" type="image" src="'
.
htmlentities
(
$image
,
ENT_COMPAT
,
'UTF-8'
)
.
'" title="'
.
$label
.
'" alt="'
.
$label
.
'" '
.
'name="listing_'
.
$action
[
'name'
]
.
'_'
.
$row
.
'"/>'
;
}
...
...
@@ -1138,15 +1139,19 @@ class listing
for
(
$i
=
3
;
$i
<
func_num_args
();
$i
++
)
{
$val
=
func_get_arg
(
$i
);
if
(
is_array
(
$val
))
{
$val
=
$val
[
0
];
$val
=
implode
(
"<br/>
\n
"
,
$val
);
}
if
(
!
empty
(
$val
))
{
$params
[]
=
htmlentities
(
$val
,
ENT_COMPAT
,
'UTF-8'
);
}
$params
[]
=
htmlentities
(
$val
,
ENT_COMPAT
,
'UTF-8'
);
}
$result
=
" "
;
$trans
=
call_user_func_array
(
"sprintf"
,
$params
);
if
(
$trans
!=
""
)
{
return
"<a href='?plug="
.
$_GET
[
'plug'
]
.
"&PID=
$pid
&act=listing_edit_
$row
' title='
$dn
'>
$trans
</a>"
;
if
(
count
(
$params
)
>
1
)
{
$trans
=
call_user_func_array
(
'sprintf'
,
$params
);
if
(
$trans
!=
''
)
{
return
'<a href="?plug='
.
$_GET
[
'plug'
]
.
'&PID='
.
$pid
.
'&act=listing_edit_'
.
$row
.
'" title="'
.
$dn
.
'">'
.
$trans
.
'</a>'
;
}
}
return
$result
;
...
...
This diff is collapsed.
Click to expand it.
include/simpleplugin/class_simpleManagement.inc
+
0
−
16
View file @
0eba01e8
...
...
@@ -294,7 +294,6 @@ class simpleManagement extends management
}
}
}
$this
->
headpage
->
registerElementFilter
(
'filterRowLink'
,
'simpleManagement::filterRowLink'
);
$this
->
headpage
->
refreshBasesList
();
}
...
...
@@ -865,21 +864,6 @@ class simpleManagement extends management
return
""
;
}
static
function
filterRowLink
()
{
$pid
=
func_get_arg
(
0
);
$row
=
func_get_arg
(
1
);
$dn
=
func_get_arg
(
2
);
$trans
=
func_get_arg
(
3
);
unset
(
$trans
[
'count'
]);
$trans
=
join
(
"<br/>
\n
"
,
$trans
);
if
(
$trans
!=
""
)
{
return
'<a href="?plug='
.
$_GET
[
'plug'
]
.
'&PID='
.
$pid
.
'&act=listing_edit_'
.
$row
.
'" title="'
.
$dn
.
'">'
.
$trans
.
'</a>'
;
}
return
''
;
}
static
function
mainInc
(
$classname
)
{
global
$remove_lock
,
$cleanup
,
$display
,
$config
,
$ui
;
...
...
This diff is collapsed.
Click to expand it.
plugins/admin/users/user-list.xml
+
1
−
2
View file @
0eba01e8
...
...
@@ -33,7 +33,7 @@
<label>
Surname
</label>
<sortAttribute>
sn
</sortAttribute>
<sortType>
string
</sortType>
<value>
%{filter:
filterRowLink(pid,
row,dn,sn,cn)}
</value>
<value>
%{filter:
link(
row,dn,
"%s",
sn,cn)}
</value>
<export>
true
</export>
</column>
...
...
@@ -179,7 +179,6 @@
<action>
<name>
cp
</name>
<objectclass></objectclass>
<type>
copypaste
</type>
</action>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets