added listPrintTableCellContent()
This commit is contained in:
parent
5fd4f7b73c
commit
f6be307eef
|
@ -4,6 +4,10 @@
|
|||
-> ShadowAccount: PDF entry for expire date was wrong (1658868)
|
||||
-> Debian package did not include lamdaemonOld.pl (1660493)
|
||||
|
||||
Developers:
|
||||
API changes:
|
||||
- added listPrintTableCellContent() to class lamList
|
||||
|
||||
|
||||
24.01.2007 1.2.0
|
||||
- Samba 3: better handling of date values
|
||||
|
|
|
@ -2,6 +2,24 @@ Upgrade instructions:
|
|||
=====================
|
||||
|
||||
|
||||
1.2.0 -> 1.3.0:
|
||||
===============
|
||||
|
||||
Users:
|
||||
|
||||
No changes.
|
||||
|
||||
|
||||
Developers:
|
||||
|
||||
New lamList function:
|
||||
|
||||
The function listPrintTableCellContent() allows you to control how the LDAP
|
||||
attributes are displayed in the table. This can be used to display links
|
||||
or binary data.
|
||||
|
||||
|
||||
|
||||
1.1.x -> 1.2.0:
|
||||
===============
|
||||
|
||||
|
|
|
@ -204,27 +204,28 @@ class lamList {
|
|||
* @return array filtered list of accounts
|
||||
*/
|
||||
function listFilterAccounts() {
|
||||
$entries = $this->entries;
|
||||
$entries = array();
|
||||
$filter = $this->listBuildFilter();
|
||||
$attributes = array_keys($filter);
|
||||
for ($r = 0; $r < sizeof($entries); $r++) {
|
||||
for ($r = 0; $r < sizeof($this->entries); $r++) {
|
||||
$skip = false;
|
||||
for ($a = 0; $a < sizeof($attributes); $a++) {
|
||||
// check if filter fits
|
||||
$found = false;
|
||||
for ($i = 0; $i < sizeof($entries[$r][$attributes[$a]]); $i++) {
|
||||
if (eregi($filter[$attributes[$a]]['regex'], $entries[$r][$attributes[$a]][$i])) {
|
||||
for ($i = 0; $i < sizeof($this->entries[$r][$attributes[$a]]); $i++) {
|
||||
if (eregi($filter[$attributes[$a]]['regex'], $this->entries[$r][$attributes[$a]][$i])) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
// remove account and reindex array
|
||||
unset($entries[$r]);
|
||||
$entries = array_values($entries);
|
||||
$r--;
|
||||
$skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$skip) {
|
||||
$entries[] = &$this->entries[$r];
|
||||
}
|
||||
}
|
||||
if (sizeof($entries) == 0) StatusMessage("WARN", $this->labels['error_noneFound']);
|
||||
return $entries;
|
||||
|
@ -237,7 +238,7 @@ class lamList {
|
|||
* @param array $info the account list
|
||||
* @return array sorted account list
|
||||
*/
|
||||
function listSort($info) {
|
||||
function listSort(&$info) {
|
||||
if (!is_array($this->attrArray)) return $info;
|
||||
if (!is_string($this->sortColumn)) return $info;
|
||||
// sort and return account list
|
||||
|
@ -256,7 +257,7 @@ class lamList {
|
|||
* @param array $b second row which is compared
|
||||
* @return integer 0 if both are equal, 1 if $a is greater, -1 if $b is greater
|
||||
*/
|
||||
function cmp_array($a, $b) {
|
||||
function cmp_array(&$a, &$b) {
|
||||
// sort specifies the sort column
|
||||
$sort = $this->sortColumn;
|
||||
$attr_array = $this->attrArray;
|
||||
|
@ -363,7 +364,7 @@ class lamList {
|
|||
*
|
||||
* @param array $info entries
|
||||
*/
|
||||
function listPrintTableBody($info) {
|
||||
function listPrintTableBody(&$info) {
|
||||
// calculate which rows to show
|
||||
$table_begin = ($this->page - 1) * $this->maxPageEntries;
|
||||
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
|
||||
|
@ -385,18 +386,8 @@ class lamList {
|
|||
echo (" <td align='center'><a href=\"../account/edit.php?type=" . $this->type . "&DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
|
||||
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
|
||||
echo ("<td>");
|
||||
// print all attribute entries seperated by "; "
|
||||
$attrName = strtolower($this->attrArray[$k]);
|
||||
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
|
||||
// delete "count" entry
|
||||
unset($info[$i][$attrName]['count']);
|
||||
if (is_array($info[$i][$attrName])) {
|
||||
// sort array
|
||||
sort($info[$i][$attrName]);
|
||||
echo implode("; ", $info[$i][$attrName]);
|
||||
}
|
||||
else echo $info[$i][$attrName];
|
||||
}
|
||||
$this->listPrintTableCellContent($info[$i], $attrName);
|
||||
echo ("</td>\n");
|
||||
}
|
||||
echo("</tr>\n");
|
||||
|
@ -412,6 +403,26 @@ class lamList {
|
|||
echo ("</table>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the content of a cell in the account list for a given LDAP entry and attribute.
|
||||
*
|
||||
* @param array $entry LDAP attributes
|
||||
* @param string $attribute attribute name
|
||||
*/
|
||||
function listPrintTableCellContent(&$entry, &$attribute) {
|
||||
// print all attribute entries seperated by "; "
|
||||
if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) {
|
||||
// delete "count" entry
|
||||
unset($entry[$attribute]['count']);
|
||||
if (is_array($entry[$attribute])) {
|
||||
// sort array
|
||||
sort($entry[$attribute]);
|
||||
echo implode("; ", $entry[$attribute]);
|
||||
}
|
||||
else echo $entry[$attribute];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages all POST actions (e.g. button pressed) for the account lists.
|
||||
*/
|
||||
|
@ -665,7 +676,10 @@ class lamList {
|
|||
// delete first array entry which is "count"
|
||||
unset($info['count']);
|
||||
// save position in original $info
|
||||
for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i;
|
||||
for ($i = 0; $i < sizeof($info); $i++) {
|
||||
$info[$i]['LAM_ID'] = $i;
|
||||
if (isset($info[$i]['count'])) unset($info[$i]['count']);
|
||||
}
|
||||
// save results
|
||||
$this->entries = $info;
|
||||
}
|
||||
|
|
|
@ -110,78 +110,35 @@ class lamGroupList extends lamList {
|
|||
'nav' => _("%s group(s) found"),
|
||||
'error_noneFound' => _("No groups found!"),
|
||||
'newEntry' => _("New group"),
|
||||
'deleteEntry' => _("Delete group"),
|
||||
'deleteEntry' => _("Delete group(s)"),
|
||||
'createPDF' => _("Create PDF for selected group(s)"),
|
||||
'createPDFAll' => _("Create PDF for all groups"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the entry list
|
||||
* Prints the content of a cell in the account list for a given LDAP entry and attribute.
|
||||
*
|
||||
* @param array $info entries
|
||||
* @param array $entry LDAP attributes
|
||||
* @param string $attribute attribute name
|
||||
*/
|
||||
function listPrintTableBody($info) {
|
||||
// calculate which rows to show
|
||||
$table_begin = ($this->page - 1) * $this->maxPageEntries;
|
||||
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
|
||||
else $table_end = ($this->page * $this->maxPageEntries);
|
||||
// print account list
|
||||
for ($i = $table_begin; $i < $table_end; $i++) {
|
||||
echo("<tr class=\"" . $this->type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
|
||||
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
|
||||
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
|
||||
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&DN=" . $info[$i]['dn'] . "'\">\n");
|
||||
if (isset($_GET['selectall'])) {
|
||||
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
|
||||
" type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
|
||||
}
|
||||
else {
|
||||
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
|
||||
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
|
||||
}
|
||||
echo (" <td align='center'><a href=\"../account/edit.php?type=" . $this->type . "&DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
|
||||
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
|
||||
echo ("<td>");
|
||||
// print all attribute entries seperated by "; "
|
||||
$attrName = strtolower($this->attrArray[$k]);
|
||||
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
|
||||
// delete "count" entry
|
||||
unset($info[$i][$attrName]['count']);
|
||||
// generate links for group members
|
||||
if ($attrName == "memberuid") {
|
||||
function listPrintTableCellContent(&$entry, &$attribute) {
|
||||
if ($attribute == "memberuid") {
|
||||
if (!is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return;
|
||||
if (isset($entry[$attribute]['count'])) unset($entry[$attribute]['count']);
|
||||
// sort array
|
||||
sort($info[$i][$attrName]);
|
||||
sort($entry[$attribute]);
|
||||
// make a link for each member of the group
|
||||
$linklist = array();
|
||||
for ($d = 0; $d < sizeof($info[$i][$attrName]); $d++) {
|
||||
$user = $info[$i][$attrName][$d]; // user name
|
||||
for ($d = 0; $d < sizeof($entry[$attribute]); $d++) {
|
||||
$user = $entry[$attribute][$d]; // user name
|
||||
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
|
||||
}
|
||||
echo implode("; ", $linklist);
|
||||
}
|
||||
// print all other attributes
|
||||
else {
|
||||
if (is_array($info[$i][$attrName])) {
|
||||
// sort array
|
||||
sort($info[$i][$attrName]);
|
||||
echo implode("; ", $info[$i][$attrName]);
|
||||
parent::listPrintTableCellContent($entry, $attribute);
|
||||
}
|
||||
else echo $info[$i][$attrName];
|
||||
}
|
||||
}
|
||||
echo ("</td>\n");
|
||||
}
|
||||
echo("</tr>\n");
|
||||
}
|
||||
// display select all link
|
||||
$colspan = sizeof($this->attrArray) + 1;
|
||||
echo "<tr class=\"" . $this->type . "list\">\n";
|
||||
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
|
||||
echo "<td colspan=$colspan> <a href=\"list.php?type=" . $this->type . "&norefresh=y&page=" . $this->page .
|
||||
"&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" .
|
||||
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
|
||||
echo "</tr>\n";
|
||||
echo ("</table>");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class lamHostList extends lamList {
|
|||
'nav' => _("%s host(s) found"),
|
||||
'error_noneFound' => _("No hosts found!"),
|
||||
'newEntry' => _("New host"),
|
||||
'deleteEntry' => _("Delete host"),
|
||||
'deleteEntry' => _("Delete host(s)"),
|
||||
'createPDF' => _("Create PDF for selected host(s)"),
|
||||
'createPDFAll' => _("Create PDF for all hosts"));
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class lamMailAliasList extends lamList {
|
|||
'nav' => _("%s alias(es) found"),
|
||||
'error_noneFound' => _("No aliases found!"),
|
||||
'newEntry' => _("New alias"),
|
||||
'deleteEntry' => _("Delete alias"),
|
||||
'deleteEntry' => _("Delete alias(es)"),
|
||||
'createPDF' => _("Create PDF for selected alias(es)"),
|
||||
'createPDFAll' => _("Create PDF for all aliases"));
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class lamSmbDomainList extends lamList {
|
|||
'nav' => _("%s domain(s) found"),
|
||||
'error_noneFound' => _("No domains found!"),
|
||||
'newEntry' => _("New domain"),
|
||||
'deleteEntry' => _("Delete domain"),
|
||||
'deleteEntry' => _("Delete domain(s)"),
|
||||
'createPDF' => _("Create PDF for selected domain(s)"),
|
||||
'createPDFAll' => _("Create PDF for all domains"));
|
||||
}
|
||||
|
|
|
@ -89,7 +89,8 @@ class user extends baseType {
|
|||
"homedirectory" => _("Home directory"),
|
||||
"loginshell" => _("Login shell"),
|
||||
"mail" => _("E-Mail"),
|
||||
"gecos" => _("Description")
|
||||
"gecos" => _("Description"),
|
||||
"jpegphoto" => _('Photo')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ class lamUserList extends lamList {
|
|||
'nav' => _("%s user(s) found"),
|
||||
'error_noneFound' => _("No users found!"),
|
||||
'newEntry' => _("New user"),
|
||||
'deleteEntry' => _("Delete user"),
|
||||
'deleteEntry' => _("Delete user(s)"),
|
||||
'createPDF' => _("Create PDF for selected user(s)"),
|
||||
'createPDFAll' => _("Create PDF for all users"));
|
||||
}
|
||||
|
@ -154,70 +155,48 @@ class lamUserList extends lamList {
|
|||
}
|
||||
|
||||
/**
|
||||
* Prints the entry list
|
||||
* Prints the content of a cell in the account list for a given LDAP entry and attribute.
|
||||
*
|
||||
* @param array $info entries
|
||||
* @param array $entry LDAP attributes
|
||||
* @param string $attribute attribute name
|
||||
*/
|
||||
function listPrintTableBody($info) {
|
||||
// calculate which rows to show
|
||||
$table_begin = ($this->page - 1) * $this->maxPageEntries;
|
||||
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
|
||||
else $table_end = ($this->page * $this->maxPageEntries);
|
||||
// translate GIDs and resort array if selected
|
||||
if ($this->trans_primary == "on") {
|
||||
// translate GIDs
|
||||
for ($i = 0; $i < sizeof($info); $i++) {
|
||||
if (isset($this->trans_primary_hash[$info[$i]['gidnumber'][0]])) {
|
||||
$info[$i]['gidnumber'][0] = $this->trans_primary_hash[$info[$i]['gidnumber'][0]];
|
||||
}
|
||||
}
|
||||
// resort if needed
|
||||
if ($this->sortColumn == "gidnumber") {
|
||||
$info = $this->listSort($info);
|
||||
}
|
||||
}
|
||||
// print account list
|
||||
for ($i = $table_begin; $i < $table_end; $i++) {
|
||||
echo("<tr class=\"" . $this->type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
|
||||
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
|
||||
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
|
||||
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&DN=" . $info[$i]['dn'] . "'\">\n");
|
||||
if (isset($_GET['selectall'])) {
|
||||
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
|
||||
" type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
|
||||
function listPrintTableCellContent(&$entry, &$attribute) {
|
||||
// check if there is something to display at all
|
||||
if (!is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return;
|
||||
if (isset($entry[$attribute]['count'])) unset($entry[$attribute]['count']);
|
||||
// translate GID to group name
|
||||
if (($attribute == "gidnumber") && ($this->trans_primary == "on")) {
|
||||
if (isset($this->trans_primary_hash[$entry[$attribute][0]])) {
|
||||
echo $this->trans_primary_hash[$entry[$attribute][0]];
|
||||
}
|
||||
else {
|
||||
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
|
||||
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
|
||||
parent::listPrintTableCellContent($entry, $attribute);
|
||||
}
|
||||
echo (" <td align='center'><a href=\"../account/edit.php?type=" . $this->type . "&DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
|
||||
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
|
||||
echo ("<td>");
|
||||
// print all attribute entries seperated by "; "
|
||||
$attrName = strtolower($this->attrArray[$k]);
|
||||
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
|
||||
// delete "count" entry
|
||||
unset($info[$i][$attrName]['count']);
|
||||
if (is_array($info[$i][$attrName])) {
|
||||
// sort array
|
||||
sort($info[$i][$attrName]);
|
||||
echo implode("; ", $info[$i][$attrName]);
|
||||
}
|
||||
else echo $info[$i][$attrName];
|
||||
// show user photos
|
||||
elseif ($attribute == "jpegphoto") {
|
||||
if (sizeof($entry[$attribute][0]) < 100) {
|
||||
// looks like we have read broken binary data, reread photo
|
||||
$result = @ldap_search($_SESSION['ldap']->server(), $entry['dn'], $attribute . "=*");
|
||||
if ($result) {
|
||||
$tempEntry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||
$binData = ldap_get_values_len($_SESSION['ldap']->server(), $tempEntry, $attribute);
|
||||
if (isset($binData['count'])) unset($binData['count']);
|
||||
$entry[$attribute] = $binData;
|
||||
echo "servus";
|
||||
}
|
||||
echo ("</td>\n");
|
||||
}
|
||||
echo("</tr>\n");
|
||||
$jpeg_filename = 'jpg' . $_SESSION['ldap']->new_rand() . '.jpg';
|
||||
$outjpeg = @fopen($_SESSION['lampath'] . 'tmp/' . $jpeg_filename, "wb");
|
||||
fwrite($outjpeg, $entry[$attribute][0]);
|
||||
fclose ($outjpeg);
|
||||
$photoFile = '../../tmp/' . $jpeg_filename;
|
||||
echo "<img src=\"" . $photoFile . "\" alt=\"" . _('Photo') . "\">";
|
||||
}
|
||||
// print all other attributes
|
||||
else {
|
||||
parent::listPrintTableCellContent($entry, $attribute);
|
||||
}
|
||||
// display select all link
|
||||
$colspan = sizeof($this->attrArray) + 1;
|
||||
echo "<tr class=\"" . $this->type . "list\">\n";
|
||||
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
|
||||
echo "<td colspan=$colspan> <a href=\"list.php?type=" . $this->type . "&norefresh=y&page=" . $this->page .
|
||||
"&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" .
|
||||
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
|
||||
echo "</tr>\n";
|
||||
echo ("</table>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue