2008-02-12 18:59:44 +01:00
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
|
|
|
* http://ldapsaisie.labs.libre-entreprise.org
|
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2009-03-25 13:26:32 +01:00
|
|
|
require_once 'core.php';
|
2008-02-12 18:59:44 +01:00
|
|
|
|
2009-01-24 18:45:14 +01:00
|
|
|
if(LSsession :: startLSsession()) {
|
2008-02-12 18:59:44 +01:00
|
|
|
|
|
|
|
if (isset($_POST['LSform_objecttype'])) {
|
|
|
|
$LSobject = $_POST['LSform_objecttype'];
|
|
|
|
}
|
|
|
|
else if (isset($_GET['LSobject'])) {
|
|
|
|
$LSobject = $_GET['LSobject'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($LSobject)) {
|
2009-02-03 01:51:27 +01:00
|
|
|
// LSObject creation
|
2009-01-24 18:45:14 +01:00
|
|
|
if (LSsession ::loadLSobject($LSobject)) {
|
|
|
|
if ( LSsession :: canCreate($LSobject) ) {
|
2008-02-12 18:59:44 +01:00
|
|
|
$object = new $LSobject();
|
|
|
|
|
|
|
|
if ($_GET['load']!='') {
|
|
|
|
$form = $object -> getForm('create',$_GET['load']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$form = $object -> getForm('create');
|
|
|
|
}
|
2010-11-17 19:00:09 +01:00
|
|
|
|
|
|
|
if (isset($_REQUEST['LSform_dataEntryForm'])) {
|
|
|
|
$form -> applyDataEntryForm((string)$_REQUEST['LSform_dataEntryForm']);
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSform_dataEntryForm',(string)$_REQUEST['LSform_dataEntryForm']);
|
|
|
|
}
|
|
|
|
|
2010-11-18 11:17:46 +01:00
|
|
|
$GLOBALS['Smarty'] -> assign('listAvailableDataEntryForm',LSform :: listAvailableDataEntryForm($LSobject));
|
2010-11-17 19:00:09 +01:00
|
|
|
$GLOBALS['Smarty'] -> assign('DataEntryFormLabel',_('Data entry form'));
|
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
if ($form->validate()) {
|
2009-02-03 01:51:27 +01:00
|
|
|
// Data update for LDAP object
|
2008-10-14 15:27:46 +02:00
|
|
|
if ($object -> updateData('create')) {
|
2009-01-21 18:37:02 +01:00
|
|
|
if (!LSerror::errorsDefined()) {
|
2009-02-12 13:38:56 +01:00
|
|
|
LSsession :: addInfo(_("Object has been added."));
|
2008-10-14 15:27:46 +02:00
|
|
|
}
|
2008-11-10 00:24:46 +01:00
|
|
|
if (isset($_REQUEST['ajax'])) {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: displayAjaxReturn (
|
2008-11-10 00:24:46 +01:00
|
|
|
array(
|
2009-01-21 18:08:09 +01:00
|
|
|
'LSredirect' => 'view.php?LSobject='.$LSobject.'&dn='.$object -> getDn()
|
2008-11-10 00:24:46 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
exit();
|
2008-10-14 15:27:46 +02:00
|
|
|
}
|
2008-11-10 00:24:46 +01:00
|
|
|
else {
|
2009-01-21 18:08:09 +01:00
|
|
|
if (!LSdebugDefined()) {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: redirect('view.php?LSobject='.$LSobject.'&dn='.$object -> getDn());
|
2008-11-10 00:24:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-02-12 11:04:50 +01:00
|
|
|
if (isset($_REQUEST['ajax'])) {
|
|
|
|
LSsession :: displayAjaxReturn (
|
|
|
|
array(
|
|
|
|
'LSformErrors' => $form -> getErrors()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LSsession :: displayTemplate();
|
|
|
|
}
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
}
|
2008-11-10 00:24:46 +01:00
|
|
|
else if (isset($_REQUEST['ajax']) && $form -> definedError()) {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: displayAjaxReturn (
|
2008-11-10 00:24:46 +01:00
|
|
|
array(
|
|
|
|
'LSformErrors' => $form -> getErrors()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
exit();
|
|
|
|
}
|
2009-02-03 01:51:27 +01:00
|
|
|
// Define page title
|
2009-02-12 13:38:56 +01:00
|
|
|
$GLOBALS['Smarty'] -> assign('pagetitle',_('New').' : '.$object -> getLabel());
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: setTemplate('create.tpl');
|
2008-02-12 18:59:44 +01:00
|
|
|
$form -> display();
|
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSsession_11');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSldapObject_01');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSerror :: addErrorCode('LSsession_12');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: setTemplate('login.tpl');
|
2008-02-12 18:59:44 +01:00
|
|
|
}
|
2009-01-24 18:45:14 +01:00
|
|
|
LSsession :: displayTemplate();
|
2008-11-10 00:24:46 +01:00
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
?>
|