summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9bc8306)
raw | patch | inline | side by side (parent: 9bc8306)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 7 Oct 2010 13:55:22 +0000 (13:55 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 7 Oct 2010 13:55:22 +0000 (13:55 +0000) |
-It lists now
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19935 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19935 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-filter.xml b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-filter.xml
index 54d213cc4c87be26fa3c71ffb6cd7712950792b9..365a2c7930d68181bc0ebc494f5fe158298ced87 100644 (file)
<category>Groupware</category>
<initial>true</initial>
<default>default</default>
- <scope>sub</scope>
+ <scope>auto</scope>
<attribute>-</attribute>
</definition>
<tag>default</tag>
<label>Default filter</label>
<query>
- <backend>LDAP</backend>
+ <backend>FolderWidget</backend>
<filter>$</filter>
</query>
<autocomplete>
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.tpl b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.tpl
index c80f9a2389577f40e56489b37a374fc60e4f18ed..44dcd716e50bf218a27cf1fa3008fabc0c0d5768 100644 (file)
<div class="mainlist-nav">
<table summary="{$HEADLINE}">
<tr>
- <td>{$ROOT}</td>
- <td>{$BACK}</td>
- <td>{$HOME}</td>
<td>{$RELOAD}</td>
+ <td class="left-border">{t}Basis{/t}: {$RELEASE}</td>
<td class="left-border">{$ACTIONS}</td>
<td class="left-border">{$FILTER}</td>
</tr>
</div>
<div class="clear"></div>
-
-<input type="hidden" name="ignore">
+<hr>
+<div class='plugin-actions'>
+ <button name='FolderWidget_ok'>{msgPool type=okButton}</button>
+ <button name='FolderWidget_cancel'>{msgPool type=cancelButton}</button>
+</div>
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml
index 66937308a2c9b609e1b8503d0862cdd1d84a4aaa..6344097491c0faf0c7431c77fb4f406fb7f7b94e 100644 (file)
<list>
<definition>
- <departmentBrowser>true</departmentBrowser>
- <departmentRootVisible>true</departmentRootVisible>
- <baseMode>true</baseMode>
+ <departmentBrowser>false</departmentBrowser>
+ <departmentRootVisible>false</departmentRootVisible>
+ <baseMode>false</baseMode>
<multiSelect>true</multiSelect>
<template>../plugins/personal/groupware/FolderWidget/FolderWidget-list.tpl</template>
<module>users</module>
</definition>
<table>
- <layout>|20px;c|120px||170px;r|</layout>
+ <layout>|20px;c|||170px;r|</layout>
<column>
<value>%{filter:objectType(dn,objectClass)}</value>
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc
index 899e20916bd5c4d3b5e79f15a7fa25660f77510b..904714ff74997c07458b6087c4cc9ab977a8d6e9 100644 (file)
{
public $config;
private $FolderWidgetListing = NULL;
+ private $folderList;
+
+ private $baseEntryMap = array();
function __construct(&$config)
{
}
+ /*! \brief Tell the widget which folders should be displayed.
+ */
+ function setFolderList($arr)
+ {
+ $this->folderList = $this->buildRecursiveList($arr, '/');
+ $this->FolderWidgetListing->setBase('cn=/');
+ $this->FolderWidgetListing->setFolderRoot('cn=/');
+ }
+
+
+ /* \brief Builds a hierarchical structure which can then be
+ * used by the FolderWidgetListing.
+ *
+ * @param Array The folder list
+ * @return Array A hierarchical representation of the input array.
+ */
+ function buildRecursiveList($arr, $seperator)
+ {
+ $data = array();
+ $base = &$data;
+ $last = NULL;
+ $ret = array();
+ foreach($arr as $path => $entry){
+ $current = &$base;
+ $pathSteps = preg_split("/".preg_quote($seperator,'/')."/", $path);
+
+ $entryPath = "";
+ $entryBase = "cn=/";
+ foreach($pathSteps as $name){
+ $entryPath = (empty($entryPath)) ? $name : "{$entryPath}{$seperator}{$name}";
+ $entryBase = trim("cn={$name},{$entryBase}", ' ,');
+ if(!isset($current[$entryPath])){
+ $current[$entryPath] = array();
+ $current[$entryPath]['children'] = array();
+ $current[$entryPath]['name'] = $name;
+ $current[$entryPath]['path'] = $path;
+ $current[$entryPath]['status'] = '';
+ $current[$entryPath]['type'] = 'manual';
+ $current[$entryPath]['base'] = $entryBase;
+
+ $ret['linear'][$entryPath] = &$current[$entryPath];
+
+ $this->baseEntryMap[$entryBase] = $entryPath;
+ }
+ $last = &$current[$entryPath];
+ $current = &$current[$entryPath]['children'];
+ }
+ $last['acls'] = $entry['acls'];
+ $last['name'] = $entry['name'];
+ $last['type'] = 'real';
+ $last['status'] = $entry['status'];
+
+ $ret['linear'][$path] = &$last;
+
+ }
+ $ret['recursive'] = $data;
+ return($ret);
+ }
+
+
function execute()
{
+ session::set('FolderWidgetListing::folderList', $this->folderList);
+ $this->FolderWidgetListing->setFolderList($this->folderList);
return($this->FolderWidgetListing->execute());
}
+
+ function save_object()
+ {
+ $this->FolderWidgetListing->save_object();
+ }
}
?>
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc
index 3712d2b523b12a226c1d7fd61d2e11c9ae4d0318..1d74043dd9da53199d0aaacbb77f024e5e2e6f43 100644 (file)
class FolderWidgetListing extends management
{
+
+ private $folderSelector = NULL;
+ private $folderList = array();
+
+ private $rootBase = 'cn=/';
+
function __construct($config,$ui)
{
$this->config = $config;
$this->ui = $ui;
-
$this->storagePoints = array("");
// Build filter
- if (session::global_is_set(get_class($this)."_filter")){
+ if (FALSE && session::global_is_set(get_class($this)."_filter")){
$filter= session::global_get(get_class($this)."_filter");
} else {
$filter = new filter(get_template_path("FolderWidget-filter.xml", true, dirname(__FILE__)));
// Build headpage
$headpage = new listing(get_template_path("FolderWidget-list.xml", true, dirname(__FILE__)));
$headpage->setFilter($filter);
+ $headpage->setBase($this->rootBase);
+ // Create folderSelector using dummy entries, those will be replaced
+ // once setFolderList is called.
+ $this->folderSelector = new ItemSelector(array($this->rootBase => '/'),$this->rootBase,$this->rootBase);
parent::__construct($config, $ui, "Folder", $headpage);
}
+
+ function setFolderList($folderList)
+ {
+ $this->folderList = $folderList;
+ }
-}
+ function getBase()
+ {
+ return($this->base);
+ }
+
+
+ function setBase($base)
+ {
+ $this->base = $base;
+ $this->folderSelector->setBase($this->base);
+ $headpage = $this->getHeadpage();
+ $headpage->setBase($this->base);
+ }
+
+
+ function setFolderRoot($base)
+ {
+ $this->rootBase = $base;
+ $this->folderSelector->setRootBase($base);
+ }
+
+
+ /*! \brief Overridden render method of class mangement.
+ * this allows us to add a release selection box.
+ */
+ function renderList()
+ {
+ $this->folderSelector->setBases($this->getSimpleFolderList($this->folderList['recursive']));
+ $this->folderSelector->update(true);
+ $headpage = $this->getHeadpage();
+ $headpage->update();
+ $smarty = get_smarty();
+ $smarty->assign("RELEASE", $this->folderSelector->render());
+ $display = $headpage->render();
+ return($this->getHeader().$display);
+ }
+
+
+ function getSimpleFolderList($arr)
+ {
+ $ret = array($this->rootBase => '/');
+ foreach($arr as $path => $entry){
+ $ret[$entry['base']] = $entry['name'];
+ if(isset($entry['children'])){
+ $ret = array_merge($ret, $this->getSimpleFolderList($entry['children']));
+ }
+ }
+ return($ret);
+ }
+
+
+ function save_object()
+ {
+ $this->folderSelector->update();
+ $this->setBase($this->folderSelector->getBase());
+ }
+}
?>
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+class filterFolderWidget {
+
+ static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+ {
+ $data = session::get('FolderWidgetListing::folderList');
+
+ // Prepare filter, strip out regex regex related chars, except for *
+ $filter = preg_replace('/\*/','____STAR____', $filter);
+ $filter = preg_quote($filter,'/');
+ $filter = preg_replace('/____STAR____/','.*', $filter);
+
+ // Detect starting position in folder tree.
+ $items = $data['recursive'];
+ foreach($data['linear'] as $item){
+ if($item['base'] == $base){
+ $items = $item['children'];
+ }
+ }
+
+ // Add entries
+ $ret = array();
+ foreach($items as $item){
+ filterFolderWidget::addEntry($ret, $item, $scope == 'sub', $filter);
+ }
+ return($ret);
+ }
+
+ static function addEntry(&$ret, $item, $recursive = FALSE, $filter)
+ {
+ if(preg_match("/".$filter."/",$item['name'])){
+ $entry = array();
+ $entry['dn'] = $item['base'];
+ $entry[] = 'dn';
+ $entry['cn'] = array($item['name'], 'count' => 1);
+ $entry[] = 'cn';
+ $entry['objectClass'] = array('FAKE_OC_GroupwareFolder','count' => 1);
+ $entry[] = 'objectClass';
+ $entry['count'] = 3;
+ $ret[] = $entry;
+ }
+
+ if($recursive && isset($item['children']) && count($item['children'])){
+ foreach($item['children'] as $item){
+ filterFolderWidget::addEntry($ret, $item, $recursive,$filter);
+ }
+ }
+ }
+}
+?>