summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c355347)
raw | patch | inline | side by side (parent: c355347)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 30 Sep 2010 08:19:22 +0000 (08:19 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 30 Sep 2010 08:19:22 +0000 (08:19 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19862 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/goto/admin/systems/goto/Config/AddItemDialog.tpl | [new file with mode: 0644] | patch | blob |
gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig-list.xml | patch | blob | history | |
gosa-plugins/goto/admin/systems/goto/Config/class_AddItemDialog.inc | [new file with mode: 0644] | patch | blob |
gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc | patch | blob | history |
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/AddItemDialog.tpl b/gosa-plugins/goto/admin/systems/goto/Config/AddItemDialog.tpl
--- /dev/null
@@ -0,0 +1,21 @@
+
+<h3>{t}Add item{/t}</h3>
+
+{t}Please specify a name for the item to add, this name has to be uniq within the item configuration.{/t}
+<br>
+
+<hr>
+
+<p>
+ <b>{$itemCfg.name}</b> - {$itemCfg.description}
+</p>
+
+{t}Name{/t}: <input type='text' name='itemName' value="{$itemName}">
+
+<hr>
+
+<div class='plugin-actions'>
+ <button name='saveItemAdd'>{msgPool type=okButton}</button>
+ <button name='cancelItemAdd'>{msgPool type=cancelButton}</button>
+</div>
+
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig-list.xml b/gosa-plugins/goto/admin/systems/goto/Config/DeviceConfig-list.xml
index e5783ccae784378e0c503b7bec0f6a910261d80c..27e6ec474e00458a1be5c6390de3f2013f2af694 100644 (file)
</definition>
<table>
- <layout>|20px;c||80px|170px;r|</layout>
+ <layout>|20px;c|||170px;r|</layout>
<column>
<value>%{filter:objectType(dn,objectClass)}</value>
<actionmenu>
- <action>
- <type>sub</type>
- <image>images/lists/element.png[new]</image>
- <label>Create</label>
- <action>
- <name>remove</name>
- <type>entry</type>
- <image>images/lists/trash.png</image>
- <label>Blaa</label>
- </action>
- </action>
+ %ITEMS%
<action>
<name>remove</name>
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_AddItemDialog.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_AddItemDialog.inc
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+class AddItemDialog
+{
+ private $itemCfg = NULL;
+ private $config = NULL;
+
+ private $itemName = "";
+ private $itemType = NULL;
+
+ function __construct(&$config, $itemType, $itemCfg)
+ {
+ $this->config = $config;
+ $this->itemCfg = $itemCfg;
+ $this->itemType = $itemType;
+ }
+
+ function execute()
+ {
+ $smarty = get_smarty();
+ $smarty->assign('itemCfg', set_post($this->itemCfg));
+ $smarty->assign('itemName', set_post($this->itemName));
+ return($smarty->fetch(get_template_path('goto/Config/AddItemDialog.tpl', TRUE)));
+ }
+
+ function getItemCfg()
+ {
+ return($this->itemCfg);
+ }
+
+ function getName()
+ {
+ return($this->itemName);
+ }
+
+ function getItemType()
+ {
+ return($this->itemType);
+ }
+
+ function save_object()
+ {
+ if(isset($_POST['itemName'])){
+ $this->itemName = get_post('itemName');
+ }
+ }
+
+ function check()
+ {
+ $message = array();
+ if(empty($this->itemName)){
+ $message[] = msgPool::required(_("Name"));
+ }else
+ if(!tests::is_uid($this->itemName)){
+ $message[] = msgPool::invalid(_("Name"));
+ }
+ return($message);
+ }
+}
+
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
index 87d317a895d73eaf062edb9c5adcc73266866edb..ad89ebb6739dc8d73eb49abd7513c87f4d52ceb8 100644 (file)
private $baseToDN = array();
+ private $addableContainerItems = array();
+
/*! \brief Constructs the device configuration plugin
* @param Config The GOsa configuration object.
*/
}
- function cancelItemEdit()
- {
- $this->closeDialogs();
- $this->dialog = FALSE;
- }
-
-
function saveItemChanges()
{
// Save eventually changed values
}
}
$this->closeDialogs();
- $this->dialog = FALSE;
}
// Load service xml file and fill in placeholders
$contents =file_get_contents(get_template_path("goto/Config/DeviceConfig-list.xml", true));
+
+
+ $items = "";
+ foreach($this->addableContainerItems as $item){
+ $desc = $this->itemConfig[$item]['description'];
+ $items .=
+ "<action>".
+ " <name>add_{$item}</name>".
+ " <type>entry</type>".
+ " <image>images/lists/edit.png</image>".
+ " <label>{$desc}</label>".
+ "</action>";
+ }
+
+ if(!empty($item)){
+ $items =
+
+ "<action>".
+ " <type>sub</type>".
+ " <image>images/lists/element.png[new]</image>".
+ " <label>Create</label>".
+ " {$items}".
+ "</action>";
+ }
+
+ $contents = preg_replace("/%ITEMS%/", $items, $contents);
+
$headpage = new listing($contents,TRUE);
$headpage->setBase($this->base);
$headpage->setFilter($filter);
$this->registerAction("editEntry", "editEntry");
$this->registerAction("saveItemChanges", "saveItemChanges");
- $this->registerAction("cancelItemEdit", "cancelItemEdit");
+ $this->registerAction("cancelItemEdit", "closeDialogs");
+ $this->registerAction("cancelItemAdd", "closeDialogs");
+ $this->registerAction("saveItemAdd", "saveItemAdd");
+ foreach($this->itemConfig as $name => $item){
+ $this->registerAction("add_{$name}", "newEntry");
+ }
+ }
+
+
+ /*! \brief This method intiates the object creation.
+ *
+ * @param String 'action' The name of the action which was the used as trigger.
+ * @param Array 'target' A list of object dns, which should be affected by this method.
+ * @param Array 'all' A combination of both 'action' and 'target'.
+ */
+ function newEntry($action="",$target=array(),$all=array(),
+ $altTabClass ="", $altTabType = "", $altAclCategory="")
+ {
+ $toAdd = preg_replace("/^add_/", "",$action);
+ $itemToAdd = $this->itemConfig[$toAdd];
+
+ $this->dialogObject = new AddItemDialog($this->config,$toAdd,$itemToAdd);
+ $this->dialog = true;
+ }
+
+
+ function saveItemAdd()
+ {
+ if(!$this->dialogObject instanceOf AddItemDialog) return;
+
+ $msgs = $this->dialogObject->save_object();
+ $msgs = $this->dialogObject->check();
+ if(count($msgs)){
+ msg_dialog::displayChecks($msgs);
+ }else{
+ $itemName = $this->dialogObject->getName();
+ $itemCfg = $this->dialogObject->getItemCfg();
+ $itemType = $this->dialogObject->getItemType();
+
+ $this->setCurrentItem($this->baseToDN[$this->base]);
+
+ $this->addItem($itemType, $itemName);
+ $this->closeDialogs();
+
+# $this->setCurrentItem($itemName);
+# $this->dialogObject = $this->TemplateEngine;
+# $this->skipFooter = TRUE;
+# $this->dialog = TRUE;
+
+ }
}
* @param Array values The initial values for this object.
* @return
*/
- function addItem($type,$name, $values)
+ function addItem($type,$name, $values = array())
{
if(!isset($this->itemConfig[$type])){
echo "Invalid type {$type}, skipping item!";
}
$allValuesSet = TRUE;
- foreach($this->itemConfig[$type]['options'] as $oName => $option){
+ foreach($this->itemConfig[$type]['options'] as $oName => $oValue){
if(!isset($values[$oName])){
- echo "Missing value for option {$oName}! Skipping addItem({$type},{$name},array())!<br>";
- return;
+ $values[$oName] = $oValue;
}
}
{
$this->base = $base;
$item = $this->currentItemValues[$this->baseToDN[$base]];
+ $this->addableContainerItems = $this->itemConfig[$item['type']]['container'];
}
{
$action = management::detectPostActions();
if(isset($_POST['saveItemEdit'])) $action['action'] = "saveItemChanges";
+ if(isset($_POST['saveItemAdd'])) $action['action'] = "saveItemAdd";
if(isset($_POST['cancelItemEdit'])) $action['action'] = "cancelItemEdit";
+ if(isset($_POST['cancelItemAdd'])) $action['action'] = "cancelItemAdd";
if($action['action'] == 'remove'){
echo "Löschen geht nicht!";
}
return($action);
}
+
+
+ function closeDialogs()
+ {
+ parent::closeDialogs();
+ $this->dialog = false;
+ }
function check()