2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
23 require_once 'core.php';
25 if(LSsession :: startLSsession()) {
27 if (isset($_POST['LSform_objecttype'])) {
28 $LSobject = $_POST['LSform_objecttype'];
30 else if (isset($_GET['LSobject'])) {
31 $LSobject = $_GET['LSobject'];
34 if (isset($LSobject)) {
36 if (LSsession ::loadLSobject($LSobject)) {
37 if ( LSsession :: canCreate($LSobject) ) {
38 $object = new $LSobject();
40 if ($_GET['load']!='') {
41 $form = $object -> getForm('create',$_GET['load']);
44 $form = $object -> getForm('create');
47 if (isset($_REQUEST['LSform_dataEntryForm'])) {
48 $form -> applyDataEntryForm((string)$_REQUEST['LSform_dataEntryForm']);
49 $GLOBALS['Smarty'] -> assign('LSform_dataEntryForm',(string)$_REQUEST['LSform_dataEntryForm']);
52 $GLOBALS['Smarty'] -> assign('listAvailableDataEntryForm',array_merge(array(''=>''),LSform :: listAvailableDataEntryForm($LSobject)));
53 $GLOBALS['Smarty'] -> assign('DataEntryFormLabel',_('Data entry form'));
55 if ($form->validate()) {
56 // Data update for LDAP object
57 if ($object -> updateData('create')) {
58 if (!LSerror::errorsDefined()) {
59 LSsession :: addInfo(_("Object has been added."));
61 if (isset($_REQUEST['ajax'])) {
62 LSsession :: displayAjaxReturn (
64 'LSredirect' => 'view.php?LSobject='.$LSobject.'&dn='.$object -> getDn()
70 if (!LSdebugDefined()) {
71 LSsession :: redirect('view.php?LSobject='.$LSobject.'&dn='.$object -> getDn());
76 if (isset($_REQUEST['ajax'])) {
77 LSsession :: displayAjaxReturn (
79 'LSformErrors' => $form -> getErrors()
85 LSsession :: displayTemplate();
89 else if (isset($_REQUEST['ajax']) && $form -> definedError()) {
90 LSsession :: displayAjaxReturn (
92 'LSformErrors' => $form -> getErrors()
98 $GLOBALS['Smarty'] -> assign('pagetitle',_('New').' : '.$object -> getLabel());
99 LSsession :: setTemplate('create.tpl');
103 LSerror :: addErrorCode('LSsession_11');
107 LSerror :: addErrorCode('LSldapObject_01');
111 LSerror :: addErrorCode('LSsession_12');
116 LSsession :: setTemplate('login.tpl');
118 LSsession :: displayTemplate();