summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a3384bd)
raw | patch | inline | side by side (parent: a3384bd)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 24 Aug 2009 16:46:11 +0000 (16:46 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 24 Aug 2009 16:46:11 +0000 (16:46 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14122 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_listing.inc | patch | blob | history | |
gosa-core/include/exporter/class_cvsExporter.inc | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/admin/users/class_userManagement.inc | patch | blob | history |
index 9ba7defd7ea9cfe951753059dc19aef1e0ac1ac3..ecaaf244c894de9c0d71e3545c64d91d0d94e1ec 100644 (file)
var $objectTypeCount= array();
var $copyPasteHandler= null;
var $snapshotHandler= null;
+ var $exporter= array();
+ var $exportColumns= array();
+ var $showExporter= false;
function listing($filename)
{
global $config;
+ global $class_mapping;
// Initialize pid
$this->pid= preg_replace("/[^0-9]/", "", microtime(TRUE));
$this->registerElementFilter("departmentLink", "listing::filterDepartmentLink");
$this->registerElementFilter("link", "listing::filterLink");
$this->registerElementFilter("actions", "listing::filterActions");
+
+ // Load exporters
+ foreach($class_mapping as $class => $dummy) {
+ if (preg_match('/Exporter$/', $class)) {
+ $info= call_user_func(array($class, "getInfo"));
+ $this->exporter= array_merge($this->exporter, $info);
+ }
+ }
}
$this->categories= array($this->categories);
}
+ // Evaluate columns to be exported
+ if (isset($this->xmlData['table']['column'])){
+ foreach ($this->xmlData['table']['column'] as $index => $config) {
+ if (isset($config['export']) && $config['export'] == "true"){
+ $this->exportColumns[]= $index;
+ }
+ }
+ }
+
return true;
}
function renderHeader()
{
$this->header= array();
+ $this->plainHeader= array();
// Initialize sort?
$sortInit= false;
} else {
$this->header[$index]= "<td class='listheader' ".$this->colprops[$index].">"._($config['label'])."</td>";
}
+ $this->plainHeader[]= _($config['label']);
} else {
if ($sortable) {
$this->header[$index]= "<td class='listheader' ".$this->colprops[$index]."><a $link> $sorter</a></td>";
} else {
$this->header[$index]= "<td class='listheader' ".$this->colprops[$index]."> </td>";
}
+ $this->plainHeader[]= "";
}
}
}
// Fill with contents, sort as configured
foreach ($this->entries as $row => $entry) {
- $trow ="<tr class='rowxp".($alt&1)."'>\n";
+ $trow= "";
// Render multi select if needed
if ($this->multiSelect) {
}
$this->entries[$row]["_sort$index"]= $sort;
}
- $trow.="</tr>\n";
// Save rendered entry
$this->entries[$row]['_rendered']= $trow;
-
- $alt++;
}
// Complete list by sorting entries for _sort$index and appending them to the output
$entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
foreach ($entryIterator as $row => $entry){
+ $alt++;
+ $result.="<tr class='rowxp".($alt&1)."'>\n";
$result.= $entry['_rendered'];
+ $result.="</tr>\n";
}
// Need to fill the list if it's not full (nobody knows why this is 22 ;-))
$result.= "</table></div>";
+ // Open export window?
+ if ($this->showExporter) {
+ $result.= "<SCRIPT TYPE='text/javascript'>window.open('getbin.php', '"._("GOsa - export list")."');</SCRIPT>";
+ $this->showExporter= false;
+ }
+
$smarty= get_smarty();
$smarty->assign("FILTER", $this->filter->render());
$smarty->assign("SIZELIMIT", print_sizelimit_warning());
}
}
+ // Filter POST with "act" attributes -> posted from action menu
+ if (isset($_POST['act']) && $_POST['act'] != '') {
+ if (preg_match('/^export.*$/', $_POST['act']) && isset($this->exporter[$_POST['act']])) {
+ $exporter= $this->exporter[$_POST['act']];
+ $instance= new $exporter['class']($this->plainHeader, $this->entries, $this->exportColumns);
+ $type= call_user_func(array($exporter['class'], "getInfo"));
+ $type= $type[$_POST['act']];
+ session::set('binarytype', $type['mime']);
+ session::set('binaryfile', $type['filename']);
+ session::set('binary', $instance->query());
+ $this->showExporter= true;
+ }
+ }
+
// Filter GET with "act" attributes
if (isset($_GET['act'])) {
$key= validate($_GET['act']);
// Filter POST with "act" attributes -> posted from action menu
if (isset($_POST['act']) && $_POST['act'] != '') {
- $result['action']= validate($_POST['act']);
+ if (!preg_match('/^export.*$/', $_POST['act'])){
+ $result['action']= validate($_POST['act']);
+ }
}
// Drop targets if empty
$result.= "<li$separator><a href='#'><img border='0' class='center' src='images/lists/export.png'> "._("Export list")." <img border='0' src='images/forward-arrow.png'></a><ul class='level3'>";
// Export CVS as build in exporter
- $result.= "<li><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"exportCSV\";mainform.submit();'><img border='0' class='center' src='plugins/lists/exportCSV.png'> CSV</a></li>";
+ foreach ($this->exporter as $action => $exporter) {
+ $result.= "<li><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"$action\";mainform.submit();'><img border='0' class='center' src='".$exporter['image']."'> ".$exporter['label']."</a></li>";
+ }
// Finalize list
$result.= "</ul></li>";
diff --git a/gosa-core/include/exporter/class_cvsExporter.inc b/gosa-core/include/exporter/class_cvsExporter.inc
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+class csvExporter
+{
+ var $result;
+
+ function csvExporter($header, $entries, $columns= array()) {
+ // If no preset, render all columns
+ if (!count($columns)) {
+ foreach ($header as $index => $dummy) {
+ $columns[]= $index;
+ }
+ }
+
+ // Generate header
+ $this->result= "#";
+ foreach ($columns as $index) {
+ if (isset($header[$index])){
+ $this->result.= $header[$index].";";
+ } else {
+ $this->result.= ";";
+ }
+ }
+ $this->result= preg_replace('/;$/', '', $this->result)."\n";
+
+ // Append entries
+ foreach ($entries as $row) {
+ foreach ($columns as $index) {
+ if (isset($row["_sort$index"])){
+ $this->result.= $row["_sort$index"].";";
+ } else {
+ $this->result.= ";";
+ }
+ }
+ $this->result= preg_replace('/;$/', '', $this->result)."\n";
+ }
+ }
+
+
+ function query()
+ {
+ return $this->result;
+ }
+
+
+ static function getInfo()
+ {
+ return array("exportCVS" => array( "label" => _("CSV"), "image" => "plugins/lists/exportCSV.png", "class"=> "csvExporter", "mime" => "text/x-csv", "filename" => "export.csv" ));
+ }
+
+}
+
+?>
diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc
index 1d128a6bba5ac5904a836e89604716d42de91643..3099387cde0d8265ba7aa62a0726ee7bdf68b8b6 100644 (file)
$this->DivListUsers->setEntries($this->list);
# FILTER Test #################################################
- ## Build filter
- #if (!$this->filter) {
- # $this->filter = new filter(get_template_path("user-filter.xml", true));
- # $this->filter->setObjectStorage(get_people_ou());
- #}
- #$this->filter->update();
- #session::set('autocomplete', $this->filter);
- #if (!$this->filter->isValid()){
- # msg_dialog::display(_("Filter error"), _("The filter is uncomplete!"), ERROR_DIALOG);
- #}
-
- ## Build headpage
- #if (!$this->headpage){
- # $this->headpage = new listing(get_template_path("user-list.xml", true));
- # $this->headpage->registerElementFilter("accountProperties", "userManagement::filterProperties");
- # $this->headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
- # $this->headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
- # $this->headpage->setCopyPasteHandler($this->CopyPasteHandler);
- # $this->SnapshotHandler->setSnapshotBases($this->get_used_snapshot_bases());
- # $this->headpage->setSnapshotHandler($this->SnapshotHandler);
- # $this->headpage->setFilter($this->filter);
- #}
-
- ## Needs to be called before update!
- #$action= $this->headpage->getAction();
- #if ($action['action'] != '') {
- # echo "List detected action:";
- # print_a($action);
- #}
-
- ## Refresh for filter
- #$this->headpage->update();
- #
- #return($this->headpage->render());
+ # Build filter
+ if (!$this->filter) {
+ $this->filter = new filter(get_template_path("user-filter.xml", true));
+ $this->filter->setObjectStorage(get_people_ou());
+ }
+ $this->filter->update();
+ session::set('autocomplete', $this->filter);
+ if (!$this->filter->isValid()){
+ msg_dialog::display(_("Filter error"), _("The filter is uncomplete!"), ERROR_DIALOG);
+ }
+
+ # Build headpage
+ if (!$this->headpage){
+ $this->headpage = new listing(get_template_path("user-list.xml", true));
+ $this->headpage->registerElementFilter("accountProperties", "userManagement::filterProperties");
+ $this->headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
+ $this->headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
+ $this->headpage->setFilter($this->filter);
+ }
+
+ # Needs to be called before update!
+ $action= $this->headpage->getAction();
+ if ($action['action'] != '') {
+ echo "List detected action:";
+ print_a($action);
+ }
+
+ # Refresh for filter
+ $this->headpage->update();
+
+ return($this->headpage->render());
################################################### FILTER Test
return($this->DivListUsers->Draw());