An error occurred while loading the file. Please try again.
-
Côme Chilliet authored
Merge branch '5797-cancel-button-has-no-effect-apply-template' into '1.3-dev' See merge request fusiondirectory/fd!456 (cherry picked from commit 3d826a19) 6720ec0c Merge branch '5797-cancel-button-has-no-effect-apply-template' into '1.4-dev'
dcb39552
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2013-2016 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class templateDialog
{
protected $simpleManagement;
protected $type;
protected $template = NULL;
protected $templates;
protected $target = NULL;
protected $tabObject;
protected $post_finish = 'template_continue';
protected $post_cancel = 'template_cancel';
function __construct($simpleManagement, $type, $dn = NULL, $target = NULL)
{
$this->simpleManagement = $simpleManagement;
$this->type = $type;
$this->templates = objects::getTemplates($this->type);
if ($dn !== NULL) {
if (isset($this->templates[$dn])) {
$this->template = new template($this->type, $dn);
} else {
trigger_error('Unknown template "'.$dn.'"');
}
}
$this->target = $target;
}
function save_object ()
{
if (isset($_POST[$this->post_cancel])) {
return $this->handle_cancel();
}
if (($this->target === NULL) &&
(isset($_POST[$this->post_finish]) || isset($_GET[$this->post_finish])) &&
is_object($this->template)) {
$this->template->save_object();
return $this->handle_finish();
}
if (
isset($_POST['template']) &&
isset($this->templates[$_POST['template']])
) {
if (is_object($this->template)) {
trigger_error('redefining template object');
}
$this->template = new template($this->type, $_POST['template']);
/* This method can loop if there are several targets */
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
unset($_POST['template']);
}
if (is_object($this->template)) {
if ($this->target !== NULL) {
$this->simpleManagement->openTabObject($this->template->apply($this->target), $this->template->getBase());
$this->simpleManagement->handleTemplateApply();
return FALSE;
} else {
$this->template->save_object();
}
}
return TRUE;
}
function setNextTarget ($target)
{
$this->target = $target;
$this->template->reset();
}
function execute ()
{
$smarty = get_smarty();
if (is_object($this->template)) {
$smarty->assign('template_dialog', $this->template->execute());
} else {
$smarty->assign('templates', $this->templates);
}
$display = $smarty->fetch(get_template_path('template.tpl'));
return $display;
}
function handle_finish ()
{
$this->simpleManagement->closeDialogs();
$this->simpleManagement->openTabObject($this->template->apply(), $this->template->getBase());
return FALSE;
}
function handle_cancel ()
{
$this->simpleManagement->remove_lock();
$this->simpleManagement->closeDialogs();
return FALSE;
}
}
class simpleManagement
{
// The currently used object(s) (e.g. in edit, removal)
// $dn is public due to some compatibility problems with class plugin..
public $dn = '';
protected $dns = array();
// The last used object(s).
protected $last_dn = '';
protected $last_dns = array();
// The common places the displayed objects are stored in. (e.g. array("ou=groups,",".."))
protected $storagePoints = array();
// The opened object.
protected $tabObject = NULL;
protected $dialogObject = NULL;
// The last opened object.
protected $last_tabObject = NULL;
protected $last_dialogObject = NULL;
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
// Whether to display the apply button or not
protected $displayApplyBtn = FALSE;
// Whether to display a header or not.
protected $skipHeader = FALSE;
// Whether to display a footer or not.
protected $skipFooter = FALSE;
// Copy&Paste handler
protected $cpHandler = NULL;
// Indicates that we want to paste objects right now.
protected $cpPastingStarted = FALSE;
// The Snapshot handler class.
protected $snapHandler = NULL;
// The listing handlers
protected $headpage = NULL;
protected $filter = NULL;
// A list of configured actions/events
protected $actions = array();
// Some management classes are used in tab groups and needs this
public $is_template = FALSE;
public $attributes = array();
/* Attributes that child classes should override */
protected $objectTypes = array();
/* Attributes that child classes can override */
protected $departmentBrowser = TRUE;
protected $departmentRootVisible = TRUE;
protected $baseMode = TRUE;
protected $multiSelect = TRUE;
protected $filterXMLPath = NULL;
protected $listXMLPath = NULL;
protected $autoFilter = TRUE;
protected $autoActions = TRUE;
protected $skipCpHandler = FALSE;
protected $skipSnapHandler = FALSE;
protected $autoFilterAttributes = array('dn', 'cn', 'description');
protected $headpageClass = "listing";
public static $skipTemplates = TRUE;
function __construct()
{
global $config;
if ($this->filterXMLPath === NULL) {
$this->filterXMLPath = get_template_path('simple-filter.xml', TRUE, dirname(__FILE__));
}
if ($this->listXMLPath === NULL) {
$this->listXMLPath = get_template_path('simple-list.xml', TRUE, dirname(__FILE__));
}
foreach ($this->objectTypes as &$object) {
$object = strtoupper($object);
}
unset($object);
$this->storagePoints = array();
foreach ($this->objectTypes as $key => $object) {
try {